changeset 20838:8f123945970e

maint: Periodic merge of stable to default.
author Rik <rik@octave.org>
date Thu, 10 Dec 2015 12:50:06 -0800
parents c54ae1fb7e3b (diff) c132fbc748da (current diff)
children e429ddca0d51
files libinterp/corefcn/hess.cc
diffstat 1263 files changed, 49344 insertions(+), 43053 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Tue Dec 08 07:49:49 2015 -0800
+++ b/.hgignore	Thu Dec 10 12:50:06 2015 -0800
@@ -6,7 +6,7 @@
 # gnulib makes these silly backup files
 .~$
 
-# This directory gets created by gnulib during the build. 
+# This directory gets created by gnulib during the build.
 # It contains no Octave files.
 ^libgnu/*
 
@@ -32,8 +32,8 @@
 #      doc/interpreter/octave.info-4
 ^doc/.*\.info(-\d)?$
 
-^doc/\w*/stamp-vti$
-^doc/\w*/version\.texi$
+^doc/\w*/stamp-(vti|\d+)$
+^doc/\w*/version-\w+\.texi$
 ^doc/interpreter/images\.mk$
 
 # e.g. liboctave/operators/smx-op-inc.mk
--- a/.hgtags	Tue Dec 08 07:49:49 2015 -0800
+++ b/.hgtags	Thu Dec 10 12:50:06 2015 -0800
@@ -94,3 +94,4 @@
 eba80000fa0dad32ba0f1cd767dd826d1ce1aba6 rc-4-0-0-2
 065f933ef08318e40b81f7fe75236e6175088117 rc-4-0-0-3
 42bb3a776c9fcc008669f382d2409297c4a901b3 rc-4-0-0-4
+3ccc2d02e64b61c6827009d42e5b12274e7ba5fc release-4-0-0
--- a/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ b/Makefile.am	Thu Dec 10 12:50:06 2015 -0800
@@ -20,75 +20,131 @@
 
 include build-aux/common.mk
 
-## Avoid making multiple subdirs in parallel which can lead
-## to a confusing error message stream
-.NOTPARALLEL:
+image_DATA =
+octdata_DATA =
+octetc_DATA =
+octlocale_DATA =
 
 ACLOCAL_AMFLAGS = -I m4
 
-BUILT_DISTFILES = AUTHORS BUGS ChangeLog INSTALL.OCTAVE
+DOC_TARGETS =
 
-EXTRA_DIST = \
+BUILT_DISTFILES =
+BUILT_NODISTFILES =
+EXTRA_DIST =
+
+BUILT_DISTFILES += \
   AUTHORS \
   BUGS \
+  ChangeLog \
+  INSTALL.OCTAVE
+
+EXTRA_DIST += \
+  CITATION \
   COPYING \
-  ChangeLog \
   INSTALL \
-  INSTALL.OCTAVE \
   NEWS \
   README \
-  CITATION \
+  build-aux/OctJavaQry.class \
   build-aux/find-files-with-tests.sh \
   build-aux/mk-opts.pl \
   build-aux/move-if-change \
-  build-aux/OctJavaQry.class \
   build-aux/stl_algo.h-fixed \
-  etc/NEWS.1 \
-  etc/NEWS.2 \
-  etc/NEWS.3 \
-  etc/OLD-ChangeLogs/ChangeLog \
-  etc/OLD-ChangeLogs/ChangeLog.1 \
-  etc/OLD-ChangeLogs/doc-ChangeLog \
-  etc/OLD-ChangeLogs/libcruft-ChangeLog \
-  etc/OLD-ChangeLogs/liboctave-ChangeLog \
-  etc/OLD-ChangeLogs/scripts-ChangeLog \
-  etc/OLD-ChangeLogs/src-ChangeLog \
-  etc/OLD-ChangeLogs/test-ChangeLog \
-  etc/PROJECTS \
-  etc/README.Cygwin \
-  etc/README.Linux \
-  etc/README.MacOS \
-  etc/README.MinGW \
-  etc/README.Windows \
-  etc/README.gnuplot \
-  etc/README.kpathsea \
-  etc/gdbinit \
-  run-octave.in
+  run-octave.in \
+  $(BUILT_DISTFILES)
+
+DIRSTAMP_FILES =
+
+octave_dirstamp = $(am__leading_dot)octave-dirstamp
+
+$(DIRSTAMP_FILES):
+	$(AM_V_GEN)$(MKDIR_P) $(@D) && \
+	: > $@
+
+CLEANFILES =
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
+info_TEXINFOS =
+BUILT_SOURCES =
+TEST_FILES =
+
+DOC_IMAGES_SRC =
+BUILT_DOC_IMAGES =
+BUILT_DOC_IMAGES_EPS =
+BUILT_DOC_IMAGES_PDF =
+BUILT_DOC_IMAGES_PNG =
+BUILT_DOC_IMAGES_TXT =
+DOC_IMAGES =
+DOC_IMAGES_EPS =
+DOC_IMAGES_PDF =
+DOC_IMAGES_PNG =
+DOC_IMAGES_TXT =
+
+FCN_FILE_DIRS =
+FCN_FILES =
+GEN_FCN_FILES =
+PKG_ADD_FILES =
+SCRIPTS_IMAGES =
+JAR_FILES =
+DOCSTRING_FILES =
 
-include m4/module.mk
+bin_PROGRAMS =
+archlib_PROGRAMS =
+noinst_HEADERS =
+OCTAVE_VERSION_LINKS =
+OCTAVE_CROSS_TOOLS =
+OCTAVE_INTERPRETER_TARGETS =
+
+octlib_LTLIBRARIES =
+noinst_LTLIBRARIES =
+
+octinclude_HEADERS =
+nodist_octinclude_HEADERS =
+
+DIST_SRC =
+
+ALL_LOCAL_TARGETS =
 
-# Subdirectories in which to run `make all'.  Including "." before
-# @DOCDIR@ is an attempt to force all preceding directories in the list
-# to be processed before the current directory so that the
-# scripts/DOCSTRINGS libinterp/DOCSTRINGS files are built before
-# attempting to build AUTHORS and BUGS.  Including "." again at the end
-# of the list ensures that we display the "Octave sucessfully built..."
-# message at the very end of the output from Make.  Another fix for
-# these problems would be to continue eliminating the recursive make
-# invocations so that we have better control over the dependencies and
-# the order that things are built.
-SUBDIRS = libgnu liboctave libinterp
-if AMCOND_BUILD_GUI
-SUBDIRS += libgui
-endif
-SUBDIRS += src scripts . @DOCDIR@ examples etc/icons test .
+include liboctave/module.mk
+include liboctave/link-deps.mk
+include libinterp/module.mk
+include libinterp/link-deps.mk
+include libgui/module.mk
+include libgui/link-deps.mk
+include src/module.mk
+include scripts/module.mk
+include doc/module.mk
+include doc/interpreter/images.mk
+include etc/module.mk
+include examples/module.mk
+include m4/module.mk
+include test/module.mk
 
-if ! AMCOND_BUILD_DOCS
-dist-hook:
-	echo "Documentation disabled.  Cannot package distribution!" ; exit 1;
+# Subdirectories in which to run make recursively.  Other
+# directories are handled directly from this Makefile (see also the
+# included makefile fragments).
+
+SUBDIRS = libgnu
+
+dist-hook: doc-interpreter-dist-hook docs-dist-hook icons-dist-hook scripts-dist-hook
+
+if AMCOND_BUILD_DOCS
+docs-dist-hook:
+else
+docs-dist-hook:
+	@echo "Documentation disabled.  Cannot package distribution!" ; exit 1;
 endif
 
-BUILT_SOURCES = run-octave
+if AMCOND_HAVE_ICON_TOOLS
+icons-dist-hook:
+else
+icons-dist-hook:
+	@echo "Packaging distribution requires icotool and rsvg-convert." ; exit 1;
+endif
+
+BUILT_SOURCES += \
+  run-octave \
+  $(DIRSTAMP_FILES)
 
 if AMCOND_HAVE_BROKEN_STL_ALGO_H
   BUILT_SOURCES += bits/stl_algo.h
@@ -98,25 +154,25 @@
 
 noinst_SCRIPTS = run-octave
 
-INFO_FILES = \
-  AUTHORS \
-  BUGS \
-  INSTALL.OCTAVE
+OCTAVE_INTERPRETER_TARGETS += run-octave
+
+CLEANFILES += \
+  $(BUILT_SOURCES)
 
-CLEANFILES = $(BUILT_SOURCES)
-
-DISTCLEANFILES = \
+DISTCLEANFILES += \
   .gdbinit \
-  ChangeLog
+  $(DIRSTAMP_FILES)
 
-MAINTAINERCLEANFILES = $(BUILT_DISTFILES)
+MAINTAINERCLEANFILES += \
+  ChangeLog \
+  $(BUILT_DISTFILES)
 
 CONFIG_FILES = @ac_config_headers@ @ac_config_files@
 
-nodist_octinclude_HEADERS = config.h
-octinclude_HEADERS = oct-conf-post.h
+octinclude_HEADERS += oct-conf-post.h
+nodist_octinclude_HEADERS += config.h
 
-all-local: $(noinst_SCRIPTS) $(INFO_FILES) .gdbinit
+all-local: $(ALL_LOCAL_TARGETS) $(noinst_SCRIPTS) $(DIST_INFO_FILES) .gdbinit $(DOC_TARGETS)
 	@echo ""
 	@echo "Octave successfully built.  Now choose from the following:"
 	@echo ""
@@ -125,14 +181,6 @@
 	@echo "   make install    - to install (PREFIX=$(prefix))"
 	@echo ""
 
-check: all
-	$(MAKE) -C test check
-
-if AMCOND_HAVE_LLVM
-check-jit: all
-	$(MAKE) -C test check-jit
-endif
-
 run-octave: run-octave.in Makefile
 	$(AM_V_GEN)$(do_subst_script_vals) && \
 	chmod a+rx "$@"
@@ -145,33 +193,32 @@
 ## there isn't a stray copy sitting in the build tree.
 
 nonexistent-file:
-	rm -f bits/stl_algo.h
+	$(AM_V_at)rm -f bits/stl_algo.h
 .PHONY: nonexistent-file
 
 .gdbinit: etc/gdbinit
 	@$(gdbinit_install_rule)
 
-if AMCOND_BUILD_DOCS
-AUTHORS BUGS INSTALL.OCTAVE:
-	$(AM_V_GEN)$(MAKE) -C doc/interpreter ../../$@
-endif
-.PHONY: AUTHORS BUGS INSTALL.OCTAVE
-
 define changelog-from-hg-log
-  rm -f $@-t $@ && \
-  ( cd $(srcdir); \
-    hg log --style=build-aux/changelog.tmpl --prune=b0e60ad4ae26 --only-branch=`hg branch`; \
-    echo ""; \
-    echo "See the files in the directory etc/OLD-ChangeLogs for changes before 2011-04-19"; \
-  ) > $@-t && \
-  mv $@-t $@
+  rm -f $@-t && \
+  if [ -d $(srcdir)/.hg ]; then \
+    ( cd $(srcdir); \
+      hg log --style=build-aux/changelog.tmpl --prune=b0e60ad4ae26 --only-branch=`hg branch`; \
+      echo ""; \
+      echo "See the files in the directory etc/OLD-ChangeLogs for changes before 2011-04-19"; \
+    ) > $@-t && \
+    mv $@-t $@; \
+  elif [ ! -f $@ ] && [ ! -f $(srcdir)/$@ ]; then \
+    echo "Empty ChangeLog generated because no hg log available" > $@-t && \
+    mv $@-t $@; \
+  fi
 endef
 
 ChangeLog:
 	$(AM_V_GEN)$(changelog-from-hg-log)
 .PHONY: ChangeLog
 
-octetc_DATA = \
+octetc_DATA += \
   CITATION \
   NEWS
 
@@ -179,10 +226,6 @@
 octetc_DATA += config.log
 endif
 
-doxyhtml:
-	$(MAKE) -C doc/doxyhtml doxyhtml
-.PHONY: doxyhtml
-
 DIRS_TO_MAKE = \
   $(localfcnfiledir) \
   $(localapifcnfiledir) \
@@ -198,3 +241,10 @@
 	$(MKDIR_P) $(addprefix $(DESTDIR), $(DIRS_TO_MAKE))
 
 install-data-local: installdirs-local
+
+clean-local: doc-clean
+
+distclean-local:
+
+maintainer-clean-local: doc-maintainer-clean
+
--- a/NEWS	Tue Dec 08 07:49:49 2015 -0800
+++ b/NEWS	Thu Dec 10 12:50:06 2015 -0800
@@ -1,3 +1,108 @@
+Summary of important user-visible changes for version 4.2:
+---------------------------------------------------------
+
+ ** The parser has been extended to accept, but ignore, underscore characters
+    in numbers.  This facilitates writing more legible code by using '_' as
+    a thousands separator or to group nibbles into bytes in hex constants.
+
+    Examples: 1_000_000 == 1e6 or 0xDE_AD_BE_EF
+
+ ** The parser has been extended to understand binary numbers which begin
+    with the prefix '0b' or '0B'.  The value returned is Octave's default
+    numeric class of double, not at unsigned integer class.  Therefore numbers
+    greater than flintmax, i.e., 2^53, will lose some precision.
+
+    Examples: 0b101 == 5 or 0B1100_0001 == 0xC1
+
+ ** The default colormap is now set to "viridis" which is also the default
+    colormap in matplotlib.  This new colormap fixes some of the main issues
+    with the old default colormap "jet" such as its bad "luminance profile"
+    and is also more similar to Matlab's new default colormap "parula".
+
+ ** Octal ('\NNN') and hex ('\xNN') escape sequences in single quoted
+    strings are now interpreted by the function do_string_escapes().
+    The *printf family of functions now supports octal and hex escape
+    sequences in single-quoted strings for Matlab compatibility.
+
+ ** Special octal and hex escape sequences for the pattern and replacement
+    strings in regular expressions are now interpreted for Matlab compatibility.
+
+    octal: '\oNNN' or '\o{NNN}'
+    hex  : '\xNN'  or '\x{NN}'
+
+ ** Unknown escape sequences in the replacement string for regexprep are now
+    substituted with their unescaped version and no warning is emitted.
+    This change was made for Matlab compatibility.
+
+    Example: regexprep ('a', 'a', 'x\yz')
+             => 'xyz'
+
+ ** mkfifo now interprets the MODE argument as an octal, not decimal, integer.
+    This is consistent with the equivalent shell command.
+
+ ** linspace now returns an empty matrix if the number of requested points
+    is 0 or a negative number.  This change was made to be compatible with
+    Matlab releases newer than 2011.  In addition, Octave no longer supports
+    matrix inputs for A or B.
+
+ ** The griddata function no longer plots the interpolated mesh if no output
+    argument is requested, instead the vector or array of interpolated values
+    is always returned for Matlab compatibility.
+
+ ** The surfnorm function now returns unnormalized (magnitude != 1) normal
+    vectors for compatibility with Matlab.
+
+ ** The quadl function now uses an absolute, rather than relative, tolerance
+    for Matlab compatibility.  The default tolerance is 1e-6 which may result
+    in lower precision results than previous versions of Octave which used
+    eps as the relative tolerance.  The quadl function has also been extended
+    to return a second output with the total number of function evaluations.
+
+ ** Other new functions added in 4.2:
+
+      deg2rad
+      im2double
+      psi
+      odeset
+      odeget
+      ode45
+      rad2deg
+
+ ** Deprecated functions.
+
+    The following functions have been deprecated in Octave 4.2 and will
+    be removed from Octave 4.6 (or whatever version is the second major
+    release after 4.2):
+
+      Function             | Replacement
+      ---------------------|------------------
+      bitmax               | flintmax
+      mahalanobis          | mahal in Octave-Forge statistics pkg
+      wavread              | audioread
+      wavwrite             | audiowrite
+
+ ** The following functions were deprecated in Octave 3.8 and have been
+    removed from Octave 4.2.
+
+      default_save_options    java_new
+      gen_doc_cache           java_unsigned_conversion
+      interp1q                javafields
+      isequalwithequalnans    javamethods
+      java_convert_matrix     re_read_readline_init_file
+      java_debug              read_readline_init_file
+      java_invoke             saving_history
+
+ ** The global error_state variable in Octave's C++ API has been
+    deprecated and will be removed in a future version.  Now the error
+    and print_usage functions throw an exception
+    (octave_execution_exception) after displaying the error message.
+    This makes the error and print_usage functions in C++ work more like
+    the corresponding functions in the scripting language.
+
+ ** New configure option, --enable-address-sanitizer-flags, to build
+    Octave with memory allocator checks (similar to those provided by
+    valgrind) built in.
+
 Summary of important user-visible changes for version 4.0:
 ---------------------------------------------------------
 
@@ -147,7 +252,7 @@
 
  ** The inpolygon function now returns true for points that are within
     the polygon OR on it's edge.  This change was made for Matlab
-    compatibility. 
+    compatibility.
 
  ** The archive family of functions (bzip2, gzip, zip, tar) and their
     unpacking routines (bunzip2, gunzip, unzip, untar, unpack) have
--- a/bootstrap	Tue Dec 08 07:49:49 2015 -0800
+++ b/bootstrap	Thu Dec 10 12:50:06 2015 -0800
@@ -1,10 +1,10 @@
 #! /bin/sh
 # Print a version string.
-scriptversion=2013-08-15.22; # UTC
+scriptversion=2014-12-08.12; # UTC
 
 # Bootstrap this package from checked-out sources.
 
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 Free Software Foundation, Inc.
 
 # 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
@@ -32,7 +32,7 @@
 nl='
 '
 
-# Ensure file names are sorted consistently across platforms.
+# Ensure filenames are sorted consistently across platforms.
 LC_ALL=C
 export LC_ALL
 
@@ -42,6 +42,9 @@
 
 local_gl_dir=gl
 
+# Honour $PERL, but work even if there is none
+PERL="${PERL-perl}"
+
 me=$0
 
 usage() {
@@ -209,12 +212,26 @@
 # Use git to update gnulib sources
 use_git=true
 
+check_exists() {
+  if test "$1" = "--verbose"; then
+    ($2 --version </dev/null) >/dev/null 2>&1
+    if test $? -ge 126; then
+      # If not found, run with diagnostics as one may be
+      # presented with env variables to set to find the right version
+      ($2 --version </dev/null)
+    fi
+  else
+    ($1 --version </dev/null) >/dev/null 2>&1
+  fi
+
+  test $? -lt 126
+}
+
 # find_tool ENVVAR NAMES...
 # -------------------------
 # Search for a required program.  Use the value of ENVVAR, if set,
-# otherwise find the first of the NAMES that can be run (i.e.,
-# supports --version).  If found, set ENVVAR to the program name,
-# die otherwise.
+# otherwise find the first of the NAMES that can be run.
+# If found, set ENVVAR to the program name, die otherwise.
 #
 # FIXME: code duplication, see also gnu-web-doc-update.
 find_tool ()
@@ -225,7 +242,7 @@
   eval "find_tool_res=\$$find_tool_envvar"
   if test x"$find_tool_res" = x; then
     for i; do
-      if ($i --version </dev/null) >/dev/null 2>&1; then
+      if check_exists $i; then
         find_tool_res=$i
         break
       fi
@@ -404,7 +421,7 @@
 get_version() {
   app=$1
 
-  $app --version >/dev/null 2>&1 || return 1
+  $app --version >/dev/null 2>&1 || { $app --version; return 1; }
 
   $app --version 2>&1 |
   sed -n '# Move version to start of line.
@@ -442,6 +459,7 @@
     test "$appvar" = TAR && appvar=AMTAR
     case $appvar in
         GZIP) ;; # Do not use $GZIP:  it contains gzip options.
+        PERL::*) ;; # Keep perl modules as-is
         *) eval "app=\${$appvar-$app}" ;;
     esac
 
@@ -459,12 +477,22 @@
           ret=1
           continue
         } ;;
+      # Another check is for perl modules.  These can be written as
+      # e.g. perl::XML::XPath in case of XML::XPath module, etc.
+      perl::*)
+        # Extract module name
+        app="${app#perl::}"
+        if ! $PERL -m"$app" -e 'exit 0' >/dev/null 2>&1; then
+          warn_ "Error: perl module '$app' not found"
+          ret=1
+        fi
+        continue
+        ;;
     esac
     if [ "$req_ver" = "-" ]; then
       # Merely require app to exist; not all prereq apps are well-behaved
       # so we have to rely on $? rather than get_version.
-      $app --version >/dev/null 2>&1 </dev/null
-      if [ 126 -le $? ]; then
+      if ! check_exists --verbose $app; then
         warn_ "Error: '$app' not found"
         ret=1
       fi
@@ -548,13 +576,21 @@
   fi
 fi
 
+# Warn the user if autom4te appears to be broken; this causes known
+# issues with at least gettext 0.18.3.
+probe=$(echo 'm4_quote([hi])' | autom4te -l M4sugar -t 'm4_quote:$%' -)
+if test "x$probe" != xhi; then
+  warn_ "WARNING: your autom4te wrapper eats stdin;"
+  warn_ "if bootstrap fails, consider upgrading your autotools"
+fi
+
 echo "$0: Bootstrapping from checked-out $package sources..."
 
 # See if we can use gnulib's git-merge-changelog merge driver.
-if $use_git && test -d .git && (git --version) >/dev/null 2>/dev/null ; then
+if $use_git && test -d .git && check_exists git; then
   if git config merge.merge-changelog.driver >/dev/null ; then
     :
-  elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
+  elif check_exists git-merge-changelog; then
     echo "$0: initializing git-merge-changelog driver"
     git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
     git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
@@ -587,8 +623,8 @@
   # Note that $use_git is necessarily true in this case.
   if git_modules_config submodule.gnulib.url >/dev/null; then
     echo "$0: getting gnulib files..."
-    git submodule init || exit $?
-    git submodule update || exit $?
+    git submodule init -- "$gnulib_path" || exit $?
+    git submodule update -- "$gnulib_path" || exit $?
 
   elif [ ! -d "$gnulib_path" ]; then
     echo "$0: getting gnulib files..."
@@ -617,13 +653,14 @@
       # This fallback allows at least git 1.5.5.
       if test -f "$gnulib_path"/gnulib-tool; then
         # Since file already exists, assume submodule init already complete.
-        git submodule update || exit $?
+        git submodule update -- "$gnulib_path" || exit $?
       else
         # Older git can't clone into an empty directory.
         rmdir "$gnulib_path" 2>/dev/null
         git clone --reference "$GNULIB_SRCDIR" \
           "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
-          && git submodule init && git submodule update \
+          && git submodule init -- "$gnulib_path" \
+          && git submodule update -- "$gnulib_path" \
           || exit $?
       fi
     fi
@@ -878,7 +915,8 @@
   esac
 fi
 echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
-$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
+$gnulib_tool $gnulib_tool_options --import $gnulib_modules \
+  || die "gnulib-tool failed"
 
 for file in $gnulib_files; do
   symlink_to_dir "$GNULIB_SRCDIR" $file \
--- a/build-aux/common.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/build-aux/common.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -143,6 +143,7 @@
 LD_CXX = @LD_CXX@
 LD_STATIC_FLAG = @LD_STATIC_FLAG@
 LIBFLAGS = -L$(top_builddir)
+WARN_LDFLAGS = @WARN_LDFLAGS@
 #ALL_LDFLAGS = $(LIBFLAGS) $(LD_STATIC_FLAG) $(CPICFLAG) $(LDFLAGS)
 
 BUILD_LDFLAGS = @BUILD_LDFLAGS@
@@ -318,6 +319,10 @@
 USE_64_BIT_IDX_T = @USE_64_BIT_IDX_T@
 OCTAVE_IDX_TYPE = @OCTAVE_IDX_TYPE@
 
+if AMCOND_ADDRESS_SANITIZER_ENABLED
+  ADDRESS_SANITIZER_OPTIONS="symbolize=1"
+endif
+
 # The arguments passed to configure.
 config_opts = @config_opts@
 
@@ -537,7 +542,6 @@
     -e "s|%OCTAVE_CONF_CXXCPP%|\"${CXXCPP}\"|" \
     -e "s|%OCTAVE_CONF_CXXFLAGS%|\"${CXXFLAGS}\"|" \
     -e "s|%OCTAVE_CONF_CXXPICFLAG%|\"${CXXPICFLAG}\"|" \
-    -e "s|%OCTAVE_CONF_CXX_VERSION%|\"${CXX_VERSION}\"|" \
     -e "s|%OCTAVE_CONF_DEFAULT_PAGER%|\"${DEFAULT_PAGER}\"|" \
     -e "s|%OCTAVE_CONF_DEFS%|\"${DEFS}\"|" \
     -e "s|%OCTAVE_CONF_DEPEND_FLAGS%|\"${DEPEND_FLAGS}\"|" \
@@ -707,7 +711,6 @@
     -e "s|%OCTAVE_CONF_CXXCPP%|\"${CXXCPP}\"|" \
     -e "s|%OCTAVE_CONF_CXXFLAGS%|\"${CXXFLAGS}\"|" \
     -e "s|%OCTAVE_CONF_CXXPICFLAG%|\"${CXXPICFLAG}\"|" \
-    -e "s|%OCTAVE_CONF_CXX_VERSION%|\"${CXX_VERSION}\"|" \
     -e "s|%OCTAVE_CONF_DEFAULT_PAGER%|\"${DEFAULT_PAGER}\"|" \
     -e "s|%OCTAVE_CONF_DEFS%|\"${DEFS}\"|" \
     -e "s|%OCTAVE_CONF_DEPEND_FLAGS%|\"${DEPEND_FLAGS}\"|" \
@@ -886,6 +889,7 @@
     -e "s|%AWK%|${AWK}|g" \
     -e "s|%FIND%|${FIND}|g" \
     -e "s|%SED%|${SED}|g" \
+    -e "s|%ADDRESS_SANITIZER_OPTIONS%|${ADDRESS_SANITIZER_OPTIONS}|g" \
     -e "s|%abs_top_srcdir%|${abs_top_srcdir}|" \
     -e "s|%builddir%|$(shell pwd)|" > $@-t && \
   $(simple_move_if_change_rule)
@@ -931,10 +935,10 @@
 endef
 
 define gdbinit_install_rule
-  if [ -f .gdbinit ]; then \
-    echo "refusing to overwrite .gdbinit with newer version from $<" 1>&2; \
+  if [ -f $@ ]; then \
+    echo "refusing to overwrite $@ with newer version from $<" 1>&2; \
   else \
-    echo "Installing .gdbinit from version at $<" ; \
+    echo "Installing $@ from version at $<" ; \
     cp $< $@; \
   fi
 endef
--- a/build-aux/mk-opts.pl	Tue Dec 08 07:49:49 2015 -0800
+++ b/build-aux/mk-opts.pl	Thu Dec 10 12:50:06 2015 -0800
@@ -372,7 +372,7 @@
 // DO NOT EDIT!
 // Generated automatically from $DEFN_FILE.
 
-#if !defined (octave_${CLASS_NAME}_h)
+#if ! defined (octave_${CLASS_NAME}_h)
 #define octave_${CLASS_NAME}_h 1
 
 #include <cfloat>
@@ -676,14 +676,14 @@
               $elt_type = "octave_idx_type";
             }
           print qq|    Array<$elt_type> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n|;
-          print qq|    if (val.length () == 1)
+          print qq|    if (val.numel () == 1)
       {
         os << val(0) << "\\n";
       }
     else
       {
         os << "\\n\\n";
-        octave_idx_type len = val.length ();
+        octave_idx_type len = val.numel ();
         Matrix tmp (len, 1);
         for (octave_idx_type i = 0; i < len; i++)
           tmp(i,0) = val(i);
@@ -694,7 +694,7 @@
       elsif ($TYPE[$i] eq "Array<double>")
         {
           print qq|    Array<double> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n|;
-          print qq|    if (val.length () == 1)
+          print qq|    if (val.numel () == 1)
       {
         os << val(0) << "\\n";
       }
@@ -709,7 +709,7 @@
       elsif ($TYPE[$i] eq "Array<float>")
         {
           print qq|    Array<float> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n|;
-          print qq|    if (val.length () == 1)
+          print qq|    if (val.numel () == 1)
       {
         os << val(0) << "\\n";
       }
@@ -752,44 +752,37 @@
       if ($TYPE[$i] eq "double")
         {
           print "      double tmp = val.double_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       elsif ($TYPE[$i] eq "float")
         {
           print "      float tmp = val.float_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       elsif ($TYPE[$i] eq "int" or $TYPE[$i] eq "octave_idx_type")
         {
           print "      int tmp = val.int_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       elsif ($TYPE[$i] eq "std::string")
         {
           print "      std::string tmp = val.string_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       elsif ($TYPE[$i] eq "Array<int>" or $TYPE[$i] eq "Array<octave_idx_type>")
         {
           print "      Array<int> tmp = val.int_vector_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       elsif ($TYPE[$i] eq "Array<double>")
         {
           print "      Array<double> tmp = val.vector_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       elsif ($TYPE[$i] eq "Array<float>")
         {
           print "      Array<float> tmp = val.float_vector_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       else
         {
@@ -856,13 +849,13 @@
               $elt_type = "octave_idx_type";
             }
           print "      Array<$elt_type> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n";
-          print "      if (val.length () == 1)
+          print "      if (val.numel () == 1)
         {
           retval = static_cast<double> (val(0));
         }
       else
         {
-          octave_idx_type len = val.length ();
+          octave_idx_type len = val.numel ();
           ColumnVector tmp (len);
           for (octave_idx_type i = 0; i < len; i++)
             tmp(i) = val(i);
@@ -872,7 +865,7 @@
       elsif ($TYPE[$i] eq "Array<double>")
         {
           print "      Array<double> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n";
-          print "      if (val.length () == 1)
+          print "      if (val.numel () == 1)
         {
           retval = val(0);
         }
@@ -884,7 +877,7 @@
       elsif ($TYPE[$i] eq "Array<float>")
         {
           print "      Array<float> val = $STATIC_OBJECT_NAME.$OPT[$i] ();\n\n";
-          print "      if (val.length () == 1)
+          print "      if (val.numel () == 1)
         {
           retval = val(0);
         }
@@ -939,26 +932,22 @@
 
   int nargin = args.length ();
 
+  if (nargin > 2)
+    print_usage ();
+
   if (nargin == 0)
     {
       print_$CLASS_NAME (octave_stdout);
     }
-  else if (nargin == 1 || nargin == 2)
+  else
     {
-      std::string keyword = args(0).string_value ();
+      std::string keyword = args(0).xstring_value ("$OPT_FCN_NAME: expecting keyword as first argument");
 
-      if (! error_state)
-        {
-          if (nargin == 1)
-            retval = show_$CLASS_NAME (keyword);
-          else
-            set_$CLASS_NAME (keyword, args(1));
-        }
+      if (nargin == 1)
+        retval = show_$CLASS_NAME (keyword);
       else
-        error ("$OPT_FCN_NAME: expecting keyword as first argument");
+        set_$CLASS_NAME (keyword, args(1));
     }
-  else
-    print_usage ();
 
   return retval;
 }
--- a/build-aux/move-if-change	Tue Dec 08 07:49:49 2015 -0800
+++ b/build-aux/move-if-change	Thu Dec 10 12:50:06 2015 -0800
@@ -5,7 +5,7 @@
 
 if test -r $2; then
   if cmp $1 $2 > /dev/null; then
-    echo $2 is unchanged
+    echo $2 is unchanged 1>&2
     rm -f $1
   else
     mv -f $1 $2
--- a/build-aux/stl_algo.h-fixed	Tue Dec 08 07:49:49 2015 -0800
+++ b/build-aux/stl_algo.h-fixed	Thu Dec 10 12:50:06 2015 -0800
@@ -383,10 +383,10 @@
   template<typename _RandomAccessIter, typename _Integer, typename _Tp>
     _RandomAccessIter
     __search_n(_RandomAccessIter __first, _RandomAccessIter __last,
-	       _Integer __count, const _Tp& __val, 
+	       _Integer __count, const _Tp& __val,
 	       std::random_access_iterator_tag)
     {
-      
+
       typedef typename std::iterator_traits<_RandomAccessIter>::difference_type
 	_DistanceType;
 
@@ -399,7 +399,7 @@
 	  __tailSize -= __remainder;
 	  // __first here is always pointing to one past the last element of
 	  // next possible match.
-	  _RandomAccessIter __backTrack = __first; 
+	  _RandomAccessIter __backTrack = __first;
 	  while (*--__backTrack == __val)
 	    {
 	      if (--__remainder == 0)
@@ -464,7 +464,7 @@
 	       _Integer __count, const _Tp& __val,
 	       _BinaryPredicate __binary_pred, std::random_access_iterator_tag)
     {
-      
+
       typedef typename std::iterator_traits<_RandomAccessIter>::difference_type
 	_DistanceType;
 
@@ -477,7 +477,7 @@
 	  __tailSize -= __remainder;
 	  // __first here is always pointing to one past the last element of
 	  // next possible match.
-	  _RandomAccessIter __backTrack = __first; 
+	  _RandomAccessIter __backTrack = __first;
 	  while (__binary_pred(*--__backTrack, __val))
 	    {
 	      if (--__remainder == 0)
@@ -1052,7 +1052,7 @@
       __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
 	    typename iterator_traits<_InputIterator>::value_type>)
       __glibcxx_requires_valid_range(__first, __last);
-      
+
       for (; __first != __last; ++__first)
 	if (__pred(*__first))
 	  {
@@ -1657,7 +1657,7 @@
    *  @param  __last    A forward iterator.
    *  @return  Nothing.
    *
-   *  Rotates the elements of the range @p [__first,__last) by 
+   *  Rotates the elements of the range @p [__first,__last) by
    *  @p (__middle - __first) positions so that the element at @p __middle
    *  is moved to @p __first, the element at @p __middle+1 is moved to
    *  @p __first+1 and so on for each element in the range
@@ -1696,13 +1696,13 @@
    *  @return   An iterator designating the end of the resulting sequence.
    *
    *  Copies the elements of the range @p [__first,__last) to the
-   *  range beginning at @result, rotating the copied elements by 
+   *  range beginning at @result, rotating the copied elements by
    *  @p (__middle-__first) positions so that the element at @p __middle
    *  is moved to @p __result, the element at @p __middle+1 is moved
    *  to @p __result+1 and so on for each element in the range @p
    *  [__first,__last).
    *
-   *  Performs 
+   *  Performs
    *  @p *(__result+(n+(__last-__middle))%(__last-__first))=*(__first+n)
    *  for each @p n in the range @p [0,__last-__first).
   */
@@ -2584,10 +2584,10 @@
       __glibcxx_function_requires(_LessThanOpConcept<_ValueType, _Tp>)
       __glibcxx_function_requires(_LessThanOpConcept<_Tp, _ValueType>)	
       __glibcxx_requires_partitioned_lower(__first, __last, __val);
-      __glibcxx_requires_partitioned_upper(__first, __last, __val);      
+      __glibcxx_requires_partitioned_upper(__first, __last, __val);
 
       _DistanceType __len = std::distance(__first, __last);
- 
+
       while (__len > 0)
 	{
 	  _DistanceType __half = __len >> 1;
@@ -2984,7 +2984,7 @@
     }
 
   /// This is a helper function for the merge routines.
-  template<typename _BidirectionalIterator, typename _Distance, 
+  template<typename _BidirectionalIterator, typename _Distance,
 	   typename _Pointer, typename _Compare>
     void
     __merge_adaptive(_BidirectionalIterator __first,
@@ -4068,7 +4068,7 @@
    *  @ingroup sorting_algorithms
    *  @param  __first  Start of range.
    *  @param  __last   End of range.
-   *  @return  make_pair(m, M), where m is the first iterator i in 
+   *  @return  make_pair(m, M), where m is the first iterator i in
    *           [__first, __last) such that no other element in the range is
    *           smaller, and where M is the last iterator i in [__first, __last)
    *           such that no other element in the range is larger.
@@ -4144,7 +4144,7 @@
    *  @param  __first  Start of range.
    *  @param  __last   End of range.
    *  @param  __comp   Comparison functor.
-   *  @return  make_pair(m, M), where m is the first iterator i in 
+   *  @return  make_pair(m, M), where m is the first iterator i in
    *           [__first, __last) such that no other element in the range is
    *           smaller, and where M is the last iterator i in [__first, __last)
    *           such that no other element in the range is larger.
@@ -4262,7 +4262,7 @@
    *  @param  __last1   End of first range.
    *  @param  __first2  Start of second range.
    *  @return true if there exists a permutation of the elements in the range
-   *          [__first2, __first2 + (__last1 - __first1)), beginning with 
+   *          [__first2, __first2 + (__last1 - __first1)), beginning with
    *          ForwardIterator2 begin, such that equal(__first1, __last1, begin)
    *          returns true; otherwise, returns false.
   */
@@ -4337,7 +4337,7 @@
 	  if (__scan != _GLIBCXX_STD_A::find_if(__first1, __scan,
 						std::bind(__pred, _1, *__scan)))
 	    continue; // We've seen this one before.
-	  
+	
 	  auto __matches = std::count_if(__first2, __last2,
 					 std::bind(__pred, _1, *__scan));
 	  if (0 == __matches
@@ -5106,9 +5106,9 @@
    *
    *  _GLIBCXX_RESOLVE_LIB_DEFECTS
    *  DR 241. Does unique_copy() require CopyConstructible and Assignable?
-   *  
+   *
    *  _GLIBCXX_RESOLVE_LIB_DEFECTS
-   *  DR 538. 241 again: Does unique_copy() require CopyConstructible and 
+   *  DR 538. 241 again: Does unique_copy() require CopyConstructible and
    *  Assignable?
   */
   template<typename _InputIterator, typename _OutputIterator>
@@ -5427,7 +5427,7 @@
    *  @return  Nothing.
    *
    *  Sorts the elements in the range @p [__first,__last) in ascending order,
-   *  such that for each iterator @e i in the range @p [__first,__last-1),  
+   *  such that for each iterator @e i in the range @p [__first,__last-1),
    *  *(i+1)<*i is false.
    *
    *  The relative ordering of equivalent elements is not preserved, use
@@ -6202,7 +6202,7 @@
 	    ++__first1;
 	    ++__first2;
 	  }
-      return std::copy(__first2, __last2, 
+      return std::copy(__first2, __last2,
 		       std::copy(__first1, __last1, __result));
     }
 
--- a/configure.ac	Tue Dec 08 07:49:49 2015 -0800
+++ b/configure.ac	Thu Dec 10 12:50:06 2015 -0800
@@ -19,14 +19,14 @@
 ### <http://www.gnu.org/licenses/>.
 
 AC_PREREQ([2.63])
-AC_INIT([GNU Octave], [4.0.0], [http://octave.org/bugs.html], [octave])
+AC_INIT([GNU Octave], [4.1.0+], [http://octave.org/bugs.html], [octave])
 
 dnl Note that the version number is duplicated here and in AC_INIT
 dnl because AC_INIT requires it to be static, not computed from
 dnl shell variables.
 OCTAVE_MAJOR_VERSION=4
-OCTAVE_MINOR_VERSION=0
-OCTAVE_PATCH_VERSION=0
+OCTAVE_MINOR_VERSION=1
+OCTAVE_PATCH_VERSION=0+
 
 dnl PACKAGE_VERSION is set by the AC_INIT VERSION arg
 OCTAVE_VERSION="$PACKAGE_VERSION"
@@ -256,16 +256,15 @@
 ### Disable running Make in the doc directory.
 ### This is useful, for example, when building Octave on systems without TeX.
 
-DOCDIR=doc
+ENABLE_DOCS=yes
 AC_ARG_ENABLE([docs],
   [AS_HELP_STRING([--disable-docs], [don't build documentation files])],
   [if test "$enableval" = no; then
-     DOCDIR=
+     ENABLE_DOCS=no
      warn_docs="building documentation disabled; make dist will fail"
      OCTAVE_CONFIGURE_WARNING([warn_docs])
    fi],
   [])
-AC_SUBST(DOCDIR)
 
 ### If possible, use a 64-bit integer type for array dimensions and indexing.
 
@@ -584,11 +583,6 @@
 
 ### Determine the Fortran compiler and how to invoke it
 
-## Default FFLAGS is -O.
-if test -z "$FFLAGS"; then
-  FFLAGS="-O"
-fi
-
 ## Prefer gfortran, but the user's F77 environment variable will override.
 AC_PROG_F77([gfortran])
 if test -z "$F77"; then
@@ -2452,25 +2446,24 @@
 ### makeinfo are missing.  Skip this warning if building docs was
 ### disabled with a configure option.
 
-if test -n "$DOCDIR"; then
+if test $ENABLE_DOCS = yes; then
   if test -n "$warn_gnuplot"; then
-    DOCDIR=
+    ENABLE_DOCS = no
     warn_docs_gnuplot="building documentation disabled because gnuplot was not found; make dist will fail"
     OCTAVE_CONFIGURE_WARNING([warn_docs_gnuplot])
   fi
   if test -n "$warn_makeinfo"; then
-    DOCDIR=
+    ENABLE_DOCS = no
     warn_docs_makeinfo="building documentation disabled because makeinfo was not found; make dist will fail"
     OCTAVE_CONFIGURE_WARNING([warn_docs_makeinfo])
   fi
 fi
-AM_CONDITIONAL([AMCOND_BUILD_DOCS], [test -n "$DOCDIR"])
+AM_CONDITIONAL([AMCOND_BUILD_DOCS], [test $ENABLE_DOCS = yes])
 
 ### Maybe add -Wall, -W, and -Wshadow to compiler flags now that we're
 ### done feature testing.
 
 GCC_EXTRA_FLAGS="-Wall -W -Wshadow -Wformat -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wcast-align -Wcast-qual"
-
 GXX_EXTRA_FLAGS="-Wall -W -Wshadow -Wold-style-cast -Wformat -Wpointer-arith -Wwrite-strings -Wcast-align -Wcast-qual"
 
 try_extra_warning_flags=yes
@@ -2497,7 +2490,6 @@
 fi
 
 GCC_STRICT_FLAGS="-Wconversion"
-
 GXX_STRICT_FLAGS="-Wconversion -Weffc++"
 
 try_strict_warning_flags=no
@@ -2523,8 +2515,45 @@
   done
 fi
 
+GCC_ADDRESS_SANITIZER_FLAGS="-fsanitize=address -fno-omit-frame-pointer"
+GXX_ADDRESS_SANITIZER_FLAGS="-fsanitize=address -fno-omit-frame-pointer"
+LD_ADDRESS_SANITIZER_FLAGS="-fsanitize=address"
+
+try_address_sanitizer_flags=no
+
+AC_ARG_ENABLE([address-sanitizer-flags],
+  [AS_HELP_STRING([--enable-address-sanitizer-flags],
+    [add extra -fsanitize=address and -fno-omit-frame-pointer options to CFLAGS, CXXFLAGS, and LDFLAGS])],
+  [if test "$enableval" = yes; then
+     try_address_sanitizer_flags=yes
+   fi],
+  [])
+
+AM_CONDITIONAL([AMCOND_ADDRESS_SANITIZER_ENABLED],
+  [test $try_address_sanitizer_flags = yes])
+
+if test $try_address_sanitizer_flags = yes; then
+  for flag in $GCC_ADDRESS_SANITIZER_FLAGS; do
+    OCTAVE_CC_FLAG([$flag], [
+      WARN_CFLAGS="$WARN_CFLAGS $flag";
+      AC_MSG_RESULT([adding $flag to WARN_CFLAGS])])
+  done
+  for flag in $GXX_ADDRESS_SANITIZER_FLAGS; do
+    OCTAVE_CXX_FLAG([$flag], [
+      WARN_CXXFLAGS="$WARN_CXXFLAGS $flag";
+      AC_MSG_RESULT([adding $flag to WARN_CXXFLAGS])])
+  done
+  dnl FIXME: do we really need an LD-specific test, or is this good enough?
+  for flag in $LD_ADDRESS_SANITIZER_FLAGS; do
+    OCTAVE_CC_FLAG([$flag], [
+      WARN_LDFLAGS="$WARN_LDFLAGS $flag";
+      AC_MSG_RESULT([adding $flag to WARN_LDFLAGS])])
+  done
+fi
+
 AC_SUBST(WARN_CFLAGS)
 AC_SUBST(WARN_CXXFLAGS)
+AC_SUBST(WARN_LDFLAGS)
 
 ### Check for Java.
 
@@ -2664,7 +2693,7 @@
     ;;
   esac
 
-  ## Determine which library file name to search for.
+  ## Determine which library filename to search for.
   case $host_os in
     darwin*)
       jvmlib=libjvm.dylib
@@ -2865,6 +2894,12 @@
   fi
 
   if test $build_gui = yes; then
+    OCTAVE_CHECK_QT_OPENGL_OK([],
+      [warn_gui="Qt does not work with the OpenGL libs (GL and GLU) -- disabling GUI"
+       build_gui=no])
+  fi
+
+  if test $build_gui = yes; then
     OCTAVE_CHECK_FUNC_QABSTRACTITEMMODEL_BEGINRESETMODEL
     if test $octave_cv_func_qabstractitemmodel_beginresetmodel = no; then
       warn_gui="QAbstractItemModel::beginResetModel() not found -- disabling GUI"
@@ -3002,24 +3037,9 @@
 AC_CONFIG_FILES([
   oct-conf-post.h:oct-conf-post.in.h
   Makefile
-  doc/Makefile
-  doc/doxyhtml/Makefile
   doc/doxyhtml/Doxyfile
-  doc/interpreter/Makefile
-  doc/liboctave/Makefile
-  doc/refcard/Makefile
-  etc/icons/Makefile
-  examples/Makefile
-  examples/code/Makefile
-  examples/data/Makefile
   libgnu/Makefile
-  libgui/Makefile
-  libinterp/Makefile
-  liboctave/Makefile
-  liboctave/cruft/mkf77def
-  scripts/Makefile
-  src/Makefile
-  test/Makefile])
+  liboctave/cruft/mkf77def])
 
 AC_OUTPUT
 
@@ -3037,6 +3057,7 @@
   Fortran libraries:           $FLIBS
   Lex libraries:               $LEXLIB
   LIBS:                        $LIBS
+  Extra LDFLAGS:               $WARN_LDFLAGS
 
   AMD CPPFLAGS:                $AMD_CPPFLAGS
   AMD LDFLAGS:                 $AMD_LDFLAGS
@@ -3143,6 +3164,7 @@
   64-bit array dims and indexing:     $USE_64_BIT_IDX_T
   OpenMP SMP multithreading:          $USE_OPENMP
   Build cross tools:                  $cross_tools
+  Build docs:                         $ENABLE_DOCS
 ])
 
 warn_msg_printed=false
--- a/doc/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-# Makefile for Octave's doc directory
-#
-# Copyright (C) 1993-2015 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 $(top_srcdir)/build-aux/common.mk
-
-## Avoid making multiple subdirs in parallel
-## which can lead to a confusing error message stream.
-.NOTPARALLEL:
-
-EXTRA_DIST = \
-  Makefile.am \
-  texmf.cnf
-
-SUBDIRS = doxyhtml interpreter liboctave refcard
-
--- a/doc/doxyhtml/Doxyfile.in	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/doxyhtml/Doxyfile.in	Thu Dec 10 12:50:06 2015 -0800
@@ -189,6 +189,23 @@
 MACRO_EXPANSION = YES
 EXPAND_ONLY_PREDEF = NO
 
+# We need to specify INCLUDE_PATH otherwise preprocessor will fail to
+# include, and macro expansion will not work.
+
+INCLUDE_PATH = \
+  @top_srcdir@/libgnu \
+  @top_srcdir@/libinterp/corefcn \
+  @top_srcdir@/libinterp/octave-value \
+  @top_srcdir@/libinterp/operators \
+  @top_srcdir@/libinterp/parse-tree \
+  @top_srcdir@/libinterp/template-inst \
+  @top_srcdir@/liboctave/array \
+  @top_srcdir@/liboctave/numeric \
+  @top_srcdir@/liboctave/operators \
+  @top_srcdir@/liboctave/system \
+  @top_srcdir@/liboctave/util \
+  @top_srcdir@/src
+
 # So that features that are behind #ifdef HAVE_FOO macros get processed by Doxygen
 
 PREDEFINED = HAVE_ARPACK=1          \
@@ -314,4 +331,4 @@
 
 # Some of our dependency graphs are really huge...
 
-DOT_GRAPH_MAX_NODES    = 100
\ No newline at end of file
+DOT_GRAPH_MAX_NODES    = 100
--- a/doc/doxyhtml/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-# Makefile for Octave's doc/doxyhtml directory
-#
-# Copyright (C) 1993-2015 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 $(top_srcdir)/build-aux/common.mk
-
-doxyhtml:
-	doxygen Doxyfile
-
-EXTRA_DIST = \
-  Doxyfile.in \
-  Makefile.am \
-  README
-
-maintainer-clean-local:
-	rm -rf `ls | $(GREP) -v Doxyfile | $(GREP) -v Makefile.am | $(GREP) -v Makefile.in | $(GREP) -v README`
--- a/doc/interpreter/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,303 +0,0 @@
-# Makefile for Octave's doc/interpreter directory
-#
-# Copyright (C) 1993-2015 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 $(top_srcdir)/build-aux/common.mk
-
-## Leading PATH_SEPARATOR required due to weak parsing by dvips (12/04/09)
-TEXINPUTS := "$(PATH_SEPARATOR)$(srcdir)$(PATH_SEPARATOR)$(TEXINPUTS)$(PATH_SEPARATOR)"
-export TEXINPUTS
-
-## Include custom texmf.cnf necessary to run @seealso macro
-TEXMFCNF := "..$(PATH_SEPARATOR)$(srcdir)/..$(PATH_SEPARATOR)$(TEXMFCNF)$(PATH_SEPARATOR)"
-export TEXMFCNF
-
-dist_man_MANS = \
-  mkoctfile.1 \
-  octave-cli.1 \
-  octave-config.1 \
-  octave.1
-
-## The following files are included in the manual via the @EXAMPLEFILE macro.
-## They are dependencies for the documentation.
-## They must not be distributed from this directory.
-EXAMPLE_FILES = \
-  $(top_srcdir)/examples/code/@FIRfilter/FIRfilter.m \
-  $(top_srcdir)/examples/code/@FIRfilter/FIRfilter_aggregation.m \
-  $(top_srcdir)/examples/code/@FIRfilter/display.m \
-  $(top_srcdir)/examples/code/@FIRfilter/subsasgn.m \
-  $(top_srcdir)/examples/code/@FIRfilter/subsref.m \
-  $(top_srcdir)/examples/code/@polynomial/display.m \
-  $(top_srcdir)/examples/code/@polynomial/double.m \
-  $(top_srcdir)/examples/code/@polynomial/end.m \
-  $(top_srcdir)/examples/code/@polynomial/get.m \
-  $(top_srcdir)/examples/code/@polynomial/mtimes.m \
-  $(top_srcdir)/examples/code/@polynomial/plot.m \
-  $(top_srcdir)/examples/code/@polynomial/polynomial.m \
-  $(top_srcdir)/examples/code/@polynomial/polynomial_superiorto.m \
-  $(top_srcdir)/examples/code/@polynomial/polyval.m \
-  $(top_srcdir)/examples/code/@polynomial/set.m \
-  $(top_srcdir)/examples/code/@polynomial/subsref.m \
-  $(top_srcdir)/examples/code/addtwomatrices.cc \
-  $(top_srcdir)/examples/code/celldemo.cc \
-  $(top_srcdir)/examples/code/embedded.cc \
-  $(top_srcdir)/examples/code/fortrandemo.cc \
-  $(top_srcdir)/examples/code/fortransub.f \
-  $(top_srcdir)/examples/code/funcdemo.cc \
-  $(top_srcdir)/examples/code/globaldemo.cc \
-  $(top_srcdir)/examples/code/helloworld.cc \
-  $(top_srcdir)/examples/code/mycell.c \
-  $(top_srcdir)/examples/code/myfeval.c \
-  $(top_srcdir)/examples/code/myfunc.c \
-  $(top_srcdir)/examples/code/myhello.c \
-  $(top_srcdir)/examples/code/mypow2.c \
-  $(top_srcdir)/examples/code/mysparse.c \
-  $(top_srcdir)/examples/code/mystring.c \
-  $(top_srcdir)/examples/code/mystruct.c \
-  $(top_srcdir)/examples/code/paramdemo.cc \
-  $(top_srcdir)/examples/code/standalone.cc \
-  $(top_srcdir)/examples/code/stringdemo.cc \
-  $(top_srcdir)/examples/code/structdemo.cc \
-  $(top_srcdir)/examples/code/unwinddemo.cc
-
-
-include images.mk
-
-$(srcdir)/images.mk: $(srcdir)/config-images.sh $(srcdir)/images.awk $(srcdir)/images
-	$(srcdir)/config-images.sh $(top_srcdir)
-
-JAVA_IMAGES = \
-  java-images/image001.png \
-  java-images/image002.png \
-  java-images/image003.png \
-  java-images/image004.png \
-  java-images/image005.png \
-  java-images/image006.png \
-  java-images/image007.png \
-  java-images/image008.png \
-  java-images/image009.png
-
-BUILT_IMAGES = \
-  $(IMAGES_EPS) \
-  $(IMAGES_PDF) \
-  $(IMAGES_PNG) \
-  $(IMAGES_TXT)
-
-IMAGES = \
-  $(BUILT_IMAGES) \
-  $(JAVA_IMAGES)
-
-## FIXME: JAVA_IMAGES will eventually need to be added to the HTML build.
-##        It will require a different Makefile rule later because
-##        JAVA_IMAGES live in a subdir rather than in the current directory.
-HTMLDIR_IMAGES = $(addprefix octave.html/, $(IMAGES_PNG))
-
-LOGOS = \
-  octave_logo.eps \
-  octave_logo.pdf
-
-MUNGED_TEXI_SRC = \
-  arith.texi \
-  audio.texi \
-  basics.texi \
-  bugs.texi \
-  container.texi \
-  contrib.texi \
-  cp-idx.texi \
-  data.texi \
-  debug.texi \
-  diffeq.texi \
-  diagperm.texi \
-  external.texi \
-  emacs.texi \
-  errors.texi \
-  eval.texi \
-  expr.texi \
-  fn-idx.texi \
-  func.texi \
-  geometry.texi \
-  gui.texi \
-  gpl.texi \
-  grammar.texi \
-  image.texi \
-  install.texi \
-  interp.texi \
-  intro.texi \
-  io.texi \
-  java.texi \
-  linalg.texi \
-  matrix.texi \
-  nonlin.texi \
-  numbers.texi \
-  obsolete.texi \
-  oop.texi \
-  op-idx.texi \
-  optim.texi \
-  package.texi \
-  plot.texi \
-  poly.texi \
-  preface.texi \
-  quad.texi \
-  set.texi \
-  signal.texi \
-  sparse.texi \
-  stats.texi \
-  stmt.texi \
-  strings.texi \
-  system.texi \
-  testfun.texi \
-  tips.texi \
-  var.texi \
-  vectorize.texi
-
-TXI_SRC = $(MUNGED_TEXI_SRC:.texi=.txi)
-
-include graphics_properties.mk
-
-BUILT_TEXINFOS = \
-  contributors.texi \
-  $(GRAPH_PROP_TEXI_SRC) \
-  $(MUNGED_TEXI_SRC)
-
-info_TEXINFOS = octave.texi
-
-octave_TEXINFOS = \
-  $(BUILT_TEXINFOS) \
-  $(EXAMPLE_FILES) \
-  $(IMAGES) \
-  $(LOGOS) \
-  $(srcdir)/images.mk
-
-all-local: dvi html pdf ps doc-cache
-
-html: $(HTMLDIR_IMAGES)
-
-$(HTMLDIR_IMAGES): $(IMAGES_PNG) | octave.html
-	cp $(@F) octave.html
-
-## The texi2dvi script (used to create both PDF and DVI output formats)
-## uses some fixed temporary file names.  In order to avoid a race condition
-## the DVI and PDF builds are forced to run serially through a Makefile rule.
-octave.pdf: octave.dvi
-
-# Prevent packaging of distribution unless all libraries
-# necessary to create documentation are present
-dist-hook:
-	@$(GREP) '#define HAVE_COLAMD 1' $(top_builddir)/config.h > /dev/null || { echo "Documentation creation requires missing COLAMD library.  Cannot package distribution!" ; exit 1; }
-	@$(GREP) '#define HAVE_CHOLMOD 1' $(top_builddir)/config.h > /dev/null || { echo "Documentation creation requires missing CHOLMOD library.  Cannot package distribution!" ; exit 1; }
-	@$(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 macros.texi
-
-DOCSTRING_FILES = $(shell $(srcdir)/find-docstring-files.sh "$(top_srcdir)")
-
-doc-cache: $(DOCSTRING_FILES) mk_doc_cache.m
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(top_builddir)/run-octave -f -q -H $(srcdir)/mk_doc_cache.m - $(srcdir)/macros.texi $(DOCSTRING_FILES) >$@-t && \
-	mv $@-t $@
-
-$(MUNGED_TEXI_SRC): $(DOCSTRING_FILES) $(munge_texi_SOURCES)
-
-%.texi: %.txi munge-texi.pl
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(PERL) $(srcdir)/munge-texi.pl $(top_srcdir) $(DOCSTRING_FILES) < $< > $@-t && \
-	mv $@-t $@
-
-contributors.texi: contributors.in
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(AWK) -f $(srcdir)/mkcontrib.awk $(srcdir)/contributors.in > $@-t && \
-	mv $@-t $@
-
-../../AUTHORS: preface.texi contributors.texi
-	$(AM_V_MAKEINFO)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 -I $(srcdir) \
-	  --no-validate --no-headers --no-split --output AUTHORS $< && \
-	mv AUTHORS ../../AUTHORS
-
-../../BUGS: bugs.texi
-	$(AM_V_MAKEINFO)rm -f BUGS && \
-	$(MAKEINFO) -D BUGSONLY -I $(srcdir) \
-	  --no-validate --no-headers --no-split --output BUGS $< && \
-	mv BUGS ../../BUGS
-
-../../INSTALL.OCTAVE: install.texi
-	$(AM_V_MAKEINFO)rm -f INSTALL && \
-	$(MAKEINFO) -D INSTALLONLY -I $(srcdir) \
-	  --no-validate --no-headers --no-split --output INSTALL $< && \
-	mv INSTALL ../../INSTALL.OCTAVE
-
-
-undocumented_list:
-	rm -f $@
-	-$(PERL) $(srcdir)/doccheck/mk_undocumented_list > $@
-.PHONY: undocumented_list
-
-SPELLCHECK_FILES = $(MUNGED_TEXI_SRC:.texi=.scheck)
-
-%.scheck: %.texi
-	$(srcdir)/doccheck/spellcheck $< > $@-t
-	mv $@-t $@
-	[ -s $@ ] || rm -f $@
-
-spellcheck: $(SPELLCHECK_FILES)
-	@if ls *.scheck >/dev/null 2>&1 ; then \
-		echo "Spellcheck failed"; \
-		echo "Review the following files:"; \
-		ls *.scheck ; \
-		exit 1 ; \
-	else \
-		echo "Spellcheck passed"; \
-	fi
-.PHONY: spellcheck
-
-EXTRA_DIST = \
-  config-images.sh \
-  contributors.in \
-  doc-cache \
-  find-docstring-files.sh \
-  genpropdoc.m \
-  graphics_properties.mk \
-  images \
-  images.awk \
-  images.mk \
-  macros.texi \
-  mk_doc_cache.m \
-  mkcontrib.awk \
-  munge-texi.pl \
-  octave.dvi \
-  octave.html \
-  octave.pdf \
-  octave.ps \
-  $(IMAGES) \
-  $(IMAGES_SRC) \
-  $(LOGOS) \
-  $(TXI_SRC)
-
-clean-local:
-	rm -rf t2d_cache
-
-DISTCLEANFILES = $(BUILT_TEXINFOS)
-
-MAINTAINERCLEANFILES = $(BUILT_IMAGES) doc-cache
-
--- a/doc/interpreter/arith.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/arith.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -111,12 +111,8 @@
 @ifnottex
 @code{pi/180}
 @end ifnottex
-(e.g., @code{sin (30 * pi/180)} returns the sine of 30 degrees).  As
-an alternative, Octave provides a number of trigonometric functions
-which work directly on an argument specified in degrees.  These functions
-are named after the base trigonometric function with a @samp{d} suffix.  For
-example, @code{sin} expects an angle in radians while @code{sind} expects an
-angle in degrees.
+or use the @code{deg2rad} function.  For example, @code{sin (30 * pi/180)}
+returns the sine of 30 degrees.  As an alternative, Octave provides a number of trigonometric functions which work directly on an argument specified in degrees.  These functions are named after the base trigonometric function with a @samp{d} suffix.  As an example, @code{sin} expects an angle in radians while @code{sind} expects an angle in degrees.
 
 Octave uses the C library trigonometric functions.  It is expected that these
 functions are defined by the ISO/IEC 9899 Standard.  This Standard is available
@@ -136,6 +132,9 @@
 It should be noted that @sc{matlab} uses different definitions which apparently
 do not distinguish -0.
 
+@DOCSTRING(deg2rad)
+@DOCSTRING(rad2deg)
+
 @DOCSTRING(sin)
 @DOCSTRING(cos)
 @DOCSTRING(tan)
@@ -315,6 +314,8 @@
 @anchor{XREFgammaln}
 @DOCSTRING(lgamma)
 
+@DOCSTRING(psi)
+
 @node Rational Approximations
 @section Rational Approximations
 
--- a/doc/interpreter/audio.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/audio.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -182,6 +182,3 @@
 
 @DOCSTRING(soundsc)
 
-@DOCSTRING(wavread)
-
-@DOCSTRING(wavwrite)
--- a/doc/interpreter/basics.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/basics.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -984,7 +984,7 @@
 interpreter to be run, and an optional initial command line argument to
 pass to that interpreter.  The operating system then runs the
 interpreter with the given argument and the full argument list of the
-executed program.  The first argument in the list is the full file name
+executed program.  The first argument in the list is the full filename
 of the Octave executable.  The rest of the argument list will either be
 options to Octave, or data files, or both.  The @samp{-qf} options are
 usually specified in stand-alone Octave programs to prevent them from
--- a/doc/interpreter/config-images.sh	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/config-images.sh	Thu Dec 10 12:50:06 2015 -0800
@@ -14,6 +14,6 @@
 
 interp_dir=$top_srcdir/doc/interpreter
 
-$AWK -f $interp_dir/images.awk < $interp_dir/images > $interp_dir/images.mk-t
+$AWK -v dir=doc/interpreter -f $interp_dir/images.awk < $interp_dir/images > $interp_dir/images.mk-t
 
 $move_if_change $interp_dir/images.mk-t $interp_dir/images.mk
--- a/doc/interpreter/container.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/container.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -891,8 +891,9 @@
 Strings}), @code{strcmp}, @code{strncmp}, @code{strcmpi},
 @code{strncmpi} (@pxref{Comparing Strings}), @code{str2double},
 @code{deblank}, @code{strtrim}, @code{strtrunc}, @code{strfind},
-@code{strmatch}, , @code{regexp}, @code{regexpi} (@pxref{Manipulating 
-Strings}) and @code{str2double} (@pxref{String Conversions}).
+@code{strmatch}, , @code{regexp}, @code{regexpi}
+(@pxref{Manipulating Strings}) and @code{str2double}
+(@pxref{String Conversions}).
 
 The function @code{iscellstr} can be used to test if an object is a
 cell array of strings.
--- a/doc/interpreter/contributors.in	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/contributors.in	Thu Dec 10 12:50:06 2015 -0800
@@ -11,6 +11,7 @@
 Branden Archer
 Willem Atsma
 Marco Atzeri
+Ander Aurrekoetxea
 Shai Ayal
 Roger Banks
 Ben Barrowes
--- a/doc/interpreter/diffeq.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/diffeq.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -115,6 +115,45 @@
 Octave distribution in the examples directory under the name
 @file{oregonator.m}.
 
+@menu
+* Matlab-compatible solvers::
+@end menu
+
+@node Matlab-compatible solvers
+@subsection Matlab-compatible solvers
+
+Octave also provides a set of solvers for initial value problems for Ordinary
+Differential Equations that have a @sc{matlab}-compatible interface.
+The options for this class of methods are set using the functions.
+
+@itemize
+  @item @code{odeset}
+
+  @item @code{odeget}
+@end itemize
+
+Currently implemented solvers are:
+
+@itemize
+  @item @nospell{Runge-Kutta} methods
+
+  @itemize
+    @item @code{ode45} Integrates a system of non--stiff ordinary differential equations
+    (non--stiff ODEs and DAEs) using second order @nospell{Dormand-Prince}
+    method.  This is a fourth--order accurate integrator therefore the local
+    error normally expected is @math{O(h^5)}.  This solver requires six
+    function evaluations per integration step.
+  @end itemize
+@end itemize
+
+
+@DOCSTRING(ode45)
+
+@DOCSTRING(odeset)
+
+@DOCSTRING(odeget)
+
+
 @node Differential-Algebraic Equations
 @section Differential-Algebraic Equations
 
--- a/doc/interpreter/doccheck/aspell-octave.en.pws	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/doccheck/aspell-octave.en.pws	Thu Dec 10 12:50:06 2015 -0800
@@ -74,7 +74,6 @@
 binornd
 Biomathematics
 bitmapped
-bitmax
 bitwise
 bivariate
 Blackman
@@ -121,6 +120,9 @@
 changesets
 chdir
 Chebyshev
+checkbox
+checkboxes
+checksums
 chisq
 chisquare
 chol
@@ -175,6 +177,7 @@
 courseware
 cov
 CPLEX
+createcancelbtn
 CreateFcn
 CRLF
 Crout
@@ -226,9 +229,11 @@
 diag
 diagcomp
 diamondsuit
+digamma
 dir
 disp
 DisplayName
+displayname
 DisplayNames
 displayrange
 dMatrix
@@ -310,6 +315,7 @@
 fftw
 fieldname
 fieldnames
+FIFOs
 filename
 filenames
 filepaths
@@ -437,6 +443,7 @@
 hygernd
 Hypergeometric
 hypergeometric
+hypervolume
 ichol
 ict
 IEC
@@ -543,6 +550,7 @@
 linestyle
 linewidth
 linkprop
+listbox
 listdlg
 ListSize
 ListString
@@ -701,12 +709,14 @@
 oct
 octaverc
 ODEPACK
+ODEs
 Ogg
 ogg
 OKString
 OLS
 onCleanup
 online
+OpenBLAS
 OpenGL
 OpenJDK
 oplus
@@ -740,6 +750,7 @@
 pcx
 pdf
 PDF
+pdflatex
 pearson
 pentadiagonal
 periodogram
@@ -762,7 +773,9 @@
 polyderiv
 polyeig
 polyfit
+polygamma
 polyval
+popupmenu
 pos
 POSDEF
 POSIX
@@ -778,6 +791,7 @@
 presolver
 printf
 priori
+probit
 Profiler
 profiler
 programmatically
@@ -793,6 +807,7 @@
 pseudospectrum
 ptrace
 punct
+pushbutton
 Pxx
 Qhull
 qhull
@@ -814,6 +829,7 @@
 qz
 QZ
 radices
+radiobutton
 randn
 randperm
 rangle
@@ -885,6 +901,7 @@
 simplecholperm
 simplematrix
 simplices
+sinc
 sinetone
 slx
 sm
@@ -913,6 +930,7 @@
 sprank
 SPSS
 spstats
+SQP
 sqrt
 sqrtm
 sr
@@ -1013,9 +1031,13 @@
 tif
 TikZ
 Timestamp
+TimeStepNumber
+TimeStepSize
 tinv
 tmp
 Toeplitz
+togglebutton
+togglebuttons
 tokenExtents
 TolF
 TolFun
@@ -1032,6 +1054,7 @@
 treelayout
 treeplot
 tridiagonal
+trigamma
 trimesh
 triplot
 trnd
@@ -1048,10 +1071,25 @@
 uchar
 UHESS
 UI
+uicontextmenu
+Uicontextmenu
+Uicontrol
+uicontrol
+uicontrols
 UID
 uimenu
 uint
+uipanel
+Uipanel
+uipanels
+Uipushtool
+uipushtool
+uipushtools
 uiputfile
+uitoggletool
+Uitoggletool
+uitoolbar
+Uitoolbar
 ulong
 Ultrix
 umfpack
@@ -1091,6 +1129,7 @@
 userdata
 Username
 ushort
+UTC
 Vandermonde
 variable's
 varphi
@@ -1106,6 +1145,7 @@
 vee
 versa
 vertcat
+VertexNormals
 verticalalignment
 vertices
 Vorbis
@@ -1163,6 +1203,7 @@
 xmin
 xon
 xPBTRF
+xpos
 xPOTRF
 xPTSV
 xtest
@@ -1183,6 +1224,7 @@
 ylim
 ymax
 ymin
+ypos
 yy
 YY
 yyyy
--- a/doc/interpreter/doccheck/mk_undocumented_list	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/doccheck/mk_undocumented_list	Thu Dec 10 12:50:06 2015 -0800
@@ -4,7 +4,8 @@
 # Get a list from Octave of all visible functions
 @octave_output = <<`_END_OCT_SCRIPT_`;
 ../../run-octave --norc --silent --no-history --eval '\
- funclist  = vertcat (__list_functions__ , __builtins__) \
+ funclist = vertcat (__list_functions__ , __builtins__); \
+ funclist = funclist(! strncmp (funclist, \"meta.\", 5)) \
  disp("#!-separator-!#") \
  where = cellfun (\@which, funclist, \"UniformOutput\", 0)'
 _END_OCT_SCRIPT_
@@ -89,6 +90,7 @@
 F_GETFL
 fact
 finite
+flipdim
 fmod
 F_SETFD
 F_SETFL
@@ -102,9 +104,12 @@
 isfinite
 j
 J
+java2mat
 lower
 lstat
+metaclass
 nan
+nargchk
 octave_tmp_file_name
 O_APPEND
 O_ASYNC
@@ -117,10 +122,12 @@
 O_TRUNC
 O_WRONLY
 paren
+putenv
 SEEK_CUR
 SEEK_END
 semicolon
 setenv
+tmpnam
 toc
 triu
 unimplemented
--- a/doc/interpreter/expr.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/expr.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -1014,6 +1014,8 @@
 strongly discouraged.  Instead, you should use the @samp{&&} and @samp{||}
 operators that always have short-circuit behavior.
 
+@DOCSTRING(do_braindead_shortcircuit_evaluation)
+
 Finally, the ternary operator (?:) is not supported in Octave.  If
 short-circuiting is not important, it can be replaced by the @code{ifelse}
 function.
--- a/doc/interpreter/external.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/external.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -363,12 +363,15 @@
 explicitly checks that there are sufficient arguments available before
 accessing these arguments.  It then obtains two multi-dimensional arrays
 of type @code{NDArray} and adds these together.  Note that the array_value
-method is called without using the @code{is_matrix_type} type, and instead the
-error_state is checked before returning @code{A + B}.  The reason to
+method is called without using the @code{is_matrix_type} type.  If an
+error occurs when attempting to extract the value, Octave will print a
+message and throw an exception.  The reason to
 prefer this is that the arguments might be a type that is not an
 @code{NDArray}, but it would make sense to convert it to one.  The
 @code{array_value} method allows this conversion to be performed
-transparently if possible, and sets @code{error_state} if it is not.
+transparently if possible.  If you need to catch errors like this and
+perform some kind of cleanup or other operation, you can catch the
+@code{octave_execution_error} exception.
 
 @code{A + B}, operating on two @code{NDArray}'s returns an
 @code{NDArray}, which is cast to an @code{octave_value} on the return
--- a/doc/interpreter/find-docstring-files.sh	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-#! /bin/sh
-
-if [ $# -ne 1 ]; then
-  echo "usage: find-docstring-files TOP-SRCDIR" 1>&2
-  exit 1
-fi
-
-## if there is a file in the build directory tree, assume it is
-## the file we are looking for.  Otherwise, get the one from the
-## source tree.
-
-if [ -f "../../scripts/DOCSTRINGS" ]; then
-  echo "../../scripts/DOCSTRINGS"
-else
-  echo "$1/scripts/DOCSTRINGS"
-fi
-
-if [ -f "../../libinterp/DOCSTRINGS" ]; then
-  echo "../../libinterp/DOCSTRINGS"
-else
-  echo "$1/libinterp/DOCSTRINGS"
-fi
--- a/doc/interpreter/genpropdoc.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/genpropdoc.m	Thu Dec 10 12:50:06 2015 -0800
@@ -30,7 +30,9 @@
 
 function genpropdoc (objname, fname)
   objnames = {"root", "figure", "axes", "line", ...
-              "text", "image", "patch", "surface"};
+              "text", "image", "patch", "surface", ...
+              "uimenu", "uicontextmenu", "uipanel", ...
+              "uicontrol", "uitoolbar", "uipushtool", "uitoggletool"};
 
   ## Base properties
   base = getstructure ("base");
@@ -123,6 +125,7 @@
       case "busyaction"
       case "buttondownfcn"
         s.valid = valid_fcn;
+
       case "children"
         s.doc = "Graphics handles of the __objname__'s children.";
         s.valid = "vector of graphics handles";
@@ -169,7 +172,7 @@
         s.doc = "Graphics handle of the uicontextmenu object that is \
 currently associated to this __objname__ object.";
         s.valid = valid_handle;
-        
+
       case "userdata"
         s.doc = "User-defined data to associate with the graphics object.";
         s.valid = "Any Octave data";
@@ -195,9 +198,9 @@
 
       ## Specific properties
       case "callbackobject"
+        s.doc = "Graphics handle of the current object whose callback is executing.";
         s.valid = valid_handle;
 
-      case "commandwindowsize"
       case "currentfigure"
         s.doc = "Graphics handle of the current figure.";
         s.valid = valid_handle;
@@ -282,6 +285,7 @@
       ## Specific properties
       case "alphamap"
         s.doc = sprintf (doc_notimpl, "Transparency");
+
       case "closerequestfcn"
         s.valid = valid_fcn;
 
@@ -325,10 +329,14 @@
         s.doc = doc_unused;
 
       case "doublebuffer"
+
       case "filename"
-        s.doc = "The filename used when saving the plot figure";
+        s.doc = "The filename used when saving the plot figure.";
         s.valid = valid_string;
 
+      case "graphicssmoothing"
+        s.doc = doc_unused;
+
       case "integerhandle"
         s.doc = "Assign the next lowest unused integer as the Figure number.";
 
@@ -355,7 +363,7 @@
 
       case "menubar"
         s.doc = "Control the display of the figure menu bar in the upper \
-left of the figure.";  
+left of the figure.";
 
       case "name"
         s.doc = "Name to be displayed in the figure title bar.  The name is \
@@ -363,6 +371,10 @@
 property.";
         s.valid = valid_string;
 
+      ## FIXME: Uncomment when support added in graphics.in.h
+      #case "number"
+      #  s.doc = "Number of current figure (RO).";
+
       case "nextplot"
 
       case "numbertitle"
@@ -388,7 +400,7 @@
       case "papersize"
         s.doc = "Vector @code{[width height]} defining the size of the \
 paper for printing.  Setting this property forces the @code{papertype} \
-property to be set to @qcode{\"<custom>\"}.";
+property to the value @qcode{\"<custom>\"}.";
         s.valid = valid_2elvec;
 
       case "papertype"
@@ -410,15 +422,23 @@
 
       case "renderer"
       case "renderermode"
+
       case "resize"
+        s.doc = doc_unused;
+
       case "resizefcn"
         s.valid = valid_fcn;
 
       case "selectiontype"
-        s.doc = doc_unused;
+        ## FIXME: docstring explaining what "{normal}|open|alt|extend" mean.
+
+      case "sizechangedfcn"
+        s.valid = valid_fcn;
 
       case "toolbar"
-        s.doc = doc_unused;
+        s.doc = "Control the display of the toolbar along the bottom of the \
+figure window.  When set to @qcode{\"auto\"}, the display is based on the \
+value of the @code{menubar} property.";
 
       case "units"
         s.doc = "The unit used to compute the @code{position} and \
@@ -452,6 +472,9 @@
         s.valid = valid_fcn;
 
       case "windowstyle"
+        s.doc = doc_unused;
+
+      ## FIXME: Need to deprecate these for 4.2
       case "wvisual"
       case "wvisualmode"
       case "xdisplay"
@@ -471,12 +494,17 @@
       case "activepositionproperty"
       case "alim"
         s.doc = sprintf (doc_notimpl, "Transparency");
+
       case "alimmode"
       case "ambientlightcolor"
         s.doc = sprintf (doc_notimpl, "Light");
+
       case "box"
         s.doc = "Control whether the axes has a surrounding box.";
 
+      case "boxstyle"
+        s.doc = doc_unused;
+
       case "cameraposition"
         s.valid = valid_3elvec;
 
@@ -500,6 +528,9 @@
 
       case "climmode"
 
+      case "clippingstyle"
+        s.doc = doc_unused;
+
       case "color"
         s.doc = "Color of the axes background.  @xref{Colors, , colorspec}.";
         s.valid = valid_color;
@@ -509,6 +540,9 @@
 coloring.";
         s.valid = "N-by-3 RGB matrix";
 
+      case "colororderindex"
+        s.doc = doc_unused;
+
       case "currentpoint"
         s.doc = "Matrix @code{[xf, yf, zf; xb, yb, zb]} which holds the \
 coordinates (in axes data units) of the point over which the mouse pointer \
@@ -528,7 +562,6 @@
         s.valid = valid_3elvec;
 
       case "dataaspectratiomode"
-      case "drawmode"
       case "fontangle"
       case "fontname"
         s.doc = "Name of the font used for axes annotations.";
@@ -542,21 +575,55 @@
       case "fontunits"
         s.doc = "Unit used to interpret @code{fontsize} property.";
 
+      case "fontsmoothing"
+        s.doc = doc_unused;
+
       case "fontweight"
 
+      case "gridalpha"
+        s.doc = sprintf (doc_notimpl, "Transparency");
+
+      case "gridalphamode"
+        s.doc = doc_unused;
+
+      case "gridcolor"
+        s.doc = doc_unused;
+
+      case "gridcolormode"
+        s.doc = doc_unused;
+
       case "gridlinestyle"
-      case "interpreter"
+
+      case "labelfontsizemultiplier"
+        s.doc = doc_unused;
 
       case "layer"
         s.doc = "Control whether the axes is drawn below child graphics \
 objects (ticks, labels, etc. covered by plotted objects) or above.";
 
       case "linestyleorder"
+        s.doc = doc_unused;
+
+      case "linestyleorderindex"
+        s.doc = doc_unused;
 
       case "linewidth"
+
+      case "minorgridalpha"
+        s.doc = sprintf (doc_notimpl, "Transparency");
+
+      case "minorgridalphamode"
+        s.doc = doc_unused;
+
+      case "minorgridcolor"
+        s.doc = doc_unused;
+
+      case "minorgridcolormode"
+        s.doc = doc_unused;
+
       case "minorgridlinestyle"
       case "mousewheelzoom"
-        s.doc = "Fraction of axes limits to zoom for each wheel movement."; 
+        s.doc = "Fraction of axes limits to zoom for each wheel movement.";
         s.valid = "scalar in the range (0, 1)";
 
       case "nextplot"
@@ -571,6 +638,9 @@
 @xref{XREFaxesposition, , @w{position property}}.";
         s.valid = valid_4elvec;
 
+      case "pickableparts"
+        s.doc = doc_unused;
+
       case "plotboxaspectratio"
       case "plotboxaspectratiomode"
       case "position"
@@ -585,6 +655,10 @@
         s.valid = valid_4elvec;
 
       case "projection"
+        s.doc = doc_unused;
+
+      case "sortmethod"
+        s.doc = doc_unused;
 
       case "tickdir"
         s.doc = "Control whether axes tick marks project \"in\" to the plot \
@@ -592,6 +666,10 @@
 
       case "tickdirmode"
 
+      case "ticklabelinterpreter"
+        s.doc = "Control the way x/y/zticklabel properties are interpreted.\n\
+@xref{XREFinterpreterusage, , @w{Use of the interpreter property}}.";
+
       case "ticklength"
         s.doc = "Two-element vector @code{[2Dlen 3Dlen]} specifying the \
 length of the tickmarks relative to the longest visible axis.";
@@ -602,6 +680,12 @@
         s.doc = "Graphics handle of the title text object.";
         s.valid = valid_handle;
 
+      case "titlefontsizemultiplier"
+        s.doc = doc_unused;
+
+      case "titlefontweight"
+        s.doc = doc_unused;
+
       case "units"
       case "view"
         s.doc = "Two-element vector @code{[azimuth elevation]} specifying \
@@ -613,6 +697,9 @@
         s.doc = "Color of the x-axis.  @xref{Colors, , colorspec}.";
         s.valid = packopt ({markdef(valid_color), "@qcode{\"none\"}"});
 
+      case "xcolormode"
+        s.doc = doc_unused;
+
       case "xdir"
       case "xgrid"
         s.doc = "Control whether major x grid lines are displayed.";
@@ -642,12 +729,18 @@
         s.valid = valid_cellstring;
 
       case "xticklabelmode"
+      case "xticklabelrotation"
+        s.doc = doc_unused;
+
       case "xtickmode"
       case "yaxislocation"
       case "ycolor"
         s.doc = "Color of the y-axis.  @xref{Colors, , colorspec}.";
         s.valid = packopt ({markdef(valid_color), "@qcode{\"none\"}"});
 
+      case "ycolormode"
+        s.doc = doc_unused;
+
       case "ydir"
       case "ygrid"
         s.doc = "Control whether major y grid lines are displayed.";
@@ -677,11 +770,17 @@
         s.valid = valid_cellstring;
 
       case "yticklabelmode"
+      case "yticklabelrotation"
+        s.doc = doc_unused;
+
       case "ytickmode"
       case "zcolor"
         s.doc = "Color of the z-axis.  @xref{Colors, , colorspec}.";
         s.valid = packopt ({markdef(valid_color), "@qcode{\"none\"}"});
 
+      case "zcolormode"
+        s.doc = doc_unused;
+
       case "zdir"
       case "zgrid"
         s.doc = "Control whether major z grid lines are displayed.";
@@ -711,6 +810,9 @@
         s.valid = valid_cellstring;
 
       case "zticklabelmode"
+      case "zticklabelrotation"
+        s.doc = doc_unused;
+
       case "ztickmode"
     endswitch
 
@@ -734,6 +836,7 @@
         s.doc = doc_unused;
 
       case "interpreter"
+
       case "linestyle"
         s.doc = "@xref{Line Styles}.";
 
@@ -836,6 +939,10 @@
 
       case "horizontalalignment"
       case "interpreter"
+        s.doc = "Control the way the @qcode{\"string\"} property is \
+interpreted.\n\
+@xref{XREFinterpreterusage, , @w{Use of the interpreter property}}.";
+
       case "linestyle"
         s.doc = sprintf (doc_notimpl, "Background area");
 
@@ -1130,6 +1237,140 @@
         s.valid = valid_vecmat;
 
     endswitch
+
+  ## uimenu properties
+  elseif (strcmp (objname, "uimenu"))
+    switch (field)
+      ## Overridden shared properties
+      case "buttondownfcn"
+        s.doc = doc_unused;
+
+      ## Specific properties
+      case "accelerator"
+      case "callback"
+      case "checked"
+      case "enable"
+      case "foregroundcolor"
+      case "label"
+      case "position"
+      case "separator"
+
+    endswitch
+
+  ## uicontextmenu properties
+  elseif (strcmp (objname, "uicontextmenu"))
+    switch (field)
+      ## Overridden shared properties
+      case "buttondownfcn"
+        s.doc = doc_unused;
+
+      ## Specific properties
+      case "callback"
+      case "position"
+
+    endswitch
+
+  ## uipanel properties
+  elseif (strcmp (objname, "uipanel"))
+    switch (field)
+      ## Overridden shared properties
+
+      ## Specific properties
+      case "backgroundcolor"
+      case "bordertype"
+      case "borderwidth"
+      case "fontangle"
+      case "fontname"
+      case "fontsize"
+      case "fontunits"
+      case "fontweight"
+      case "foregroundcolor"
+      case "highlightcolor"
+      case "position"
+      case "resizefcn"
+      case "shadowcolor"
+      case "title"
+      case "titleposition"
+      case "units"
+
+    endswitch
+
+  ## uicontrol properties
+  elseif (strcmp (objname, "uicontrol"))
+    switch (field)
+      ## Overridden shared properties
+
+      ## Specific properties
+      case "backgroundcolor"
+      case "callback"
+      case "cdata"
+      case "enable"
+      case "extent"
+      case "fontangle"
+      case "fontname"
+      case "fontsize"
+      case "fontunits"
+      case "fontweight"
+      case "foregroundcolor"
+      case "horizontalalignment"
+      case "keypressfcn"
+      case "listboxtop"
+      case "max"
+      case "min"
+      case "position"
+      case "sliderstep"
+      case "string"
+      case "style"
+      case "tooltipstring"
+      case "units"
+      case "value"
+      case "verticalalignment"
+
+    endswitch
+
+  ## uitoolbar properties
+  elseif (strcmp (objname, "uitoolbar"))
+    switch (field)
+      ## Overridden shared properties
+      case "buttondownfcn"
+        s.doc = doc_unused;
+
+    endswitch
+
+  ## uipushtool properties
+  elseif (strcmp (objname, "uipushtool"))
+    switch (field)
+      ## Overridden shared properties
+      case "buttondownfcn"
+        s.doc = doc_unused;
+
+      ## Specific properties
+      case "cdata"
+      case "clickedcallback"
+      case "enable"
+      case "separator"
+      case "tooltipstring"
+
+    endswitch
+
+  ## uitoggletool properties
+  elseif (strcmp (objname, "uitoggletool"))
+    switch (field)
+      ## Overridden shared properties
+      case "buttondownfcn"
+        s.doc = doc_unused;
+
+      ## Specific properties
+      case "cdata"
+      case "clickedcallback"
+      case "enable"
+      case "offcallback"
+      case "oncallback"
+      case "separator"
+      case "state"
+      case "tooltipstring"
+
+    endswitch
   endif
 
   ## Replace keywords
@@ -1338,4 +1579,5 @@
   elseif (! isempty (default))
     str = ["def. " default];
   endif
+
 endfunction
--- a/doc/interpreter/geometry.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/geometry.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -433,7 +433,8 @@
 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);
+zz = griddata (x, y, z, xx, yy);
+mesh (xx, yy, zz);
 @end group
 @end example
 
--- a/doc/interpreter/geometryimages.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/geometryimages.m	Thu Dec 10 12:50:06 2015 -0800
@@ -16,10 +16,11 @@
 ## along with Octave; see the file COPYING.  If not, see
 ## <http://www.gnu.org/licenses/>.
 
-function geometryimages (nm, typ)
-  graphics_toolkit ("gnuplot");
+function geometryimages (d, nm, typ)
+  set_graphics_toolkit ();
   set_print_size ();
   hide_output ();
+  outfile = fullfile (d, [nm "." typ]);
   if (strcmp (typ, "png"))
     set (0, "defaulttextfontname", "*");
   endif
@@ -32,9 +33,9 @@
   if (! __have_feature__ ("QHULL")
       && any (strcmp (nm, {"voronoi", "griddata", "convhull", "delaunay", ...
                            "triplot"})))
-    sombreroimage (nm, typ, d_typ);
+    sombreroimage (outfile, typ, d_typ);
   elseif (strcmp (typ, "txt"))
-    image_as_txt (nm);
+    image_as_txt (d, nm);
   elseif (strcmp (nm, "voronoi"))
     rand ("state", 9);
     x = rand (10, 1);
@@ -49,31 +50,32 @@
     xc = r * sin (pi*pc) + c(1);
     yc = r * cos (pi*pc) + c(2);
     plot (xc, yc, "g-", "LineWidth", 3);
-    axis([0, 1, 0, 1]);
+    axis ([0, 1, 0, 1]);
     legend ("Delaunay Triangulation", "Voronoi Diagram");
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "triplot"))
     rand ("state", 2)
     x = rand (20, 1);
     y = rand (20, 1);
     tri = delaunay (x, y);
     triplot (tri, x, y);
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "griddata"))
     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);
-    print ([nm "." typ], d_typ);
+    zz = griddata (x, y, z, xx, yy);
+    mesh (xx, yy, zz);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "convhull"))
     x = -3:0.05:3;
     y = abs (sin (x));
     k = convhull (x, y);
     plot (x(k),y(k),'r-', x,y,'b+');
     axis ([-3.05, 3.05, -0.05, 1.05]);
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "delaunay"))
     rand ("state", 1);
     x = rand (1, 10);
@@ -83,7 +85,7 @@
     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*");
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "inpolygon"))
     randn ("state", 2);
     x = randn (100, 1);
@@ -93,7 +95,7 @@
     in = inpolygon (x, y, vx, vy);
     plot (vx, vy, x(in), y(in), "r+", x(!in), y(!in), "bo");
     axis ([-2, 2, -2, 2]);
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   else
     error ("unrecognized plot requested");
   endif
@@ -111,6 +113,37 @@
   r = sqrt ((xc - x(1)).^2 + (yc - y(1)).^2);
 endfunction
 
+function sombreroimage (outfile, typ, d_typ)
+  if (strcmp (typ, "txt"))
+    fid = fopen (outfile, "wt");
+    fputs (fid, "+-----------------------------+\n");
+    fputs (fid, "| Image unavailable because   |\n");
+    fputs (fid, "| of a missing QHULL library. |\n");
+    fputs (fid, "+-----------------------------+\n");
+    fclose (fid);
+    return;
+  else
+    [x, y, z] = sombrero ();
+    unwind_protect
+      mesh (x, y, z);
+      title ("Sorry, graphics not available because Octave was\\ncompiled without the QHULL library.");
+    unwind_protect_cleanup
+      print (outfile, d_typ);
+      hide_output ();
+    end_unwind_protect
+  endif
+endfunction
+
+## This function no longer sets the graphics toolkit; That is now done
+## automatically by C++ code which will ordinarily choose 'qt', but might
+## choose gnuplot on older systems.  Only a complete lack of plotting is a
+## problem.
+function set_graphics_toolkit ()
+  if (isempty (available_graphics_toolkits ()))
+    error ("no graphics toolkit available for plotting");
+  endif
+endfunction
+
 function set_print_size ()
   image_size = [5.0, 3.5]; # in inches, 16:9 format
   border = 0;              # For postscript use 50/72
@@ -120,41 +153,16 @@
   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).
+## Use this function before plotting commands and after every call to print
+## since print() resets output to stdout (unfortunately, gnuplot can't pop
+## output as it can the terminal type).
 function hide_output ()
-  f = figure (1);
-  set (f, "visible", "off");
-endfunction
-
-function sombreroimage (nm, typ, d_typ)
-  if (strcmp (typ, "txt"))
-    fid = fopen (sprintf ("%s.txt", nm), "wt");
-    fputs (fid, "+-----------------------------+\n");
-    fputs (fid, "| Image unavailable because   |\n");
-    fputs (fid, "| of a missing QHULL library. |\n");
-    fputs (fid, "+-----------------------------+\n");
-    fclose (fid);
-    return;
-  else ## if (!strcmp (typ, "txt"))
-
-    hide_output ();
-
-    [x, y, z] = sombrero ();
-    unwind_protect
-      mesh (x, y, z);
-      title ("Sorry, graphics not available because octave was\\ncompiled without the QHULL library.");
-    unwind_protect_cleanup
-      print ([nm "." typ], d_typ);
-      hide_output ();
-    end_unwind_protect
-  endif
+  hf = figure (1, "visible", "off");
 endfunction
 
 ## generate something for the texinfo @image command to process
-function image_as_txt (nm)
-  fid = fopen (sprintf ("%s.txt", nm), "wt");
+function image_as_txt (d, nm)
+  fid = fopen (fullfile (d, [nm ".txt"]), "wt");
   fputs (fid, "\n");
   fputs (fid, "+---------------------------------+\n");
   fputs (fid, "| Image unavailable in text mode. |\n");
--- a/doc/interpreter/graphics_properties.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/graphics_properties.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,39 +1,39 @@
 GRAPH_PROP_TEXI_SRC= \
-  plot-axesproperties.texi \
-  plot-figureproperties.texi \
-  plot-imageproperties.texi \
-  plot-lineproperties.texi \
-  plot-patchproperties.texi \
-  plot-rootproperties.texi \
-  plot-surfaceproperties.texi \
-  plot-textproperties.texi
+  interpreter/plot-axesproperties.texi \
+  interpreter/plot-figureproperties.texi \
+  interpreter/plot-imageproperties.texi \
+  interpreter/plot-lineproperties.texi \
+  interpreter/plot-patchproperties.texi \
+  interpreter/plot-rootproperties.texi \
+  interpreter/plot-surfaceproperties.texi \
+  interpreter/plot-textproperties.texi
 
 define gen-propdoc-texi
   rm -f $@-t $@ && \
-  $(top_builddir)/run-octave -f -q -H -p $(srcdir) --eval "genpropdoc ('$(1)');" > $@-t && \
+  $(top_builddir)/run-octave -f -q -H -p $(srcdir)/interpreter --eval "genpropdoc ('$(1)');" > $@-t && \
   mv $@-t $@
 endef
 
-plot-axesproperties.texi: genpropdoc.m
+interpreter/plot-axesproperties.texi: interpreter/genpropdoc.m
 	$(AM_V_GEN)$(call gen-propdoc-texi,axes)
 
-plot-figureproperties.texi: genpropdoc.m
+interpreter/plot-figureproperties.texi: interpreter/genpropdoc.m
 	$(AM_V_GEN)$(call gen-propdoc-texi,figure)
 
-plot-imageproperties.texi: genpropdoc.m
+interpreter/plot-imageproperties.texi: interpreter/genpropdoc.m
 	$(AM_V_GEN)$(call gen-propdoc-texi,image)
 
-plot-lineproperties.texi: genpropdoc.m
+interpreter/plot-lineproperties.texi: interpreter/genpropdoc.m
 	$(AM_V_GEN)$(call gen-propdoc-texi,line)
 
-plot-patchproperties.texi: genpropdoc.m
+interpreter/plot-patchproperties.texi: interpreter/genpropdoc.m
 	$(AM_V_GEN)$(call gen-propdoc-texi,patch)
 
-plot-rootproperties.texi: genpropdoc.m
+interpreter/plot-rootproperties.texi: interpreter/genpropdoc.m
 	$(AM_V_GEN)$(call gen-propdoc-texi,root)
 
-plot-surfaceproperties.texi: genpropdoc.m
+interpreter/plot-surfaceproperties.texi: interpreter/genpropdoc.m
 	$(AM_V_GEN)$(call gen-propdoc-texi,surface)
 
-plot-textproperties.texi: genpropdoc.m
+interpreter/plot-textproperties.texi: interpreter/genpropdoc.m
 	$(AM_V_GEN)$(call gen-propdoc-texi,text)
--- a/doc/interpreter/gui.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/gui.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -28,7 +28,7 @@
 results a script can open a dialog box and allow the user to choose a file.
 Similarly, if a calculation is expected to take a long time a script can
 display a progress bar.  The various UI elements can be used to fully customize
-the plot window with menubars, context menus, 
+the plot window with menubars, context menus,
 
 Several utility functions make it possible to store private data for use with
 a GUI which will not pollute the user's variable space.
@@ -50,7 +50,7 @@
 
 Simple dialog menus are available for choosing directories or files.  They
 return a string variable which can then be used with any command requiring
-a file name.
+a filename.
 
 @DOCSTRING(uigetdir)
 
@@ -71,6 +71,8 @@
 toolkit, although some functionality is available with the @code{fltk} toolkit.
 There is no support for the @code{gnuplot} toolkit.
 
+@DOCSTRING(uimenu)
+
 @DOCSTRING(uicontextmenu)
 
 @DOCSTRING(uicontrol)
--- a/doc/interpreter/image.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/image.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -140,6 +140,8 @@
 an RGB color.  The color map must be of class @code{double} with values
 between 0 and 1.
 
+@DOCSTRING(im2double)
+
 @DOCSTRING(iscolormap)
 
 @DOCSTRING(gray2ind)
@@ -190,6 +192,8 @@
 
 @DOCSTRING(summer)
 
+@DOCSTRING(viridis)
+
 @DOCSTRING(white)
 
 @DOCSTRING(winter)
--- a/doc/interpreter/images.awk	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/images.awk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,36 +1,39 @@
 BEGIN {
-  print "## DO NOT EDIT -- generated from module-files by config-module.awk";
+  print "## DO NOT EDIT -- generated from module-files by images.awk";
   print "";
+  print "if AMCOND_BUILD_DOCS";
+
+  if (dir !~ /\/$/)
+      dir = dir "/";
 
   exts[1] = "eps";
   exts[2] = "pdf";
   exts[3] = "png";
   exts[4] = "txt";
-  printf ("IMAGES_SRC =\n");
-  for (i = 1; i <= 4; i++) {
-    printf ("IMAGES_%s =\n", toupper (exts[i]));
-  }
 } {
   script = $1;
   basename = script;
   sub (/\.m$/, "", basename);
   ubasename = toupper (basename);
-  printf ("IMAGES_SRC += %s\n", script);
+  printf ("DOC_IMAGES_SRC += %s%s\n", dir, script);
   for (i = 1; i <= 4; i++) {
     ext = exts[i];
     uext = toupper (ext);
 
     printf ("%s_%s =", ubasename, uext);
     for (j = 2; j <= NF; j++)
-      printf (" %s.%s", $j, ext);
+      printf (" %s%s.%s", dir, $j, ext);
     printf ("\n");
 
-    printf ("IMAGES_%s += $(%s_%s)\n", uext, ubasename, uext);
+    printf ("BUILT_DOC_IMAGES_%s += $(%s_%s)\n", uext, ubasename, uext);
 
     for (j = 2; j <= NF; j++) {
-      printf ("%s.%s: %s\n", $j, ext, script);
-      printf ("\t$(AM_V_GEN)$(top_builddir)/run-octave -f -q -H -p $(srcdir) --eval \"%s ('%s', '%s');\"\n",
-              basename, $j, ext);
+      printf ("%s%s.%s: %s%s\n", dir, $j, ext, dir, script);
+      printf ("\t$(AM_V_GEN)$(abs_top_builddir)/run-octave -f -q -H -p $(abs_top_srcdir)/%s --eval \"%s ('%s', '%s', '%s');\"\n",
+              dir, basename, dir, $j, ext);
     }
   }
 }
+END {
+  print "endif";
+}
--- a/doc/interpreter/interpimages.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/interpimages.m	Thu Dec 10 12:50:06 2015 -0800
@@ -16,10 +16,11 @@
 ## along with Octave; see the file COPYING.  If not, see
 ## <http://www.gnu.org/licenses/>.
 
-function interpimages (nm, typ)
-  graphics_toolkit ("gnuplot");
+function interpimages (d, nm, typ)
+  set_graphics_toolkit ();
   set_print_size ();
   hide_output ();
+  outfile = fullfile (d, [nm "." typ]);
   if (strcmp (typ, "png"))
     set (0, "defaulttextfontname", "*");
   endif
@@ -30,7 +31,7 @@
   endif
 
   if (strcmp (typ, "txt"))
-    image_as_txt (nm);
+    image_as_txt (d, nm);
   elseif (strcmp (nm, "interpft"))
     t = 0 : 0.3 : pi; dt = t(2)-t(1);
     n = length (t); k = 100;
@@ -40,7 +41,7 @@
     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");
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "interpn"))
     x = y = z = -1:1;
     f = @(x,y,z) x.^2 - y - z.^2;
@@ -50,7 +51,7 @@
     [xxi, yyi, zzi] = ndgrid (xi, yi, zi);
     vi = interpn (x, y, z, v, xxi, yyi, zzi, "spline");
     mesh (zi, yi, squeeze (vi(1,:,:)));
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "interpderiv1"))
     t = -2:2;
     dt = 1;
@@ -61,7 +62,7 @@
     yp = interp1 (t,y,ti,"pchip");
     plot (ti, ys,"r-", ti, yp,"g-");
     legend ("spline","pchip", 4);
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "interpderiv2"))
     t = -2:2;
     dt = 1;
@@ -72,11 +73,21 @@
     ddyp = diff (diff (interp1 (t,y,ti,"pchip"))./dti)./dti;
     plot (ti(2:end-1),ddys,"r*", ti(2:end-1),ddyp,"g+");
     legend ("spline", "pchip");
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   endif
   hide_output ();
 endfunction
 
+## This function no longer sets the graphics toolkit; That is now done
+## automatically by C++ code which will ordinarily choose 'qt', but might
+## choose gnuplot on older systems.  Only a complete lack of plotting is a
+## problem.
+function set_graphics_toolkit ()
+  if (isempty (available_graphics_toolkits ()))
+    error ("no graphics toolkit available for plotting");
+  endif
+endfunction
+
 function set_print_size ()
   image_size = [5.0, 3.5]; # in inches, 16:9 format
   border = 0;              # For postscript use 50/72
@@ -86,17 +97,16 @@
   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).
+## Use this function before plotting commands and after every call to print
+## since print() resets output to stdout (unfortunately, gnuplot can't pop
+## output as it can the terminal type).
 function hide_output ()
-  f = figure (1);
-  set (f, "visible", "off");
+  hf = figure (1, "visible", "off");
 endfunction
 
 ## generate something for the texinfo @image command to process
-function image_as_txt(nm)
-  fid = fopen (sprintf ("%s.txt", nm), "wt");
+function image_as_txt (d, nm)
+  fid = fopen (fullfile (d, [nm ".txt"]), "wt");
   fputs (fid, "\n");
   fputs (fid, "+---------------------------------+\n");
   fputs (fid, "| Image unavailable in text mode. |\n");
--- a/doc/interpreter/io.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/io.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -269,7 +269,7 @@
 argument lists for some of the input functions are slightly different,
 however, because Octave has no way of passing arguments by reference.
 
-In the following, @var{file} refers to a file name and @code{fid} refers
+In the following, @var{file} refers to a filename and @code{fid} refers
 to an integer file number, as returned by @code{fopen}.
 
 There are three files that are always available.  Although these files
--- a/doc/interpreter/mkoctfile.1	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/mkoctfile.1	Thu Dec 10 12:50:06 2015 -0800
@@ -88,7 +88,7 @@
 Create a MEX file.  Set the default output extension to \fB.mex\fP.
 .TP
 .B \-o \fIfile\fP\fR,\fB \-\-output \fIfile\fP
-Output file name.  Default extension is \fB.oct\fP (or \fB.mex\fP if \-\-mex is
+Output filename.  Default extension is \fB.oct\fP (or \fB.mex\fP if \-\-mex is
 specified) unless linking a stand-alone executable.
 .TP
 .B \-p \fIVAR\fP\fR,\fB \-\-print \fIVAR\fP
--- a/doc/interpreter/munge-texi.pl	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/munge-texi.pl	Thu Dec 10 12:50:06 2015 -0800
@@ -97,12 +97,12 @@
   while (defined ($_ = <DOCFH>) and ! /$doc_delim/o)
   {
     # expand any @seealso references
-    if (m'^@seealso{')
+    if (m'^@seealso\{')
     {
       # Join multiple lines until full macro body found
       while (! /}/m) { $_ .= <DOCFH>; }
 
-      ($arg_list, $rest_of_line) = m'^@seealso{(.*)}(.*)?'s;
+      ($arg_list, $rest_of_line) = m'^@seealso\{(.*)\}(.*)?'s;
 
       $func_list = $arg_list;
       $func_list =~ s/\s+//gs;
--- a/doc/interpreter/numbers.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/numbers.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -619,12 +619,8 @@
 
 As the maximum value that can be represented by a number is important
 for bit manipulation, particularly when forming masks, Octave supplies
-the function @code{bitmax}.
-
-@DOCSTRING(bitmax)
-
-This is the double precision version of the function @code{intmax},
-previously discussed.
+two utility functions: @code{flintmax} for floating point integers, and
+@code{intmax} for integer objects (@code{uint8}, @code{int64}, etc.).
 
 Octave also includes the basic bitwise 'and', 'or', and 'exclusive or'
 operators.
--- a/doc/interpreter/octave.texi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/octave.texi	Thu Dec 10 12:50:06 2015 -0800
@@ -57,7 +57,7 @@
 @c The version.texi file doesn't include a chapter, so it must not be
 @c included if you want to run the Emacs function
 @c texinfo-multiple-files-update.
-@include version.texi
+@include version-octave.texi
 
 @settitle GNU Octave
 
@@ -542,6 +542,13 @@
 * Image Properties::
 * Patch Properties::
 * Surface Properties::
+* Uimenu Properties::
+* Uicontextmenu Properties::
+* Uipanel Properties::
+* Uicontrol Properties::
+* Uitoolbar Properties::
+* Uipushtool Properties::
+* Uitoggletool Properties::
 
 Advanced Plotting
 
@@ -668,6 +675,10 @@
 * Ordinary Differential Equations::
 * Differential-Algebraic Equations::
 
+Ordinary Differential Equations
+
+* Matlab-compatible solvers::
+
 Optimization
 
 * Linear Programming::
--- a/doc/interpreter/plot.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/plot.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -617,6 +617,7 @@
 
 @node Use of the @code{interpreter} Property
 @subsection Use of the @code{interpreter} Property
+@anchor{XREFinterpreterusage}
 
 All text objects---such as titles, labels, legends, and text---include
 the property @qcode{"interpreter"} that determines the manner in
@@ -913,31 +914,6 @@
 @end tex
 @end float
 
-A complete example showing the capabilities of the extended text is
-
-@example
-@group
-x = 0:0.01:3;
-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',
-' @{\fontsize@{16@}\int_@{\fontsize@{8@}0@}^@{\fontsize@{8@}x@}@}',
-' e^@{-t^2@} dt@} = 0.6175'))
-@end group
-@end example
-
-@ifnotinfo
-@noindent
-The result of which can be seen in @ref{fig:extendedtext}
-
-@float Figure,fig:extendedtext
-@center @image{extended,4in}
-@caption{Example of inclusion of text with the @TeX{} interpreter}
-@end float
-@end ifnotinfo
-
 @node Printing and Saving Plots
 @subsection Printing and Saving Plots
 @cindex plotting, saving and printing plots
@@ -962,12 +938,49 @@
 saves the current figure to an encapsulated PostScript file called
 @file{foo.eps}.
 
-The different graphic toolkits have different print capabilities.  In
-particular, the OpenGL based toolkits such as @code{fltk} do not support
-the @qcode{"interpreter"} property of text objects.  This means special
-symbols drawn with the @qcode{"tex"} interpreter will appear correctly
-on-screen but will be rendered with interpreter @qcode{"none"} when printing.
-Switch graphics toolkits for printing if this is a concern.
+The current graphic toolkits produce very similar graphic displays but differ
+in their capability to display text and in print capabilities.  In particular,
+the OpenGL based toolkits such as @code{fltk} and @code{qt} do not support the
+@qcode{"interpreter"} property of text objects.  This means that when using
+OpenGL toolkits special symbols drawn with the @qcode{"tex"} interpreter will
+appear correctly on-screen but will be rendered with interpreter @qcode{"none"}
+when printing unless one of the @qcode{standalone} (see below) modes is used.
+These modes provide access to the pdflatex processor and therefore allow full
+use of @LaTeX{} commands.
+
+A complete example showing the capabilities of text printing using the
+@code{-dpdflatexstandalone} option is:
+
+@example
+@group
+x = 0:0.01:3;
+hf = figure ();
+plot (x, erf (x));
+hold on;
+plot (x, x, "r");
+axis ([0, 3, 0, 1]);
+text (0.65, 0.6175, ['$\displaystyle\leftarrow x = @{2\over\sqrt@{\pi@}@}'...
+                     '\int_@{0@}^@{x@}e^@{-t^2@} dt = 0.6175$']);
+xlabel ("x");
+ylabel ("erf (x)");
+title ("erf (x) with text annotation");
+set (hf, "visible", "off");
+print (hf, "plot15_7.pdf", "-dpdflatexstandalone");
+set (hf, "visible", "on");
+system ("pdflatex plot15_7");
+open ("plot15_7.pdf");
+@end group
+@end example
+
+@ifnotinfo
+@noindent
+The result of this example can be seen in @ref{fig:extendedtext}
+
+@float Figure,fig:extendedtext
+@center @image{extended,4in}
+@caption{Example of inclusion of text with use of @code{-dpdflatexstandalone}}
+@end float
+@end ifnotinfo
 
 @DOCSTRING(print)
 
@@ -990,9 +1003,8 @@
 @subsection Interacting with Plots
 
 The user can select points on a plot with the @code{ginput} function or
-selection the position at which to place text on the plot with the
-@code{gtext} function using the mouse.  Menus may also be created
-and populated with specific user commands via the @code{uimenu} function.
+select the position at which to place text on the plot with the
+@code{gtext} function using the mouse.
 
 @DOCSTRING(ginput)
 
@@ -1000,7 +1012,8 @@
 
 @DOCSTRING(gtext)
 
-@DOCSTRING(uimenu)
+More sophisticated user interaction mechanisms can be obtained using the
+@nospell{ui*} family of functions, @pxref{UI Elements}.
 
 @node Test Plotting Functions
 @subsection Test Plotting Functions
@@ -1357,6 +1370,13 @@
 * Image Properties::
 * Patch Properties::
 * Surface Properties::
+* Uimenu Properties::
+* Uicontextmenu Properties::
+* Uipanel Properties::
+* Uicontrol Properties::
+* Uitoolbar Properties::
+* Uipushtool Properties::
+* Uitoggletool Properties::
 @end menu
 
 In this Section the graphics object properties are discussed in detail, starting
@@ -1442,6 +1462,61 @@
 
 @include plot-surfaceproperties.texi
 
+@node Uimenu Properties
+@subsubsection Uimenu Properties
+@cindex uimenu properties
+
+The @code{uimenu} properties are:
+
+@include plot-uimenuproperties.texi
+
+@node Uicontextmenu Properties
+@subsubsection Uicontextmenu Properties
+@cindex uicontextmenu properties
+
+The @code{uicontextmenu} properties are:
+
+@include plot-uicontextmenuproperties.texi
+
+@node Uipanel Properties
+@subsubsection Uipanel Properties
+@cindex uipanel properties
+
+The @code{uipanel} properties are:
+
+@include plot-uipanelproperties.texi
+
+@node Uicontrol Properties
+@subsubsection Uicontrol Properties
+@cindex uicontrol properties
+
+The @code{uicontrol} properties are:
+
+@include plot-uicontrolproperties.texi
+
+@node Uitoolbar Properties
+@subsubsection Uitoolbar Properties
+@cindex uitoolbar properties
+
+The @code{uitoolbar} properties are:
+
+@include plot-uitoolbarproperties.texi
+
+@node Uipushtool Properties
+@subsubsection Uipushtool Properties
+@cindex uipushtool properties
+
+The @code{uipushtool} properties are:
+
+@include plot-uipushtoolproperties.texi
+
+@node Uitoggletool Properties
+@subsubsection Uitoggletool Properties
+@cindex uitoggletool properties
+
+The @code{uitoggletool} properties are:
+
+@include plot-uitoggletoolproperties.texi
 
 @node Searching Properties
 @subsection Searching Properties
--- a/doc/interpreter/plotimages.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/plotimages.m	Thu Dec 10 12:50:06 2015 -0800
@@ -16,10 +16,11 @@
 ## along with Octave; see the file COPYING.  If not, see
 ## <http://www.gnu.org/licenses/>.
 
-function plotimages (nm, typ)
-  graphics_toolkit ("gnuplot");
+function plotimages (d, nm, typ)
+  set_graphics_toolkit ();
   set_print_size ();
   hide_output ();
+  outfile = fullfile (d, [nm "." typ]);
   if (strcmp (typ, "png"))
     set (0, "defaulttextfontname", "*");
   endif
@@ -29,22 +30,22 @@
     d_typ = ["-d", typ];
   endif
 
-  if (strcmp(typ , "txt"))
-    image_as_txt(nm);
+  if (strcmp (typ , "txt"))
+    image_as_txt (d, nm);
   elseif (strcmp (nm, "plot"))
     x = -10:0.1:10;
     plot (x, sin (x));
     xlabel ("x");
     ylabel ("sin (x)");
     title ("Simple 2-D Plot");
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "hist"))
     randn ("state", 1);
     hist (randn (10000, 1), 30);
     xlabel ("Value");
     ylabel ("Count");
     title ("Histogram of 10,000 normally distributed random numbers");
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "errorbar"))
     rand ("state", 2);
     x = 0:0.1:10;
@@ -56,11 +57,11 @@
     xlabel ("x");
     ylabel ("sin (x)");
     title ("Errorbar plot of sin (x)");
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "polar"))
     polar (0:0.1:10*pi, 0:0.1:10*pi);
     title ("Example polar plot from 0 to 10*pi");
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "mesh"))
     tx = ty = linspace (-8, 8, 41)';
     [xx, yy] = meshgrid (tx, ty);
@@ -71,35 +72,59 @@
     ylabel ("ty");
     zlabel ("tz");
     title ("3-D Sombrero plot");
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "plot3"))
     t = 0:0.1:10*pi;
     r = linspace (0, 1, numel (t));
     z = linspace (0, 1, numel (t));
-    plot3 (r.*sin(t), r.*cos(t), z);
+    plot3 (r.*sin (t), r.*cos (t), z);
     xlabel ("r.*sin (t)");
     ylabel ("r.*cos (t)");
     zlabel ("z");
     title ("plot3 display of 3-D helix");
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "extended"))
     x = 0:0.01:3;
-    plot (x,erf(x));
+    plot (x, erf (x));
     hold on;
-    plot (x,x,"r");
+    plot (x, x, "r");
     axis ([0, 3, 0, 1]);
-    text (0.65, 0.6175, ['\leftarrow x = {2/\surd\pi {\fontsize{16}' ...
-          '\int_{\fontsize{8}0}^{\fontsize{8}x}} e^{-t^2} dt} = 0.6175']);
     xlabel ("x");
     ylabel ("erf (x)");
     title ("erf (x) with text annotation");
-    print ([nm "." typ], d_typ);
+    if (strcmp (typ, "pdf") && ! strcmp (graphics_toolkit, "gnuplot"))
+      text (0.65, 0.6175, ['$\displaystyle\leftarrow x = {2\over\sqrt{\pi}}'...
+                           '\int_{0}^{x}e^{-t^2} dt = 0.6175$']);
+      ## Be very careful about modifying this.  pdflatex expects to be in
+      ## the same directory as the file it is operating on.
+      cd (make_absolute_filename (d));
+      print ([nm ".pdf"], "-dpdflatexstandalone");
+      [status, output] = system (["pdflatex " nm]);
+      if (status)
+        error ("plotimages: Failed to run pdflatex on <extended.pdf>");
+      endif
+      delete ([nm ".aux"], [nm "-inc.pdf"], [nm ".log"], [nm ".tex"]);
+    else
+      text (0.65, 0.6175, ['\leftarrow x = {2/\surd\pi {\fontsize{16}' ...
+            '\int_{\fontsize{8}0}^{\fontsize{8}x}} e^{-t^2} dt} = 0.6175']);
+      print (outfile, d_typ);
+    endif
   else
     error ("unrecognized plot requested");
   endif
   hide_output ();
 endfunction
 
+## This function no longer sets the graphics toolkit; That is now done
+## automatically by C++ code which will ordinarily choose 'qt', but might
+## choose gnuplot on older systems.  Only a complete lack of plotting is a
+## problem.
+function set_graphics_toolkit ()
+  if (isempty (available_graphics_toolkits ()))
+    error ("no graphics toolkit available for plotting");
+  endif
+endfunction
+
 function set_print_size ()
   image_size = [5.0, 3.5]; # in inches, 16:9 format
   border = 0;              # For postscript use 50/72
@@ -109,20 +134,20 @@
   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).
+## Use this function before plotting commands and after every call to print
+## since print() resets output to stdout (unfortunately, gnuplot can't pop
+## output as it can the terminal type).
 function hide_output ()
-  f = figure (1);
-  set (f, "visible", "off");
+  hf = figure (1, "visible", "off");
 endfunction
 
 ## generate something for the texinfo @image command to process
-function image_as_txt(nm)
-  fid = fopen (sprintf ("%s.txt", nm), "wt");
+function image_as_txt (d, nm)
+  fid = fopen (fullfile (d, [nm ".txt"]), "wt");
   fputs (fid, "\n");
   fputs (fid, "+---------------------------------+\n");
   fputs (fid, "| Image unavailable in text mode. |\n");
   fputs (fid, "+---------------------------------+\n");
   fclose (fid);
 endfunction
+
--- a/doc/interpreter/sparseimages.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/sparseimages.m	Thu Dec 10 12:50:06 2015 -0800
@@ -16,30 +16,233 @@
 ## along with Octave; see the file COPYING.  If not, see
 ## <http://www.gnu.org/licenses/>.
 
-function sparseimages (nm, typ)
-  graphics_toolkit ("gnuplot");
+function sparseimages (d, nm, typ)
+  set_graphics_toolkit ();
   set_print_size ();
+  hide_output ();
+  outfile = fullfile (d, [nm "." typ]);
   if (strcmp (typ, "png"))
     set (0, "defaulttextfontname", "*");
   endif
+  if (strcmp (typ, "eps"))
+    d_typ = "-depsc2";
+  else
+    d_typ = ["-d" typ];
+  endif
 
-  if (__have_feature__ ("COLAMD")
-      && __have_feature__ ("CHOLMOD")
-      && __have_feature__ ("UMFPACK"))
-    if (strcmp (typ,"txt"))
-      txtimages (nm, 15, typ);
+  if (! (__have_feature__ ("COLAMD")
+         && __have_feature__ ("CHOLMOD")
+         && __have_feature__ ("UMFPACK")))
+    ## There is no sparse matrix implementation available because
+    ## of missing libraries, plot sombreros instead.
+    sombreroimage (d, nm, typ);
+  elseif (strcmp (typ, "txt"))
+    txtimages (d, nm, 15, typ);
+  elseif (strcmp (nm, "gplot"))
+    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);
+    print (outfile, d_typ);
+  elseif (strcmp (nm, "grid"))
+    femimages (outfile, d_typ);
+  elseif (strcmp (nm, "spmatrix"))
+    n = 200;
+    a = 10*speye (n) + sparse (1:n,ceil ([1:n]/2),1,n,n) + ...
+        sparse (ceil ([1:n]/2),1:n,1,n,n);
+    spy (a);
+    axis ("ij");
+    print (outfile, d_typ);
+  elseif (strcmp (nm, "spchol"))
+    n = 200;
+    a = 10*speye (n) + sparse (1:n,ceil ([1:n]/2),1,n,n) + ...
+        sparse (ceil ([1:n]/2),1:n,1,n,n);
+    r1 = chol (a);
+    spy (r1);
+    axis ("ij");
+    print (outfile, d_typ);
+  elseif (strcmp (nm, "spcholperm"))
+    n = 200;
+    a = 10*speye (n) + sparse (1:n,ceil ([1:n]/2),1,n,n) + ...
+        sparse (ceil ([1:n]/2),1:n,1,n,n);
+    [r2,p2,q2] = chol (a);
+    spy (r2);
+    axis ("ij");
+    print (outfile, d_typ);
+  else
+    error ("unrecognized plot requested");
+  endif
+  hide_output ();
+endfunction
+
+function txtimages (d, nm, n, typ)
+  outfile = fullfile (d, [nm "." typ]);
+  a = 10*speye (n) + sparse (1:n,ceil([1:n]/2),1,n,n) + ...
+      sparse (ceil ([1:n]/2),1:n,1,n,n);
+  if (strcmp (nm, "gplot") || strcmp (nm, "grid"))
+    fid = fopen (outfile, "wt");
+    fputs (fid, "\n");
+    fputs (fid, "+---------------------------------+\n");
+    fputs (fid, "| Image unavailable in text mode. |\n");
+    fputs (fid, "+---------------------------------+\n");
+    fclose (fid);
+  elseif (strcmp (nm, "spmatrix"))
+    printsparse (a, outfile);
+  elseif (strcmp (nm, "spchol"))
+    r1 = chol (a);
+    printsparse (r1, outfile);
+  elseif (strcmp (nm, "spcholperm"))
+    [r2,p2,q2] = chol (a);
+    printsparse (r2, outfile);
+  else
+    error ("unrecognized plot requested");
+  endif
+endfunction
+
+function printsparse (a, nm)
+  fid = fopen (nm, "wt");
+  fputs (fid, "\n");
+  for i = 1:rows (a)
+    if (rem (i,5) == 0)
+      fprintf (fid, "         %2d - ", i);
+    else
+      fprintf (fid, "            | ");
+    endif
+    for j = 1:columns (a)
+      if (a(i,j) == 0)
+        fprintf (fid, "  ");
+      else
+        fprintf (fid, " *");
+      endif
+    endfor
+    fprintf (fid, "\n");
+  endfor
+  fprintf (fid, "            |-");
+  for j = 1:columns (a)
+    if (rem (j,5) == 0)
+      fprintf (fid, "-|");
+    else
+      fprintf (fid, "--");
+    endif
+  endfor
+  fprintf (fid, "\n");
+  fprintf (fid, "              ");
+  for j = 1:columns (a)
+    if (rem (j,5) == 0)
+      fprintf (fid, "%2d", j);
     else
-      if (strcmp (nm, "gplot"))
-        gplotimages ("gplot", typ);
-      elseif (strcmp (nm, "grid"))
-        femimages ("grid", typ);
-      else
-        otherimages (nm, 200, typ);
-      endif
+      fprintf (fid, "  ");
     endif
-  else ## There is no sparse matrix implementation available because
-       ## of missing libraries, plot sombreros instead
-    sombreroimage (nm, typ);
+  endfor
+  fclose (fid);
+endfunction
+
+function femimages (outfile, d_typ)
+
+  ## build a rectangle
+  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(:)];
+
+  [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)]'];
+    elems = [elems; widx+[(2:h);h+(2:h);h+(1:h-1)]'];
+  endfor
+
+  E = size (elems,1);  # No. of elements
+  N = size (nodes,1);  # No. of elements
+  D = size (elems,2);  # dimensions+1
+
+  ## Plot FEM Geometry
+  elemx = elems(:,[1,2,3,1])';
+  xelems = reshape (nodes(elemx, 1), 4, E);
+  yelems = reshape (nodes(elemx, 2), 4, E);
+
+  ## Set element conductivity
+  conductivity = [1*ones(1,16), 2*ones(1,48), 1*ones(1,16)];
+
+  ## Dirichlet boundary conditions
+  D_nodes = [1:5, 51:55];
+  D_value = [10*ones(1,5), 20*ones(1,5)];
+
+  ## Neumann boundary conditions
+  ## Note that N_value must be normalized by the boundary
+  ##   length and element conductivity
+  N_nodes = [];
+  N_value = [];
+
+  ## Calculate connectivity matrix
+  C = sparse ((1:D*E), reshape (elems',D*E,1),1, D*E, N);
+
+  ## Calculate stiffness 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 = prod (2:(D-1));
+  for j = 1:E
+    a = inv ([ ones(D,1), nodes( elems(j,:), : ) ]);
+    const = conductivity(j)*2/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;
+
+  ## Set Dirichlet boundary
+  V = zeros (N,1);
+  V(D_nodes) = D_value;
+  idx = 1:N;
+  idx(D_nodes) = [];
+
+  ## Set Neumann boundary
+  Q = zeros (N,1);
+  Q(N_nodes) = N_value; # FIXME
+
+  V(idx) = S(idx,idx) \ ( Q(idx) - S(idx,D_nodes)*V(D_nodes) );
+
+  velems = reshape (V(elemx), 4, E);
+
+  plot3 (xelems, yelems, velems);
+  view (80, 10);
+  print (outfile, d_typ);
+endfunction
+
+## There is no sparse matrix implementation available because of missing
+## libraries, plot sombreros instead.  Also plot a nice title that we are
+## sorry about that.
+function sombreroimage (outfile, typ, d_typ)
+  if (strcmp (typ, "txt"))
+    fid = fopen (outfile, "wt");
+    fputs (fid, "+---------------------------------------+\n");
+    fputs (fid, "| Image unavailable because of a        |\n");
+    fputs (fid, "| missing sparse matrix implementation. |\n");
+    fputs (fid, "+---------------------------------------+\n");
+    fclose (fid);
+    return;
+  else
+    [x, y, z] = sombrero ();
+    unwind_protect
+      mesh (x, y, z);
+      title ("Sorry, graphics are unavailable because Octave was\ncompiled without a sparse matrix implementation.");
+    unwind_protect_cleanup
+      print (outfile, d_typ);
+      hide_output ();
+    end_unwind_protect
+  endif
+endfunction
+
+## This function no longer sets the graphics toolkit; That is now done
+## automatically by C++ code which will ordinarily choose 'qt', but might
+## choose gnuplot on older systems.  Only a complete lack of plotting is a
+## problem.
+function set_graphics_toolkit ()
+  if (isempty (available_graphics_toolkits ()))
+    error ("no graphics toolkit available for plotting");
   endif
 endfunction
 
@@ -52,252 +255,10 @@
   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, gnuplot can't pop
+## output as it can the terminal type).
 function hide_output ()
-  f = figure (1);
-  set (f, "visible", "off");
-endfunction
-
-function gplotimages (nm, typ)
-  hide_output ();
-  if (strcmp (typ, "eps"))
-    d_typ = "-depsc2";
-  else
-    d_typ = ["-d" typ];
-  endif
-
-  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);
-  print ([nm "." typ], d_typ);
-  hide_output ();
-endfunction
-
-function txtimages (nm, n, typ)
-  a = 10*speye (n) + sparse (1:n,ceil([1:n]/2),1,n,n) + ...
-      sparse (ceil ([1:n]/2),1:n,1,n,n);
-  if (strcmp (nm, "gplot") || strcmp (nm, "grid"))
-    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);
-  elseif (strcmp (nm, "spmatrix"))
-    printsparse (a, ["spmatrix." typ]);
-  else
-    if (__have_feature__ ("COLAMD") && __have_feature__ ("CHOLMOD"))
-      if (strcmp (nm, "spchol"))
-        r1 = chol (a);
-        printsparse (r1, ["spchol." typ]);
-      elseif (strcmp (nm, "spcholperm"))
-        [r2,p2,q2] = chol (a);
-        printsparse(r2, ["spcholperm." typ]);
-      endif
-      ## printf("Text NNZ: Matrix %d, Chol %d, PermChol %d\n",nnz(a),nnz(r1),nnz(r2));
-    endif
-  endif
-endfunction
-
-function otherimages (nm, n, typ)
-  hide_output ();
-  if (strcmp (typ, "eps"))
-    d_typ = "-depsc2";
-  else
-    d_typ = ["-d" typ];
-  endif
-
-  a = 10*speye (n) + sparse (1:n,ceil([1:n]/2),1,n,n) + ...
-      sparse (ceil ([1:n]/2),1:n,1,n,n);
-  if (strcmp (nm, "spmatrix"))
-    spy (a);
-    axis ("ij");
-    print (["spmatrix." typ], d_typ);
-    hide_output ();
-  else
-    if (__have_feature__ ("COLAMD") && __have_feature__ ("CHOLMOD"))
-      if (strcmp (nm, "spchol"))
-        r1 = chol (a);
-        spy (r1);
-        axis ("ij");
-        print (["spchol." typ], d_typ);
-        hide_output ();
-      elseif (strcmp (nm, "spcholperm"))
-        [r2,p2,q2] = chol (a);
-        spy (r2);
-        axis ("ij");
-        print (["spcholperm." typ], d_typ);
-        hide_output ();
-      endif
-      ## printf("Image NNZ: Matrix %d, Chol %d, PermChol %d\n",nnz(a),nnz(r1),nnz(r2));
-    endif
-  endif
-endfunction
-
-function printsparse (a, nm)
-  fid = fopen (nm,"wt");
-  fputs (fid, "\n");
-  for i = 1:rows (a)
-    if (rem (i,5) == 0)
-      fprintf (fid,"         %2d - ", i);
-    else
-      fprintf (fid,"            | ");
-    endif
-    for j = 1:columns (a)
-      if (a(i,j) == 0)
-        fprintf (fid,"  ");
-      else
-        fprintf (fid," *");
-      endif
-    endfor
-    fprintf (fid,"\n");
-  endfor
-  fprintf (fid,"            |-");
-  for j = 1:columns (a)
-    if (rem (j,5) == 0)
-      fprintf (fid,"-|");
-    else
-      fprintf (fid,"--");
-    endif
-  endfor
-  fprintf (fid,"\n");
-  fprintf (fid,"              ");
-  for j = 1:columns (a)
-    if (rem (j,5) == 0)
-      fprintf (fid,"%2d",j);
-    else
-      fprintf (fid,"  ");
-    endif
-  endfor
-  fclose (fid);
+  hf = figure (1, "visible", "off");
 endfunction
 
-function femimages (nm, typ)
-  hide_output ();
-  if (strcmp (typ, "eps"))
-    d_typ = "-depsc2";
-  else
-    d_typ = ["-d" typ];
-  endif
-
-  if (__have_feature__ ("COLAMD")
-      && __have_feature__ ("CHOLMOD")
-      && __have_feature__ ("UMFPACK"))
-    ## build a rectangle
-    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(:)];
-
-    [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)]'];
-      elems = [elems; widx+[(2:h);h+(2:h);h+(1:h-1)]'];
-    endfor
-
-    E = size (elems,1);  # No. of elements
-    N = size (nodes,1);  # No. of elements
-    D = size (elems,2);  # dimensions+1
-
-    ## Plot FEM Geometry
-    elemx = elems(:,[1,2,3,1])';
-    xelems = reshape (nodes(elemx, 1), 4, E);
-    yelems = reshape (nodes(elemx, 2), 4, E);
-
-    ## Set element conductivity
-    conductivity = [1*ones(1,16), 2*ones(1,48), 1*ones(1,16)];
-
-    ## Dirichlet boundary conditions
-    D_nodes = [1:5, 51:55];
-    D_value = [10*ones(1,5), 20*ones(1,5)];
-
-    ## Neumann boundary conditions
-    ## Note that N_value must be normalized by the boundary
-    ##   length and element conductivity
-    N_nodes = [];
-    N_value = [];
-
-    ## Calculate connectivity matrix
-    C = sparse ((1:D*E), reshape (elems',D*E,1),1, D*E, N);
-
-    ## Calculate stiffness 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 = prod (2:(D-1));
-    for j = 1:E
-      a = inv ([ ones(D,1), nodes( elems(j,:), : ) ]);
-      const = conductivity(j)*2/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;
-
-    ## Set Dirichlet boundary
-    V = zeros (N,1);
-    V(D_nodes) = D_value;
-    idx = 1:N;
-    idx(D_nodes) = [];
-
-    ## Set Neumann boundary
-    Q = zeros (N,1);
-    Q(N_nodes) = N_value; # FIXME
-
-    V(idx) = S(idx,idx) \ ( Q(idx) - S(idx,D_nodes)*V(D_nodes) );
-
-    velems = reshape (V(elemx), 4, E);
-
-    plot3 (xelems, yelems, velems);
-    view (80, 10);
-    print ([nm "." typ], d_typ);
-    hide_output ();
-  endif
-endfunction
-
-## There is no sparse matrix implementation available because of missing
-## libraries, plot sombreros instead. Also plot a nice title that we are
-## sorry about that.
-function sombreroimage (nm, typ)
-  if (strcmp (typ, "txt"))
-    fid = fopen (sprintf ("%s.txt", nm), "wt");
-    fputs (fid, "\n");
-    fputs (fid, "+---------------------------------------+\n");
-    fputs (fid, "| Image unavailable because of a        |\n");
-    fputs (fid, "| missing sparse matrix implementation. |\n");
-    fputs (fid, "+---------------------------------------+\n");
-    fclose (fid);
-    return;
-  else ## if (!strcmp (typ, "txt"))
-
-    hide_output ();
-    if (strcmp (typ, "eps"))
-      d_typ = "-depsc2";
-    else
-      d_typ = ["-d" typ];
-    endif
-
-    [x, y, z] = sombrero ();
-    unwind_protect
-      mesh (x, y, z);
-      title ("Sorry, graphics are unavailable because Octave was\ncompiled without a sparse matrix implementation.");
-    unwind_protect_cleanup
-      print ([nm "." typ], d_typ);
-      hide_output ();
-    end_unwind_protect
-  endif
-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
-
--- a/doc/interpreter/splineimages.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/splineimages.m	Thu Dec 10 12:50:06 2015 -0800
@@ -16,10 +16,11 @@
 ## along with Octave; see the file COPYING.  If not, see
 ## <http://www.gnu.org/licenses/>.
 
-function splineimages (nm, typ)
-  graphics_toolkit ("gnuplot");
+function splineimages (d, nm, typ)
+  set_graphics_toolkit ();
   set_print_size ();
   hide_output ();
+  outfile = fullfile (d, [nm "." typ]);
   if (strcmp (typ, "png"))
     set (0, "defaulttextfontname", "*");
   endif
@@ -30,7 +31,7 @@
   endif
 
   if (strcmp (typ, "txt"))
-    image_as_txt (nm);
+    image_as_txt (d, 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));
@@ -47,7 +48,7 @@
     axis tight;
     ylim ([-2.5 2.5]);
     legend ("data", "41 breaks, 40 pieces", "11 breaks, 10 pieces");
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "splinefit2")) ## Spline orders
     ## Data (200 points)
     x = 2 * pi * rand (1, 200);
@@ -69,7 +70,7 @@
     axis tight;
     ylim ([-2.5 2.5]);
     legend ({"data", "order 0", "order 1", "order 2", "order 3", "order 4"});
-    print ([nm, "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "splinefit3"))
     ## Data (100 points)
     x = 2 * pi * [0, (rand (1, 98)), 1];
@@ -86,7 +87,7 @@
     axis tight;
     ylim ([-2 3]);
     legend ({"data", "no constraints", "periodic"});
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "splinefit4"))
     ## Data (200 points)
     x = 2 * pi * rand (1, 200);
@@ -108,8 +109,8 @@
     plot (x, y, ".", xx, [y1; y2]);
     axis tight;
     ylim ([-1.5 1.5]);
-    legend({"data", "clamped", "hinged periodic"});
-    print ([nm "." typ], d_typ);
+    legend ({"data", "clamped", "hinged periodic"});
+    print (outfile, d_typ);
   elseif (strcmp (nm, "splinefit5"))
     ## Truncated data
     x = [0,  1,  2,  4,  8, 16, 24, 40, 56, 72, 80] / 80;
@@ -130,7 +131,7 @@
     legend ({"data", "spline", "breaks"});
     axis tight;
     ylim ([0 0.1]);
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   elseif (strcmp (nm, "splinefit6"))
     ## Data
     x = linspace (0, 2*pi, 200);
@@ -153,11 +154,21 @@
              "robust, beta = 0.75", "no robust fitting"});
     axis tight;
     ylim ([-2 2]);
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
   endif
   hide_output ();
 endfunction
 
+## This function no longer sets the graphics toolkit; That is now done
+## automatically by C++ code which will ordinarily choose 'qt', but might
+## choose gnuplot on older systems.  Only a complete lack of plotting is a
+## problem.
+function set_graphics_toolkit ()
+  if (isempty (available_graphics_toolkits ()))
+    error ("no graphics toolkit available for plotting");
+  endif
+endfunction
+
 function set_print_size ()
   image_size = [5.0, 3.5]; # in inches, 16:9 format
   border = 0;              # For postscript use 50/72
@@ -167,17 +178,16 @@
   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).
+## Use this function before plotting commands and after every call to print
+## since print() resets output to stdout (unfortunately, gnuplot can't pop
+## output as it can the terminal type).
 function hide_output ()
-  f = figure (1);
-  set (f, "visible", "off");
+  hf = figure (1, "visible", "off");
 endfunction
 
 ## generate something for the texinfo @image command to process
-function image_as_txt(nm)
-  fid = fopen (sprintf ("%s.txt", nm), "wt");
+function image_as_txt (d, nm)
+  fid = fopen (fullfile (d, [nm ".txt"]), "wt");
   fputs (fid, "\n");
   fputs (fid, "+---------------------------------+\n");
   fputs (fid, "| Image unavailable in text mode. |\n");
--- a/doc/interpreter/stats.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/stats.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -137,8 +137,6 @@
 
 @DOCSTRING(cloglog)
 
-@DOCSTRING(mahalanobis)
-
 @DOCSTRING(table)
 
 @node Statistical Plots
--- a/doc/interpreter/system.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/system.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -80,6 +80,9 @@
 @item isdst
 Daylight Savings Time flag.
 
+@item gmtoff
+Seconds offset from UTC.
+
 @item zone
 Time zone.
 @end table
--- a/doc/interpreter/tips.txi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/interpreter/tips.txi	Thu Dec 10 12:50:06 2015 -0800
@@ -189,8 +189,7 @@
 This line should contain a single name/address as in the Author line, or
 an address only, or the string @samp{jwe}.  If there is no maintainer
 line, the person(s) in the Author field are presumed to be the
-maintainers.  The example above is mildly bogus because the maintainer
-line is redundant.
+maintainers.
 
 The idea behind the @samp{Author} and @samp{Maintainer} lines is to make
 possible a function to ``send mail to the maintainer'' without
--- a/doc/liboctave/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-# Makefile for Octave's doc/liboctave directory
-#
-# Copyright (C) 1996-2015 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 $(top_srcdir)/build-aux/common.mk
-
-info_TEXINFOS = liboctave.texi
-
-liboctave_TEXINFOS = \
-  array.texi \
-  bugs.texi \
-  cp-idx.texi \
-  dae.texi \
-  diffeq.texi \
-  error.texi \
-  factor.texi \
-  fn-idx.texi \
-  gpl.texi \
-  install.texi \
-  intro.texi \
-  matvec.texi \
-  nleqn.texi \
-  nlfunc.texi \
-  ode.texi \
-  optim.texi \
-  preface.texi \
-  quad.texi \
-  range.texi
-
-all-local: dvi html pdf ps
-
-## The texi2dvi script (used to create both PDF and DVI output formats)
-## uses some fixed temporary file names.  In order to avoid a race condition
-## the DVI and PDF builds are forced to run serially through a Makefile rule.
-liboctave.pdf: liboctave.dvi
-
-EXTRA_DIST = liboctave.dvi liboctave.html liboctave.pdf liboctave.ps
-
-clean-local:
-	rm -rf t2d_cache
-
--- a/doc/liboctave/liboctave.texi	Tue Dec 08 07:49:49 2015 -0800
+++ b/doc/liboctave/liboctave.texi	Thu Dec 10 12:50:06 2015 -0800
@@ -50,7 +50,7 @@
 @c The version.texi file doesn't include a chapter, so it must not be
 @c included if you want to run the Emacs function
 @c texinfo-multiple-files-update.
-@include version.texi
+@include version-liboctave.texi
 
 @settitle Octave C++ Classes
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,596 @@
+doc_EXTRA_DIST =
+
+doc_CLEANFILES =
+doc_DISTCLEANFILES =
+doc_MAINTAINERCLEANFILES =
+
+TEXINPUTS := $(PATH_SEPARATOR)$(abs_top_srcdir)/doc/interpreter$(PATH_SEPARATOR)$(PATH_SEPARATOR)$(abs_top_builddir)/doc/interpreter$(PATH_SEPARATOR)$(abs_top_builddir)/doc/.texmf-var//$(PATH_SEPARATOR)$(TEXINPUTS)$(PATH_SEPARATOR)
+
+TEXMFCNF := $(PATH_SEPARATOR)$(abs_top_srcdir)/doc$(PATH_SEPARATOR)$(abs_top_builddir)/doc$(PATH_SEPARATOR)$(TEXMFCNF)$(PATH_SEPARATOR)
+
+TEXMFVAR := $(abs_top_builddir)/doc/.texmf-var
+
+export TEXINPUTS
+export TEXMFCNF
+export TEXMFVAR
+
+DVIPS = dvips
+TEX = tex
+PDFTEX = pdftex
+
+AM_V_TEX = $(am__v_TEX_$(V))
+am__v_TEX_ = $(am__v_TEX_$(AM_DEFAULT_VERBOSITY))
+am__v_TEX_0 = @echo "  TEX     " $@;
+am__v_TEX_1 =
+
+AM_V_PDFTEX = $(am__v_PDFTEX_$(V))
+am__v_PDFTEX_ = $(am__v_PDFTEX_$(AM_DEFAULT_VERBOSITY))
+am__v_PDFTEX_0 = @echo "  PDFTEX  " $@;
+am__v_PDFTEX_1 =
+
+if AMCOND_BUILD_DOCS
+
+## Listing "dvi" explicitly here seems to cause two simultaneous
+## builds of the DVI files, presumably because the PS version
+## also depends on the DVI file and somehow the rules are invoked
+## twice.  Is that a bug in automake or make or what?
+
+doc_EXTRA_DIST += doc/texmf.cnf
+
+doc_EXTRA_DIST += \
+  doc/doxyhtml/Doxyfile.in \
+  doc/doxyhtml/README
+
+doxyhtml: | doc/doxyhtml/$(octave_dirstamp)
+	doxygen doc/doxyhtml/Doxyfile
+
+doxyhtml-maintainer-clean:
+	rm -f doc/doxygen_sqlite3.db
+	cd doc/doxyhtml && \
+	rm -rf `ls | $(GREP) -v Doxyfile.in | $(GREP) -v README`
+
+DIRSTAMP_FILES += doc/doxyhtml/$(octave_dirstamp)
+
+GRAPH_PROP_TEXI_SRC = \
+  doc/interpreter/plot-axesproperties.texi \
+  doc/interpreter/plot-figureproperties.texi \
+  doc/interpreter/plot-imageproperties.texi \
+  doc/interpreter/plot-lineproperties.texi \
+  doc/interpreter/plot-patchproperties.texi \
+  doc/interpreter/plot-rootproperties.texi \
+  doc/interpreter/plot-surfaceproperties.texi \
+  doc/interpreter/plot-textproperties.texi \
+  doc/interpreter/plot-uimenuproperties.texi \
+  doc/interpreter/plot-uicontextmenuproperties.texi \
+  doc/interpreter/plot-uipanelproperties.texi \
+  doc/interpreter/plot-uicontrolproperties.texi \
+  doc/interpreter/plot-uitoolbarproperties.texi \
+  doc/interpreter/plot-uipushtoolproperties.texi \
+  doc/interpreter/plot-uitoggletoolproperties.texi
+
+$(GRAPH_PROP_TEXI_SRC): | $(OCTAVE_INTERPRETER_TARGETS)
+
+define gen-propdoc-texi
+  rm -f $@-t $@ && \
+  $(top_builddir)/run-octave -f -q -H -p $(srcdir)/doc/interpreter --eval "genpropdoc ('$(1)');" > $@-t && \
+  mv $@-t $@
+endef
+
+doc/interpreter/plot-axesproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,axes)
+
+doc/interpreter/plot-figureproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,figure)
+
+doc/interpreter/plot-imageproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,image)
+
+doc/interpreter/plot-lineproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,line)
+
+doc/interpreter/plot-patchproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,patch)
+
+doc/interpreter/plot-rootproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,root)
+
+doc/interpreter/plot-surfaceproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,surface)
+
+doc/interpreter/plot-textproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,text)
+
+doc/interpreter/plot-uimenuproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,uimenu)
+
+doc/interpreter/plot-uicontextmenuproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,uicontextmenu)
+
+doc/interpreter/plot-uipanelproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,uipanel)
+
+doc/interpreter/plot-uicontrolproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,uicontrol)
+
+doc/interpreter/plot-uitoolbarproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,uitoolbar)
+
+doc/interpreter/plot-uipushtoolproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,uipushtool)
+
+doc/interpreter/plot-uitoggletoolproperties.texi: doc/interpreter/genpropdoc.m
+	$(AM_V_GEN)$(call gen-propdoc-texi,uitoggletool)
+
+dist_man_MANS = \
+  doc/interpreter/mkoctfile.1 \
+  doc/interpreter/octave-cli.1 \
+  doc/interpreter/octave-config.1 \
+  doc/interpreter/octave.1
+
+DOC_JAVA_IMAGES = \
+  doc/interpreter/java-images/image001.png \
+  doc/interpreter/java-images/image002.png \
+  doc/interpreter/java-images/image003.png \
+  doc/interpreter/java-images/image004.png \
+  doc/interpreter/java-images/image005.png \
+  doc/interpreter/java-images/image006.png \
+  doc/interpreter/java-images/image007.png \
+  doc/interpreter/java-images/image008.png \
+  doc/interpreter/java-images/image009.png
+
+BUILT_DOC_IMAGES += \
+  $(BUILT_DOC_IMAGES_EPS) \
+  $(BUILT_DOC_IMAGES_PDF) \
+  $(BUILT_DOC_IMAGES_PNG) \
+  $(BUILT_DOC_IMAGES_TXT)
+
+DOC_IMAGES_EPS += $(BUILT_DOC_IMAGES_EPS)
+DOC_IMAGES_PDF += $(BUILT_DOC_IMAGES_PDF)
+DOC_IMAGES_PNG += $(BUILT_DOC_IMAGES_PNG)
+DOC_IMAGES_TXT += $(BUILT_DOC_IMAGES_TXT)
+
+DOC_IMAGES += \
+  $(BUILT_DOC_IMAGES) \
+  $(DOC_JAVA_IMAGES)
+
+$(BUILT_DOC_IMAGES): | $(OCTAVE_INTERPRETER_TARGETS)
+
+## FIXME: DOC_JAVA_IMAGES will eventually need to be added to the HTML build.
+##        It will require a different Makefile rule later because
+##        DOC_JAVA_IMAGES live in a subdir rather than in the current directory.
+
+HTMLDIR_IMAGES = $(patsubst doc/interpreter/%.png, doc/interpreter/octave.html/%.png, $(DOC_IMAGES_PNG))
+
+LOGOS = \
+  doc/interpreter/octave_logo.eps \
+  doc/interpreter/octave_logo.pdf
+
+DOC_IMAGES_EPS += doc/interpreter/octave_logo.eps
+DOC_IMAGES_PDF += doc/interpreter/octave_logo.pdf
+
+MUNGED_TEXI_SRC = \
+  doc/interpreter/arith.texi \
+  doc/interpreter/audio.texi \
+  doc/interpreter/basics.texi \
+  doc/interpreter/bugs.texi \
+  doc/interpreter/container.texi \
+  doc/interpreter/contrib.texi \
+  doc/interpreter/cp-idx.texi \
+  doc/interpreter/data.texi \
+  doc/interpreter/debug.texi \
+  doc/interpreter/diffeq.texi \
+  doc/interpreter/diagperm.texi \
+  doc/interpreter/external.texi \
+  doc/interpreter/emacs.texi \
+  doc/interpreter/errors.texi \
+  doc/interpreter/eval.texi \
+  doc/interpreter/expr.texi \
+  doc/interpreter/fn-idx.texi \
+  doc/interpreter/func.texi \
+  doc/interpreter/geometry.texi \
+  doc/interpreter/gui.texi \
+  doc/interpreter/gpl.texi \
+  doc/interpreter/grammar.texi \
+  doc/interpreter/image.texi \
+  doc/interpreter/install.texi \
+  doc/interpreter/interp.texi \
+  doc/interpreter/intro.texi \
+  doc/interpreter/io.texi \
+  doc/interpreter/java.texi \
+  doc/interpreter/linalg.texi \
+  doc/interpreter/matrix.texi \
+  doc/interpreter/nonlin.texi \
+  doc/interpreter/numbers.texi \
+  doc/interpreter/obsolete.texi \
+  doc/interpreter/oop.texi \
+  doc/interpreter/op-idx.texi \
+  doc/interpreter/optim.texi \
+  doc/interpreter/package.texi \
+  doc/interpreter/plot.texi \
+  doc/interpreter/poly.texi \
+  doc/interpreter/preface.texi \
+  doc/interpreter/quad.texi \
+  doc/interpreter/set.texi \
+  doc/interpreter/signal.texi \
+  doc/interpreter/sparse.texi \
+  doc/interpreter/stats.texi \
+  doc/interpreter/stmt.texi \
+  doc/interpreter/strings.texi \
+  doc/interpreter/system.texi \
+  doc/interpreter/testfun.texi \
+  doc/interpreter/tips.texi \
+  doc/interpreter/var.texi \
+  doc/interpreter/vectorize.texi
+
+TXI_SRC = $(MUNGED_TEXI_SRC:.texi=.txi)
+
+BUILT_OCTAVE_TEXI_SRC = \
+  doc/interpreter/contributors.texi \
+  $(GRAPH_PROP_TEXI_SRC) \
+  $(MUNGED_TEXI_SRC)
+
+info_TEXINFOS += \
+  doc/interpreter/octave.texi
+
+## The $(examples_code_SRC) files are included here because
+## they are included in the manual via the @EXAMPLEFILE macro,
+## so they are dependencies for the documentation.
+
+octave_TEXINFOS = \
+  $(BUILT_OCTAVE_TEXI_SRC) \
+  $(examples_code_SRC)
+
+## As of version 1.14.1, automake does not seem to generate
+## rules for DVI, PDF, or HTML output that work for us when
+## there are additional dependencies, so we include our own
+## versions of the rules here.
+
+OCTAVE_HTML_DIR = doc/interpreter/octave.html
+OCTAVE_HTML_TMP_DIR = $(OCTAVE_HTML_DIR:.html=.htp)
+OCTAVE_HTML_STAMP = $(OCTAVE_HTML_DIR)/.html-stamp
+
+$(srcdir)/doc/interpreter/octave.info: $(DOC_IMAGES_TXT) $(octave_TEXINFOS)
+doc/interpreter/octave.dvi: $(DOC_IMAGES_EPS) $(octave_TEXINFOS)
+doc/interpreter/octave.pdf: $(DOC_IMAGES_PDF) $(octave_TEXINFOS)
+$(OCTAVE_HTML_STAMP): $(DOC_IMAGES_PNG) $(octave_TEXINFOS)
+
+$(srcdir)/doc/interpreter/octave.info: doc/interpreter/octave.texi $(srcdir)/doc/interpreter/version-octave.texi
+	$(AM_V_MAKEINFO)restore=: && backupdir="$(am__leading_dot)am$$$$" && \
+	am__cwd=`pwd` && $(am__cd) $(srcdir) && \
+	rm -rf $$backupdir && mkdir $$backupdir && \
+	if ($(MAKEINFO) --version) >/dev/null 2>&1; then \
+	  for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \
+	    if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \
+	  done; \
+	else :; fi && \
+	cd "$$am__cwd"; \
+	if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc/interpreter -I $(abs_top_srcdir)/doc/interpreter \
+	 -o $@ $(srcdir)/doc/interpreter/octave.texi; \
+	then \
+	  rc=0; \
+	  $(am__cd) $(srcdir); \
+	else \
+	  rc=$$?; \
+	  $(am__cd) $(srcdir) && \
+	  $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \
+	fi; \
+	rm -rf $$backupdir; exit $$rc
+
+doc/interpreter/octave.dvi: doc/interpreter/octave.texi $(srcdir)/doc/interpreter/version-octave.texi | doc/interpreter/$(am__dirstamp)
+	$(AM_V_TEXI2DVI)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
+	MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc/interpreter -I $(abs_top_srcdir)/doc/interpreter' \
+	$(TEXI2DVI) $(AM_V_texinfo) --build-dir=$(@:.dvi=.t2d) -o $@ $(AM_V_texidevnull) \
+	`test -f 'doc/interpreter/octave.texi' || echo '$(abs_top_srcdir)/'`doc/interpreter/octave.texi
+
+doc/interpreter/octave.pdf: doc/interpreter/octave.texi $(srcdir)/doc/interpreter/version-octave.texi | doc/interpreter/$(am__dirstamp)
+	$(AM_V_TEXI2PDF)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
+	MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc/interpreter -I $(abs_top_srcdir)/doc/interpreter' \
+	$(TEXI2PDF) $(AM_V_texinfo) --build-dir=$(@:.pdf=.t2p) -o $@ $(AM_V_texidevnull) \
+	`test -f 'doc/interpreter/octave.texi' || echo '$(abs_top_srcdir)/'`doc/interpreter/octave.texi
+
+doc/interpreter/octave.html: $(OCTAVE_HTML_STAMP)
+
+$(OCTAVE_HTML_STAMP): doc/interpreter/octave.texi $(srcdir)/doc/interpreter/version-octave.texi | doc/interpreter/$(am__dirstamp)
+	$(AM_V_MAKEINFO)rm -rf $(OCTAVE_HTML_DIR)
+	$(AM_V_at)if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc/interpreter -I $(abs_top_srcdir)/doc/interpreter \
+	 -o $(OCTAVE_HTML_TMP_DIR) `test -f 'doc/interpreter/octave.texi' || echo '$(abs_top_srcdir)/'`doc/interpreter/octave.texi; \
+	then \
+	  rm -rf $(OCTAVE_HTML_DIR)@ && \
+	  mv $(OCTAVE_HTML_TMP_DIR) $(OCTAVE_HTML_DIR) && \
+	  touch $@; \
+	else \
+	  rm -rf $(OCTAVE_HTML_TMP_DIR); exit 1; \
+	fi
+
+$(HTMLDIR_IMAGES) : doc/interpreter/octave.html/%.png: doc/interpreter/%.png $(OCTAVE_HTML_STAMP)
+	$(AM_V_GEN)cp $< $@
+
+DOC_TARGETS += \
+  $(srcdir)/doc/interpreter/octave.info \
+  doc/interpreter/doc-cache \
+  doc/interpreter/octave.ps \
+  doc/interpreter/octave.pdf \
+  $(OCTAVE_HTML_STAMP) \
+  $(HTMLDIR_IMAGES)
+
+doc_EXTRA_DIST += \
+  $(BUILT_OCTAVE_TEXI_SRC) \
+  $(srcdir)/doc/interpreter/octave.info \
+  doc/interpreter/TODO \
+  doc/interpreter/doc-cache \
+  doc/interpreter/octave.dvi \
+  doc/interpreter/octave.ps \
+  doc/interpreter/octave.pdf \
+  doc/interpreter/octave.html \
+  $(HTMLDIR_IMAGES)
+
+# Prevent packaging of distribution unless all libraries
+# necessary to create documentation are present
+doc-interpreter-dist-hook:
+	@$(GREP) '#define HAVE_COLAMD 1' $(top_builddir)/config.h > /dev/null || { echo "Documentation creation requires missing COLAMD library.  Cannot package distribution!" ; exit 1; }
+	@$(GREP) '#define HAVE_CHOLMOD 1' $(top_builddir)/config.h > /dev/null || { echo "Documentation creation requires missing CHOLMOD library.  Cannot package distribution!" ; exit 1; }
+	@$(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/interpreter/doc-cache \
+  doc/interpreter/macros.texi
+
+doc/interpreter/doc-cache: $(DOCSTRING_FILES) doc/interpreter/mk_doc_cache.m | $(OCTAVE_INTERPRETER_TARGETS) doc/interpreter/$(octave_dirstamp)
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	$(top_builddir)/run-octave -f -q -H $(srcdir)/doc/interpreter/mk_doc_cache.m - $(srcdir)/doc/interpreter/macros.texi $(DOCSTRING_FILES) > $@-t && \
+	mv $@-t $@
+
+$(MUNGED_TEXI_SRC): $(DOCSTRING_FILES) $(munge_texi_SOURCES)
+
+%.texi : %.txi doc/interpreter/munge-texi.pl | doc/interpreter/$(octave_dirstamp)
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	$(PERL) $(srcdir)/doc/interpreter/munge-texi.pl $(top_srcdir) $(DOCSTRING_FILES) < $< > $@-t && \
+	mv $@-t $@
+
+doc/interpreter/contributors.texi: doc/interpreter/contributors.in | doc/interpreter/$(octave_dirstamp)
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	$(AWK) -f $(srcdir)/doc/interpreter/mkcontrib.awk $(srcdir)/doc/interpreter/contributors.in > $@-t && \
+	mv $@-t $@
+
+AUTHORS: doc/interpreter/preface.texi doc/interpreter/contributors.texi | doc/interpreter/$(octave_dirstamp)
+	$(AM_V_MAKEINFO)rm -f $@-t $@ && \
+	if [ "x$(srcdir)" != "x." ] && [ -f $(srcdir)/doc/interpreter/contributors.texi ] && [ ! -f doc/interpreter/contributors.texi ]; then \
+		cp $(srcdir)/doc/interpreter/contributors.texi doc/interpreter/contributors.texi; \
+		touch -r $(srcdir)/doc/interpreter/contributors.texi doc/interpreter/contributors.texi; \
+	fi && \
+	$(MAKEINFO) -D AUTHORSONLY -I $(srcdir)/doc/interpreter/ \
+	  --no-validate --no-headers --no-split --output $@-t $< && \
+	mv $@-t $@
+
+BUGS: doc/interpreter/bugs.texi | doc/interpreter/$(octave_dirstamp)
+	$(AM_V_MAKEINFO)rm -f $@-t $@ && \
+	$(MAKEINFO) -D BUGSONLY -I $(srcdir)/doc/interpreter \
+	  --no-validate --no-headers --no-split --output $@-t $< && \
+	mv $@-t $@
+
+INSTALL.OCTAVE: doc/interpreter/install.texi | doc/interpreter/$(octave_dirstamp)
+	$(AM_V_MAKEINFO)rm -f $@-t $@ && \
+	$(MAKEINFO) -D INSTALLONLY -I $(srcdir)/doc/interpreter \
+	  --no-validate --no-headers --no-split --output $@-t $< && \
+	mv $@-t $@
+
+doc_EXTRA_DIST += \
+  doc/interpreter/config-images.sh \
+  doc/interpreter/contributors.in \
+  doc/interpreter/doc-cache \
+  doc/interpreter/genpropdoc.m \
+  doc/interpreter/graphics_properties.mk \
+  doc/interpreter/images \
+  doc/interpreter/images.awk \
+  doc/interpreter/images.mk \
+  doc/interpreter/macros.texi \
+  doc/interpreter/mk_doc_cache.m \
+  doc/interpreter/mkcontrib.awk \
+  doc/interpreter/munge-texi.pl \
+  $(DOC_IMAGES) \
+  $(DOC_IMAGES_SRC) \
+  $(LOGOS) \
+  $(TXI_SRC)
+
+doc_DISTCLEANFILES += \
+  $(OCTAVE_HTML_STAMP)
+
+doc_MAINTAINERCLEANFILES += \
+  AUTHORS \
+  $(BUILT_DOC_IMAGES) \
+  $(BUILT_OCTAVE_TEXI_SRC) \
+  doc/interpreter/doc-cache
+
+## The TeX software suite is used to create both PDF and PS output formats.
+## In order to avoid race conditions between simultaneous TeX commands, the
+## PDF and PS builds are forced to run serially through the following rule.
+doc/interpreter/octave.pdf: doc/interpreter/octave.ps
+
+DIRSTAMP_FILES += doc/interpreter/$(octave_dirstamp)
+
+liboctave_TEXINFOS = \
+  doc/liboctave/array.texi \
+  doc/liboctave/bugs.texi \
+  doc/liboctave/cp-idx.texi \
+  doc/liboctave/dae.texi \
+  doc/liboctave/diffeq.texi \
+  doc/liboctave/error.texi \
+  doc/liboctave/factor.texi \
+  doc/liboctave/fn-idx.texi \
+  doc/liboctave/gpl.texi \
+  doc/liboctave/install.texi \
+  doc/liboctave/intro.texi \
+  doc/liboctave/matvec.texi \
+  doc/liboctave/nleqn.texi \
+  doc/liboctave/nlfunc.texi \
+  doc/liboctave/ode.texi \
+  doc/liboctave/optim.texi \
+  doc/liboctave/preface.texi \
+  doc/liboctave/quad.texi \
+  doc/liboctave/range.texi
+
+info_TEXINFOS += \
+  doc/liboctave/liboctave.texi
+
+doc/liboctave/liboctave.dvi: doc/liboctave/liboctave.texi $(srcdir)/doc/liboctave/version-liboctave.texi | doc/liboctave/$(am__dirstamp)
+	$(AM_V_TEXI2DVI)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
+	MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc/liboctave -I $(srcdir)/doc/liboctave' \
+	$(TEXI2DVI) $(AM_V_texinfo) --build-dir=$(@:.dvi=.t2d) -o $@ $(AM_V_texidevnull) \
+	`test -f 'doc/liboctave/liboctave.texi' || echo '$(srcdir)/'`doc/liboctave/liboctave.texi
+
+doc/liboctave/liboctave.pdf: doc/liboctave/liboctave.texi $(srcdir)/doc/liboctave/version-liboctave.texi | doc/liboctave/$(am__dirstamp)
+	$(AM_V_TEXI2PDF)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
+	MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc/liboctave -I $(srcdir)/doc/liboctave' \
+	$(TEXI2PDF) $(AM_V_texinfo) --build-dir=$(@:.pdf=.t2p) -o $@ $(AM_V_texidevnull) \
+	`test -f 'doc/liboctave/liboctave.texi' || echo '$(srcdir)/'`doc/liboctave/liboctave.texi
+
+doc/liboctave/liboctave.html: doc/liboctave/liboctave.texi $(srcdir)/doc/liboctave/version-liboctave.texi | doc/liboctave/$(am__dirstamp)
+	$(AM_V_MAKEINFO)rm -rf $(@:.html=.htp)
+	$(AM_V_at)if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc/liboctave -I $(srcdir)/doc/liboctave \
+	 -o $(@:.html=.htp) `test -f 'doc/liboctave/liboctave.texi' || echo '$(srcdir)/'`doc/liboctave/liboctave.texi; \
+	then \
+	  rm -rf $@ && mv $(@:.html=.htp) $@; \
+	else \
+	  rm -rf $(@:.html=.htp); exit 1; \
+	fi
+
+DOC_TARGETS += \
+  $(srcdir)/doc/liboctave/liboctave.info \
+  doc/liboctave/liboctave.ps \
+  doc/liboctave/liboctave.pdf \
+  doc/liboctave/liboctave.html
+
+doc_EXTRA_DIST += \
+  $(liboctave_TEXINFOS) \
+  $(srcdir)/doc/liboctave/liboctave.info \
+  doc/liboctave/liboctave.dvi \
+  doc/liboctave/liboctave.ps \
+  doc/liboctave/liboctave.pdf \
+  doc/liboctave/liboctave.html
+
+## The TeX software suite is used to create both PDF and PS output formats.
+## In order to avoid race conditions between simultaneous TeX commands, the
+## PDF and PS builds are forced to run serially through the following rule.
+doc/liboctave/liboctave.pdf: doc/liboctave/liboctave.ps
+
+DIRSTAMP_FILES += doc/liboctave/$(octave_dirstamp)
+
+refcard_TEX_SRC = \
+  doc/refcard/refcard.tex \
+  doc/refcard/refcard-a4.tex \
+  doc/refcard/refcard-legal.tex \
+  doc/refcard/refcard-letter.tex
+
+refcard_DVI = \
+  doc/refcard/refcard-a4.dvi \
+  doc/refcard/refcard-legal.dvi \
+  doc/refcard/refcard-letter.dvi
+
+refcard_PDF = \
+  doc/refcard/refcard-a4.pdf \
+  doc/refcard/refcard-legal.pdf \
+  doc/refcard/refcard-letter.pdf
+
+refcard_PS = \
+  doc/refcard/refcard-letter.ps \
+  doc/refcard/refcard-a4.ps \
+  doc/refcard/refcard-legal.ps
+
+refcard_FORMATTED = \
+  $(refcard_DVI) \
+  $(refcard_PDF) \
+  $(refcard_PS)
+
+DOC_TARGETS += \
+  $(refcard_FORMATTED)
+
+doc/refcard/refcard-a4.pdf: doc/refcard/refcard.tex
+doc/refcard/refcard-a4.dvi: doc/refcard/refcard.tex
+doc/refcard/refcard-a4.ps: doc/refcard/refcard-a4.dvi
+	-$(AM_V_DVIPS)$(DVIPS) $(AM_V_texinfo) -T 297mm,210mm -o $@ $<
+
+doc/refcard/refcard-legal.pdf: doc/refcard/refcard.tex
+doc/refcard/refcard-legal.dvi: doc/refcard/refcard.tex
+doc/refcard/refcard-legal.ps: doc/refcard/refcard-legal.dvi
+	-$(AM_V_DVIPS)$(DVIPS) $(AM_V_texinfo) -T 14in,8.5in -o $@ $<
+
+doc/refcard/refcard-letter.pdf: doc/refcard/refcard.tex
+doc/refcard/refcard-letter.dvi: doc/refcard/refcard.tex
+doc/refcard/refcard-letter.ps: doc/refcard/refcard-letter.dvi
+	-$(AM_V_DVIPS)$(DVIPS) $(AM_V_texinfo) -T 11in,8.5in -o $@ $<
+
+DIRSTAMP_FILES += doc/refcard/$(octave_dirstamp)
+
+$(srcdir)/doc/interpreter/images.mk: $(srcdir)/doc/interpreter/config-images.sh $(srcdir)/doc/interpreter/images.awk $(srcdir)/doc/interpreter/images
+	$(srcdir)/doc/interpreter/config-images.sh $(top_srcdir)
+
+$(refcard_DVI) : %.dvi : %.tex | doc/refcard/$(octave_dirstamp)
+	-$(AM_V_TEX)cd $(@D) && \
+	TEXINPUTS="$(abs_top_srcdir)/doc/refcard:$(TEXINPUTS):" \
+	$(TEX) $(<F) $(AM_V_texidevnull)
+
+$(refcard_PDF) : %.pdf : %.tex | doc/refcard/$(octave_dirstamp)
+	-$(AM_V_PDFTEX)cd $(@D) && \
+	TEXINPUTS="$(abs_top_srcdir)/doc/refcard:$(TEXINPUTS):" \
+	$(PDFTEX) $(<F) $(AM_V_texidevnull)
+
+doc_EXTRA_DIST += \
+  $(refcard_FORMATTED) \
+  $(refcard_TEX_SRC)
+
+doc_CLEANFILES += \
+  doc/refcard/refcard-a4.log \
+  doc/refcard/refcard-legal.log \
+  doc/refcard/refcard-letter.log
+
+doc_MAINTAINERCLEANFILES += \
+  $(refcard_FORMATTED)
+
+endif
+
+doc/interpreter/undocumented_list:
+	rm -f $@-t $@
+	-cd $(srcdir)/doc/interpreter; $(PERL) ./doccheck/mk_undocumented_list > $(@F)-t
+	mv $@-t $@
+.PHONY: doc/interpreter/undocumented_list
+
+SPELLCHECK_FILES = $(MUNGED_TEXI_SRC:.texi=.scheck)
+
+%.scheck: %.texi | doc/interpreter/$(octave_dirstamp)
+	cd $(srcdir)/doc/interpreter; ./doccheck/spellcheck $(<F) > $(@F)-t
+	mv $@-t $@
+	[ -s $@ ] || rm -f $@
+
+spellcheck: $(SPELLCHECK_FILES)
+	@cd $(srcdir)/doc/interpreter ; \
+	if ls *.scheck >/dev/null 2>&1 ; then \
+		echo "Spellcheck failed"; \
+		echo "Review the following files:"; \
+		ls *.scheck ; \
+		exit 1 ; \
+	else \
+		echo "Spellcheck passed"; \
+	fi
+.PHONY: spellcheck
+
+EXTRA_DIST += $(doc_EXTRA_DIST)
+
+CLEANFILES += $(doc_CLEANFILES)
+DISTCLEANFILES += $(doc_DISTCLEANFILES)
+MAINTAINERCLEANFILES += $(doc_MAINTAINERCLEANFILES)
+
+doc-clean:
+	rm -f $(doc_CLEANFILES)
+	rm -rf doc/interpreter/octave.t2d
+	rm -rf doc/interpreter/octave.t2p
+	rm -rf doc/liboctave/liboctave.t2d
+	rm -rf doc/liboctave/liboctave.t2p
+	rm -rf doc/.texmf-var
+
+
+doc-distclean: doc-clean
+	rm -f $(doc_DISTCLEANFILES)
+
+doc-maintainer-clean: doc-distclean
+	rm -f $(doc_MAINTAINERCLEANFILES)
--- a/doc/refcard/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-# Makefile for Octave's doc/refcard directory
-#
-# Copyright (C) 1996-2015 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 $(top_srcdir)/build-aux/common.mk
-
-DVIPS = dvips
-TEX = tex
-PDFTEX = pdftex
-
-AM_V_TEX = $(am__v_TEX_$(V))
-am__v_TEX_ = $(am__v_TEX_$(AM_DEFAULT_VERBOSITY))
-am__v_TEX_0 = @echo "  TEX     " $@;
-am__v_TEX_1 = 
-
-AM_V_PDFTEX = $(am__v_PDFTEX_$(V))
-am__v_PDFTEX_ = $(am__v_PDFTEX_$(AM_DEFAULT_VERBOSITY))
-am__v_PDFTEX_0 = @echo "  PDFTEX  " $@;
-am__v_PDFTEX_1 = 
-
-## The following three blocks of variable definitions can be eliminated
-## if we merge the makefiles in teh doc directory.
-
-AM_V_texidevnull = $(am__v_texidevnull_$(V))
-am__v_texidevnull_ = $(am__v_texidevnull_$(AM_DEFAULT_VERBOSITY))
-am__v_texidevnull_0 = > /dev/null
-am__v_texidevnull_1 = 
-
-AM_V_DVIPS = $(am__v_DVIPS_$(V))
-am__v_DVIPS_ = $(am__v_DVIPS_$(AM_DEFAULT_VERBOSITY))
-am__v_DVIPS_0 = @echo "  DVIPS   " $@;
-am__v_DVIPS_1 =
-
-AM_V_texinfo = $(am__v_texinfo_$(V))
-am__v_texinfo_ = $(am__v_texinfo_$(AM_DEFAULT_VERBOSITY))
-am__v_texinfo_0 = -q
-am__v_texinfo_1 = 
-
-%.dvi : %.tex
-	-$(AM_V_TEX)TEXINPUTS="$(srcdir):$(TEXINPUTS):" \
-	$(TEX) $< $(AM_V_texidevnull)
-
-%.pdf : %.tex
-	-$(AM_V_PDFTEX)TEXINPUTS="$(srcdir):$(TEXINPUTS):" \
-	$(PDFTEX) $< $(AM_V_texidevnull)
-
-TEX_SRC = \
-  refcard.tex \
-  refcard-a4.tex \
-  refcard-legal.tex \
-  refcard-letter.tex
-
-FORMATTED = \
-  refcard-a4.dvi \
-  refcard-a4.ps \
-  refcard-a4.pdf \
-  refcard-legal.dvi \
-  refcard-legal.ps \
-  refcard-legal.pdf \
-  refcard-letter.dvi \
-  refcard-letter.ps \
-  refcard-letter.pdf
-
-all-local: $(FORMATTED)
-
-refcard-a4.pdf: refcard-a4.tex refcard.tex
-refcard-a4.dvi: refcard-a4.tex refcard.tex
-refcard-a4.ps: refcard-a4.dvi
-	-$(AM_V_DVIPS)$(DVIPS) $(AM_V_texinfo) -T 297mm,210mm -o $@ $<
-
-refcard-legal.pdf: refcard-legal.tex refcard.tex
-refcard-legal.dvi: refcard-legal.tex refcard.tex
-refcard-legal.ps: refcard-legal.dvi
-	-$(AM_V_DVIPS)$(DVIPS) $(AM_V_texinfo) -T 14in,8.5in -o $@ $<
-
-refcard-letter.pdf: refcard-letter.tex refcard.tex
-refcard-letter.dvi: refcard-letter.tex refcard.tex
-refcard-letter.ps: refcard-letter.dvi
-	-$(AM_V_DVIPS)$(DVIPS) $(AM_V_texinfo) -T 11in,8.5in -o $@ $<
-
-EXTRA_DIST = \
-  $(TEX_SRC) \
-  $(FORMATTED)
-
-CLEANFILES = refcard-a4.log refcard-legal.log refcard-letter.log
-
-
-MAINTAINERCLEANFILES = $(FORMATTED)
-
--- a/etc/RELEASE.PROCESS	Tue Dec 08 07:49:49 2015 -0800
+++ b/etc/RELEASE.PROCESS	Thu Dec 10 12:50:06 2015 -0800
@@ -45,7 +45,7 @@
 #: Completion Date:
 <!----------------------------------------------------------------------------->
 # Run Octave test suite under [http://valgrind.org Valgrind] to check for memory leaks
-#* Results posted to bug report: 
+#* Results posted to bug report:
 #: Completion Date:
 <!----------------------------------------------------------------------------->
 # Review documentation
--- a/etc/icons/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-# Makefile for Octave's doc/icons directory
-#
-# Copyright (C) 2012-2015 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 $(top_srcdir)/build-aux/common.mk
-
-IMAGE_FILES = \
-  octave-logo.svg \
-  octave-sombrero.png
-
-PNG_SIZES = \
-  512 \
-  256 \
-  128 \
-  64 \
-  48 \
-  32 \
-  24 \
-  22 \
-  16
-
-BUILT_PNG_ICONS = $(patsubst %,octave-logo-%.png,$(PNG_SIZES))
-
-WINDOWS_PNG_ICONS = $(filter %-16.png %-32.png %-48.png %-256.png,$(BUILT_PNG_ICONS))
-
-BUILT_ICONS = \
-  $(BUILT_PNG_ICONS) \
-  octave-logo.ico
-
-image_DATA = \
-  $(IMAGE_FILES) \
-  octave-logo.ico
-
-VENDOR = www.octave.org
-
-DESKTOP_FILE = $(VENDOR)-octave.desktop
-
-all-local: octave.appdata.xml octave.desktop $(BUILT_ICONS)
-
-octave.appdata.xml: octave.appdata.xml.in Makefile
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(SED) < $< > $@-t \
-	  -e "s|%OCTAVE_DESKTOP_FILE%|${DESKTOP_FILE}|" && \
-	mv $@-t $@
-
-octave.desktop: octave.desktop.in Makefile
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(SED) < $< > $@-t \
-	  -e "s|%OCTAVE_IMAGEDIR%|${imagedir}|" \
-	  -e "s|%OCTAVE_PREFIX%|${prefix}|" && \
-	mv $@-t $@
-
-$(BUILT_PNG_ICONS): octave-logo.svg
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(RSVG_CONVERT) -w $(lastword $(subst -, ,$(patsubst %.png,%,$@))) $< > $@-t && \
-	mv $@-t $@
-
-octave-logo.ico: $(WINDOWS_PNG_ICONS)
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(ICOTOOL) --create --raw $^ > $@-t && \
-	mv $@-t $@
-
-install-data-local:
-	-if test -n "$(DESKTOP_FILE_INSTALL)"; then \
-	  $(DESKTOP_FILE_INSTALL) --dir=$(DESTDIR)$(datadir)/applications \
-	    --vendor $(VENDOR) octave.desktop; \
-	fi
-	for f in $(BUILT_PNG_ICONS); do \
-	  size=`echo $$f | $(SED) -n -e "s/.*-\([0-9]\+\)\.png/\1/p"`; \
-	  if test -f $$f; then d=; else d="$(srcdir)/"; fi; \
-	  $(MKDIR_P) $(DESTDIR)$(datadir)/icons/hicolor/$${size}x$${size}/apps; \
-	  $(INSTALL_DATA) "$$d$$f" $(DESTDIR)$(datadir)/icons/hicolor/$${size}x$${size}/apps/octave.png; \
-	done
-	$(MKDIR_P) $(DESTDIR)$(datadir)/icons/hicolor/scalable/apps
-	$(INSTALL_DATA) $(srcdir)/octave-logo.svg $(DESTDIR)$(datadir)/icons/hicolor/scalable/apps/octave.svg
-	$(MKDIR_P) $(DESTDIR)$(datadir)/appdata
-	$(INSTALL_DATA) octave.appdata.xml $(DESTDIR)$(datadir)/appdata/$(VENDOR)-octave.appdata.xml
-
-uninstall-local:
-	if test -n "$(DESKTOP_FILE_INSTALL)"; then \
-	  rm -f $(DESTDIR)$(datadir)/applications/$(DESKTOP_FILE); \
-	fi
-	for f in $(BUILT_PNG_ICONS); do \
-	  size=`echo $$f | $(SED) -n -e "s/.*-\([0-9]\+\)\.png/\1/p"`; \
-	  rm -f $(DESTDIR)$(datadir)/icons/hicolor/$${size}x$${size}/apps/octave.png; \
-	done
-	rm -f $(DESTDIR)$(datadir)/icons/hicolor/scalable/apps/octave.svg
-	rm -f $(DESTDIR)$(datadir)/appdata/$(VENDOR)-octave.appdata.xml
-
-if AMCOND_HAVE_ICON_TOOLS
-else
-dist-hook:
-	@echo "Packaging distribution requires icotool and rsvg-convert." ; exit 1;
-endif
-
-EXTRA_DIST = \
-  $(BUILT_ICONS) \
-  $(IMAGE_FILES) \
-  octave.appdata.xml.in \
-  octave.desktop.in
-
-CLEANFILES = octave.appdata.xml octave.desktop
-
-MAINTAINERCLEANFILES = $(BUILT_ICONS)
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,147 @@
+etc_EXTRA_DIST =
+
+etc_CLEANFILES =
+etc_DISTCLEANFILES =
+etc_MAINTAINERCLEANFILES =
+
+etc_EXTRA_DIST += \
+  etc/NEWS.1 \
+  etc/NEWS.2 \
+  etc/NEWS.3 \
+  etc/PROJECTS \
+  etc/README.Cygwin \
+  etc/README.Linux \
+  etc/README.MacOS \
+  etc/README.MinGW \
+  etc/README.Windows \
+  etc/README.gnuplot \
+  etc/README.kpathsea \
+  etc/gdbinit
+
+etc_EXTRA_DIST += \
+  etc/OLD-ChangeLogs/ChangeLog \
+  etc/OLD-ChangeLogs/ChangeLog.1 \
+  etc/OLD-ChangeLogs/doc-ChangeLog \
+  etc/OLD-ChangeLogs/libcruft-ChangeLog \
+  etc/OLD-ChangeLogs/liboctave-ChangeLog \
+  etc/OLD-ChangeLogs/scripts-ChangeLog \
+  etc/OLD-ChangeLogs/src-ChangeLog \
+  etc/OLD-ChangeLogs/test-ChangeLog
+
+icon_IMAGE_FILES = \
+  etc/icons/octave-logo.svg \
+  etc/icons/octave-sombrero.png
+
+icon_PNG_SIZES = \
+  512 \
+  256 \
+  128 \
+  64 \
+  48 \
+  32 \
+  24 \
+  22 \
+  16
+
+BUILT_PNG_ICONS = $(patsubst %,etc/icons/octave-logo-%.png,$(icon_PNG_SIZES))
+
+WINDOWS_PNG_ICONS = $(filter %-16.png %-32.png %-48.png %-256.png,$(BUILT_PNG_ICONS))
+
+BUILT_ICONS = \
+  $(BUILT_PNG_ICONS) \
+  etc/icons/octave-logo.ico
+
+etc_EXTRA_DIST += \
+  $(BUILT_ICONS) \
+  $(icon_IMAGE_FILES) \
+  etc/icons/octave.appdata.xml.in \
+  etc/icons/octave.desktop.in
+
+image_DATA += \
+  $(icon_IMAGE_FILES) \
+  etc/icons/octave-logo.ico
+
+VENDOR = www.octave.org
+
+DIRSTAMP_FILES += \
+  etc/icons/$(octave_dirstamp)
+
+all-local: all-icons
+
+all-icons: etc/icons/octave.appdata.xml etc/icons/octave.desktop $(BUILT_ICONS)
+
+etc/icons/octave.appdata.xml: etc/icons/octave.appdata.xml.in Makefile | etc/icons/$(octave_dirstamp)
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	$(SED) < $< > $@-t \
+	  -e "s|%OCTAVE_DESKTOP_FILE%|${VENDOR}-octave.desktop|" && \
+	mv $@-t $@
+
+etc/icons/octave.desktop: etc/icons/octave.desktop.in Makefile | etc/icons/$(octave_dirstamp)
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	$(SED) < $< > $@-t \
+	  -e "s|%OCTAVE_IMAGEDIR%|${imagedir}|" \
+	  -e "s|%OCTAVE_PREFIX%|${prefix}|" && \
+	mv $@-t $@
+
+$(BUILT_PNG_ICONS): etc/icons/octave-logo.svg | etc/icons/$(octave_dirstamp)
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	$(RSVG_CONVERT) -w $(lastword $(subst -, ,$(patsubst %.png,%,$@))) $< > $@-t && \
+	mv $@-t $@
+
+etc/icons/octave-logo.ico: $(WINDOWS_PNG_ICONS) | etc/icons/$(octave_dirstamp)
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	$(ICOTOOL) --create --raw  $(WINDOWS_PNG_ICONS) > $@-t && \
+	mv $@-t $@
+
+install-data-local: install-icons
+
+uninstall-local: uninstall-icons
+
+install-icons:
+	-if test -n "$(DESKTOP_FILE_INSTALL)"; then \
+	  $(DESKTOP_FILE_INSTALL) --dir=$(DESTDIR)$(datadir)/applications \
+	    --vendor $(VENDOR) etc/icons/octave.desktop; \
+	fi
+	for f in $(BUILT_PNG_ICONS); do \
+	  size=`echo $$f | $(SED) -n -e "s/.*-\([0-9]\+\)\.png/\1/p"`; \
+	  if test -f $$f; then d=; else d="$(srcdir)/"; fi; \
+	  $(MKDIR_P) $(DESTDIR)$(datadir)/icons/hicolor/$${size}x$${size}/apps; \
+	  $(INSTALL_DATA) "$$d$$f" $(DESTDIR)$(datadir)/icons/hicolor/$${size}x$${size}/apps/octave.png; \
+	done
+	$(MKDIR_P) $(DESTDIR)$(datadir)/icons/hicolor/scalable/apps
+	$(INSTALL_DATA) $(srcdir)/etc/icons/octave-logo.svg $(DESTDIR)$(datadir)/icons/hicolor/scalable/apps/octave.svg
+	$(MKDIR_P) $(DESTDIR)$(datadir)/appdata
+	$(INSTALL_DATA) etc/icons/octave.appdata.xml $(DESTDIR)$(datadir)/appdata/$(VENDOR)-octave.appdata.xml
+
+uninstall-icons:
+	if test -n "$(DESKTOP_FILE_INSTALL)"; then \
+	  rm -f $(DESTDIR)$(datadir)/applications/$(VENDOR)-octave.desktop; \
+	fi
+	for f in $(BUILT_PNG_ICONS); do \
+	  size=`echo $$f | $(SED) -n -e "s/.*-\([0-9]\+\)\.png/\1/p"`; \
+	  rm -f $(DESTDIR)$(datadir)/icons/hicolor/$${size}x$${size}/apps/octave.png; \
+	done
+	rm -f $(DESTDIR)$(datadir)/icons/hicolor/scalable/apps/octave.svg
+	rm -f $(DESTDIR)$(datadir)/appdata/$(VENDOR)-octave.appdata.xml
+
+EXTRA_DIST += $(etc_EXTRA_DIST)
+
+etc_CLEANFILES += \
+  etc/icons/octave.appdata.xml \
+  etc/icons/octave.desktop
+
+etc_MAINTAINERCLEANFILES += \
+  $(BUILT_ICONS)
+
+CLEANFILES += $(etc_CLEANFILES)
+DISTCLEANFILES += $(etc_DISTCLEANFILES)
+MAINTAINERCLEANFILES += $(etc_MAINTAINERCLEANFILES)
+
+etc-clean:
+	rm -f $(etc_CLEANFILES)
+
+etc-distclean: etc-clean
+	rm -f $(etc_DISTCLEANFILES)
+
+etc-maintainer-clean: etc-distclean
+	rm -f $(etc_MAINTAINERCLEANFILES)
--- a/examples/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-# Makefile for Octave's example directory
-#
-# Copyright (C) 1993-2015 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/>.
-
-## Pass-through layer.  Simply pass make commands down to SUBDIRS.
-
-include $(top_srcdir)/build-aux/common.mk
-
-EXTRA_DIST = \
-  Makefile.am
-
-SUBDIRS = code data
-
--- a/examples/code/@FIRfilter/FIRfilter.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/@FIRfilter/FIRfilter.m	Thu Dec 10 12:50:06 2015 -0800
@@ -11,7 +11,7 @@
     p = @polynomial ([1]);
   elseif (nargin == 1)
     if (!isa (p, "polynomial"))
-      error ("FIRfilter: expecting polynomial as input argument");
+      error ("@FIRfilter: expecting polynomial as input argument");
     endif
   else
     print_usage ();
--- a/examples/code/@FIRfilter/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-FCN_FILE_DIRS += @FIRfilter
-
-EXTRA_DIST += @FIRfilter/module.mk
-
-at_FIRfilter_FCN_FILES = \
-  @FIRfilter/display.m \
-  @FIRfilter/FIRfilter_aggregation.m \
-  @FIRfilter/FIRfilter.m \
-  @FIRfilter/subsasgn.m \
-  @FIRfilter/subsref.m
-
-FCN_FILES += $(at_FIRfilter_FCN_FILES)
--- a/examples/code/@FIRfilter/subsasgn.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/@FIRfilter/subsasgn.m	Thu Dec 10 12:50:06 2015 -0800
@@ -6,9 +6,9 @@
         out = f;
         out.polynomial = val;
       else
-        error ("@FIRfilter/subsref: invalid property \"%s\"", fld);
+        error ("@FIRfilter/subsasgn: invalid property \"%s\"", fld);
       endif
     otherwise
-      error ("FIRfilter/subsagn: Invalid index type")
+      error ("@FIRfilter/subsasgn: Invalid index type")
   endswitch
 endfunction
--- a/examples/code/@polynomial/get.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/@polynomial/get.m	Thu Dec 10 12:50:06 2015 -0800
@@ -7,10 +7,10 @@
         case "poly"
           s = p.poly;
         otherwise
-          error ("get: invalid property %s", f);
+          error ("@polynomial/get: invalid property %s", f);
       endswitch
     else
-      error ("get: expecting the property to be a string");
+      error ("@polynomial/get: expecting the property to be a string");
     endif
   else
     print_usage ();
--- a/examples/code/@polynomial/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-FCN_FILE_DIRS += @polynomial
-
-EXTRA_DIST += @polynomial/module.mk
-
-at_polynomial_FCN_FILES = \
-  @polynomial/display.m \
-  @polynomial/double.m \
-  @polynomial/end.m \
-  @polynomial/get.m \
-  @polynomial/mtimes.m \
-  @polynomial/numel.m \
-  @polynomial/plot.m \
-  @polynomial/polynomial.m \
-  @polynomial/polynomial_superiorto.m \
-  @polynomial/polyval.m \
-  @polynomial/roots.m \
-  @polynomial/set.m \
-  @polynomial/subsasgn.m \
-  @polynomial/subsref.m
-
-FCN_FILES += $(at_polynomial_FCN_FILES)
--- a/examples/code/@polynomial/polynomial.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/@polynomial/polynomial.m	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
       p.poly = a(:).';
       p = class (p, "polynomial");
     else
-      error ("polynomial: expecting real vector");
+      error ("@polynomial: expecting real vector");
     endif
   else
     print_usage ();
--- a/examples/code/@polynomial/polynomial_superiorto.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/@polynomial/polynomial_superiorto.m	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
       p.poly = a(:).';
       p = class (p, "polynomial");
     else
-      error ("polynomial: expecting real vector");
+      error ("@polynomial: expecting real vector");
     endif
   else
     print_usage ();
--- a/examples/code/@polynomial/set.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/@polynomial/set.m	Thu Dec 10 12:50:06 2015 -0800
@@ -1,7 +1,7 @@
 function s = set (p, varargin)
   s = p;
   if (length (varargin) < 2 || rem (length (varargin), 2) != 0)
-    error ("set: expecting property/value pairs");
+    error ("@polynomial/set: expecting property/value pairs");
   endif
   while (length (varargin) > 1)
     prop = varargin{1};
@@ -11,10 +11,10 @@
       if (isvector (val) && isreal (val))
         s.poly = val(:).';
       else
-        error ("set: expecting the value to be a real vector");
+        error ("@polynomial/set: expecting the value to be a real vector");
       endif
     else
-      error ("set: invalid property of polynomial class");
+      error ("@polynomial/set: invalid property of polynomial class");
     endif
   endwhile
 endfunction
--- a/examples/code/@polynomial/subsasgn.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/@polynomial/subsasgn.m	Thu Dec 10 12:50:06 2015 -0800
@@ -1,12 +1,12 @@
 function p = subsasgn (p, s, val)
   if (length (s) < 1)
-    error ("polynomial: needs index");
+    error ("@polynomial/subsasgn: needs index");
   endif
   switch (s(1).type)
     case "{}"
       ind = s(1).subs;
       if (numel (ind) != 1)
-        error ("polynomial: need exactly one index");
+        error ("@polynomial/subsasgn: need exactly one index");
       else
         if (length (s) == 1)
           if (isnumeric (ind{1}))
@@ -15,7 +15,7 @@
             p.poly(ind{1}) = val;
           endif
         else
-          error ("polynomial: chained subscripts not allowed for {}");
+          error ("@polynomial/subsasgn: chained subscripts not allowed for {}");
         endif
       endif
     case "."
@@ -27,9 +27,9 @@
           p.poly = subsasgn (p.poly, s(2:end), val);
         endif
       else
-        error ("@polynomial/subsref: invalid property \"%s\"", fld);
+        error ("@polynomial/subsasgn: invalid property \"%s\"", fld);
       endif
     otherwise
-      error ("invalid subscript type");
+      error ("@polynomial/subsasgn: invalid subscript type");
   endswitch
 endfunction
--- a/examples/code/@polynomial/subsref.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/@polynomial/subsref.m	Thu Dec 10 12:50:06 2015 -0800
@@ -1,19 +1,19 @@
 function b = subsref (a, s)
   if (isempty (s))
-    error ("polynomial: missing index");
+    error ("@polynomial/subsref: missing index");
   endif
   switch (s(1).type)
     case "()"
       ind = s(1).subs;
       if (numel (ind) != 1)
-        error ("polynomial: need exactly one index");
+        error ("@polynomial/subsref: need exactly one index");
       else
         b = polyval (fliplr (a.poly), ind{1});
       endif
     case "{}"
       ind = s(1).subs;
       if (numel (ind) != 1)
-        error ("polynomial: need exactly one index");
+        error ("@polynomial/subsref: need exactly one index");
       else
         if (isnumeric (ind{1}))
           b = a.poly(ind{1}+1);
@@ -29,7 +29,7 @@
         error ("@polynomial/subsref: invalid property \"%s\"", fld);
       endif
     otherwise
-      error ("invalid subscript type");
+      error ("@polynomial/subsref: invalid subscript type");
   endswitch
   if (numel (s) > 1)
     b = subsref (b, s(2:end));
--- a/examples/code/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-# Makefile for Octave's examples directory
-#
-# Copyright (C) 1996-2015 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 $(top_srcdir)/build-aux/common.mk
-
-EXTRA_DIST =
-
-FCN_FILE_DIRS =
-
-FCN_FILES =
-
-include @polynomial/module.mk
-include @FIRfilter/module.mk
-
-EXTRA_DIST += \
-  $(FCN_FILES) \
-  addtwomatrices.cc \
-  celldemo.cc \
-  embedded.cc \
-  fortrandemo.cc \
-  fortransub.f \
-  funcdemo.cc \
-  globaldemo.cc \
-  helloworld.cc \
-  make_int.cc \
-  mex_demo.c \
-  mycell.c \
-  myfeval.c \
-  myfevalf.f \
-  myfunc.c \
-  myhello.c \
-  mypow2.c \
-  myprop.c \
-  myset.c \
-  mysparse.c \
-  mystring.c \
-  mystruct.c \
-  oct_demo.cc \
-  oregonator.cc \
-  oregonator.m \
-  paramdemo.cc \
-  standalone.cc \
-  standalonebuiltin.cc \
-  stringdemo.cc \
-  structdemo.cc \
-  unwinddemo.cc
-
--- a/examples/code/addtwomatrices.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/addtwomatrices.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -2,17 +2,11 @@
 
 DEFUN_DLD (addtwomatrices, args, , "Add A to B")
 {
-  int nargin = args.length ();
-
-  if (nargin != 2)
+  if (args.length () != 2)
     print_usage ();
-  else
-    {
-      NDArray A = args(0).array_value ();
-      NDArray B = args(1).array_value ();
-      if (! error_state)
-        return octave_value (A + B);
-    }
 
-  return octave_value_list ();
+  NDArray A = args(0).array_value ();
+  NDArray B = args(1).array_value ();
+
+  return octave_value (A + B);
 }
--- a/examples/code/celldemo.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/celldemo.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -4,19 +4,16 @@
 DEFUN_DLD (celldemo, args, , "Cell Demo")
 {
   octave_value_list retval;
-  int nargin = args.length ();
+
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin != 1)
-    print_usage ();
-  else
+  Cell c = args(0).cell_value ();
+
+  for (octave_idx_type i = 0; i < c.numel (); i++)
     {
-      Cell c = args(0).cell_value ();
-      if (! error_state)
-        for (octave_idx_type i = 0; i < c.numel (); i++)
-          {
-            retval(i) = c(i);          // using operator syntax
-            //retval(i) = c.elem (i);  // using method syntax
-          }
+      retval(i) = c(i);          // using operator syntax
+      //retval(i) = c.elem (i);  // using method syntax
     }
 
   return retval;
--- a/examples/code/embedded.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/embedded.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
   octave_value_list out = feval ("gcd", in, 1);
 
-  if (! error_state && out.length () > 0)
+  if (out.length () > 0)
     std::cout << "GCD of ["
               << in(0).int_value ()
               << ", "
--- a/examples/code/fortrandemo.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/fortrandemo.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -11,25 +11,22 @@
 DEFUN_DLD (fortrandemo, args, , "Fortran Demo")
 {
   octave_value_list retval;
-  int nargin = args.length ();
 
-  if (nargin != 1)
+  if (args.length () != 1)
     print_usage ();
-  else
-    {
-      NDArray a = args(0).array_value ();
-      if (! error_state)
-        {
-          double *av = a.fortran_vec ();
-          octave_idx_type na = a.numel ();
-          OCTAVE_LOCAL_BUFFER (char, ctmp, 128);
+
+  NDArray a = args(0).array_value ();
+
+  double *av = a.fortran_vec ();
+  octave_idx_type na = a.numel ();
 
-          F77_XFCN (fortransub, FORTSUB,
-                    (na, av, ctmp F77_CHAR_ARG_LEN (128)));
+  OCTAVE_LOCAL_BUFFER (char, ctmp, 128);
 
-          retval(1) = std::string (ctmp);
-          retval(0) = a;
-        }
-    }
+  F77_XFCN (fortransub, FORTSUB,
+            (na, av, ctmp F77_CHAR_ARG_LEN (128)));
+
+  retval(1) = std::string (ctmp);
+  retval(0) = a;
+
   return retval;
 }
--- a/examples/code/funcdemo.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/funcdemo.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -4,29 +4,31 @@
 DEFUN_DLD (funcdemo, args, nargout, "Function Demo")
 {
   octave_value_list retval;
+
   int nargin = args.length ();
 
   if (nargin < 2)
     print_usage ();
-  else
+
+  octave_value_list newargs;
+
+  for (octave_idx_type i = nargin - 1; i > 0; i--)
+    newargs(i-1) = args(i);
+
+  if (args(0).is_function_handle () || args(0).is_inline_function ())
     {
-      octave_value_list newargs;
-      for (octave_idx_type i = nargin - 1; i > 0; i--)
-        newargs(i-1) = args(i);
-      if (args(0).is_function_handle () || args(0).is_inline_function ())
-        {
-          octave_function *fcn = args(0).function_value ();
-          if (! error_state)
-            retval = feval (fcn, newargs, nargout);
-        }
-      else if (args(0).is_string ())
-        {
-          std::string fcn = args(0).string_value ();
-          if (! error_state)
-            retval = feval (fcn, newargs, nargout);
-        }
-      else
-        error ("funcdemo: INPUT must be string, inline, or function handle");
+      octave_function *fcn = args(0).function_value ();
+
+      retval = feval (fcn, newargs, nargout);
     }
+  else if (args(0).is_string ())
+    {
+      std::string fcn = args(0).string_value ();
+
+      retval = feval (fcn, newargs, nargout);
+    }
+  else
+    error ("funcdemo: INPUT must be string, inline, or function handle");
+
   return retval;
 }
--- a/examples/code/globaldemo.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/globaldemo.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -3,23 +3,20 @@
 DEFUN_DLD (globaldemo, args, , "Global Demo")
 {
   octave_value retval;
-  int nargin = args.length ();
+
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin != 1)
-    print_usage ();
+  std::string s = args(0).string_value ();
+
+  octave_value tmp = get_global_value (s, true);
+
+  if (tmp.is_defined ())
+    retval = tmp;
   else
-    {
-      std::string s = args(0).string_value ();
-      if (! error_state)
-        {
-          octave_value tmp = get_global_value (s, true);
-          if (tmp.is_defined ())
-            retval = tmp;
-          else
-            retval = "Global variable not found";
+    retval = "Global variable not found";
 
-          set_global_value ("a", 42.0);
-        }
-    }
+  set_global_value ("a", 42.0);
+
   return retval;
 }
--- a/examples/code/helloworld.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/helloworld.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -3,10 +3,8 @@
 DEFUN_DLD (helloworld, args, nargout,
            "Hello World Help String")
 {
-  int nargin = args.length ();
-
   octave_stdout << "Hello World has "
-                << nargin << " input arguments and "
+                << args.length () << " input arguments and "
                 << nargout << " output arguments.\n";
 
   return octave_value_list ();
--- a/examples/code/make_int.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/make_int.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -278,8 +278,7 @@
     {
       double d = args(0).double_value ();
 
-      if (! error_state)
-        retval = octave_value (new octave_integer (NINT (d)));
+      retval = octave_value (new octave_integer (NINT (d)));
     }
   else
     usage ("make_int");
--- a/examples/code/paramdemo.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/paramdemo.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -2,29 +2,33 @@
 
 DEFUN_DLD (paramdemo, args, nargout, "Parameter Check Demo")
 {
-  octave_value retval;
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin != 1)
-    print_usage ();
-  else if (nargout != 0)
+  if (nargout != 0)
     error ("paramdemo: OUTPUT argument required");
-  else
-    {
-      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 ())
-        octave_stdout << "  includes Inf or NaN values\n";
-      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 ())
-        octave_stdout << "  includes only int, Inf or NaN values\n";
-      if (m.all_integers (min_val, max_val))
-        octave_stdout << "  includes only integers in [-10,10]\n";
-    }
-  return retval;
+
+  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 ())
+    octave_stdout << "  includes Inf or NaN values\n";
+
+  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 ())
+    octave_stdout << "  includes only int, Inf or NaN values\n";
+
+  if (m.all_integers (min_val, max_val))
+    octave_stdout << "  includes only integers in [-10,10]\n";
+
+  return octave_value ();
 }
--- a/examples/code/stringdemo.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/stringdemo.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -3,27 +3,25 @@
 DEFUN_DLD (stringdemo, args, , "String Demo")
 {
   octave_value_list retval;
-  int nargin = args.length ();
 
-  if (nargin != 1)
+  if (args.length () != 1)
     print_usage ();
-  else
-    {
-      charMatrix ch = args(0).char_matrix_value ();
+
+  charMatrix ch = args(0).char_matrix_value ();
+
+  retval(1) = octave_value (ch, '\'');  // Single Quote String
+
+  octave_idx_type nr = ch.rows ();
 
-      if (! error_state)
-        {
-          retval(1) = octave_value (ch, '\'');  // Single Quote String
+  for (octave_idx_type i = 0; i < nr / 2; i++)
+    {
+      std::string tmp = ch.row_as_string (i);
 
-          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 (), i, 0);
-              ch.insert (tmp.c_str (), nr-i-1, 0);
-            }
-          retval(0) = octave_value (ch, '"');  // Double Quote String
-        }
+      ch.insert (ch.row_as_string (nr-i-1).c_str (), i, 0);
+      ch.insert (tmp.c_str (), nr-i-1, 0);
     }
+
+  retval(0) = octave_value (ch, '"');  // Double Quote String
+
   return retval;
 }
--- a/examples/code/structdemo.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/structdemo.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -3,43 +3,30 @@
 
 DEFUN_DLD (structdemo, args, , "Struct Demo")
 {
-  octave_value retval;
-  int nargin = args.length ();
-
-  if (args.length () == 2)
-    {
-      octave_scalar_map arg0 = args(0).scalar_map_value ();
-      //octave_map arg0 = args(0).map_value ();
-
-      if (! error_state)
-        {
-          std::string arg1 = args(1).string_value ();
-
-          if (! error_state)
-            {
-              octave_value tmp = arg0.contents (arg1);
-              //octave_value tmp = arg0.contents (arg1)(0);
-
-              if (tmp.is_defined ())
-                {
-                  octave_scalar_map st;
-
-                  st.assign ("selected", tmp);
-
-                  retval = octave_value (st);
-                }
-              else
-                error ("structdemo: struct does not have a field named '%s'\n",
-                       arg1.c_str ());
-            }
-          else
-            error ("structdemo: ARG2 must be a character string");
-        }
-      else
-        error ("structdemo: ARG1 must be a struct");
-    }
-  else
+  if (args.length () != 2)
     print_usage ();
 
-  return retval;
+  if (! args(0).is_map ())
+    error ("structdemo: ARG1 must be a struct");
+
+  octave_scalar_map arg0 = args(0).scalar_map_value ();
+  //octave_map arg0 = args(0).map_value ();
+
+  if (! args(1).is_string ())
+    error ("structdemo: ARG2 must be a character string");
+
+  std::string arg1 = args(1).string_value ();
+
+  octave_value tmp = arg0.contents (arg1);
+  //octave_value tmp = arg0.contents (arg1)(0);
+
+  if (! tmp.is_defined ())
+    error ("structdemo: struct does not have a field named '%s'\n",
+           arg1.c_str ());
+
+  octave_scalar_map st;
+
+  st.assign ("selected", tmp);
+
+  return octave_value (st);
 }
--- a/examples/code/unwinddemo.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/examples/code/unwinddemo.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -15,33 +15,23 @@
 
 DEFUN_DLD (unwinddemo, args, nargout, "Unwind Demo")
 {
-  octave_value retval;
-  int nargin = args.length ();
-
-  if (nargin < 2)
+  if (args.length () < 2)
     print_usage ();
-  else
-    {
-      NDArray a = args(0).array_value ();
-      NDArray b = args(1).array_value ();
+
+  NDArray a = args(0).array_value ();
+  NDArray b = args(1).array_value ();
 
-      if (! error_state)
-        {
-          // Declare unwind_protect frame which lasts as long as
-          // the variable frame has scope.
-          unwind_protect frame;
-          frame.add_fcn (set_liboctave_warning_handler,
-                         current_liboctave_warning_handler);
+  // Declare unwind_protect frame which lasts as long as
+  // the variable frame has scope.
+  unwind_protect frame;
+  frame.add_fcn (set_liboctave_warning_handler,
+                 current_liboctave_warning_handler);
 
-          frame.add_fcn (set_liboctave_warning_with_id_handler,
-                         current_liboctave_warning_with_id_handler);
-
-          set_liboctave_warning_handler (my_err_handler);
-          set_liboctave_warning_with_id_handler (my_err_with_id_handler);
+  frame.add_fcn (set_liboctave_warning_with_id_handler,
+                 current_liboctave_warning_with_id_handler);
 
-          retval = octave_value (quotient (a, b));
-        }
-    }
+  set_liboctave_warning_handler (my_err_handler);
+  set_liboctave_warning_with_id_handler (my_err_with_id_handler);
 
-  return retval;
+  return octave_value (quotient (a, b));
 }
--- a/examples/data/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-# Makefile for Octave's examples/data directory
-#
-# Copyright (C) 2012-2015 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 $(top_srcdir)/build-aux/common.mk
-
-DATA_FILES = \
-   penny.mat
-
-octdata_DATA = $(DATA_FILES)
-
-EXTRA_DIST = $(DATA_FILES)
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,83 @@
+examples_EXTRA_DIST =
+
+examples_CLEANFILES =
+examples_DISTCLEANFILES =
+examples_MAINTAINERCLEANFILES =
+
+examples_data_SRC = \
+   examples/data/penny.mat
+
+octdata_DATA += \
+  $(examples_data_SRC)
+
+examples_code_SRC = \
+  examples/code/@FIRfilter/FIRfilter.m \
+  examples/code/@FIRfilter/FIRfilter_aggregation.m \
+  examples/code/@FIRfilter/display.m \
+  examples/code/@FIRfilter/subsasgn.m \
+  examples/code/@FIRfilter/subsref.m \
+  examples/code/@polynomial/display.m \
+  examples/code/@polynomial/double.m \
+  examples/code/@polynomial/end.m \
+  examples/code/@polynomial/get.m \
+  examples/code/@polynomial/mtimes.m \
+  examples/code/@polynomial/numel.m \
+  examples/code/@polynomial/plot.m \
+  examples/code/@polynomial/polynomial.m \
+  examples/code/@polynomial/polynomial_superiorto.m \
+  examples/code/@polynomial/polyval.m \
+  examples/code/@polynomial/roots.m \
+  examples/code/@polynomial/set.m \
+  examples/code/@polynomial/subsasgn.m \
+  examples/code/@polynomial/subsref.m \
+  examples/code/addtwomatrices.cc \
+  examples/code/celldemo.cc \
+  examples/code/embedded.cc \
+  examples/code/fortrandemo.cc \
+  examples/code/fortransub.f \
+  examples/code/funcdemo.cc \
+  examples/code/globaldemo.cc \
+  examples/code/helloworld.cc \
+  examples/code/make_int.cc \
+  examples/code/mex_demo.c \
+  examples/code/mycell.c \
+  examples/code/myfeval.c \
+  examples/code/myfevalf.f \
+  examples/code/myfunc.c \
+  examples/code/myhello.c \
+  examples/code/mypow2.c \
+  examples/code/myprop.c \
+  examples/code/myset.c \
+  examples/code/mysparse.c \
+  examples/code/mystring.c \
+  examples/code/mystruct.c \
+  examples/code/oct_demo.cc \
+  examples/code/oregonator.cc \
+  examples/code/oregonator.m \
+  examples/code/paramdemo.cc \
+  examples/code/standalone.cc \
+  examples/code/standalonebuiltin.cc \
+  examples/code/stringdemo.cc \
+  examples/code/structdemo.cc \
+  examples/code/unwinddemo.cc
+
+examples_EXTRA_DIST += \
+  $(examples_data_SRC) \
+  $(examples_code_SRC) \
+  examples/code/COPYING \
+  examples/module.mk
+
+EXTRA_DIST += $(examples_EXTRA_DIST)
+
+CLEANFILES += $(examples_CLEANFILES)
+DISTCLEANFILES += $(examples_DISTCLEANFILES)
+MAINTAINERCLEANFILES += $(examples_MAINTAINERCLEANFILES)
+
+examples-clean:
+	rm -f $(examples_CLEANFILES)
+
+examples-distclean: examples-clean
+	rm -f $(examples_DISTCLEANFILES)
+
+examples-maintainer-clean: examples-distclean
+	rm -f $(examples_MAINTAINERCLEANFILES)
--- a/libgui/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-# Makefile for Octave's libgui directory
-#
-# Copyright (C) 2012-2015 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 $(top_srcdir)/build-aux/common.mk
-
-MOC_CPPFLAGS =
-
-## Fix for bug #42839 where -mieee CFLAG option is added to CPPFLAGS by gnulib.
-## Users may also pass other options in CPPFLAGS that moc does not understand.
-## Only keep moc-compatible options -Idir, -Dmacro, and -Umacro.
-MOC_OCTAVE_CPPFLAGS = $(filter -I% -D% -U%, $(AM_CPPFLAGS) $(CPPFLAGS))
-
-octlib_LTLIBRARIES = liboctgui.la
-
-TRANSLATIONS = \
-  languages/be_BY.ts \
-  languages/de_DE.ts \
-  languages/en_US.ts \
-  languages/es_ES.ts \
-  languages/fr_FR.ts \
-  languages/it_IT.ts \
-  languages/ja_JP.ts \
-  languages/nl_NL.ts \
-  languages/pt_BR.ts \
-  languages/pt_PT.ts \
-  languages/ru_RU.ts \
-  languages/uk_UA.ts \
-  languages/zh_CN.ts
-
-LOCALES = $(patsubst languages/%.ts, languages/%.qm, $(TRANSLATIONS))
-
-EXTRA_DIST = default-qt-settings.in $(TRANSLATIONS)
-CLEANFILES =
-
-BUILT_SOURCES =
-
-noinst_HEADERS =
-
-noinst_LTLIBRARIES =
-
-include src/module.mk
-include graphics/module.mk
-include qterminal-module.mk
-
-## liboctgui merely collects a bunch of compiled convenience libraries.
-## It has no source code itself.
-liboctgui_la_SOURCES =
-
-include link-deps.mk
-
-# Dummy C++ source to force C++ linking.
-nodist_EXTRA_liboctgui_la_SOURCES = dummy.cc
-
-liboctgui_la_LIBADD = \
-  qterminal/libqterminal.la \
-  src/libgui-src.la \
-  graphics/libgui-graphics.la \
-  $(top_builddir)/libinterp/liboctinterp.la \
-  $(top_builddir)/liboctave/liboctave.la \
-  $(LIBOCTGUI_LINK_DEPS)
-
-# Increment these as needed and according to the rules in the libtool manual:
-liboctgui_current = 1
-liboctgui_revision = 0
-liboctgui_age = 0
-
-liboctgui_version_info = $(liboctgui_current):$(liboctgui_revision):$(liboctgui_age)
-
-liboctgui_la_LDFLAGS = \
-  -version-info $(liboctgui_version_info) \
-  $(NO_UNDEFINED_LDFLAG) \
-  -bindir $(bindir) \
-  $(LIBOCTGUI_LINK_OPTS)
-
-octetc_DATA = default-qt-settings
-
-octlocale_DATA = $(LOCALES)
-
-default-qt-settings: default-qt-settings.in
-	$(AM_V_GEN)$(do_subst_qt_settings)
-
-define moc-command
-  rm -f $@-t $@ && \
-  ( echo "#ifdef HAVE_CONFIG_H"; \
-    echo "#include <config.h>"; \
-    echo "#endif"; \
-    $(MOC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(MOC_OCTAVE_CPPFLAGS) $(MOC_CPPFLAGS) $(liboctgui_la_CPPFLAGS) $< ) > $@-t && \
-  mv $@-t $@
-endef
-
-define rcc-command
-  rm -f $@-t $@ && \
-  ( echo "#ifdef HAVE_CONFIG_H"; \
-    echo "#include <config.h>"; \
-    echo "#endif"; \
-    $(RCC) -name $(@D) $< ) > $@-t && \
-  mv $@-t $@
-endef
-
-moc-%.cc: %.h
-	$(AM_V_GEN)$(moc-command)
-
-ui-%.h: %.ui
-	$(AM_V_GEN)$(UIC) -o $@ $<
-
-qrc-%.cc: %.qrc
-	$(AM_V_GEN)$(rcc-command)
-
-AM_V_lrelease = $(am__v_lrelease_$(V))
-am__v_lrelease_ = $(am__v_lrelease_$(AM_DEFAULT_VERBOSITY))
-am__v_lrelease_0 = -silent
-am__v_lrelease_1 =
-
-%.qm: %.ts
-	$(AM_V_GEN)$(MKDIR_P) languages && \
-	$(LRELEASE) $(AM_V_lrelease) -qm $@ $<
-
-DISTCLEANFILES = \
-  default-qt-settings \
-  $(LOCALES)
-
--- a/libgui/graphics/Backend.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/graphics/Backend.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -215,8 +215,7 @@
         {
           OCTAVE_INTPTR_TYPE ptr = ov.OCTAVE_PTR_SCALAR ().value ();
 
-          if (! error_state)
-            return reinterpret_cast<ObjectProxy*> (ptr);
+          return reinterpret_cast<ObjectProxy*> (ptr);
         }
     }
 
--- a/libgui/graphics/Canvas.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/graphics/Canvas.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -268,7 +268,6 @@
           ap.set_zgrid (state);
 
           redraw (true);
-            
         }
     }
 }
@@ -348,18 +347,6 @@
 }
 
 static bool
-rotate_enabled (const graphics_object figObj)
-{
-  // Getting rotate mode property:
-  octave_value ov_rm
-    = Utils::properties<figure> (figObj).get___rotate_mode__ ();
-
-  octave_scalar_map rm = ov_rm.scalar_map_value ();
-
-  return rm.contents ("Enable").string_value () == "on";
-}
-
-static bool
 zoom_enabled (const graphics_object figObj)
 {
   // Getting zoom mode property:
@@ -383,16 +370,84 @@
   return zm.contents ("Motion").string_value ();
 }
 
-static std::string
-zoom_direction (const graphics_object figObj)
+void
+Canvas::select_object (graphics_object obj, QMouseEvent* event,
+                       graphics_object &currentObj, graphics_object &axesObj,
+                       bool axes_only)
 {
-  // Getting zoom mode property:
-  octave_value ov_zm
-    = Utils::properties<figure> (figObj).get___zoom_mode__ ();
+  QList<graphics_object> axesList;
+  Matrix children = obj.get_properties ().get_all_children ();
+  octave_idx_type num_children = children.numel ();
+
+  for (int i = 0; i < num_children; i++)
+    {
+      graphics_object childObj (gh_manager::get_object (children(i)));
+
+      if (childObj.isa ("axes"))
+        axesList.append (childObj);
+      else if (childObj.isa ("uicontrol") || childObj.isa ("uipanel"))
+        {
+          Matrix bb = childObj.get_properties ().get_boundingbox (false);
+          QRectF r (bb(0), bb(1), bb(2), bb(3));
+
+          r.adjust (-5, -5, 5, 5);
+          if (r.contains (event->posF ()))
+            {
+              currentObj = childObj;
+              break;
+            }
+        }
+    }
+
+  if (axes_only)
+    {
+      QPoint pt = event->pos ();
+
+      for (QList<graphics_object>::ConstIterator it = axesList.begin ();
+           it != axesList.end (); ++it)
+        {
+          const axes::properties& ap =
+            dynamic_cast<const axes::properties&> ((*it).get_properties ());
 
-  octave_scalar_map zm = ov_zm.scalar_map_value ();
+          ColumnVector p0 = ap.pixel2coord (pt.x (), pt.y ());
+          Matrix xlim = ap.get_xlim ().matrix_value ();
+          Matrix ylim = ap.get_ylim ().matrix_value ();
+
+          if (xlim(0) < p0(0) && xlim(1) > p0(0)
+              && ylim(0) < p0(1) && ylim(1) > p0(1))
+            {
+              axesObj = *it;
+              return;
+            }
+        }
+    }
+  else if (! currentObj)
+    {
+      for (QList<graphics_object>::ConstIterator it = axesList.begin ();
+           it != axesList.end (); ++it)
+        {
+          graphics_object go = selectFromAxes (*it, event->pos ());
 
-  return zm.contents ("Direction").string_value ();
+          if (go)
+            {
+              currentObj = go;
+              axesObj = *it;
+            }
+          // FIXME: is this really necessary? the axes object should
+          //        have been selected through selectFromAxes anyway
+          else if (it->get_properties ().is_hittest ())
+            {
+              Matrix bb = it->get_properties ().get_boundingbox (true);
+              QRectF r (bb(0), bb(1), bb(2), bb(3));
+
+              if (r.contains (event->posF ()))
+                axesObj = *it;
+            }
+
+          if (axesObj && currentObj)
+            break;
+        }
+    }
 }
 
 void
@@ -460,9 +515,35 @@
         {
           graphics_object figObj (obj.get_ancestor ("figure"));
 
-          updateCurrentPoint (figObj, obj, event);
-          gh_manager::post_callback (figObj.get_handle (),
-                                     "windowbuttonmotionfcn");
+          if (figObj.valid_object () &&
+              ! figObj.get ("windowbuttonmotionfcn").is_empty ())
+            {
+              updateCurrentPoint (figObj, obj, event);
+              gh_manager::post_callback (figObj.get_handle (),
+                                         "windowbuttonmotionfcn");
+            }
+        }
+    }
+
+  // Update mouse coordinates in the figure window status bar
+  graphics_object obj = gh_manager::get_object (m_handle);
+  graphics_object figObj = obj.get_ancestor ("figure");
+
+  if (figObj.valid_object () && obj.valid_object ())
+    {
+      graphics_object currentObj, axesObj;
+      select_object (obj, event, currentObj, axesObj, true);
+
+      if (axesObj.valid_object ())
+        {
+          // FIXME: should we use signal/slot mechanism instead of
+          //        directly calling parent fig methods
+          Figure* fig =
+            dynamic_cast<Figure*> (Backend::toolkitObject (figObj));
+          axes::properties& ap = Utils::properties<axes> (axesObj);
+
+          if (fig)
+            fig->updateStatusBar (ap.pixel2coord (event->x (), event->y ()));
         }
     }
 }
@@ -512,66 +593,16 @@
     {
       graphics_object figObj (obj.get_ancestor ("figure"));
       graphics_object currentObj, axesObj;
-      QList<graphics_object> axesList;
-
-      Matrix children = obj.get_properties ().get_all_children ();
-      octave_idx_type num_children = children.numel ();
-
-      for (int i = 0; i < num_children; i++)
-        {
-          graphics_object childObj (gh_manager::get_object (children(i)));
 
-          if (childObj.isa ("axes"))
-            axesList.append (childObj);
-          else if (childObj.isa ("uicontrol") || childObj.isa ("uipanel"))
-            {
-              Matrix bb = childObj.get_properties ().get_boundingbox (false);
-              QRectF r (bb(0), bb(1), bb(2), bb(3));
+      select_object (obj, event, currentObj, axesObj);
 
-              r.adjust (-5, -5, 5, 5);
-              if (r.contains (event->posF ()))
-                {
-                  currentObj = childObj;
-                  break;
-                }
-            }
-        }
-
-      if (! currentObj)
+      if (axesObj)
         {
-          for (QList<graphics_object>::ConstIterator it = axesList.begin ();
-               it != axesList.end (); ++it)
-            {
-              graphics_object go = selectFromAxes (*it, event->pos ());
-
-              if (go)
-                {
-                  currentObj = go;
-                  axesObj = *it;
-                }
-              // FIXME: is this really necessary? the axes object should
-              //        have been selected through selectFromAxes anyway
-              else if (it->get_properties ().is_hittest ())
-                {
-                  Matrix bb = it->get_properties ().get_boundingbox (true);
-                  QRectF r (bb(0), bb(1), bb(2), bb(3));
-
-                  if (r.contains (event->posF ()))
-                    axesObj = *it;
-                }
-
-              if (axesObj && currentObj)
-                break;
-            }
-
-          if (axesObj)
-            {
-              if (axesObj.get_properties ().handlevisibility_is ("on"))
-                Utils::properties<figure> (figObj)
-                  .set_currentaxes (axesObj.get_handle ().as_octave_value ());
-              if (! currentObj)
-                currentObj = axesObj;
-            }
+          if (axesObj.get_properties ().handlevisibility_is ("on"))
+            Utils::properties<figure> (figObj)
+              .set_currentaxes (axesObj.get_handle ().as_octave_value ());
+          if (! currentObj)
+            currentObj = axesObj;
         }
 
       if (! currentObj)
@@ -604,7 +635,7 @@
 
           if (currentObj.get ("buttondownfcn").is_empty ())
             {
-              graphics_object parentObj = 
+              graphics_object parentObj =
                 gh_manager::get_object (currentObj.get_parent ());
 
               if (parentObj.valid_object () && parentObj.isa ("hggroup"))
--- a/libgui/graphics/Canvas.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/graphics/Canvas.h	Thu Dec 10 12:50:06 2015 -0800
@@ -106,6 +106,9 @@
                            const graphics_object& obj);
 
   void annotation_callback (const octave_value_list& args);
+  void select_object (graphics_object obj, QMouseEvent* event,
+                      graphics_object &currentObj, graphics_object &axesObj,
+                      bool axes_only = false);
 
 private:
   graphics_handle m_handle;
--- a/libgui/graphics/Figure.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/graphics/Figure.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -132,49 +132,58 @@
 
   figure::properties& fp = properties<figure> ();
 
-  createFigureToolBarAndMenuBar ();
+  // Status bar
+  m_statusBar = win->statusBar ();
+  int boffset = 0;
 
-  int offset = 0;
+  // Toolbar and menubar
+  createFigureToolBarAndMenuBar ();
+  int toffset = 0;
+
   if (fp.toolbar_is ("figure") ||
       (fp.toolbar_is ("auto") && fp.menubar_is ("figure") &&
        ! hasUiControlChildren (fp)))
-    offset += m_figureToolBar->sizeHint ().height ();
+    {
+      toffset += m_figureToolBar->sizeHint ().height ();
+      boffset += m_statusBar->sizeHint ().height ();
+    }
   else
-    m_figureToolBar->hide ();
+    {
+      m_figureToolBar->hide ();
+      m_statusBar->hide ();
+    }
+
   if (fp.menubar_is ("figure") || hasUiMenuChildren (fp))
-    offset += m_menuBar->sizeHint ().height () + 1;
+    toffset += m_menuBar->sizeHint ().height () + 1;
   else
     m_menuBar->hide ();
 
   m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
   m_outerRect = boundingBoxToRect (fp.get_boundingbox (false));
 
-  //qDebug () << "Figure::Figure:" << m_innerRect;
-  win->setGeometry (m_innerRect.adjusted (0, -offset, 0, 0));
-  //qDebug () << "Figure::Figure(adjusted)" << m_innerRect.adjusted (0, -offset, 0, 0);
-  win->setWindowTitle (Utils::fromStdString (fp.get_title ()));
+  win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
+
+  // Enable mouse tracking unconditionally
+  enableMouseTracking ();
+
+  // When this constructor gets called all properties are already
+  // set, even non default. We force "update" here to get things right.
 
-  int eventMask = 0;
-  if (! fp.get_keypressfcn ().is_empty ())
-    eventMask |= Canvas::KeyPress;
-  if (! fp.get_keyreleasefcn ().is_empty ())
-    eventMask |= Canvas::KeyRelease;
-  m_container->canvas (m_handle)->setEventMask (eventMask);
+  // Figure title
+  update (figure::properties::ID_NUMBERTITLE);
 
-  if (! fp.get_windowbuttonmotionfcn ().is_empty ())
-    {
-      m_container->setMouseTracking (true);
-      m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true);
-    }
+  // Decide what keyboard events we listen to
+  m_container->canvas (m_handle)->setEventMask (0);
+  update (figure::properties::ID_KEYPRESSFCN);
+  update (figure::properties::ID_KEYRELEASEFCN);
+
+  // Visibility
+  update (figure::properties::ID_VISIBLE);
+
 
   connect (this, SIGNAL (asyncUpdate (void)),
            this, SLOT (updateContainer (void)));
 
-  if (fp.is_visible ())
-    QTimer::singleShot (0, win, SLOT (show ()));
-  else
-    win->hide ();
-
   win->addReceiver (this);
   m_container->addReceiver (this);
 }
@@ -411,17 +420,20 @@
     case figure::properties::ID_POSITION:
         {
           m_innerRect = boundingBoxToRect (fp.get_boundingbox (true));
-          //qDebug () << "Figure::update(position):" << m_innerRect;
-          int offset = 0;
+          int toffset = 0;
+          int boffset = 0;
 
           foreach (QToolBar* tb, win->findChildren<QToolBar*> ())
             if (! tb->isHidden ())
-              offset += tb->sizeHint ().height ();
+              toffset += tb->sizeHint ().height ();
+
           if (! m_menuBar->isHidden ())
-            offset += m_menuBar->sizeHint ().height () + 1;
-          //qDebug () << "Figure::update(position)(adjusted):" << m_innerRect.adjusted (0, -offset, 0, 0);
-          win->setGeometry (m_innerRect.adjusted (0, -offset, 0, 0));
-          //qDebug () << "Figure::update(position): done";
+            toffset += m_menuBar->sizeHint ().height () + 1;
+
+          if (! m_statusBar->isHidden ())
+            boffset += m_statusBar->sizeHint ().height () + 1;
+
+          win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
         }
       break;
 
@@ -467,16 +479,6 @@
         m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease);
       break;
 
-    case figure::properties::ID_WINDOWBUTTONMOTIONFCN:
-        {
-          bool hasCallback = ! fp.get_windowbuttonmotionfcn ().is_empty ();
-
-          m_container->setMouseTracking (hasCallback);
-          foreach (QWidget* w, m_container->findChildren<QWidget*> ())
-            { w->setMouseTracking (hasCallback); }
-        }
-      break;
-
     default:
       break;
     }
@@ -489,17 +491,19 @@
 {
   if ((! m_figureToolBar->isHidden ()) != visible)
     {
-      int dy = m_figureToolBar->sizeHint ().height ();
+      int dy1 = m_figureToolBar->sizeHint ().height ();
+      int dy2 = m_statusBar->sizeHint ().height ();
       QRect r = qWidget<QWidget> ()->geometry ();
 
       if (! visible)
-        r.adjust (0, dy, 0, 0);
+        r.adjust (0, dy1, 0, -dy2);
       else
-        r.adjust (0, -dy, 0, 0);
+        r.adjust (0, -dy1, 0, dy2);
 
       m_blockUpdates = true;
       qWidget<QWidget> ()->setGeometry (r);
       m_figureToolBar->setVisible (visible);
+      m_statusBar->setVisible (visible);
       m_blockUpdates = false;
 
       updateBoundingBox (false);
@@ -551,6 +555,15 @@
     showMenuBar (Utils::properties<figure> (go).menubar_is ("figure"));
 }
 
+void
+Figure::updateStatusBar (ColumnVector pt)
+{
+  if (! m_statusBar->isHidden ())
+    m_statusBar->showMessage (QString ("(%1, %2)")
+                              .arg (pt(0), 0, 'g', 5)
+                              .arg (pt(1), 0, 'g', 5));
+}
+
 QWidget*
 Figure::menu (void)
 {
@@ -705,9 +718,17 @@
                   ()->isWidgetType())
                 {
                   gh_manager::auto_lock lock;
-                  const figure::properties& fp = properties<figure> ();
+                  update (figure::properties::ID_TOOLBAR);
+
+                  enableMouseTracking ();
+                }
 
-                  showFigureToolBar (! hasUiControlChildren (fp));
+            case QEvent::ChildRemoved:
+              if (dynamic_cast<QChildEvent*> (xevent)->child
+                  ()->isWidgetType())
+                {
+                  gh_manager::auto_lock lock;
+                  update (figure::properties::ID_TOOLBAR);
                 }
 
             default:
@@ -956,4 +977,14 @@
     canvas->autoAxes (m_handle);
 }
 
+void
+Figure::enableMouseTracking (void)
+{
+  // Enable mouse tracking on every widgets
+  m_container->setMouseTracking (true);
+  m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true);
+  foreach (QWidget* w, m_container->findChildren<QWidget*> ())
+    { w->setMouseTracking (true); }
+}
+
 }; // namespace QtHandles
--- a/libgui/graphics/Figure.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/graphics/Figure.h	Thu Dec 10 12:50:06 2015 -0800
@@ -24,6 +24,7 @@
 #define __QtHandles_Figure__ 1
 
 #include <QRect>
+#include <QStatusBar>
 
 #include "GenericEventNotify.h"
 #include "MenuContainer.h"
@@ -78,6 +79,7 @@
 
   Container* innerContainer (void);
   QWidget* menu (void);
+  void updateStatusBar (ColumnVector pt);
 
   bool eventNotifyBefore (QObject* watched, QEvent* event);
   void eventNotifyAfter (QObject* watched, QEvent* event);
@@ -111,6 +113,8 @@
   void save_figure_callback (const std::string& file);
   void copy_figure_callback (const std::string& format);
 
+  void enableMouseTracking (void);
+
 private slots:
   void setMouseMode (MouseMode mode);
   void fileSaveFigure (bool prompt = false);
@@ -132,6 +136,7 @@
   bool m_blockUpdates;
   QToolBar* m_figureToolBar;
   MenuBar* m_menuBar;
+  QStatusBar* m_statusBar;
   QRect m_innerRect;
   QRect m_outerRect;
   MouseModeActionGroup* m_mouseModeGroup;
--- a/libgui/graphics/ListBoxControl.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/graphics/ListBoxControl.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -48,6 +48,7 @@
       if (1 <= idx && idx <= lc)
         {
           list->item (idx-1)->setSelected (true);
+          list->scrollToItem (list->item (idx-1));
           if (i == 0
               && list->selectionMode () == QAbstractItemView::SingleSelection)
             break;
@@ -100,6 +101,7 @@
           if (1 <= idx && idx <= lc)
             {
               list->item (idx-1)->setSelected (true);
+              list->scrollToItem (list->item (idx-1));
               if (i == 0 && (list->selectionMode ()
                              == QAbstractItemView::SingleSelection))
                 break;
--- a/libgui/graphics/QtHandlesUtils.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/graphics/QtHandlesUtils.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -61,7 +61,7 @@
 fromStringVector (const string_vector& v)
 {
   QStringList l;
-  octave_idx_type n = v.length ();
+  octave_idx_type n = v.numel ();
 
   for (octave_idx_type i = 0; i < n; i++)
     l << fromStdString (v[i]);
--- a/libgui/graphics/__init_qt__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/graphics/__init_qt__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -190,7 +190,7 @@
   // Expected arguments:
   //   args(0) : File filter as a cell array {ext1, name1; ext2, name2; ...}
   //   args(1) : Dialog title
-  //   args(2) : Default file name
+  //   args(2) : Default filename
   //   args(3) : Dialog position [ignored]
   //   args(4) : Multiselection "on"/"off"
   //   args(5) : Default directory
@@ -272,7 +272,7 @@
   // Expected arguments:
   //   args(0) : File filter as a cell array {ext1, name1; ext2, name2; ...}
   //   args(1) : Dialog title
-  //   args(2) : Default file name
+  //   args(2) : Default filename
   //   args(3) : Dialog position [ignored]
   //   args(4) : Tag [ignored]
   //   args(5) : Default directory
--- a/libgui/graphics/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/graphics/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,134 +1,135 @@
-EXTRA_DIST += \
-  graphics/module.mk \
-  graphics/qthandles.qrc \
-  graphics/images/README \
-  graphics/images/pan.png \
-  graphics/images/rotate.png \
-  graphics/images/select.png \
-  graphics/images/zoom-in.png \
-  graphics/images/zoom-out.png \
-  $(octave_gui_graphics_UI)
+OCTAVE_GUI_GRAPHICS_MOC = \
+  libgui/graphics/moc-annotation-dialog.cc \
+  libgui/graphics/moc-Backend.cc \
+  libgui/graphics/moc-ButtonControl.cc \
+  libgui/graphics/moc-ContextMenu.cc \
+  libgui/graphics/moc-EditControl.cc \
+  libgui/graphics/moc-Figure.cc \
+  libgui/graphics/moc-FigureWindow.cc \
+  libgui/graphics/moc-ListBoxControl.cc \
+  libgui/graphics/moc-Menu.cc \
+  libgui/graphics/moc-MouseModeActionGroup.cc \
+  libgui/graphics/moc-Object.cc \
+  libgui/graphics/moc-ObjectFactory.cc \
+  libgui/graphics/moc-ObjectProxy.cc \
+  libgui/graphics/moc-PopupMenuControl.cc \
+  libgui/graphics/moc-PushTool.cc \
+  libgui/graphics/moc-SliderControl.cc \
+  libgui/graphics/moc-TextEdit.cc \
+  libgui/graphics/moc-ToggleTool.cc \
+  libgui/graphics/moc-ToolBar.cc
+
+$(OCTAVE_GUI_GRAPHICS_MOC): | libgui/graphics/$(octave_dirstamp)
+
+DIRSTAMP_FILES += \
+  libgui/graphics/$(octave_dirstamp)
 
 octave_gui_MOC += \
-  graphics/moc-annotation-dialog.cc \
-  graphics/moc-Backend.cc \
-  graphics/moc-ButtonControl.cc \
-  graphics/moc-ContextMenu.cc \
-  graphics/moc-EditControl.cc \
-  graphics/moc-Figure.cc \
-  graphics/moc-FigureWindow.cc \
-  graphics/moc-ListBoxControl.cc \
-  graphics/moc-Menu.cc \
-  graphics/moc-MouseModeActionGroup.cc \
-  graphics/moc-Object.cc \
-  graphics/moc-ObjectFactory.cc \
-  graphics/moc-ObjectProxy.cc \
-  graphics/moc-PopupMenuControl.cc \
-  graphics/moc-PushTool.cc \
-  graphics/moc-SliderControl.cc \
-  graphics/moc-TextEdit.cc \
-  graphics/moc-ToggleTool.cc \
-  graphics/moc-ToolBar.cc
+  $(OCTAVE_GUI_GRAPHICS_MOC)
 
 octave_gui_graphics_UI = \
-  graphics/annotation-dialog.ui
+  libgui/graphics/annotation-dialog.ui
 
-octave_gui_graphics_UI_H = $(patsubst graphics/%.ui, graphics/ui-%.h, $(octave_gui_graphics_UI))
+octave_gui_graphics_UI_H = $(patsubst libgui/graphics/%.ui, libgui/graphics/ui-%.h, $(octave_gui_graphics_UI))
+
+$(octave_gui_graphics_UI_H): | libgui/graphics/$(octave_dirstamp)
 
 BUILT_SOURCES += $(octave_gui_graphics_UI_H)
 
-octave_gui_graphics_RC = graphics/qrc-qthandles.cc
+octave_gui_graphics_RC = libgui/graphics/qrc-qthandles.cc
+
+$(octave_gui_graphics_RC): | libgui/graphics/$(octave_dirstamp)
 
 noinst_HEADERS += \
-  graphics/__init_qt__.h \
-  graphics/annotation-dialog.h \
-  graphics/Backend.h \
-  graphics/BaseControl.h \
-  graphics/ButtonControl.h \
-  graphics/Canvas.h \
-  graphics/CheckBoxControl.h \
-  graphics/Container.h \
-  graphics/ContextMenu.h \
-  graphics/EditControl.h \
-  graphics/Figure.h \
-  graphics/FigureWindow.h \
-  graphics/GenericEventNotify.h \
-  graphics/GLCanvas.h \
-  graphics/KeyMap.h \
-  graphics/ListBoxControl.h \
-  graphics/Logger.h \
-  graphics/Menu.h \
-  graphics/MenuContainer.h \
-  graphics/MouseModeActionGroup.h \
-  graphics/Object.h \
-  graphics/ObjectFactory.h \
-  graphics/ObjectProxy.h \
-  graphics/Panel.h \
-  graphics/PopupMenuControl.h \
-  graphics/PushButtonControl.h \
-  graphics/PushTool.h \
-  graphics/QtHandlesUtils.h \
-  graphics/RadioButtonControl.h \
-  graphics/SliderControl.h \
-  graphics/TextControl.h \
-  graphics/TextEdit.h \
-  graphics/ToggleButtonControl.h \
-  graphics/ToggleTool.h \
-  graphics/ToolBar.h \
-  graphics/ToolBarButton.h \
-  graphics/gl-select.h \
+  libgui/graphics/__init_qt__.h \
+  libgui/graphics/annotation-dialog.h \
+  libgui/graphics/Backend.h \
+  libgui/graphics/BaseControl.h \
+  libgui/graphics/ButtonControl.h \
+  libgui/graphics/Canvas.h \
+  libgui/graphics/CheckBoxControl.h \
+  libgui/graphics/Container.h \
+  libgui/graphics/ContextMenu.h \
+  libgui/graphics/EditControl.h \
+  libgui/graphics/Figure.h \
+  libgui/graphics/FigureWindow.h \
+  libgui/graphics/GenericEventNotify.h \
+  libgui/graphics/GLCanvas.h \
+  libgui/graphics/KeyMap.h \
+  libgui/graphics/ListBoxControl.h \
+  libgui/graphics/Logger.h \
+  libgui/graphics/Menu.h \
+  libgui/graphics/MenuContainer.h \
+  libgui/graphics/MouseModeActionGroup.h \
+  libgui/graphics/Object.h \
+  libgui/graphics/ObjectFactory.h \
+  libgui/graphics/ObjectProxy.h \
+  libgui/graphics/Panel.h \
+  libgui/graphics/PopupMenuControl.h \
+  libgui/graphics/PushButtonControl.h \
+  libgui/graphics/PushTool.h \
+  libgui/graphics/QtHandlesUtils.h \
+  libgui/graphics/RadioButtonControl.h \
+  libgui/graphics/SliderControl.h \
+  libgui/graphics/TextControl.h \
+  libgui/graphics/TextEdit.h \
+  libgui/graphics/ToggleButtonControl.h \
+  libgui/graphics/ToggleTool.h \
+  libgui/graphics/ToolBar.h \
+  libgui/graphics/ToolBarButton.h \
+  libgui/graphics/gl-select.h \
   $(TEMPLATE_SRC)
 
-graphics_libgui_graphics_la_SOURCES = \
-  graphics/__init_qt__.cc \
-  graphics/annotation-dialog.cc \
-  graphics/Backend.cc \
-  graphics/BaseControl.cc \
-  graphics/ButtonControl.cc \
-  graphics/Canvas.cc \
-  graphics/CheckBoxControl.cc \
-  graphics/Container.cc \
-  graphics/ContextMenu.cc \
-  graphics/EditControl.cc \
-  graphics/Figure.cc \
-  graphics/FigureWindow.cc \
-  graphics/GLCanvas.cc \
-  graphics/KeyMap.cc \
-  graphics/ListBoxControl.cc \
-  graphics/Logger.cc \
-  graphics/Menu.cc \
-  graphics/MouseModeActionGroup.cc \
-  graphics/Object.cc \
-  graphics/ObjectFactory.cc \
-  graphics/ObjectProxy.cc \
-  graphics/Panel.cc \
-  graphics/PopupMenuControl.cc \
-  graphics/PushButtonControl.cc \
-  graphics/PushTool.cc \
-  graphics/QtHandlesUtils.cc \
-  graphics/RadioButtonControl.cc \
-  graphics/SliderControl.cc \
-  graphics/TextControl.cc \
-  graphics/TextEdit.cc \
-  graphics/ToggleButtonControl.cc \
-  graphics/ToggleTool.cc \
-  graphics/ToolBar.cc \
-  graphics/gl-select.cc
+libgui_graphics_libgui_graphics_la_SOURCES = \
+  libgui/graphics/__init_qt__.cc \
+  libgui/graphics/annotation-dialog.cc \
+  libgui/graphics/Backend.cc \
+  libgui/graphics/BaseControl.cc \
+  libgui/graphics/ButtonControl.cc \
+  libgui/graphics/Canvas.cc \
+  libgui/graphics/CheckBoxControl.cc \
+  libgui/graphics/Container.cc \
+  libgui/graphics/ContextMenu.cc \
+  libgui/graphics/EditControl.cc \
+  libgui/graphics/Figure.cc \
+  libgui/graphics/FigureWindow.cc \
+  libgui/graphics/GLCanvas.cc \
+  libgui/graphics/KeyMap.cc \
+  libgui/graphics/ListBoxControl.cc \
+  libgui/graphics/Logger.cc \
+  libgui/graphics/Menu.cc \
+  libgui/graphics/MouseModeActionGroup.cc \
+  libgui/graphics/Object.cc \
+  libgui/graphics/ObjectFactory.cc \
+  libgui/graphics/ObjectProxy.cc \
+  libgui/graphics/Panel.cc \
+  libgui/graphics/PopupMenuControl.cc \
+  libgui/graphics/PushButtonControl.cc \
+  libgui/graphics/PushTool.cc \
+  libgui/graphics/QtHandlesUtils.cc \
+  libgui/graphics/RadioButtonControl.cc \
+  libgui/graphics/SliderControl.cc \
+  libgui/graphics/TextControl.cc \
+  libgui/graphics/TextEdit.cc \
+  libgui/graphics/ToggleButtonControl.cc \
+  libgui/graphics/ToggleTool.cc \
+  libgui/graphics/ToolBar.cc \
+  libgui/graphics/gl-select.cc
 
 TEMPLATE_SRC = \
-  graphics/ToolBarButton.cc
+  libgui/graphics/ToolBarButton.cc
 
-nodist_graphics_libgui_graphics_la_SOURCES = $(octave_gui_graphics_MOC) $(octave_gui_graphics_RC)
+nodist_libgui_graphics_libgui_graphics_la_SOURCES = $(octave_gui_graphics_MOC) $(octave_gui_graphics_RC)
 
-graphics_libgui_graphics_la_CPPFLAGS = \
+libgui_graphics_libgui_graphics_la_CPPFLAGS = \
   $(AM_CPPFLAGS) \
   $(FT2_CPPFLAGS) \
   $(FONTCONFIG_CPPFLAGS) \
   $(HDF5_CPPFLAGS) \
   @OCTGUI_DLL_DEFS@ \
   @QT_CPPFLAGS@ \
-  -Igraphics -I$(srcdir)/graphics \
-  -Isrc -I$(srcdir)/src \
+  -Ilibgui/graphics -I$(srcdir)/libgui/graphics \
+  -Isrc -I$(srcdir)/libgui/src \
   -I$(top_srcdir)/liboctave/cruft/misc \
   -I$(top_srcdir)/liboctave/array \
   -I$(top_builddir)/liboctave/numeric -I$(top_srcdir)/liboctave/numeric \
@@ -140,13 +141,23 @@
   -I$(top_builddir)/libinterp/corefcn -I$(top_srcdir)/libinterp/corefcn \
   -I$(top_srcdir)/libinterp/octave-value
 
-graphics_libgui_graphics_la_CFLAGS = $(AM_CFLAGS) $(WARN_CFLAGS)
+libgui_graphics_libgui_graphics_la_CFLAGS = $(AM_CFLAGS) $(WARN_CFLAGS)
 
-graphics_libgui_graphics_la_CXXFLAGS = $(AM_CXXFLAGS) $(WARN_CXXFLAGS)
+libgui_graphics_libgui_graphics_la_CXXFLAGS = $(AM_CXXFLAGS) $(WARN_CXXFLAGS)
+
+noinst_LTLIBRARIES += libgui/graphics/libgui-graphics.la
 
-noinst_LTLIBRARIES += graphics/libgui-graphics.la
+libgui_EXTRA_DIST += \
+  libgui/graphics/qthandles.qrc \
+  libgui/graphics/images/README \
+  libgui/graphics/images/pan.png \
+  libgui/graphics/images/rotate.png \
+  libgui/graphics/images/select.png \
+  libgui/graphics/images/zoom-in.png \
+  libgui/graphics/images/zoom-out.png \
+  $(octave_gui_graphics_UI)
 
-CLEANFILES += \
+libgui_CLEANFILES += \
   $(octave_gui_graphics_MOC) \
   $(octave_gui_graphics_RC) \
   $(octave_gui_graphics_UI_H)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgui/languages/eu_ES.ts	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,3541 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="eu">
+<context>
+    <name>ListDialog</name>
+    <message>
+        <location filename="../src/dialog.cc" line="+251"/>
+        <source>Select All</source>
+        <translation>Hautatu dena</translation>
+    </message>
+</context>
+<context>
+    <name>QObject</name>
+    <message>
+        <location filename="../src/workspace-model.cc" line="+75"/>
+        <source>automatic</source>
+        <translation>automatikoa</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>function</source>
+        <translation>funtzioa</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>global</source>
+        <translation>orokorra</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>hidden</source>
+        <translation>ezkutua</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>inherited</source>
+        <translation>heredatua</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>persistent</source>
+        <translation>iraunkorra</translation>
+    </message>
+    <message>
+        <location filename="../qterminal/libqterminal/QTerminal.cc" line="+65"/>
+        <source>foreground</source>
+        <translation>aurreko planoa</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>background</source>
+        <translation>atzeko planoa</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>selection</source>
+        <translation>hautapena</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>cursor</source>
+        <translation>kurtsorea</translation>
+    </message>
+</context>
+<context>
+    <name>QTerminal</name>
+    <message>
+        <location filename="../qterminal/libqterminal/QTerminal.h" line="+135"/>
+        <source>Copy</source>
+        <translation>Kopiatu</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Paste</source>
+        <translation>Itsatsi</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Select All</source>
+        <translation>Hautatu dena</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Clear Window</source>
+        <translation>Garbitu leihoa</translation>
+    </message>
+</context>
+<context>
+    <name>QWinTerminalImpl</name>
+    <message>
+        <location filename="../qterminal/libqterminal/win32/QWinTerminalImpl.cpp" line="+1778"/>
+        <source>copied selection to clipboard</source>
+        <translation>arbelean kopiatutako aukeraketa</translation>
+    </message>
+</context>
+<context>
+    <name>QtHandles::Figure</name>
+    <message>
+        <location filename="../graphics/Figure.cc" line="+282"/>
+        <source>Figure ToolBar</source>
+        <translation>Irudien tresna-barra</translation>
+    </message>
+    <message>
+        <location line="+9"/>
+        <source>Axes</source>
+        <translation>Ardatzak</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Grid</source>
+        <translation>Sarea</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Autoscale</source>
+        <translation>Autoeskalatua</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <source>&amp;File</source>
+        <translation>&amp;Fitxategia</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;Save</source>
+        <translation>&amp;Gorde</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Save &amp;As</source>
+        <translation>Gorde &amp;honela</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;Close Figure</source>
+        <translation>Irudia it&amp;xi</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>&amp;Edit</source>
+        <translation>&amp;Editatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Cop&amp;y</source>
+        <translation>Ko&amp;piatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Cu&amp;t</source>
+        <translation>Eba&amp;ki</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;Paste</source>
+        <translation>&amp;Itsatsi</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>&amp;Help</source>
+        <translation>&amp;Laguntza</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;About QtHandles</source>
+        <translation>&quot;QtHandles&quot;-i &amp;buruz</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>About &amp;Qt</source>
+        <translation>&quot;Qt&quot;-ri &amp;buruz</translation>
+    </message>
+    <message>
+        <location line="+427"/>
+        <source>About QtHandles</source>
+        <translation>&quot;QtHandles&quot;-i buruz</translation>
+    </message>
+    <message>
+        <location line="+39"/>
+        <source>Save Figure As</source>
+        <translation>Gorde irudia honela</translation>
+    </message>
+</context>
+<context>
+    <name>QtHandles::MouseModeActionGroup</name>
+    <message>
+        <location filename="../graphics/MouseModeActionGroup.cc" line="+40"/>
+        <source>Rotate</source>
+        <translation>Biratu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Zoom In</source>
+        <translation>Handitu</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Zoom Out</source>
+        <translation>Txikitu</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Pan</source>
+        <translation>Mugitu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Insert Text</source>
+        <translation>Testua sartu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Select</source>
+        <translation>Aukeratu</translation>
+    </message>
+</context>
+<context>
+    <name>documentation_dock_widget</name>
+    <message>
+        <location filename="../src/documentation-dock-widget.cc" line="+34"/>
+        <source>Documentation</source>
+        <translation>Dokumentazioa</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>See the documentation for help.</source>
+        <translation>Laguntzeko dokumentazioa ikusi.</translation>
+    </message>
+</context>
+<context>
+    <name>file_editor</name>
+    <message>
+        <location filename="../src/m-editor/file-editor.cc" line="+285"/>
+        <location line="+125"/>
+        <location line="+19"/>
+        <location line="+25"/>
+        <location line="+62"/>
+        <location line="+28"/>
+        <source>Octave Editor</source>
+        <translation>Octaveren editorea</translation>
+    </message>
+    <message>
+        <location line="-318"/>
+        <source>Octave Files (*.m);;All Files (*)</source>
+        <translation>Octaveren fitxategiak (*.m);;Fitxategi guztiak (*)</translation>
+    </message>
+    <message>
+        <location line="-40"/>
+        <source>New Function</source>
+        <translation>Beste funtzio bat sortu</translation>
+    </message>
+    <message>
+        <location line="+718"/>
+        <source>&amp;%1 %2</source>
+        <translation>&amp;%1 %2</translation>
+    </message>
+    <message>
+        <location line="+388"/>
+        <source>&amp;Save File</source>
+        <translation>&amp;Gorde fitxategia</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Save File &amp;As...</source>
+        <translation>Gorde fitxategia &amp;honela...</translation>
+    </message>
+    <message>
+        <location line="+14"/>
+        <source>Print...</source>
+        <translation>Imprimatu...</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <source>&amp;Undo</source>
+        <translation>&amp;Desegin</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>&amp;Redo</source>
+        <translation>&amp;Berregin</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>&amp;Copy</source>
+        <translation>&amp;Kopiatu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Cu&amp;t</source>
+        <translation>Eba&amp;ki</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Paste</source>
+        <translation>Itsatsi</translation>
+    </message>
+    <message>
+        <location line="+96"/>
+        <source>&amp;Next Bookmark</source>
+        <translation>Hurrengo &amp;markatzailea</translation>
+    </message>
+    <message>
+        <location line="-2"/>
+        <source>Pre&amp;vious Bookmark</source>
+        <translation>Aurreko &amp;markatzailea</translation>
+    </message>
+    <message>
+        <location line="-1237"/>
+        <source>New function name:
+</source>
+        <translation>Funtzio berriaren izena:
+</translation>
+    </message>
+    <message>
+        <location line="+99"/>
+        <source>Could not start custom file editor
+%1</source>
+        <translation>%1
+pertsonalizatutako testu-editorea ezin da ireki</translation>
+    </message>
+    <message>
+        <location line="+125"/>
+        <source>Could not open file
+%1
+for read: %2.</source>
+        <translation>%1
+fitxategia ezin da irakurri: %2.</translation>
+    </message>
+    <message>
+        <location line="+19"/>
+        <source>File
+%1
+does not exist. Do you want to create it?</source>
+        <translation>%1
+fitxategia ez dago. Sortu nahi duzu?</translation>
+    </message>
+    <message>
+        <location line="+998"/>
+        <source>Toggle &amp;Bookmark</source>
+        <translation>&amp;Markatzaileak txandatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;Remove All Bookmarks</source>
+        <translation>&amp;Markatzaile guztiak ezabatu</translation>
+    </message>
+    <message>
+        <location line="+20"/>
+        <source>Show &amp;Whitespace Characters</source>
+        <translation>Erakutsi &amp;zuriuneak</translation>
+    </message>
+    <message>
+        <location line="+34"/>
+        <source>&amp;Next Breakpoint</source>
+        <translation>&amp;Hurrengo geldiunea</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Pre&amp;vious Breakpoint</source>
+        <translation>&amp;Aurreko geldiunea</translation>
+    </message>
+    <message>
+        <location line="-6"/>
+        <source>Toggle &amp;Breakpoint</source>
+        <translation>Geldiuneak &amp;txandatu</translation>
+    </message>
+    <message>
+        <location line="+9"/>
+        <source>&amp;Remove All Breakpoints</source>
+        <translation>&amp;Ezabatu geldiune guztiak</translation>
+    </message>
+    <message>
+        <location line="-104"/>
+        <source>&amp;Comment</source>
+        <translation>&amp;Iruzkindu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;Uncomment</source>
+        <translation>&amp;Iruzkina ezabatu</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>&amp;Indent</source>
+        <translation>Koska &amp;aplikatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;Unindent</source>
+        <translation>Koska &amp;kendu</translation>
+    </message>
+    <message>
+        <location line="-55"/>
+        <source>&amp;Find and Replace...</source>
+        <translation>&amp;Bilatu eta ordezkatu...</translation>
+    </message>
+    <message>
+        <location line="+162"/>
+        <source>Save File and Run</source>
+        <translation>Fitxategia gorde eta exekutatu</translation>
+    </message>
+    <message>
+        <location line="-90"/>
+        <source>Go &amp;to Line...</source>
+        <translation>&amp;Lerrora joan...</translation>
+    </message>
+    <message>
+        <location line="-978"/>
+        <source>Create</source>
+        <translation>Sortu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Cancel</source>
+        <translation>Ezeztatu</translation>
+    </message>
+    <message>
+        <location line="+20"/>
+        <source>Could not open file
+%1
+for write: %2.</source>
+        <translation>%1
+fitxategia ezin da idatzi: %2.</translation>
+    </message>
+    <message>
+        <location line="+62"/>
+        <source>File not saved! A file with the selected name
+%1
+is already open in the editor</source>
+        <translation>%1
+fitxategia ez da gorde! 
+Izen bera duen beste fitxategi bat irekita dago editorean</translation>
+    </message>
+    <message>
+        <location line="+762"/>
+        <source>&amp;Recent Editor Files</source>
+        <translation>&amp;Azken fitxategiak</translation>
+    </message>
+    <message>
+        <location line="+8"/>
+        <source>&amp;Edit Function</source>
+        <translation>&amp;Funtzioa editatu</translation>
+    </message>
+    <message>
+        <location line="+12"/>
+        <source>&amp;Close</source>
+        <translation>It&amp;xi</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Close All</source>
+        <translation>Itxi dena</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Close Other Files</source>
+        <translation>Beste fitxategi batzuk itxi</translation>
+    </message>
+    <message>
+        <location line="+31"/>
+        <source>Select All</source>
+        <translation>Aukeratu dena</translation>
+    </message>
+    <message>
+        <location line="+10"/>
+        <source>&amp;Commands</source>
+        <translation>&amp;Aginduak</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Delete Line</source>
+        <translation>Lerroa ezabatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Copy Line</source>
+        <translation>Lerroa kopiatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Cut Line</source>
+        <translation>Lerroa ebaki</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Delete to Start of Word</source>
+        <translation>Hitz hasieraraino ezabatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Delete to End of Word</source>
+        <translation>Hitz amaieraraino ezabatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Delete to Start of Line</source>
+        <translation>Lerro hasieraraino ezabatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Delete to End of Line</source>
+        <translation>Lerro amaieraraino ezabatu</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Duplicate Selection/Line</source>
+        <translation>Bikoiztu aukeraketa/lerroa</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Transpose Line</source>
+        <translation>Txandakatu aurreko lerroarekin</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>&amp;Show Completion List</source>
+        <translation>&amp;Erakutsi bat datozen komandoen zerrenda</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;Format</source>
+        <translation>&amp;Formatua</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>&amp;Uppercase Selection</source>
+        <translation>Jarri aukeratutakoa m&amp;aiuskulan</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;Lowercase Selection</source>
+        <translation>Jarri aukeratutakoa m&amp;inuskulan</translation>
+    </message>
+    <message>
+        <location line="+19"/>
+        <source>Convert Line Endings to &amp;Windows (CRLF)</source>
+        <translation>Lerro-amaiera &quot;&amp;Windows (CRLF)&quot;-era aldatu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Convert Line Endings to &amp;Unix (LF)</source>
+        <translation>Lerro-amaiera &quot;&amp;Unix (LF)&quot;-era aldatu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Convert Line Endings to &amp;Mac (CR)</source>
+        <translation>Lerro-amaiera &quot;&amp;Mac (CR)&quot;-era aldatu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Navi&amp;gation</source>
+        <translation>&amp;Nabigazioa</translation>
+    </message>
+    <message>
+        <location line="+8"/>
+        <source>Move to Matching Brace</source>
+        <translatorcomment>Aukerak parentesiak, kako zuzenak edo giltzak dira.</translatorcomment>
+        <translation>Mugitu dagokion parentesira, kako zuzenera edo giltzara</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Select to Matching Brace</source>
+        <translation>Hautatu dagokion karaktereraino: parentesia, kako zuzenea edo giltza</translation>
+    </message>
+    <message>
+        <location line="+16"/>
+        <source>&amp;Preferences...</source>
+        <translation>&amp;Hobespenak...</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;Styles Preferences...</source>
+        <translation>&amp;Estiloen hobespenak...</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>&amp;View</source>
+        <translation>&amp;Ikusi</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;Editor</source>
+        <translation>&amp;Editorea</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Show &amp;Line Numbers</source>
+        <translation>Erakutsi &amp;lerroen zenbakiak</translation>
+    </message>
+    <message>
+        <location line="+128"/>
+        <source>Editor</source>
+        <translation>Editorea</translation>
+    </message>
+    <message>
+        <location line="-120"/>
+        <source>Show Line &amp;Endings</source>
+        <translation>Erakutsi lerro-&amp;amaierak</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Show &amp;Indentation Guides</source>
+        <translation>&amp;Koska-erakusleak bistaratu</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Show Long Line &amp;Marker</source>
+        <translation>Erakutsi lerroen &amp;luzera-markatzailea</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Zoom &amp;In</source>
+        <translation>&amp;Handitu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Zoom &amp;Out</source>
+        <translation>&amp;Txikitu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;Normal Size</source>
+        <translation>&amp;Ohiko neurria</translation>
+    </message>
+    <message>
+        <location line="+32"/>
+        <source>Run &amp;Selection</source>
+        <translation>Exekutatu &amp;aukeraketa</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>&amp;Help</source>
+        <translation>&amp;Laguntza</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>&amp;Help on Keyword</source>
+        <translation>&amp;Laguntza hitz gakoekin</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;Documentation on Keyword</source>
+        <translation>&amp;Hitz gakoen dokumentazioa</translation>
+    </message>
+    <message>
+        <location line="-969"/>
+        <source>The associated file editor tab has disappeared.</source>
+        <translation>Atxikitako testu editorearen fitxa desagertu egin da.</translation>
+    </message>
+    <message>
+        <location line="+731"/>
+        <source>&amp;File</source>
+        <translation>&amp;Fitxategia</translation>
+    </message>
+    <message>
+        <location line="+36"/>
+        <source>&amp;Edit</source>
+        <translation>&amp;Editatu</translation>
+    </message>
+    <message>
+        <location line="+166"/>
+        <source>&amp;Debug</source>
+        <translation>&amp;Akasgabetu</translation>
+    </message>
+    <message>
+        <location line="+21"/>
+        <source>&amp;Run</source>
+        <translation>&amp;Exekutatu</translation>
+    </message>
+</context>
+<context>
+    <name>file_editor_tab</name>
+    <message>
+        <location filename="../src/m-editor/file-editor-tab.cc" line="+92"/>
+        <source>eol:</source>
+        <translation>Lerro-amaiera:</translation>
+    </message>
+    <message>
+        <location line="+10"/>
+        <source>line:</source>
+        <translation>Lerroa:</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>col:</source>
+        <translation>Zutabea:</translation>
+    </message>
+    <message>
+        <location line="+156"/>
+        <source>%1 is a built-in function</source>
+        <translation>%1 Octaven integratutako funtzioa da</translation>
+    </message>
+    <message>
+        <location line="+31"/>
+        <source>Can not find function %1</source>
+        <translation>Ezin da %1 funtzioa aurkitu</translation>
+    </message>
+    <message>
+        <location line="+775"/>
+        <source>Goto line</source>
+        <translation>Lerrora joan</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Line number</source>
+        <translation>Lerro-zenbakia</translation>
+    </message>
+    <message>
+        <location line="+146"/>
+        <location line="+63"/>
+        <source>&lt;unnamed&gt;</source>
+        <translation>&lt;izen gabe&gt;</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>The file
+
+  %1
+
+is about to be closed but has been modified.  %2</source>
+        <translation>%1
+fitxategia itxi egingo da, baina aldaketak izan dira.  %2</translation>
+    </message>
+    <message>
+        <location line="+213"/>
+        <source>Could not open file %1 for write:
+%2.</source>
+        <translation>%1
+fitxategia ezin da irakurtzeko ireki: %2.</translation>
+    </message>
+    <message>
+        <location line="+177"/>
+        <source>&quot;%1&quot;
+is not a valid identifier.
+
+If you keep this file name, you will not be able to
+call your script using its name as an Octave command.
+
+Do you want to choose another name?</source>
+        <translation>&quot;%1&quot;
+ez da identifikatzaile baliagarria.
+
+Izen hori erabiltzen baduzu fitxategiarentzat, ezingo
+diozu scriptari Octaveren komando bezala deitu.
+
+Beste izen bat erabili nahi duzu?</translation>
+    </message>
+    <message>
+        <location line="+101"/>
+        <source>
+
+Warning: The contents in the editor is modified!</source>
+        <translation>
+
+Oharra: editorean edukia aldatu egin da!</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <source>It seems that the file
+%1
+has been deleted or renamed. Do you want to save it now?%2</source>
+        <translation>Antza denez,
+%1
+fitxategia ezebatu edo izenez aldatu da. Berreskuratu nahi duzu?%2</translation>
+    </message>
+    <message>
+        <location line="-210"/>
+        <source>Line Endings:</source>
+        <translation>Lerro-amaierak:</translation>
+    </message>
+    <message>
+        <location line="+23"/>
+        <source>Octave Files (*.m)</source>
+        <translation>Octaveren fitxategiak (*.m)</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>All Files (*)</source>
+        <translation>Fitxategi guztiak (*)</translation>
+    </message>
+    <message>
+        <location line="-322"/>
+        <source>Do you want to cancel closing, save or discard the changes?</source>
+        <translation>Ixtea galarazi, gorde edo aldaketak baztertu nahi dituzu?</translation>
+    </message>
+    <message>
+        <location line="-970"/>
+        <location line="+979"/>
+        <location line="+213"/>
+        <location line="+177"/>
+        <location line="+85"/>
+        <location line="+23"/>
+        <source>Octave Editor</source>
+        <translation>Octaveren editorea</translation>
+    </message>
+    <message>
+        <location line="-22"/>
+        <source>It seems that &apos;%1&apos; has been modified by another application. Do you want to reload it?</source>
+        <translation>Itxuraz &apos;%1&apos; fitxategia beste aplikazio batek aldatu du. Berriro kargatu nahi duzu?</translation>
+    </message>
+</context>
+<context>
+    <name>files_dock_widget</name>
+    <message>
+        <location filename="../src/files-dock-widget.cc" line="+69"/>
+        <source>File Browser</source>
+        <translation>Fitxategi-arakatzailea</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Browse your files.</source>
+        <translation>Arakatu zure fitxategiak.</translation>
+    </message>
+    <message>
+        <location line="+18"/>
+        <source>Enter the path or filename</source>
+        <translation>Sartu fitxategiaren kokagunea edo izena</translation>
+    </message>
+    <message>
+        <location line="+24"/>
+        <source>Set Octave directory to current browser directory</source>
+        <translation>Octaveren direktorioa fitxategi-arakatzailearen uneko direktorio egin</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Actions on current directory</source>
+        <translation>Ekintzak uneko direktorioan</translation>
+    </message>
+    <message>
+        <location line="+15"/>
+        <source>Set Browser Directory...</source>
+        <translation>Nabigatzailearen direktorioa zehaztu...</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <location line="+388"/>
+        <source>Find Files...</source>
+        <translation>Fitxategiak bilatu...</translation>
+    </message>
+    <message>
+        <location line="+123"/>
+        <source>Rename file/directory:
+</source>
+        <translation>Fitxategiari/direktorioari izena aldatu:
+</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>
+ to: </source>
+        <translation>
+ honakoaren ordez: </translation>
+    </message>
+    <message>
+        <location line="+26"/>
+        <source>Are you sure you want to delete
+</source>
+        <translation>Seguru ezabatu nahi duzula
+</translation>
+    </message>
+    <message>
+        <location line="+214"/>
+        <source>New Directory</source>
+        <translation>Direktorio berria</translation>
+    </message>
+    <message>
+        <location line="-784"/>
+        <source>Show Octave directory</source>
+        <translation>Octaveren direktorioa erakutsi</translation>
+    </message>
+    <message>
+        <location line="-4"/>
+        <source>One directory up</source>
+        <translation>Gorengo direktorioa</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Go to current Octave directory</source>
+        <translation>Joan Octaveren uneko direktoriora</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Set Octave directory</source>
+        <translation>Octaveren direktorioa hautatu</translation>
+    </message>
+    <message>
+        <location line="+9"/>
+        <source>Show Home Directory</source>
+        <translation>Erakutsi hasiera-direktorioa</translation>
+    </message>
+    <message>
+        <location line="+20"/>
+        <location line="+397"/>
+        <source>New File...</source>
+        <translation>Beste fitxategi bat...</translation>
+    </message>
+    <message>
+        <location line="-394"/>
+        <location line="+397"/>
+        <source>New Directory...</source>
+        <translation>Beste direktorio bat...</translation>
+    </message>
+    <message>
+        <location line="-335"/>
+        <source>Activate to open in editor, right click for alternatives</source>
+        <translation>Aktibatu editoren irekitzeko. Egin eskuin-klik aukerak bistaratzeko</translation>
+    </message>
+    <message>
+        <location line="+236"/>
+        <source>File size</source>
+        <translation>Fitxategiaren tamaina</translation>
+    </message>
+    <message>
+        <location line="+8"/>
+        <source>File type</source>
+        <translation>Fitxategi-mota</translation>
+    </message>
+    <message>
+        <location line="+8"/>
+        <source>Date modified</source>
+        <translation>Aldatze-data</translation>
+    </message>
+    <message>
+        <location line="+8"/>
+        <source>Show hidden</source>
+        <translation>Erakutsi ezkutukoak</translation>
+    </message>
+    <message>
+        <location line="+35"/>
+        <source>Open</source>
+        <translation>Ireki</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Open in Default Application</source>
+        <translation>Lehenetsitako aplikazioan ireki</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Copy Selection to Clipboard</source>
+        <translation>Arbelean kopiatu aukeraketa</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Run</source>
+        <translation>Exekutatu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Load Data</source>
+        <translation>Datuak kargatu</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Set Current Directory</source>
+        <translation>Uneko direktorioa aukeratu</translation>
+    </message>
+    <message>
+        <location line="+9"/>
+        <source>Rename...</source>
+        <translation>Izena aldatu...</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Delete...</source>
+        <translation>Ezabatu...</translation>
+    </message>
+    <message>
+        <location line="+115"/>
+        <source>Rename file/directory</source>
+        <translation>Fitxategia/direktorioa izenez aldatu</translation>
+    </message>
+    <message>
+        <location line="+27"/>
+        <location line="+14"/>
+        <source>Delete file/directory</source>
+        <translation>Ezabatu fitxategia/direktorioa</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Can not delete a directory that is not empty</source>
+        <translation>Ezin dira hutsik ez dauden direktorioak ezabatu</translation>
+    </message>
+    <message>
+        <location line="+151"/>
+        <source>Set directory of file browser</source>
+        <translation>Fitxategi-arakatzailetik direktorioa aukeratu</translation>
+    </message>
+    <message>
+        <location line="+29"/>
+        <source>Create File</source>
+        <translation>Fitxategia sortu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Create file in
+</source>
+        <comment>String ends with \n!</comment>
+        <translation>Fitxategia sortu hemen
+</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>New File.txt</source>
+        <translation>.txt beste fitxategi bat sortu</translation>
+    </message>
+    <message>
+        <location line="+16"/>
+        <source>Create Directory</source>
+        <translation>Direktorioa sortu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Create folder in
+</source>
+        <comment>String ends with \n!</comment>
+        <translation>Karpeta sortu hemen
+</translation>
+    </message>
+</context>
+<context>
+    <name>final_page</name>
+    <message>
+        <location filename="../src/welcome-wizard.cc" line="+199"/>
+        <source>Enjoy!</source>
+        <translation>Gozatu!</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Previous</source>
+        <translation>Aurrekoa</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Finish</source>
+        <translation>Amaitu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Cancel</source>
+        <translation>Utzi</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <source>&lt;html&gt;&lt;body&gt;
+&lt;p&gt;We hope you find Octave to be a useful tool.&lt;/p&gt;
+&lt;p&gt;If you encounter problems, there are a number of ways to get help, including commercial support options, a mailing list, a wiki, and other community-based support channels.
+You can find more information about each of these by visiting &lt;a href=&quot;http://octave.org/support.html&quot;&gt;http://octave.org/support.html&lt;/a&gt; (opens in external browser).&lt;/p&gt;
+&lt;/body&gt;&lt;/html&gt;</source>
+        <translation>&lt;html&gt;&lt;body&gt;
+&lt;p&gt;Espero dugu Octave tresna baliagarria izana.&lt;/p&gt;
+&lt;p&gt;Arazorik izan baduzu, badaude hainbat modu laguntza lortzeko, euskarri komertziala barne, korreo elektronikoko zerrenda, wiki-orria eta komunitatean oinarritutako beste euskarri-kanal batzuk.
+Aukera horien gainean informazio gehiago aurki zenezake honakoei bisita eginda &lt;a href=&quot;http://octave.org/support.html&quot;&gt;http://octave.org/support.html&lt;/a&gt; (nabigatzaile batean irekiko da).&lt;/p&gt;
+&lt;/body&gt;&lt;/html&gt;</translation>
+    </message>
+    <message>
+        <location line="+21"/>
+        <source>&lt;html&gt;&lt;head&gt;
+&lt;style&gt;
+a:link { text-decoration: underline; color: #0000ff; }
+&lt;/style&gt;
+&lt;head/&gt;&lt;body&gt;
+&lt;p&gt;For more information about Octave:&lt;/p&gt;
+&lt;ul&gt;
+&lt;li&gt;Visit &lt;a href=&quot;http://octave.org&quot;&gt;http://octave.org&lt;/a&gt; (opens in external browser)&lt;/li&gt;
+&lt;li&gt;Get the documentation online as &lt;a href=&quot;http://www.gnu.org/software/octave/doc/interpreter/index.html&quot;&gt;html&lt;/a&gt;- or &lt;a href=&quot;http://www.gnu.org/software/octave/octave.pdf&quot;&gt;pdf&lt;/span&gt;&lt;/a&gt;-document (opens in external browser)&lt;/li&gt;
+&lt;li&gt;Open the documentation browser of the Octave GUI with the help menu&lt;/li&gt;
+&lt;/ul&gt;
+&lt;/body&gt;&lt;/html&gt;</source>
+        <translation>&lt;html&gt;&lt;head&gt;
+&lt;style&gt;
+a:link { text-decoration: underline; color: #0000ff; }
+&lt;/style&gt;
+&lt;head/&gt;&lt;body&gt;
+&lt;p&gt;Octaveri buruz informazio gehiago eskuratzeko:&lt;/p&gt;
+&lt;ul&gt;
+&lt;li&gt;Bisitatu &lt;a href=&quot;http://octave.org&quot;&gt;http://octave.org&lt;/a&gt; (nabigatzaile batean irekiko da)&lt;/li&gt;
+&lt;li&gt;Eskuratu dokumentazioa linean honako formatuetan &lt;a href=&quot;http://www.gnu.org/software/octave/doc/interpreter/index.html&quot;&gt;html&lt;/a&gt; edo &lt;a href=&quot;http://www.gnu.org/software/octave/octave.pdf&quot;&gt;pdf&lt;/span&gt;&lt;/a&gt; dokumentu bezala (nabigatzaile batean irekiko da)&lt;/li&gt;
+&lt;li&gt;Zabaldu Octaveren GUIaren dokumentazioaren nabigatzailea laguntza-menuarekin&lt;/li&gt;
+&lt;/ul&gt;
+&lt;/body&gt;&lt;/html&gt;
+
+
+</translation>
+    </message>
+</context>
+<context>
+    <name>find_dialog</name>
+    <message>
+        <location filename="../src/m-editor/find-dialog.cc" line="+74"/>
+        <source>Find and Replace</source>
+        <translation>Bilatu eta ordezkatu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Find &amp;what:</source>
+        <translation>&amp;Bilatu:</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Re&amp;place with:</source>
+        <translation>&amp;Ordezkatu honekin:</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Match &amp;case</source>
+        <translation>Bereizi &amp;maiuskulak/minuskulak</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Search from &amp;start</source>
+        <translation>&amp;Hasieratik bilatu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>&amp;Wrap while searching</source>
+        <translation>&amp;Markatu bilatzen den bitartean</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;Find Next</source>
+        <translation>&amp;Hurrengoa bilatu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Find &amp;Previous</source>
+        <translation>&amp;Aurrekoa bilatu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>&amp;Replace</source>
+        <translation>&amp;Ordezkatu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Replace &amp;All</source>
+        <translation>Ordezkatu &amp;dena</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>&amp;More...</source>
+        <translation>&amp;Gehiago...</translation>
+    </message>
+    <message>
+        <location line="+13"/>
+        <source>&amp;Whole words</source>
+        <translation>Hitz &amp;osoak</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Regular E&amp;xpressions</source>
+        <translation>A&amp;dierazpen erregularrak</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Search &amp;backward</source>
+        <translation>&amp;Atzerantz bilatu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Search se&amp;lection</source>
+        <translation>Bilatu au&amp;keraketa</translation>
+    </message>
+    <message>
+        <location line="+84"/>
+        <source>Search from end</source>
+        <translation>Azkenetik bilatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Search from start</source>
+        <translation>Hasieratik bilatu</translation>
+    </message>
+    <message>
+        <location line="+205"/>
+        <source>Replace Result</source>
+        <translation>Emaitza ordezkatu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>%1 items replaced</source>
+        <translation>%1 hitz ordezkatuta</translation>
+    </message>
+    <message>
+        <location line="+15"/>
+        <source>Find Result</source>
+        <translation>Bilaketaren emaitza</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>No more matches found</source>
+        <translation>Ez dago bat etortze gehiago</translation>
+    </message>
+</context>
+<context>
+    <name>find_files_dialog</name>
+    <message>
+        <location filename="../src/find-files-dialog.cc" line="+52"/>
+        <source>Find Files</source>
+        <translation>Fitxategiak bilatu</translation>
+    </message>
+    <message>
+        <location line="+10"/>
+        <source>Named:</source>
+        <translation>Izena:</translation>
+    </message>
+    <message>
+        <location line="+8"/>
+        <source>Start in:</source>
+        <translation>Bilatu hemen:</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Enter the start directory</source>
+        <translation>Sartu hasierako direktorioa</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Browse...</source>
+        <translation>Arakatu...</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Browse for start directory</source>
+        <translation>Arakatu hasiera-direktorioa hautatzeko</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <source>Search recursively through directories for matching files</source>
+        <translation>Arakatu direktorioak modu errekurtsiboan</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Include matching directories in search results</source>
+        <translation>Bat egiten duten direktorioak gehitu bilaketa-emaitzetan</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Name case insensitive</source>
+        <translation>Izenetan maiuskulak/minuskulak ez bereizi</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Set matching name is case insensitive</source>
+        <translation>Ezarri izenetan maisukulak/minuskulak ez bereiztea</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Contains text:</source>
+        <translation>Testu hau du barnean:</translation>
+    </message>
+    <message>
+        <location line="-35"/>
+        <source>Enter the filename search expression</source>
+        <translation>Sartu bilatzeko adierazpena fitxategien izenerako</translation>
+    </message>
+    <message>
+        <location line="+18"/>
+        <source>Search subdirectories</source>
+        <translation>Bilatu azpidirektorioetan</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Include directory names</source>
+        <translation>Sartu direktorioen izenak</translation>
+    </message>
+    <message>
+        <location line="+12"/>
+        <source>Enter the file content search expression</source>
+        <translation>Sartu fitxategiaren edukiaren bilaketa-adierazpena</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Text to match</source>
+        <translation>Bilatzeko testua</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Text case insensitive</source>
+        <translation>Maiuskulak eta minuskulak ez bereizi</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Set text content is case insensitive</source>
+        <translation>Ezarri maiuskulak eta minuskulak ez bereiztea</translation>
+    </message>
+    <message>
+        <location line="+11"/>
+        <source>Search results</source>
+        <translation>Bilaketaren emaitzak</translation>
+    </message>
+    <message>
+        <location line="+17"/>
+        <source>Idle.</source>
+        <translation>Ez aktibo.</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Find</source>
+        <translation>Bilatu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Start search for matching files</source>
+        <translation>Bilaketa hasi</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Stop</source>
+        <translation>Gelditu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Stop searching</source>
+        <translation>Bilaketa gelditu</translation>
+    </message>
+    <message>
+        <location line="+15"/>
+        <source>File name/location</source>
+        <translation>Fitxategiaren izena/kokagunea</translation>
+    </message>
+    <message>
+        <location line="+17"/>
+        <source>File contents</source>
+        <translation>Fitxategiaren edukia</translation>
+    </message>
+    <message>
+        <location line="+105"/>
+        <source>Searching...</source>
+        <translation>Bilatzen...</translation>
+    </message>
+    <message>
+        <location line="+23"/>
+        <source>%1 match(es)</source>
+        <translation>%1 bat etortze(ak)</translation>
+    </message>
+    <message>
+        <location line="+9"/>
+        <source>Set search directory</source>
+        <translation>Bilaketarako direktorioa hautatu</translation>
+    </message>
+</context>
+<context>
+    <name>find_files_model</name>
+    <message>
+        <location filename="../src/find-files-model.cc" line="+82"/>
+        <source>Filename</source>
+        <translation>Fitxategiaren izena</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Directory</source>
+        <translation>Direktorioa</translation>
+    </message>
+</context>
+<context>
+    <name>history_dock_widget</name>
+    <message>
+        <location filename="../src/history-dock-widget.cc" line="+47"/>
+        <source>Browse and search the command history.</source>
+        <translation>Arakatu eta bilatu komandoen historialean.</translation>
+    </message>
+    <message>
+        <location line="+24"/>
+        <source>Double-click a command to transfer it to the terminal.</source>
+        <translation>Terminalera eroateko, komando baten gainean birritan klik egin.</translation>
+    </message>
+    <message>
+        <location line="+8"/>
+        <source>Enter text to filter the command history</source>
+        <translation>Testua idatzi komandoen historiala filtratzeko</translation>
+    </message>
+    <message>
+        <location line="+10"/>
+        <source>Filter</source>
+        <translation>Filtratu</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Command History</source>
+        <translation>Komandoen historiala</translation>
+    </message>
+    <message>
+        <location line="+89"/>
+        <source>Copy</source>
+        <translation>Kopiatu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Evaluate</source>
+        <translation>Ebaluatu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Create script</source>
+        <translation>Scripta sortu</translation>
+    </message>
+</context>
+<context>
+    <name>initial_page</name>
+    <message>
+        <location filename="../src/welcome-wizard.cc" line="-179"/>
+        <source>Welcome to Octave!</source>
+        <translation>Ongi etorri Octavera!</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Next</source>
+        <translation>Hurrengoa</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Cancel</source>
+        <translation>Deuseztatu</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <source>&lt;html&gt;&lt;body&gt;
+&lt;p&gt;You seem to be using the Octave graphical interface for the first time on this computer.
+Click &apos;Next&apos; to create a configuration file and launch Octave.&lt;/p&gt;
+&lt;p&gt;The configuration file is stored in&lt;br&gt;%1.&lt;/p&gt;
+&lt;/body&gt;&lt;/html&gt;</source>
+        <translation>&lt;html&gt;&lt;body&gt;
+&lt;p&gt;Badirudi Octaveren ingurune grafikoa lehen aldiz erabili dela ordenagailu honetan
+Sakatu &apos;Hurrengoa&apos; konfigurazio-fitxategi bat sortzeko eta Octave abiarazteko.&lt;/p&gt;
+&lt;p&gt;Konfigurazio-fitxategia hemen gordeko da&lt;br&gt;%1.&lt;/p&gt;
+&lt;/body&gt;&lt;/html&gt;</translation>
+    </message>
+</context>
+<context>
+    <name>main_window</name>
+    <message>
+        <location filename="../src/main-window.cc" line="+268"/>
+        <source>Load Workspace</source>
+        <translation>Lan-eremua kargatu</translation>
+    </message>
+    <message>
+        <location line="+732"/>
+        <location line="+931"/>
+        <source>About Octave</source>
+        <translation>&quot;Octave&quot;-ri buruz</translation>
+    </message>
+    <message>
+        <location line="-301"/>
+        <source>&amp;File</source>
+        <translation>&amp;Fitxategia</translation>
+    </message>
+    <message>
+        <location line="+49"/>
+        <source>New</source>
+        <translation>Beste bat sortu</translation>
+    </message>
+    <message>
+        <location line="-43"/>
+        <source>Open...</source>
+        <translation>Ireki...</translation>
+    </message>
+    <message>
+        <location line="+117"/>
+        <source>Preferences...</source>
+        <translation>Hobespenak...</translation>
+    </message>
+    <message>
+        <location line="-95"/>
+        <source>Exit</source>
+        <translation>Irten</translation>
+    </message>
+    <message>
+        <location line="+50"/>
+        <source>&amp;Edit</source>
+        <translation>&amp;Editatu</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Undo</source>
+        <translation>Desegin</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Copy</source>
+        <translation>Kopiatu</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Paste</source>
+        <translation>Itsatsi</translation>
+    </message>
+    <message>
+        <location line="-1469"/>
+        <source>Save Workspace As</source>
+        <translation>Gorde honela lan-eremua</translation>
+    </message>
+    <message>
+        <location line="+134"/>
+        <source>The release notes file &apos;%1&apos; is empty.</source>
+        <translation>%1 bertsioaren noten fitxategia hutsik dago.</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>The release notes file &apos;%1&apos; cannot be read.</source>
+        <translation>&apos;%1&apos; bertsioaren noten fitxategia ezin da irakurri.</translation>
+    </message>
+    <message>
+        <location line="+13"/>
+        <source>Octave Release Notes</source>
+        <translation>Octave bertsioaren notak</translation>
+    </message>
+    <message>
+        <location line="+192"/>
+        <source>Octave Community News</source>
+        <translation>Octave komunitatearen berriak</translation>
+    </message>
+    <message>
+        <location line="+187"/>
+        <source>Are you sure you want to exit Octave?</source>
+        <translation>Seguru zaude Octavetik irten nahi duzula?</translation>
+    </message>
+    <message>
+        <location line="+854"/>
+        <source>Open an existing file in editor</source>
+        <translation>Ireki fitxategi bat editorean</translation>
+    </message>
+    <message>
+        <location line="+48"/>
+        <source>New Function...</source>
+        <translation>Beste funtzio bat...</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>New Figure</source>
+        <translation>Beste irudi bat</translation>
+    </message>
+    <message>
+        <location line="+36"/>
+        <source>Select All</source>
+        <translation>Hautatu dena</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Clear Clipboard</source>
+        <translation>Paper-zorroa garbitu</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <source>Find Files...</source>
+        <translation>Bilatu fitxategiak...</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Clear Command Window</source>
+        <translation>Komandoen leihoa garbitu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Clear Command History</source>
+        <translation>Komandoen historiala garbitu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Clear Workspace</source>
+        <translation>Lan-eremua garbitu</translation>
+    </message>
+    <message>
+        <location line="+49"/>
+        <source>De&amp;bug</source>
+        <translation>&amp;Akasgabetu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Step</source>
+        <translation>Hurrengo agindua</translation>
+    </message>
+    <message>
+        <location line="+12"/>
+        <source>Continue</source>
+        <translation>Jarraitu</translation>
+    </message>
+    <message>
+        <location line="+56"/>
+        <source>Show File Browser</source>
+        <translation>Erakutsi fitxategi-arakatzailea</translation>
+    </message>
+    <message>
+        <location line="+20"/>
+        <source>File Browser</source>
+        <translation>Fitxategi-arakatzailea</translation>
+    </message>
+    <message>
+        <location line="-84"/>
+        <source>Step In</source>
+        <translation>Hasi</translation>
+    </message>
+    <message>
+        <location line="-1020"/>
+        <source>Octave</source>
+        <translation>Octave</translation>
+    </message>
+    <message>
+        <location line="+868"/>
+        <source>Load Workspace...</source>
+        <translation>Lan-eremua kargatu...</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Save Workspace As...</source>
+        <translation>Gorde honela lan-eremua...</translation>
+    </message>
+    <message>
+        <location line="+29"/>
+        <source>New Script</source>
+        <translation>Beste script bat</translation>
+    </message>
+    <message>
+        <location line="+124"/>
+        <source>Step Out</source>
+        <translation>Amaitu</translation>
+    </message>
+    <message>
+        <location line="+94"/>
+        <source>Reset Default Window Layout</source>
+        <translation>Leihoen diseinu lehenetsia berrezarri</translation>
+    </message>
+    <message>
+        <location line="+16"/>
+        <source>Octave Packages</source>
+        <translation>Ocataveren paketeak</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Share Code</source>
+        <translation>Kodea partekatu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Contribute to Octave</source>
+        <translation>Octaverekin kolaboratu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Octave Developer Resources</source>
+        <translation>Octaveren garatzaileentzako baliabideak</translation>
+    </message>
+    <message>
+        <location line="+14"/>
+        <source>On Disk</source>
+        <translation>Diskoan</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Online</source>
+        <translation>Linean</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>&amp;News</source>
+        <translation>&amp;Berriak</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Release Notes</source>
+        <translation>Bertsioaren oharrak</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Community News</source>
+        <translation>Komunitatearen berriak</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Toolbar</source>
+        <translation>Tresna-barra</translation>
+    </message>
+    <message>
+        <location line="+18"/>
+        <source>Enter directory name</source>
+        <translation>Sartu direktorioaren izena</translation>
+    </message>
+    <message>
+        <location line="+9"/>
+        <source>Current Directory: </source>
+        <translation>Uneko direktorioa:</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>One directory up</source>
+        <translation>Gorengo direktorioa</translation>
+    </message>
+    <message>
+        <location line="-1148"/>
+        <location line="+1151"/>
+        <source>Browse directories</source>
+        <translation>Direktorioak arakatu</translation>
+    </message>
+    <message>
+        <location line="-175"/>
+        <source>Quit Debug Mode</source>
+        <translation>Akasgabetze modutik irten</translation>
+    </message>
+    <message>
+        <location line="+38"/>
+        <source>&amp;Window</source>
+        <translation>&amp;Leihoa</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Show Command Window</source>
+        <translation>Erakutsi komandoen leihoa</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Show Command History</source>
+        <translation>Erakutsi komandoen historiala</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Show Workspace</source>
+        <translation>Erakutsi lan-eremua</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Show Editor</source>
+        <translation>Erakutsi editorea</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Show Documentation</source>
+        <translation>Erakutsi dokumentazioa</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Command Window</source>
+        <translation>Komandoen leihoa</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Command History</source>
+        <translation>Komandoen historiala</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Workspace</source>
+        <translation>Lan-eremua</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Editor</source>
+        <translation>Editorea</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <location line="+41"/>
+        <source>Documentation</source>
+        <translation>Dokumentazioa</translation>
+    </message>
+    <message>
+        <location line="-30"/>
+        <source>&amp;Help</source>
+        <translation>&amp;Laguntza</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <source>Report Bug</source>
+        <translation>Akatsei buruz informatu</translation>
+    </message>
+</context>
+<context>
+    <name>news_reader</name>
+    <message>
+        <location line="-1411"/>
+        <source>&lt;html&gt;
+&lt;body&gt;
+&lt;p&gt;
+Octave&apos;s community news source seems to be unavailable.
+&lt;/p&gt;
+&lt;p&gt;
+For the latest news, please check
+&lt;a href=&quot;http://octave.org/community-news.html&quot;&gt;http://octave.org/community-news.html&lt;/a&gt;
+when you have a connection to the web (link opens in an external browser).
+&lt;/p&gt;
+&lt;p&gt;
+&lt;small&gt;&lt;em&gt;&amp;mdash; The Octave Developers, </source>
+        <translation>&lt;html&gt;
+&lt;body&gt;
+&lt;p&gt;
+Badirudi Octave komunitatearen berrien gaineko iturburuak ez daudela erabilgarri.
+&lt;/p&gt;
+&lt;p&gt;
+Azken berritasunak ezagutzeko, bisita ezazu
+&lt;a href=&quot;http://octave.org/community-news.html&quot;&gt;http://octave.org/community-news.html&lt;/a&gt;
+web-konexioa duzunean (esteka nabigatzaile batean zabalduko da).
+&lt;/p&gt;
+&lt;p&gt;
+&lt;small&gt;&lt;em&gt;&amp;mdash; Octaveren garatzaileak,</translation>
+    </message>
+    <message>
+        <location line="+18"/>
+        <source>&lt;html&gt;
+&lt;body&gt;
+&lt;p&gt;
+Connecting to the web to display the latest Octave Community news has been disabled.
+&lt;/p&gt;
+&lt;p&gt;
+For the latest news, please check
+&lt;a href=&quot;http://octave.org/community-news.html&quot;&gt;http://octave.org/community-news.html&lt;/a&gt;
+when you have a connection to the web (link opens in an external browser)
+or enable web connections for news in Octave&apos;s network settings dialog.
+&lt;/p&gt;
+&lt;p&gt;
+&lt;small&gt;&lt;em&gt;&amp;mdash; The Octave Developers, </source>
+        <translation>&lt;html&gt;
+&lt;body&gt;
+&lt;p&gt;
+Octaveren gaineko azken berriak bistaratzeko web-konexioa ezgaitu da.
+&lt;/p&gt;
+&lt;p&gt;
+Azken berritasunak ezagutzeko, bisita ezazu
+&lt;a href=&quot;http://octave.org/community-news.html&quot;&gt;http://octave.org/community-news.html&lt;/a&gt;
+web-konexioa duzunean (esteka nabigatzaile batean zabalduko da)
+edo aktibatu web-konexioa azken berrikuntzak Octaveren sare ezarpen-elkarrizketan ikusteko.
+&lt;/p&gt;
+&lt;p&gt;
+&lt;small&gt;&lt;em&gt;&amp;mdash; Octaveren garatzaileak,
+</translation>
+    </message>
+</context>
+<context>
+    <name>octave_dock_widget</name>
+    <message>
+        <location filename="../src/octave-dock-widget.cc" line="+68"/>
+        <location line="+198"/>
+        <source>Undock widget</source>
+        <translation>Desakoplatu widgeta</translation>
+    </message>
+    <message>
+        <location line="-188"/>
+        <source>Hide widget</source>
+        <translation>Ezkutatu widgeta</translation>
+    </message>
+    <message>
+        <location line="+132"/>
+        <source>Dock widget</source>
+        <translation>Akoplatu widgeta</translation>
+    </message>
+</context>
+<context>
+    <name>octave_qscintilla</name>
+    <message>
+        <location filename="../src/m-editor/octave-qscintilla.cc" line="+226"/>
+        <source>Help on</source>
+        <translation>Laguntza honi buruz</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Documentation on</source>
+        <translation>Dokumentazioa honi buruz</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Edit</source>
+        <translation>Editatu</translation>
+    </message>
+</context>
+<context>
+    <name>octave_qt_link</name>
+    <message>
+        <location filename="../src/octave-qt-link.cc" line="+111"/>
+        <location line="+6"/>
+        <location line="+7"/>
+        <source>Create</source>
+        <translation>Sortu</translation>
+    </message>
+    <message>
+        <location line="-10"/>
+        <source>File
+%1
+does not exist. Do you want to create it?</source>
+        <translation>%1
+fitxategia ez dago. Sortu nahi duzu?</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Octave Editor</source>
+        <translation>Octaveren editorea</translation>
+    </message>
+    <message>
+        <location line="+211"/>
+        <source>The file %1 does not exist in the load path.  To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path.</source>
+        <translation>%1 fitxategia ez dago kargatze-helbidean. Editatzen ari zaren funtzioa akasgabetzeko, bi aukera dituzu: %2 direktoriora aldatzea edo direktorio hori kargatze-helbidera gehitzea.</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2.</source>
+        <translation>%1 fitxategia eta izen bereko beste fitxategi bat gainjarrita daude kargatze-helbidean. Editatzen ari zaren fitxategia akasgabetzeko, aldatu %2 direktoriora.</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Change Directory or Add Directory to Load Path</source>
+        <translation>Aldatu direktorioa edo gehitu direktorioa kargatze-helbidera</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Change Directory</source>
+        <translation>Aldatu direktorioa</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Add Directory to Load Path</source>
+        <translation>Gehitu direktorioa kargatze-helbidean</translation>
+    </message>
+    <message>
+        <location line="-223"/>
+        <location line="+224"/>
+        <source>Cancel</source>
+        <translation>Ezeztatu</translation>
+    </message>
+</context>
+<context>
+    <name>octave_txt_lexer</name>
+    <message>
+        <location filename="../src/m-editor/octave-txt-lexer.cc" line="+39"/>
+        <source>Default</source>
+        <translation>Lehenetsia</translation>
+    </message>
+</context>
+<context>
+    <name>resource_manager</name>
+    <message>
+        <location filename="../src/resource-manager.cc" line="+245"/>
+        <source>The settings file
+%1
+does not exist and can not be created.
+Make sure you have read and write permissions to
+%2
+
+Octave GUI must be closed now.</source>
+        <translation>%1
+konfigurazio-fitxategia ez dago eta ezin da sortu.
+Ziurta zaitez idazteko baimen guztiak dituzula honengan:
+%2
+
+Octaveren ingurune grafikoa itxi egin behar da.</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Octave Critical Error</source>
+        <translation>Octaveren akats larria</translation>
+    </message>
+</context>
+<context>
+    <name>settings_dialog</name>
+    <message>
+        <location filename="../src/settings-dialog.ui" line="+23"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1738"/>
+        <source>Settings</source>
+        <translation>Hobespenak</translation>
+    </message>
+    <message>
+        <location line="+19"/>
+        <location line="+468"/>
+        <location filename="../src/ui-settings-dialog.h" line="+25"/>
+        <location line="+1"/>
+        <source>General</source>
+        <translation>Orokorra</translation>
+    </message>
+    <message>
+        <location line="-338"/>
+        <location filename="../src/ui-settings-dialog.h" line="-17"/>
+        <source>Octave logo only</source>
+        <translation>Octaveren logoa bakarrik</translation>
+    </message>
+    <message>
+        <location line="+10"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Letter icons</source>
+        <translation>Letradun ikonoak</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Graphic icons</source>
+        <translation>Ikono grafikoak</translation>
+    </message>
+    <message>
+        <location line="-118"/>
+        <location filename="../src/ui-settings-dialog.h" line="-9"/>
+        <source>Dock widget title bar</source>
+        <translation>Akoplatu widgeta titulu-barrara</translation>
+    </message>
+    <message>
+        <location line="+53"/>
+        <location filename="../src/ui-settings-dialog.h" line="+3"/>
+        <source>Small</source>
+        <translation>Txikia</translation>
+    </message>
+    <message>
+        <location line="+17"/>
+        <location filename="../src/ui-settings-dialog.h" line="+2"/>
+        <source>Large</source>
+        <translation>Handia</translation>
+    </message>
+    <message>
+        <location line="+168"/>
+        <location filename="../src/ui-settings-dialog.h" line="+10"/>
+        <source>Custom style</source>
+        <translation>Pertsonalizatutako estiloa</translation>
+    </message>
+    <message>
+        <location line="+92"/>
+        <location filename="../src/ui-settings-dialog.h" line="+4"/>
+        <source>These preferences are applied after any .octaverc startup files.</source>
+        <translation>Hobespenok .octavercse hasierako fitxategiak exekutatu ondoren izango dute eragina.</translation>
+    </message>
+    <message>
+        <location line="+55"/>
+        <location filename="../src/ui-settings-dialog.h" line="+3"/>
+        <source>Restore working directory of previous session</source>
+        <translation>Berreskuratu aurreko saioko lan-direktorioa</translation>
+    </message>
+    <message>
+        <location line="+33"/>
+        <location filename="../src/ui-settings-dialog.h" line="+58"/>
+        <source>Editor</source>
+        <translation>Editorea</translation>
+    </message>
+    <message>
+        <location line="+151"/>
+        <location filename="../src/ui-settings-dialog.h" line="-49"/>
+        <source>Color</source>
+        <translation>Kolorea</translation>
+    </message>
+    <message>
+        <location line="+138"/>
+        <location filename="../src/ui-settings-dialog.h" line="+6"/>
+        <source>Draw a long line marker</source>
+        <translation>Erakutsi lerro-luzera markatzailea</translation>
+    </message>
+    <message>
+        <location line="+48"/>
+        <location filename="../src/ui-settings-dialog.h" line="+3"/>
+        <source>Show EOL characters</source>
+        <translation>Erakutsi lerro-bukaerako karaktereak</translation>
+    </message>
+    <message>
+        <location line="+9"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Default EOL mode</source>
+        <translation>Lehenetsitako lerro-bukaera adierazlea</translation>
+    </message>
+    <message>
+        <location line="+154"/>
+        <location filename="../src/ui-settings-dialog.h" line="+12"/>
+        <source>Indent width</source>
+        <translation>Koska zabalera</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Tab indents line</source>
+        <translation>Tabulazio bidez egin koska</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Auto indentation</source>
+        <translation>Koska automatikoa</translation>
+    </message>
+    <message>
+        <location line="+26"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Tab width</source>
+        <translation>Tabuladorearen tamaina</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Show indentation guides</source>
+        <translation>Erakutsi koska-erakusleak</translation>
+    </message>
+    <message>
+        <location line="+23"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Backspace unindents line</source>
+        <translation>Atzera-egite teklak koska ezabatzen du</translation>
+    </message>
+    <message>
+        <location line="+88"/>
+        <location filename="../src/ui-settings-dialog.h" line="+3"/>
+        <source>Match keywords</source>
+        <translation>Hitz gakoetan bat egin</translation>
+    </message>
+    <message>
+        <location line="+13"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Case sensitive</source>
+        <translation>Maiskulak/minuskulak bereizi</translation>
+    </message>
+    <message>
+        <location line="+23"/>
+        <location filename="../src/ui-settings-dialog.h" line="+2"/>
+        <source>Replace word by suggested one</source>
+        <translation>Gomendio bidez hitza ordeztu</translation>
+    </message>
+    <message>
+        <location line="-10"/>
+        <location filename="../src/ui-settings-dialog.h" line="-1"/>
+        <source>Match words in document</source>
+        <translation>Dokumentuan hitzak bat etorri</translation>
+    </message>
+    <message>
+        <location line="+173"/>
+        <location filename="../src/ui-settings-dialog.h" line="+14"/>
+        <source>Restore editor tabs from previous session on startup</source>
+        <translation>Abiaraztean berreskuratu aurreko saioko editoreko fitxak</translation>
+    </message>
+    <message>
+        <location line="-426"/>
+        <location filename="../src/ui-settings-dialog.h" line="-28"/>
+        <source>Use custom file editor</source>
+        <translation>Fitxategi-editore pertsonalizatua erabili</translation>
+    </message>
+    <message>
+        <location line="+482"/>
+        <location filename="../src/ui-settings-dialog.h" line="+33"/>
+        <source>Editor Styles</source>
+        <translation>Editorearen estiloak</translation>
+    </message>
+    <message>
+        <location line="+287"/>
+        <location filename="../src/ui-settings-dialog.h" line="+10"/>
+        <source>Terminal Colors</source>
+        <translation>Terminalaren koloreak</translation>
+    </message>
+    <message>
+        <location line="-173"/>
+        <location filename="../src/ui-settings-dialog.h" line="-6"/>
+        <source>Font</source>
+        <translation>Letra-tipo mota</translation>
+    </message>
+    <message>
+        <location line="-917"/>
+        <location filename="../src/ui-settings-dialog.h" line="-58"/>
+        <source>Show line numbers</source>
+        <translation>Erakutsi lerro-zenbakiak</translation>
+    </message>
+    <message>
+        <location line="-72"/>
+        <location filename="../src/ui-settings-dialog.h" line="-3"/>
+        <source>Highlight current line</source>
+        <translation>Momentuko lerroa nabarmendu</translation>
+    </message>
+    <message>
+        <location line="+85"/>
+        <location filename="../src/ui-settings-dialog.h" line="+4"/>
+        <source>Show complete path in window title</source>
+        <translation>Erakutsi helbidea osorik leihoaren tituluan</translation>
+    </message>
+    <message>
+        <location line="-29"/>
+        <location filename="../src/ui-settings-dialog.h" line="-2"/>
+        <source>Show whitespace</source>
+        <translation>Erakutsi zuriuneak</translation>
+    </message>
+    <message>
+        <location line="+39"/>
+        <location filename="../src/ui-settings-dialog.h" line="+3"/>
+        <source>Do not show whitespace used for indentation</source>
+        <translation>Ez erakutsi koskarako tarte-libreak</translation>
+    </message>
+    <message>
+        <location line="+625"/>
+        <location filename="../src/ui-settings-dialog.h" line="+37"/>
+        <source>Number of characters before list is shown: </source>
+        <translation>Idatzitako karaktere-kopurua bistaratutako lista bete baino lehen: </translation>
+    </message>
+    <message>
+        <location line="+112"/>
+        <location filename="../src/ui-settings-dialog.h" line="+11"/>
+        <source>Create nonexistent files without prompting</source>
+        <translation>Ez dauden fitxategiak galdetu gabe sortu</translation>
+    </message>
+    <message>
+        <location line="-429"/>
+        <location filename="../src/ui-settings-dialog.h" line="-28"/>
+        <source>command line (%f=file, %l=line):</source>
+        <translation>komandoko lerroa (%f=fitxategia, %l=lerroa):</translation>
+    </message>
+    <message>
+        <location line="+521"/>
+        <location filename="../src/ui-settings-dialog.h" line="+43"/>
+        <source>Terminal</source>
+        <translation>Terminala</translation>
+    </message>
+    <message>
+        <location line="+51"/>
+        <location filename="../src/ui-settings-dialog.h" line="-8"/>
+        <source>Cursor type:</source>
+        <translation>Kurtsore-mota:</translation>
+    </message>
+    <message>
+        <location line="-11"/>
+        <location filename="../src/ui-settings-dialog.h" line="-1"/>
+        <source>Cursor blinking</source>
+        <translation>Kurtsore keinukaria</translation>
+    </message>
+    <message>
+        <location line="-7"/>
+        <location filename="../src/ui-settings-dialog.h" line="-1"/>
+        <source>Use foreground color</source>
+        <translation>Erabili lehenengo planoko kolorea</translation>
+    </message>
+    <message>
+        <location line="+59"/>
+        <location filename="../src/ui-settings-dialog.h" line="+4"/>
+        <source>Font size</source>
+        <translation>Letra-tipoaren tamaina</translation>
+    </message>
+    <message>
+        <location line="+123"/>
+        <location filename="../src/ui-settings-dialog.h" line="+3"/>
+        <source>Set focus to terminal when running a command from within another widget</source>
+        <translation>Joan terminalera beste widget batetik agindu bat exekutatzen denean</translation>
+    </message>
+    <message>
+        <location line="+73"/>
+        <location filename="../src/ui-settings-dialog.h" line="+15"/>
+        <source>File Browser</source>
+        <translation>Fitxategi-arakatzailea</translation>
+    </message>
+    <message>
+        <location line="+46"/>
+        <location filename="../src/ui-settings-dialog.h" line="-8"/>
+        <source>Show file size</source>
+        <translation>Erakutsi fitxategiaren neurria</translation>
+    </message>
+    <message>
+        <location line="-14"/>
+        <location filename="../src/ui-settings-dialog.h" line="-2"/>
+        <source>Show file type</source>
+        <translation>Erakutsi fitxategi-mota</translation>
+    </message>
+    <message>
+        <location line="+21"/>
+        <location filename="../src/ui-settings-dialog.h" line="+3"/>
+        <source>Show date of last modification</source>
+        <translation>Erakutsi azken aldaketaren data</translation>
+    </message>
+    <message>
+        <location line="-14"/>
+        <location filename="../src/ui-settings-dialog.h" line="-2"/>
+        <source>Show hidden files</source>
+        <translation>Erakutsi ezkutuko fitxategiak</translation>
+    </message>
+    <message>
+        <location line="-1715"/>
+        <location filename="../src/ui-settings-dialog.h" line="-97"/>
+        <source>Interface</source>
+        <translation>Interfazea</translation>
+    </message>
+    <message>
+        <location line="+52"/>
+        <location filename="../src/ui-settings-dialog.h" line="+3"/>
+        <source>Confirm before exiting</source>
+        <translation>Berretsi irten aurretik</translation>
+    </message>
+    <message>
+        <location line="+103"/>
+        <location line="+592"/>
+        <location filename="../src/ui-settings-dialog.h" line="+9"/>
+        <location line="+28"/>
+        <source>Show status bar</source>
+        <translation>Erakutsi egoera-barra</translation>
+    </message>
+    <message>
+        <location line="-540"/>
+        <location filename="../src/ui-settings-dialog.h" line="-26"/>
+        <source>Text inactive</source>
+        <translation>Testua ezgaituta</translation>
+    </message>
+    <message>
+        <location line="-32"/>
+        <location line="+45"/>
+        <location filename="../src/ui-settings-dialog.h" line="-1"/>
+        <location line="+2"/>
+        <source>Active</source>
+        <translation>Gaituta</translation>
+    </message>
+    <message>
+        <location line="-152"/>
+        <location filename="../src/ui-settings-dialog.h" line="-10"/>
+        <source>Normal</source>
+        <translation>Normala</translation>
+    </message>
+    <message>
+        <location line="+191"/>
+        <location filename="../src/ui-settings-dialog.h" line="+12"/>
+        <source>Background inactive</source>
+        <translation>Atzeko planoa ezgaituta</translation>
+    </message>
+    <message>
+        <location line="+19"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>3D</source>
+        <translation>3D</translation>
+    </message>
+    <message>
+        <location line="+54"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Octave Startup</source>
+        <translation>Octaveren abiaraztea</translation>
+    </message>
+    <message>
+        <location line="+41"/>
+        <location line="+1392"/>
+        <location filename="../src/ui-settings-dialog.h" line="+2"/>
+        <location line="+82"/>
+        <source>Startup path</source>
+        <translation>Hasierako helbidea</translation>
+    </message>
+    <message>
+        <location line="-1379"/>
+        <location line="+1409"/>
+        <location filename="../src/ui-settings-dialog.h" line="-81"/>
+        <location line="+83"/>
+        <source>Browse</source>
+        <translation>Arakatu</translation>
+    </message>
+    <message>
+        <location line="-1322"/>
+        <location filename="../src/ui-settings-dialog.h" line="-78"/>
+        <source>After Column</source>
+        <translation>Zutabearen ondoren</translation>
+    </message>
+    <message>
+        <location line="+144"/>
+        <location filename="../src/ui-settings-dialog.h" line="+6"/>
+        <source>Tab width min.</source>
+        <translation>Tabuladorearen gutxieneko zabalera.</translation>
+    </message>
+    <message>
+        <location line="+64"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>max.</source>
+        <translation>max.</translation>
+    </message>
+    <message>
+        <location line="+31"/>
+        <location filename="../src/ui-settings-dialog.h" line="+2"/>
+        <source>This works well for monospaced fonts. The line is drawn at a position based on the width of a space character in the default font. It may not work very well if styles use proportional fonts or if varied font sizes or bold, italic and normal texts are used.</source>
+        <translation>Tarte finkodun letra-tipoekin ibiliko da zuzen.
+
+Karaktereen zabaleraren araberako kokapena hartzen du marraztutako lerroa, lehenetsitako
+letra-tipoaren arabera. Baliteke ongi ez funtzionatzea estiloek letra-tipo proportzionalak
+erabiltzen badituzte edo askotariko estiloak nahasten badira: askotariko tamainakoak edo
+letra lodiak, etzanak eta normalak.</translation>
+    </message>
+    <message>
+        <location line="+19"/>
+        <location filename="../src/ui-settings-dialog.h" line="+3"/>
+        <source>Enable Code Folding</source>
+        <translation>Gaitu kodea azpiltzea</translation>
+    </message>
+    <message>
+        <location line="+61"/>
+        <location filename="../src/ui-settings-dialog.h" line="+6"/>
+        <source>Windows (CRLF)</source>
+        <translation>Windows (CRLF)</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Mac (CR)</source>
+        <translation>Mac (CR)</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Unix (LF)</source>
+        <translation>Unix (LF)</translation>
+    </message>
+    <message>
+        <location line="+32"/>
+        <location filename="../src/ui-settings-dialog.h" line="+2"/>
+        <source>Show horizontal scroll bar</source>
+        <translation>Erakutsi korritze-barra horizontala</translation>
+    </message>
+    <message>
+        <location line="+68"/>
+        <location filename="../src/ui-settings-dialog.h" line="+4"/>
+        <source>Indentation</source>
+        <translation>Koska</translation>
+    </message>
+    <message>
+        <location line="+117"/>
+        <location filename="../src/ui-settings-dialog.h" line="+7"/>
+        <source>Indentation uses tabs</source>
+        <translation>Koskak tabuladorea darabil</translation>
+    </message>
+    <message>
+        <location line="+38"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Auto completion</source>
+        <translation>Osatze automatikoa</translation>
+    </message>
+    <message>
+        <location line="+101"/>
+        <location filename="../src/ui-settings-dialog.h" line="+5"/>
+        <source>With Octave builtins</source>
+        <translation>Octaveren barne funtzioekin</translation>
+    </message>
+    <message>
+        <location line="+10"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>With Octave functions</source>
+        <translation>Octaveren funtzioekin</translation>
+    </message>
+    <message>
+        <location line="+64"/>
+        <location filename="../src/ui-settings-dialog.h" line="+9"/>
+        <source>Show completion list automatically</source>
+        <translation>Erakutsi automatikoki bat datozen komandoen zerrenda</translation>
+    </message>
+    <message>
+        <location line="+31"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>File handling</source>
+        <translation>Fitxategien kudeaketa</translation>
+    </message>
+    <message>
+        <location line="+40"/>
+        <location filename="../src/ui-settings-dialog.h" line="+3"/>
+        <source>Reload externally changed files without prompt</source>
+        <translation>Birkargatu beste batzuek aldatu dituzten fitxategiak ohartarazpen gabe</translation>
+    </message>
+    <message>
+        <location line="+53"/>
+        <location filename="../src/ui-settings-dialog.h" line="+2"/>
+        <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select font, font size (as a difference from the default size), font style (&lt;b&gt;b&lt;/b&gt;old, &lt;b&gt;i&lt;/b&gt;talic, &lt;b&gt;u&lt;/b&gt;nderline), text color, and background color (for the latter, the color magenta (255,0,255) is a placeholder for the default background color).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+        <translation>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Letra-tipoa aukeratu, tamaina (lehenetsitako tamainarekiko aldea), estiloa (&lt;b&gt;l&lt;/b&gt;odia, &lt;b&gt;e&lt;/b&gt;tzana, &lt;b&gt;a&lt;/b&gt;zpimarratua), testuaren kolorea eta atzeko planoaren kolorea (azken honetan, lehenetsitako kolorearentzat magenta kolorea (255,0,255) kokapen-marka da).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
+    </message>
+    <message>
+        <location line="+192"/>
+        <location filename="../src/ui-settings-dialog.h" line="+7"/>
+        <source>(Changing buffer size clears history)</source>
+        <translation>(Bufferraren tamaina aldatzeak historiala ezabatzen du)</translation>
+    </message>
+    <message>
+        <location line="+28"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>History buffer Size</source>
+        <translation>Historialarentzako bufferraren tamaina</translation>
+    </message>
+    <message>
+        <location line="+34"/>
+        <location filename="../src/ui-settings-dialog.h" line="+2"/>
+        <source>Print debug location in terminal window in addition to the marker in the editor</source>
+        <translation>Erakutsi akasgabetzearen lokalizazioa editorearen leihoaz gain, terminalean</translation>
+    </message>
+    <message>
+        <location line="+87"/>
+        <location filename="../src/ui-settings-dialog.h" line="+3"/>
+        <source>Display</source>
+        <translation>Erakutsi</translation>
+    </message>
+    <message>
+        <location line="+39"/>
+        <location filename="../src/ui-settings-dialog.h" line="+5"/>
+        <source>Alternating row colors</source>
+        <translation>Txandakatu lerroen koloreak</translation>
+    </message>
+    <message>
+        <location line="+12"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Behavior</source>
+        <translation>Portaera</translation>
+    </message>
+    <message>
+        <location line="+34"/>
+        <location filename="../src/ui-settings-dialog.h" line="+3"/>
+        <source>Restore last directory of previous session</source>
+        <translation>Leheneratu azken direktorioa aurreko saiotik</translation>
+    </message>
+    <message>
+        <location line="+71"/>
+        <location filename="../src/ui-settings-dialog.h" line="+5"/>
+        <source>Workspace</source>
+        <translation>Lan-eremua</translation>
+    </message>
+    <message>
+        <location line="+42"/>
+        <location filename="../src/ui-settings-dialog.h" line="-1"/>
+        <source>Hide tool tips</source>
+        <translation>Ezkutatu argibide automatikoak</translation>
+    </message>
+    <message>
+        <location line="+182"/>
+        <location filename="../src/ui-settings-dialog.h" line="+14"/>
+        <source>Edit a shortcut by double-clicking in a cell</source>
+        <translation>Lasterbideak dagokion gelaxkan klik bikoitza eginez edita daitezke</translation>
+    </message>
+    <message>
+        <location line="+108"/>
+        <location filename="../src/ui-settings-dialog.h" line="+20"/>
+        <source>Network</source>
+        <translation>Sarea</translation>
+    </message>
+    <message>
+        <location line="+23"/>
+        <location filename="../src/ui-settings-dialog.h" line="-12"/>
+        <source>Allow Octave to connect to the Octave web site to display current news and information</source>
+        <translation>Octaveri baimena eman web-gunera konekta dadin azken berriak eta informazioa eskuratzeko</translation>
+    </message>
+    <message>
+        <location line="+46"/>
+        <location filename="../src/ui-settings-dialog.h" line="+8"/>
+        <source>Use proxy server</source>
+        <translation>Erabili &quot;proxy&quot; zerbitzaria</translation>
+    </message>
+    <message>
+        <location line="-23"/>
+        <location filename="../src/ui-settings-dialog.h" line="-4"/>
+        <source>HttpProxy</source>
+        <translation>HttpProxy</translation>
+    </message>
+    <message>
+        <location line="-2083"/>
+        <location filename="../src/ui-settings-dialog.h" line="-123"/>
+        <source>Icon set for dock widgets</source>
+        <translation>Aklopatutako widgetentzako ikonoak</translation>
+    </message>
+    <message>
+        <location line="-48"/>
+        <location filename="../src/ui-settings-dialog.h" line="-4"/>
+        <source>Language (requires restart)</source>
+        <translation>Hizkuntza (berrabiaraztea nahitaezkoa)</translation>
+    </message>
+    <message>
+        <location line="-58"/>
+        <location filename="../src/ui-settings-dialog.h" line="-5"/>
+        <source>Icon size</source>
+        <translation>Ikonoaren tamaina</translation>
+    </message>
+    <message>
+        <location line="+1714"/>
+        <location filename="../src/ui-settings-dialog.h" line="+100"/>
+        <source>Synchronize Octave working directory with file browser</source>
+        <translation>Sinkronizatu Octaveren lan-direktorioa fitxategi-arakatzailearekin</translation>
+    </message>
+    <message>
+        <location line="+132"/>
+        <location filename="../src/ui-settings-dialog.h" line="+5"/>
+        <source>Colors for variable attributes </source>
+        <translation>Aldagaien atributuentzako koloreak</translation>
+    </message>
+    <message>
+        <location line="+34"/>
+        <location filename="../src/ui-settings-dialog.h" line="+22"/>
+        <source>Shortcuts</source>
+        <translation>Lasterbideak</translation>
+    </message>
+    <message>
+        <location line="+31"/>
+        <location filename="../src/ui-settings-dialog.h" line="-18"/>
+        <source>Select this option to prevent conflicts with readline shortcuts</source>
+        <translation>Hautatu aukera hau komando-lerroko lasterbideekin gatazkak ekiditeko</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <location filename="../src/ui-settings-dialog.h" line="+2"/>
+        <source>Disable global shortcuts when terminal window has focus</source>
+        <translation>Ezgaitu lasterbide orokorrak terminala martxan dagoenean</translation>
+    </message>
+    <message>
+        <location line="+31"/>
+        <location line="+28"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <location line="+4"/>
+        <source>Use this set</source>
+        <translation>Erabili multzo hau</translation>
+    </message>
+    <message>
+        <location line="-21"/>
+        <location filename="../src/ui-settings-dialog.h" line="-3"/>
+        <source>Set 1:</source>
+        <translation>1. multzoa:</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <location line="+37"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <location line="+3"/>
+        <source>Export</source>
+        <translation>Esportatu</translation>
+    </message>
+    <message>
+        <location line="-30"/>
+        <location line="+37"/>
+        <location filename="../src/ui-settings-dialog.h" line="-2"/>
+        <location line="+3"/>
+        <source>Import</source>
+        <translation>Inportatu</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Set 2:</source>
+        <translation>2. multzoa:</translation>
+    </message>
+    <message>
+        <location line="+86"/>
+        <location filename="../src/ui-settings-dialog.h" line="+7"/>
+        <source>Action</source>
+        <translation>Ekintza</translation>
+    </message>
+    <message>
+        <location line="+10"/>
+        <location filename="../src/ui-settings-dialog.h" line="-1"/>
+        <source>Set 1 Default</source>
+        <translation>Lehenetsitako 1. multzoa</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <location filename="../src/ui-settings-dialog.h" line="-1"/>
+        <source>Set 1 Actual</source>
+        <translation>Uneko 1. multzoa</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <location filename="../src/ui-settings-dialog.h" line="-1"/>
+        <source>Set 2 Default</source>
+        <translation>Lehenetsitako 2. multzoa</translation>
+    </message>
+    <message>
+        <location line="+10"/>
+        <location filename="../src/ui-settings-dialog.h" line="-1"/>
+        <source>Set 2 Actual</source>
+        <translation>Uneko 2. multzoa</translation>
+    </message>
+    <message>
+        <location line="+68"/>
+        <location filename="../src/ui-settings-dialog.h" line="+11"/>
+        <source>Socks5Proxy</source>
+        <translation>&quot;Socks5Proxy&quot;</translation>
+    </message>
+    <message>
+        <location line="-16"/>
+        <location filename="../src/ui-settings-dialog.h" line="-4"/>
+        <source>Hostname:</source>
+        <translation>Ostalari-izena:</translation>
+    </message>
+    <message>
+        <location line="+44"/>
+        <location filename="../src/ui-settings-dialog.h" line="+8"/>
+        <source>Proxy type:</source>
+        <translation>Proxy-mota:</translation>
+    </message>
+    <message>
+        <location line="+10"/>
+        <location filename="../src/ui-settings-dialog.h" line="+1"/>
+        <source>Port:</source>
+        <translation>Ataka:</translation>
+    </message>
+    <message>
+        <location line="-27"/>
+        <location filename="../src/ui-settings-dialog.h" line="-3"/>
+        <source>Username:</source>
+        <translation>Erabiltzaile-izena:</translation>
+    </message>
+    <message>
+        <location line="+37"/>
+        <location filename="../src/ui-settings-dialog.h" line="+4"/>
+        <source>Password:</source>
+        <translation>Pasahitza:</translation>
+    </message>
+    <message>
+        <location filename="../src/settings-dialog.cc" line="+77"/>
+        <location line="+4"/>
+        <location line="+561"/>
+        <source>System setting</source>
+        <translation>Sistemaren hobespena</translation>
+    </message>
+    <message>
+        <location line="-355"/>
+        <source>IBeam Cursor</source>
+        <translation>IBeam kurtsorea</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Block Cursor</source>
+        <translation>Bloke-kurtsorea</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Underline Cursor</source>
+        <translation>Azpimarra-kurtsorea</translation>
+    </message>
+    <message>
+        <location line="+213"/>
+        <source>Difference to the default size</source>
+        <translation>Lehenetsitako tamainarekiko aldea</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Background color, pink (255,0,255) means default</source>
+        <translation>Kolore magentak (255,0,255) lehenetsia ezan nahi du</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>b</source>
+        <comment>short form for bold</comment>
+        <translation>l</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>i</source>
+        <comment>short form for italic</comment>
+        <translation>e</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>u</source>
+        <comment>short form for underlined</comment>
+        <translation>a</translation>
+    </message>
+    <message>
+        <location line="+497"/>
+        <source>Set Octave Startup Directory</source>
+        <translation>Octaveren hasiera-direktorioa ezarri</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Set File Browser Startup Directory</source>
+        <translation>Fitxategi-arakatzailearen hasiera-direktorioa ezarri</translation>
+    </message>
+</context>
+<context>
+    <name>setup_community_news</name>
+    <message>
+        <location filename="../src/welcome-wizard.cc" line="+44"/>
+        <source>Community News</source>
+        <translation>Komunitatearen berriak</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Previous</source>
+        <translation>Aurrekoa</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Next</source>
+        <translation>Hurrengoa</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Cancel</source>
+        <translation>Ezeztatu</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <source>&lt;html&gt;&lt;body&gt;
+&lt;p&gt;When the Octave GUI starts, it will check the Octave web site for current news and information about the Octave community.
+The check will happen at most once each day and news will only be displayed if there is something new since the last time you viewed the news.&lt;/p&gt;
+&lt;p&gt;You may also view the news by selecting the &quot;Community News&quot; item in the &quot;Help&quot; menu in the GUI, or by visiting
+&lt;a href=&quot;http://octave.org/community-news.html&quot;&gt;http://octave.org/community-news.html&lt;/a&gt;.&lt;/p&gt;
+&lt;/body&gt;&lt;/html&gt;</source>
+        <translation>&lt;html&gt;&lt;body&gt;
+&lt;p&gt;Octaveren GUIa abiarazten denean, Octaveren web-gunea txekeatuko du Octaveren komunitatearen gaineko berriak eta informazioa jasotzeko.
+Azterketa hori egunean baten egingo da gehienez, eta aldez aurretik ikusi ez diren berriak baino ez dira erakutsiko.&lt;/p&gt;
+&lt;p&gt;Berriak txekeatu ahalko dira &quot;Komunitatearen berriak&quot; atalean, GUIaren laguntza-menuan edo honakoei bisita eginda
+&lt;a href=&quot;http://octave.org/community-news.html&quot;&gt;http://octave.org/community-news.html&lt;/a&gt;.&lt;/p&gt;
+&lt;/body&gt;&lt;/html&gt;</translation>
+    </message>
+    <message>
+        <location line="+26"/>
+        <source>&lt;html&gt;&lt;head&gt;
+&lt;style&gt;
+a:link { text-decoration: underline; color: #0000ff; }
+&lt;/style&gt;
+&lt;head/&gt;&lt;body&gt;
+&lt;p&gt;Allow Octave to connect to the Octave web site when it starts to display current news and information about the Octave community.&lt;/p&gt;
+&lt;/body&gt;&lt;/html&gt;</source>
+        <translation>&lt;html&gt;&lt;head&gt;
+&lt;style&gt;
+a:link { text-decoration: underline; color: #0000ff; }
+&lt;/style&gt;
+&lt;head/&gt;&lt;body&gt;
+&lt;p&gt;Baimendu Octaveren web-gunerako konexioa abiaraztean, Octavek komunitatearen gaineko momentuko berriak eta informazioa bistara ditzan.&lt;/p&gt;
+&lt;/body&gt;&lt;/html&gt;</translation>
+    </message>
+</context>
+<context>
+    <name>shortcut_manager</name>
+    <message>
+        <location filename="../src/shortcut-manager.cc" line="+109"/>
+        <source>New File</source>
+        <translation>Beste fitxategi bat</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>New Function</source>
+        <translation>Beste funtzio bat</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>New Figure</source>
+        <translation>Beste irudi bat</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Open File</source>
+        <translation>Ireki fitxategia</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Load Workspace</source>
+        <translation>Kargatu lan-eremua</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Save Workspace As</source>
+        <translation>Gorde lan-eremua honela</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <location line="+158"/>
+        <source>Preferences</source>
+        <translation>Hobespenak</translation>
+    </message>
+    <message>
+        <location line="-157"/>
+        <source>Exit Octave</source>
+        <translation>Octavetik irten</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <location line="+84"/>
+        <source>Copy</source>
+        <translation>Kopiatu</translation>
+    </message>
+    <message>
+        <location line="-83"/>
+        <location line="+85"/>
+        <source>Paste</source>
+        <translation>Itsatsi</translation>
+    </message>
+    <message>
+        <location line="-84"/>
+        <location line="+80"/>
+        <source>Undo</source>
+        <translation>Desegin</translation>
+    </message>
+    <message>
+        <location line="-79"/>
+        <location line="+84"/>
+        <source>Select All</source>
+        <translation>Hautatu dena</translation>
+    </message>
+    <message>
+        <location line="-83"/>
+        <source>Clear Clipboard</source>
+        <translation>Paper-zorroa garbitu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Find in Files</source>
+        <translation>Fitxategietan bilatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Clear Command Window</source>
+        <translation>Komandoen leihoa garbitu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Clear Command History</source>
+        <translation>Komandoen historiala garbitu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Clear Workspace</source>
+        <translation>Lan-eremua garbitu</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Step Into</source>
+        <translation>Sartu hona</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Step Out</source>
+        <translation>Irten</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Continue</source>
+        <translation>Jarraitu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Quit Debug Mode</source>
+        <translation>Akasgabetze-modutik irten</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Show Command Window</source>
+        <translation>Erakutsi komandoen leihoa</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Show Command History</source>
+        <translation>Erakutsi komandoen historiala</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Show File Browser</source>
+        <translation>Erakutsi fitxategi-arakatzailea</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Show Workspace</source>
+        <translation>Erakutsi lan-eremua</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Show Editor</source>
+        <translation>Erakutsi editorea</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Show Documentation</source>
+        <translation>Erakutsi dokumentazioa</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Command Window</source>
+        <translation>Komandoen leihoa</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Command History</source>
+        <translation>Komandoen historiala</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>File Browser</source>
+        <translation>Fitxategi-arakatzailea</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Workspace</source>
+        <translation>Lan-eremua</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <location line="+216"/>
+        <source>Editor</source>
+        <translation>Editorea</translation>
+    </message>
+    <message>
+        <location line="-214"/>
+        <source>Documentation</source>
+        <translation>Dokumentazioa</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Show Ondisk Documentation</source>
+        <translation>Erakutsi diskoan gordetako dokumentazioa</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Show Online Documentation</source>
+        <translation>Erakutsi dokumentazioa linean</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Octave Packages</source>
+        <translation>Octaveren paketeak</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Share Code</source>
+        <translation>Kodea partekatu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Contribute to Octave</source>
+        <translation>Octaverekin kolaboratu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Octave Developer Resources</source>
+        <translation>Octaveren garatzaileentzako baliabideak</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>About Octave</source>
+        <translation>&quot;Octave&quot;-ri buruz</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Release Notes</source>
+        <translation>Bertsioaren oharrak</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Community News</source>
+        <translation>Koumunitatearen berriak</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Edit Function</source>
+        <translation>Funtzioa editatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Save File</source>
+        <translation>Gorde fitxategia</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Save File As</source>
+        <translation>Gorde fitxategia honela</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Close</source>
+        <translation>Itxi</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Close All</source>
+        <translation>Itxi dena</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Print</source>
+        <translation>Imprimatu</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Redo</source>
+        <translation>Berregin</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Cut</source>
+        <translation>Ebaki</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Find and Replace</source>
+        <translation>Bilatu eta ordezkatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Delete to Start of Word</source>
+        <translation>Hitz hasieraraino ezabatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Delete to End of Word</source>
+        <translation>Hitz amaieraraino ezabatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Delete to Start of Line</source>
+        <translation>Lerro hasieraraino ezabatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Delete to End of Line</source>
+        <translation>Lerro amaieraraino ezabatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Delete Line</source>
+        <translation>Lerroa ezabatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Copy Line</source>
+        <translation>Lerroa kopiatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Cut Line</source>
+        <translation>Lerroa ebaki</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Duplicate Selection/Line</source>
+        <translation>Bikoiztu aukeraketa/lerroa</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Transpose Line</source>
+        <translation>Txandakatu aurreko lerroarekin</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Comment Selection</source>
+        <translation>Aukeraketa iruzkindu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Uncomment Selection</source>
+        <translation>Aukeraketaren iruzkina kendu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Uppercase Selection</source>
+        <translation>Jarri aukeratutakoa maiuskulan</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Lowercase Selection</source>
+        <translation>Jarri aukeratutakoa minuskulan</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <location line="+5"/>
+        <source>Indent Selection</source>
+        <translation>Aplikatu koska aukeraketari</translation>
+    </message>
+    <message>
+        <location line="-3"/>
+        <location line="+5"/>
+        <source>Unindent Selection</source>
+        <translation>Aukeraketari koska kendu</translation>
+    </message>
+    <message>
+        <location line="+11"/>
+        <source>Goto Line</source>
+        <translation>Lerrora joan</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Move to Matching Brace</source>
+        <translation>Mugitu dagokion parentesira, kako zuzenera edo giltzara</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Select to Matching Brace</source>
+        <translation>Hautatu dagokion karaktereraino: parentesia, kako zuzena edo giltza</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Toggle Bookmark</source>
+        <translation>Markatzaileak txandatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Next Bookmark</source>
+        <translation>Hurrengo markatzailea</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Previous Bookmark</source>
+        <translation>Aurreko markatzailea</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Remove All Bookmark</source>
+        <translation>Ezabatu markatzaile guztiak</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Styles Preferences</source>
+        <translation>Estiloen hobespenak</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Show Line Numbers</source>
+        <translation>Erakutsi lerro-zenbakiak</translation>
+    </message>
+    <message>
+        <location line="-145"/>
+        <source>Step</source>
+        <translation>Hurrengo argibidea</translation>
+    </message>
+    <message>
+        <location line="+36"/>
+        <source>Reset Default Window Layout</source>
+        <translation>Leihoen diseinu lehenetsia berrezarri</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <source>Report Bug</source>
+        <translation>Akatsei buruz informatu</translation>
+    </message>
+    <message>
+        <location line="+21"/>
+        <source>Close Other Files</source>
+        <translation>Beste fitxategi batzuk itxi</translation>
+    </message>
+    <message>
+        <location line="+30"/>
+        <source>Show Completion List</source>
+        <translation>Erakutsi bat datozen komandoen zerrenda</translation>
+    </message>
+    <message>
+        <location line="+24"/>
+        <source>Convert Line Endings to Windows</source>
+        <translation>Lerro-amaierak &quot;Windows&quot;-era aldatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Convert Line Endings to Unix</source>
+        <translation>Lerro-amaierak &quot;Unix&quot;-era aldatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Convert Line Endings to Mac</source>
+        <translation>Lerro-amaierak &quot;Mac&quot;-era aldatu</translation>
+    </message>
+    <message>
+        <location line="+25"/>
+        <source>Show Whitespace Characters</source>
+        <translation>Erakutsi zuriuneak</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Show Line Endings</source>
+        <translation>Erakutsi lerro-amaierak</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Show Indentation Guides</source>
+        <translation>Erakutsi koska-erakusleak</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Show Long Line Marker</source>
+        <translation>Erakutsi lerro-luzera markatzailea</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Zoom In</source>
+        <translation>Handitu</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Zoom Out</source>
+        <translation>Txikitu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <location line="+3"/>
+        <source>Zoom Normal</source>
+        <translation>Zoom normala</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Toggle Breakpoint</source>
+        <translation>Geldiuneak txandakatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Next Breakpoint</source>
+        <translation>Hurrengo geldiunea</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Previous Breakpoint</source>
+        <translation>Aurreko geldiunea</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Remove All Breakpoints</source>
+        <translation>Ezabatu geldiune guztiak</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Run File</source>
+        <translation>Fitxategia exekutatu</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Run Selection</source>
+        <translation>Aukeraketa exekutatu</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Help on Keyword</source>
+        <translation>Laguntza hitz gakoekin</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <source>Document on Keyword</source>
+        <translation>Hitz gakoen dokumentazioa</translation>
+    </message>
+    <message>
+        <location line="+42"/>
+        <source>Main</source>
+        <translation>Nagusia</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <location line="+23"/>
+        <source>File</source>
+        <translation>Fitxategia</translation>
+    </message>
+    <message>
+        <location line="-21"/>
+        <location line="+23"/>
+        <source>Edit</source>
+        <translation>Editatu</translation>
+    </message>
+    <message>
+        <location line="-21"/>
+        <location line="+25"/>
+        <source>Debug</source>
+        <translation>Akasgabetu</translation>
+    </message>
+    <message>
+        <location line="-23"/>
+        <source>Window</source>
+        <translation>Leihoa</translation>
+    </message>
+    <message>
+        <location line="+2"/>
+        <location line="+25"/>
+        <source>Help</source>
+        <translation>Laguntza</translation>
+    </message>
+    <message>
+        <location line="-23"/>
+        <source>News</source>
+        <translation>Berriak</translation>
+    </message>
+    <message>
+        <location line="+17"/>
+        <source>View</source>
+        <translation>Ikusi</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Run</source>
+        <translation>Exekutatu</translation>
+    </message>
+    <message>
+        <location line="+124"/>
+        <source>Enter new Shortcut for Set %1</source>
+        <translation>Egin beste lasterbide bat %1 multzoarentzat</translation>
+    </message>
+    <message>
+        <location line="+5"/>
+        <source>Apply the desired shortcut or click on the right button to reset the shortcut to its default.</source>
+        <translation>Nahi duzun lasterbidea ezarri edo eskuin-klik egin lasterbidea lehenetsitako baliora bueltatzeko.</translation>
+    </message>
+    <message>
+        <location line="+7"/>
+        <source>Enter shortcut directly by performing it</source>
+        <translation>Sartu lasterbidea</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Actual shortcut</source>
+        <translation>Uneko lasterbidea</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Default shortcut</source>
+        <translation>Lehenetsitako lasterbidea</translation>
+    </message>
+    <message>
+        <location line="+6"/>
+        <source>Set to default</source>
+        <translation>Ezarri lehenetsi gisa</translation>
+    </message>
+    <message>
+        <location line="+53"/>
+        <source>Double Shortcut</source>
+        <translation>Lasterbide bikoitza</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>The chosen shortcut
+  &quot;%1&quot;
+is already used for the action
+  &quot;%2&quot;.
+Do you want to use the shortcut anyhow removing it from the previous action?</source>
+        <translation>Aukeratutako
+  &quot;%1&quot;
+lasterbidea erabilita dago honako ekintzarako:
+  &quot;%2&quot;.
+Aurrez zehaztutako lasterbidea ezabatuko da. Jarraitu nahi duzu?</translation>
+    </message>
+    <message>
+        <location line="+71"/>
+        <source>Import shortcut set %1 from file ...</source>
+        <translation>Inportatu %1 lasterbide-multzoa fitxategitik ...</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <location line="+6"/>
+        <source>Octave Shortcut Files (*.osc);;All Files (*)</source>
+        <translation>Octavere lasterbide-fitxategiak (*.osc);;Fitxategi guztiak (*)</translation>
+    </message>
+    <message>
+        <location line="-1"/>
+        <source>Export shortcut set %1 into file ...</source>
+        <translation>Esportatu %1 lasterbide-multzoa fitxategira ...</translation>
+    </message>
+    <message>
+        <location line="+15"/>
+        <source>Failed to open %1 as octave shortcut file</source>
+        <translation>Ezin da ireki %1 Octaveren lasterbide-multzo fitxategi bezala</translation>
+    </message>
+</context>
+<context>
+    <name>terminal_dock_widget</name>
+    <message>
+        <location filename="../src/terminal-dock-widget.cc" line="+38"/>
+        <source>Command Window</source>
+        <translation>Komandoen leihoa</translation>
+    </message>
+</context>
+<context>
+    <name>webinfo</name>
+    <message>
+        <location filename="../src/qtinfo/webinfo.cc" line="+83"/>
+        <source>Type here and press &apos;Return&apos; to search</source>
+        <translation>Idatzi hemen eta sakatu &apos;enter&apos; bilatzeko</translation>
+    </message>
+    <message>
+        <location line="+4"/>
+        <source>Global search</source>
+        <translation>Bilaketa globala</translation>
+    </message>
+    <message>
+        <location line="+18"/>
+        <source>Error</source>
+        <translation>Akatsa</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>The info file&lt;p&gt;%1&lt;p&gt;or compressed versions do not exist</source>
+        <translation>&lt;p&gt;%1&lt;p&gt; informazio-fitxategia edo konprimitutako fitxategia ez daude</translation>
+    </message>
+</context>
+<context>
+    <name>welcome_wizard</name>
+    <message>
+        <location filename="../src/welcome-wizard.cc" line="+135"/>
+        <source>Welcome to GNU Octave</source>
+        <translation>Ongi etorri GNU Octavera</translation>
+    </message>
+</context>
+<context>
+    <name>workspace_model</name>
+    <message>
+        <location filename="../src/workspace-model.cc" line="-42"/>
+        <source>Name</source>
+        <translation>Izena</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Class</source>
+        <translation>Mota</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Dimension</source>
+        <translation>Dimentsioa</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Value</source>
+        <translation>Balioa</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Attribute</source>
+        <translation>Atributua</translation>
+    </message>
+    <message>
+        <location line="+109"/>
+        <source>Right click to copy, rename, or display</source>
+        <translation>Eskuin-klik kopiatzeko, izena aldatzeko edo erakusteko</translation>
+    </message>
+    <message>
+        <location line="+37"/>
+        <location line="+2"/>
+        <source>complex</source>
+        <translation>Konplexua</translation>
+    </message>
+</context>
+<context>
+    <name>workspace_view</name>
+    <message>
+        <location filename="../src/workspace-view.cc" line="+50"/>
+        <source>Workspace</source>
+        <translation>Lan-eremua</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>View the variables in the active workspace.</source>
+        <translation>Erakutsi aldagaiak lan-eremu aktiboan.</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Enter text to filter the workspace</source>
+        <translation>Sartu testua lan-eremua iragazteko</translation>
+    </message>
+    <message>
+        <location line="+10"/>
+        <source>Filter</source>
+        <translation>Iragazi</translation>
+    </message>
+    <message>
+        <location line="+161"/>
+        <source>Copy name</source>
+        <translation>Izena kopiatu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Copy value</source>
+        <translation>Balioa kopiatu</translation>
+    </message>
+    <message>
+        <location line="+3"/>
+        <source>Rename</source>
+        <translation>Izena aldatu</translation>
+    </message>
+    <message>
+        <location line="+9"/>
+        <source>Only top-level symbols may be renamed.</source>
+        <translation>Maila altuko sinboloei soilik alda dakieke izena.</translation>
+    </message>
+    <message>
+        <location line="+132"/>
+        <source>View the variables in the active workspace.&lt;br&gt;</source>
+        <translation>Erakutsi aldagaiak lan-eremu aktiboan.&lt;br&gt;</translation>
+    </message>
+    <message>
+        <location line="+1"/>
+        <source>Colors for variable attributes:</source>
+        <translation>Biltegiratze-mota bakoitzerako koloreak:</translation>
+    </message>
+</context>
+</TS>
--- a/libgui/languages/translators	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/languages/translators	Thu Dec 10 12:50:06 2015 -0800
@@ -5,6 +5,7 @@
 be_BY Mihas Varantsou <meequz@gmail.com>
 de_DE Andreas Weber <andy.weber.aw@googlemail.com>
 es_ES Valentin Ortega-Clavero <arcanos3030@gmail.com>, José Luis García Pallero <jgpallero@gmail.com>
+eu_ES Ander Aurrekoetxea <zaurreko@gmail.com>
 fr_FR David Bateman <dbateman@free.fr>, Catalin Codreanu <codreanu.catalin@gmail.com>
 it_IT Massimiliano Fasi <massimiliano.fasi@gmail.com>
 ja_JP Tatsuro Matsuoka <tmacchant@yahoo.co.jp>
--- a/libgui/link-deps.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/link-deps.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,4 +1,4 @@
-include $(top_srcdir)/libinterp/link-deps.mk
+if AMCOND_BUILD_GUI
 
 if AMCOND_ENABLE_DYNAMIC_LINKING
   LIBOCTGUI_LINK_DEPS =
@@ -20,3 +20,5 @@
   OCTAVE_GUI_LINK_DEPS = $(LIBOCTGUI_LINK_DEPS)
   OCTAVE_GUI_LINK_OPTS = $(LIBOCTGUI_LINK_OPTS)
 endif
+
+endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgui/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,139 @@
+if AMCOND_BUILD_GUI
+
+libgui_EXTRA_DIST =
+
+libgui_CLEANFILES =
+libgui_DISTCLEANFILES =
+libgui_MAINTAINERCLEANFILES =
+
+MOC_CPPFLAGS =
+
+## Fix for bug #42839 where -mieee CFLAG option is added to CPPFLAGS by gnulib.
+## Users may also pass other options in CPPFLAGS that moc does not understand.
+## Only keep moc-compatible options -Idir, -Dmacro, and -Umacro.
+MOC_OCTAVE_CPPFLAGS = $(filter -I% -D% -U%, $(AM_CPPFLAGS) $(CPPFLAGS))
+
+octlib_LTLIBRARIES += libgui/liboctgui.la
+
+TRANSLATIONS = \
+  libgui/languages/be_BY.ts \
+  libgui/languages/de_DE.ts \
+  libgui/languages/en_US.ts \
+  libgui/languages/es_ES.ts \
+  libgui/languages/eu_ES.ts \
+  libgui/languages/fr_FR.ts \
+  libgui/languages/it_IT.ts \
+  libgui/languages/ja_JP.ts \
+  libgui/languages/nl_NL.ts \
+  libgui/languages/pt_BR.ts \
+  libgui/languages/pt_PT.ts \
+  libgui/languages/ru_RU.ts \
+  libgui/languages/uk_UA.ts \
+  libgui/languages/zh_CN.ts
+
+LOCALES = $(patsubst libgui/languages/%.ts, libgui/languages/%.qm, $(TRANSLATIONS))
+
+include libgui/src/module.mk
+include libgui/graphics/module.mk
+include libgui/qterminal-module.mk
+
+## liboctgui merely collects a bunch of compiled convenience libraries.
+## It has no source code itself.
+libgui_liboctgui_la_SOURCES =
+
+# Dummy C++ source to force C++ linking.
+nodist_EXTRA_libgui_liboctgui_la_SOURCES = libgui/dummy.cc
+
+libgui_liboctgui_la_LIBADD = \
+  libgui/qterminal/libqterminal.la \
+  libgui/src/libgui-src.la \
+  libgui/graphics/libgui-graphics.la \
+  $(top_builddir)/libinterp/liboctinterp.la \
+  $(top_builddir)/liboctave/liboctave.la \
+  $(LIBOCTGUI_LINK_DEPS)
+
+# Increment these as needed and according to the rules in the libtool manual:
+libgui_liboctgui_current = 1
+libgui_liboctgui_revision = 0
+libgui_liboctgui_age = 0
+
+libgui_liboctgui_version_info = $(libgui_liboctgui_current):$(libgui_liboctgui_revision):$(libgui_liboctgui_age)
+
+libgui_liboctgui_la_LDFLAGS = \
+  -version-info $(libgui_liboctgui_version_info) \
+  $(NO_UNDEFINED_LDFLAG) \
+  -bindir $(bindir) \
+  $(LIBOCTGUI_LINK_OPTS) \
+  $(WARN_LDFLAGS)
+
+octetc_DATA += libgui/default-qt-settings
+
+octlocale_DATA += $(LOCALES)
+
+libgui/default-qt-settings: libgui/default-qt-settings.in | libgui/$(octave_dirstamp)
+	$(AM_V_GEN)$(do_subst_qt_settings)
+
+DIRSTAMP_FILES += \
+  libgui/$(octave_dirstamp)
+
+define moc-command
+  rm -f $@-t $@ && \
+  ( echo "#ifdef HAVE_CONFIG_H"; \
+    echo "#include <config.h>"; \
+    echo "#endif"; \
+    $(MOC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(MOC_OCTAVE_CPPFLAGS) $(MOC_CPPFLAGS) $(libgui_liboctgui_la_CPPFLAGS) $< ) > $@-t && \
+  mv $@-t $@
+endef
+
+define rcc-command
+  rm -f $@-t $@ && \
+  ( echo "#ifdef HAVE_CONFIG_H"; \
+    echo "#include <config.h>"; \
+    echo "#endif"; \
+    $(RCC) -name $(@D) $< ) > $@-t && \
+  mv $@-t $@
+endef
+
+moc-%.cc: %.h
+	$(AM_V_GEN)$(moc-command)
+
+ui-%.h: %.ui
+	$(AM_V_GEN)$(UIC) -o $@ $<
+
+qrc-%.cc: %.qrc
+	$(AM_V_GEN)$(rcc-command)
+
+AM_V_lrelease = $(am__v_lrelease_$(V))
+am__v_lrelease_ = $(am__v_lrelease_$(AM_DEFAULT_VERBOSITY))
+am__v_lrelease_0 = -silent
+am__v_lrelease_1 =
+
+%.qm: %.ts | libgui/languages/$(octave_dirstamp)
+	$(AM_V_GEN)$(LRELEASE) $(AM_V_lrelease) -qm $@ $<
+
+DIRSTAMP_FILES += \
+  libgui/languages/$(octave_dirstamp)
+
+libgui_EXTRA_DIST += \
+  $(TRANSLATIONS) \
+  libgui/default-qt-settings.in
+
+EXTRA_DIST += $(libgui_EXTRA_DIST)
+
+libgui_DISTCLEANFILES += \
+  libgui/default-qt-settings \
+  $(LOCALES)
+
+CLEANFILES += $(libgui_CLEANFILES)
+DISTCLEANFILES += $(libgui_DISTCLEANFILES)
+MAINTAINERCLEANFILES += $(libgui_MAINTAINERCLEANFILES)
+
+libgui-clean:
+	rm -f $(libgui_CLEANFILES)
+
+libgui-distclean: libgui-clean
+	rm -f $(libgui_DISTCLEANFILES)
+
+libgui-maintainer-clean: libgui-distclean
+	rm -f $(libgui_MAINTAINERCLEANFILES)
+endif
--- a/libgui/qterminal-module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/qterminal-module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,94 +1,117 @@
-EXTRA_DIST += \
-  qterminal-module.mk
+noinst_HEADERS += \
+  libgui/qterminal/libqterminal/QTerminal.h \
+  libgui/qterminal/libqterminal/win32/QTerminalColors.h \
+  libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h \
+  libgui/qterminal/libqterminal/unix/BlockArray.h \
+  libgui/qterminal/libqterminal/unix/Character.h \
+  libgui/qterminal/libqterminal/unix/CharacterColor.h \
+  libgui/qterminal/libqterminal/unix/Emulation.h \
+  libgui/qterminal/libqterminal/unix/ExtendedDefaultTranslator.h \
+  libgui/qterminal/libqterminal/unix/ExtendedDefaultTranslatorMac.h \
+  libgui/qterminal/libqterminal/unix/Filter.h \
+  libgui/qterminal/libqterminal/unix/History.h \
+  libgui/qterminal/libqterminal/unix/KeyboardTranslator.h \
+  libgui/qterminal/libqterminal/unix/konsole_wcwidth.h \
+  libgui/qterminal/libqterminal/unix/kpty.h \
+  libgui/qterminal/libqterminal/unix/kpty_p.h \
+  libgui/qterminal/libqterminal/unix/LineFont.h \
+  libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h \
+  libgui/qterminal/libqterminal/unix/Screen.h \
+  libgui/qterminal/libqterminal/unix/ScreenWindow.h \
+  libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.h \
+  libgui/qterminal/libqterminal/unix/Vt102Emulation.h \
+  libgui/qterminal/libqterminal/unix/SelfListener.h \
+  libgui/qterminal/libqterminal/unix/TerminalModel.h \
+  libgui/qterminal/libqterminal/unix/TerminalView.h
 
-noinst_HEADERS += \
-  qterminal/libqterminal/QTerminal.h \
-  qterminal/libqterminal/win32/QTerminalColors.h \
-  qterminal/libqterminal/win32/QWinTerminalImpl.h \
-  qterminal/libqterminal/unix/BlockArray.h \
-  qterminal/libqterminal/unix/Character.h \
-  qterminal/libqterminal/unix/CharacterColor.h \
-  qterminal/libqterminal/unix/Emulation.h \
-  qterminal/libqterminal/unix/ExtendedDefaultTranslator.h \
-  qterminal/libqterminal/unix/ExtendedDefaultTranslatorMac.h \
-  qterminal/libqterminal/unix/Filter.h \
-  qterminal/libqterminal/unix/History.h \
-  qterminal/libqterminal/unix/KeyboardTranslator.h \
-  qterminal/libqterminal/unix/konsole_wcwidth.h \
-  qterminal/libqterminal/unix/kpty.h \
-  qterminal/libqterminal/unix/kpty_p.h \
-  qterminal/libqterminal/unix/LineFont.h \
-  qterminal/libqterminal/unix/QUnixTerminalImpl.h \
-  qterminal/libqterminal/unix/Screen.h \
-  qterminal/libqterminal/unix/ScreenWindow.h \
-  qterminal/libqterminal/unix/TerminalCharacterDecoder.h \
-  qterminal/libqterminal/unix/Vt102Emulation.h \
-  qterminal/libqterminal/unix/SelfListener.h \
-  qterminal/libqterminal/unix/TerminalModel.h \
-  qterminal/libqterminal/unix/TerminalView.h
+libgui_qterminal_libqterminal_la_MOC =
+
+OCTAVE_GUI_QTERMINAL_LIBQTERMINAL_MOC = \
+  libgui/qterminal/libqterminal/moc-QTerminal.cc
+
+$(OCTAVE_GUI_QTERMINAL_LIBQTERMINAL_MOC): | libgui/qterminal/libqterminal/$(octave_dirstamp)
 
-qterminal_libqterminal_la_MOC = \
-  qterminal/libqterminal/moc-QTerminal.cc
+DIRSTAMP_FILES += \
+  libgui/qterminal/libqterminal/$(octave_dirstamp)
 
-nodist_qterminal_libqterminal_la_SOURCES = $(qterminal_libqterminal_la_MOC)
+libgui_qterminal_libqterminal_la_MOC += \
+  $(OCTAVE_GUI_QTERMINAL_LIBQTERMINAL_MOC)
 
-qterminal_libqterminal_la_CPPFLAGS = \
+nodist_libgui_qterminal_libqterminal_la_SOURCES = $(libgui_qterminal_libqterminal_la_MOC)
+
+libgui_qterminal_libqterminal_la_CPPFLAGS = \
   $(AM_CPPFLAGS) \
   @QT_CPPFLAGS@ \
-  -I$(srcdir)/qterminal/libqterminal \
-  -I$(srcdir)/src
+  -I$(srcdir)/libgui/qterminal/libqterminal \
+  -I$(srcdir)/libgui/src
 
-qterminal_libqterminal_la_CFLAGS = $(AM_CFLAGS)
+libgui_qterminal_libqterminal_la_CFLAGS = $(AM_CFLAGS)
 
-qterminal_libqterminal_la_CXXFLAGS = $(AM_CXXFLAGS)
+libgui_qterminal_libqterminal_la_CXXFLAGS = $(AM_CXXFLAGS)
 
 if WIN32_TERMINAL
 
-qterminal_libqterminal_la_SOURCES = \
-  qterminal/libqterminal/win32/QTerminalColors.cpp \
-  qterminal/libqterminal/win32/QWinTerminalImpl.cpp \
-  qterminal/libqterminal/QTerminal.cc
+libgui_qterminal_libqterminal_la_SOURCES = \
+  libgui/qterminal/libqterminal/win32/QTerminalColors.cpp \
+  libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp \
+  libgui/qterminal/libqterminal/QTerminal.cc
+
+OCTAVE_GUI_QTERMINAL_LIBQTERMINAL_WIN32_MOC = \
+  libgui/qterminal/libqterminal/win32/moc-QWinTerminalImpl.cc
 
-qterminal_libqterminal_la_MOC += \
-  qterminal/libqterminal/win32/moc-QWinTerminalImpl.cc
+libgui_qterminal_libqterminal_la_MOC += \
+  $(OCTAVE_GUI_QTERMINAL_LIBQTERMINAL_WIN32_MOC)
+
+$(OCTAVE_GUI_QTERMINAL_LIBQTERMINAL_WIN32_MOC): | libgui/qterminal/libqterminal/win32/$(octave_dirstamp)
 
-qterminal_libqterminal_la_CPPFLAGS += -DUNICODE
+DIRSTAMP_FILES += \
+  libgui/qterminal/libqterminal/win32/$(octave_dirstamp)
+
+libgui_qterminal_libqterminal_la_CPPFLAGS += -DUNICODE
 
 # This flag is required to let MOC know about Q_OS_WIN32.
 MOC_CPPFLAGS += -DQ_OS_WIN32
 
 else
 
-qterminal_libqterminal_la_SOURCES = \
-  qterminal/libqterminal/unix/BlockArray.cpp \
-  qterminal/libqterminal/unix/Emulation.cpp \
-  qterminal/libqterminal/unix/Filter.cpp \
-  qterminal/libqterminal/unix/History.cpp \
-  qterminal/libqterminal/unix/KeyboardTranslator.cpp \
-  qterminal/libqterminal/unix/konsole_wcwidth.cpp \
-  qterminal/libqterminal/unix/kpty.cpp \
-  qterminal/libqterminal/unix/QUnixTerminalImpl.cpp \
-  qterminal/libqterminal/unix/Screen.cpp \
-  qterminal/libqterminal/unix/ScreenWindow.cpp \
-  qterminal/libqterminal/unix/TerminalCharacterDecoder.cpp \
-  qterminal/libqterminal/unix/Vt102Emulation.cpp \
-  qterminal/libqterminal/unix/SelfListener.cpp \
-  qterminal/libqterminal/unix/TerminalModel.cpp \
-  qterminal/libqterminal/unix/TerminalView.cpp \
-  qterminal/libqterminal/QTerminal.cc
+libgui_qterminal_libqterminal_la_SOURCES = \
+  libgui/qterminal/libqterminal/unix/BlockArray.cpp \
+  libgui/qterminal/libqterminal/unix/Emulation.cpp \
+  libgui/qterminal/libqterminal/unix/Filter.cpp \
+  libgui/qterminal/libqterminal/unix/History.cpp \
+  libgui/qterminal/libqterminal/unix/KeyboardTranslator.cpp \
+  libgui/qterminal/libqterminal/unix/konsole_wcwidth.cpp \
+  libgui/qterminal/libqterminal/unix/kpty.cpp \
+  libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp \
+  libgui/qterminal/libqterminal/unix/Screen.cpp \
+  libgui/qterminal/libqterminal/unix/ScreenWindow.cpp \
+  libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.cpp \
+  libgui/qterminal/libqterminal/unix/Vt102Emulation.cpp \
+  libgui/qterminal/libqterminal/unix/SelfListener.cpp \
+  libgui/qterminal/libqterminal/unix/TerminalModel.cpp \
+  libgui/qterminal/libqterminal/unix/TerminalView.cpp \
+  libgui/qterminal/libqterminal/QTerminal.cc
 
-qterminal_libqterminal_la_MOC += \
-  qterminal/libqterminal/unix/moc-Emulation.cc \
-  qterminal/libqterminal/unix/moc-Filter.cc \
-  qterminal/libqterminal/unix/moc-QUnixTerminalImpl.cc \
-  qterminal/libqterminal/unix/moc-ScreenWindow.cc \
-  qterminal/libqterminal/unix/moc-SelfListener.cc \
-  qterminal/libqterminal/unix/moc-TerminalModel.cc \
-  qterminal/libqterminal/unix/moc-TerminalView.cc \
-  qterminal/libqterminal/unix/moc-Vt102Emulation.cc
+OCTAVE_GUI_QTERMINAL_LIBQTERMINAL_UNIX_MOC = \
+  libgui/qterminal/libqterminal/unix/moc-Emulation.cc \
+  libgui/qterminal/libqterminal/unix/moc-Filter.cc \
+  libgui/qterminal/libqterminal/unix/moc-QUnixTerminalImpl.cc \
+  libgui/qterminal/libqterminal/unix/moc-ScreenWindow.cc \
+  libgui/qterminal/libqterminal/unix/moc-SelfListener.cc \
+  libgui/qterminal/libqterminal/unix/moc-TerminalModel.cc \
+  libgui/qterminal/libqterminal/unix/moc-TerminalView.cc \
+  libgui/qterminal/libqterminal/unix/moc-Vt102Emulation.cc
+
+libgui_qterminal_libqterminal_la_MOC += \
+  $(OCTAVE_GUI_QTERMINAL_LIBQTERMINAL_UNIX_MOC)
+
+$(OCTAVE_GUI_QTERMINAL_LIBQTERMINAL_UNIX_MOC): | libgui/qterminal/libqterminal/unix/$(octave_dirstamp)
+
+DIRSTAMP_FILES += \
+  libgui/qterminal/libqterminal/unix/$(octave_dirstamp)
 
 endif
 
-noinst_LTLIBRARIES += qterminal/libqterminal.la
+noinst_LTLIBRARIES += libgui/qterminal/libqterminal.la
 
-CLEANFILES += $(qterminal_libqterminal_la_MOC)
+libgui_CLEANFILES += $(libgui_qterminal_libqterminal_la_MOC)
--- a/libgui/qterminal/libqterminal/unix/kpty.cpp	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/qterminal/libqterminal/unix/kpty.cpp	Thu Dec 10 12:50:06 2015 -0800
@@ -176,14 +176,12 @@
 {
 }
 
-#ifndef HAVE_OPENPTY
 bool KPtyPrivate::chownpty(bool)
 {
 //    return !QProcess::execute(KStandardDirs::findExe("kgrantpty"),
 //        QStringList() << (grant?"--grant":"--revoke") << QString::number(masterFd));
     return true;
 }
-#endif
 
 /////////////////////////////
 // public member functions //
--- a/libgui/qterminal/libqterminal/unix/kpty_p.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/qterminal/libqterminal/unix/kpty_p.h	Thu Dec 10 12:50:06 2015 -0800
@@ -34,9 +34,8 @@
     KPtyPrivate(KPty* parent, int masterFd, int slaveFd);
 
     virtual ~KPtyPrivate();
-#ifndef HAVE_OPENPTY
+
     bool chownpty(bool grant);
-#endif
 
     int masterFd;
     int slaveFd;
--- a/libgui/src/dialog.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/dialog.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -265,7 +265,7 @@
     }
   listLayout->addWidget (view);
   QPushButton *select_all = new QPushButton (tr ("Select All"));
-  select_all->setEnabled (mode == "multiple");
+  select_all->setVisible (mode == "multiple");
   listLayout->addWidget (select_all);
 
   QPushButton *buttonOk = new QPushButton (ok_string);
@@ -274,6 +274,7 @@
   buttonsLayout->addStretch (1);
   buttonsLayout->addWidget (buttonOk);
   buttonsLayout->addWidget (buttonCancel);
+  buttonOk->setDefault (true);
 
   QVBoxLayout *mainLayout = new QVBoxLayout;
   mainLayout->addLayout (listLayout);
@@ -298,6 +299,9 @@
   connect (this, SIGNAL (finish_selection (const QIntList&, int)),
            &uiwidget_creator,
            SLOT (list_select_finished (const QIntList&, int)));
+
+  connect (view, SIGNAL (doubleClicked (const QModelIndex&)),
+           this, SLOT (item_double_clicked (const QModelIndex&)));
 }
 
 
@@ -338,6 +342,13 @@
 }
 
 
+void
+ListDialog::item_double_clicked (const QModelIndex&)
+{
+  buttonOk_clicked ();
+}
+
+
 InputDialog::InputDialog (const QStringList& prompt, const QString& title,
                           const QFloatList& nr, const QFloatList& nc,
                           const QStringList& defaults)
@@ -511,7 +522,7 @@
       path = directory ().absolutePath ();
     }
 
-  // Matlab expects just the file name, whereas the file dialog gave us
+  // Matlab expects just the filename, whereas the file dialog gave us
   // full path names, so fix it.
 
   for (int i = 0; i < string_result.size (); i++)
@@ -519,7 +530,7 @@
 
   // if not showing only dirs, add end slash for the path component
   if (testOption (QFileDialog::ShowDirsOnly)  == false)
-    path = path + "/";
+    path += "/";
 
   // convert to native slashes
   path = QDir::toNativeSeparators (path);
--- a/libgui/src/dialog.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/dialog.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_dialog_h)
+#if ! defined (octave_dialog_h)
 #define octave_dialog_h 1
 
 #include <QMutex>
@@ -210,6 +210,8 @@
   void buttonCancel_clicked (void);
 
   void reject (void);
+
+  void item_double_clicked (const QModelIndex&);
 };
 
 
--- a/libgui/src/files-dock-widget.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/files-dock-widget.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -69,6 +69,22 @@
   set_title (tr ("File Browser"));
   setToolTip (tr ("Browse your files"));
 
+  _sig_mapper = 0;
+
+  _columns_shown = QStringList ();
+  _columns_shown.append (tr ("File size"));
+  _columns_shown.append (tr ("File type"));
+  _columns_shown.append (tr ("Date modified"));
+  _columns_shown.append (tr ("Show hidden"));
+  _columns_shown.append (tr ("Alternating row colors"));
+
+  _columns_shown_keys = QStringList ();
+  _columns_shown_keys.append (tr ("filesdockwidget/showFileSize"));
+  _columns_shown_keys.append (tr ("filesdockwidget/showFileType"));
+  _columns_shown_keys.append (tr ("filesdockwidget/showLastModified"));
+  _columns_shown_keys.append (tr ("filesdockwidget/showHiddenFiles"));
+  _columns_shown_keys.append (tr ("filesdockwidget/useAlternatingRowColors"));
+
   QWidget *container = new QWidget (this);
 
   setWidget (container);
@@ -180,15 +196,6 @@
     }
 
   _file_system_model = new QFileSystemModel (this);
-  if (settings->value ("filesdockwidget/showHiddenFiles",false).toBool ())
-    {
-      _file_system_model->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries
-                                     | QDir::Hidden);
-    }
-  else
-    {
-      _file_system_model->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries);
-    }
   QModelIndex rootPathIndex = _file_system_model->setRootPath (
                                 startup_dir.absolutePath ());
 
@@ -283,6 +290,9 @@
   settings->setValue ("filesdockwidget/mru_dir_list", dirs);
 
   settings->sync ();
+
+  if (_sig_mapper)
+    delete _sig_mapper;
 }
 
 void
@@ -349,7 +359,6 @@
           _file_tree_view->setRootIndex (_file_system_model->
                                          index (fileInfo.absoluteFilePath ()));
           _file_system_model->setRootPath (fileInfo.absoluteFilePath ());
-          _file_system_model->sort (0, Qt::AscendingOrder);
           if (_sync_octave_dir && set_octave_dir)
             process_set_current_dir (fileInfo.absoluteFilePath ());
 
@@ -368,12 +377,21 @@
         {
           QString abs_fname = fileInfo.absoluteFilePath ();
 
+          QString suffix = fileInfo.suffix ().toLower ();
+          QSettings *settings = resource_manager::get_settings ();
+          QString ext = settings->value ("filesdockwidget/txt_file_extensions",
+                                         "m;c;cc;cpp;h;txt").toString ();
+          QStringList extensions = ext.split(";", QString::SkipEmptyParts);
+
           if (QFile::exists (abs_fname))
             {
               if (is_octave_data_file (abs_fname.toStdString ()))
                 emit load_file_signal (abs_fname);
+              else if (extensions.contains (suffix))
+                emit open_file (fileInfo.absoluteFilePath ());
               else
-                emit open_file (fileInfo.absoluteFilePath ());
+                open_item_in_app (_file_tree_view->selectionModel ()
+                                  ->currentIndex ());
             }
         }
     }
@@ -390,44 +408,29 @@
   QDesktopServices::openUrl (QUrl::fromLocalFile (file));
 }
 
-void files_dock_widget::toggle_headercontextitem_filesize ()
-{
-  QSettings *settings = resource_manager::get_settings ();
-  settings->setValue
-    ("filesdockwidget/showFileSize",
-     ! settings->value ("filesdockwidget/showFileSize",false).toBool ());
-  settings->sync ();
-  this->notice_settings (settings);
-}
-
-void files_dock_widget::toggle_headercontextitem_filetype ()
+void files_dock_widget::toggle_header (int col)
 {
   QSettings *settings = resource_manager::get_settings ();
-  settings->setValue
-    ("filesdockwidget/showFileType",
-     ! settings->value ("filesdockwidget/showFileType",false).toBool ());
+
+  QString key = _columns_shown_keys.at (col);
+  bool shown = settings->value (key,false).toBool ();
+  settings->setValue (key, ! shown);
   settings->sync ();
-  this->notice_settings (settings);
-}
 
-void files_dock_widget::toggle_headercontextitem_datemodified ()
-{
-  QSettings *settings = resource_manager::get_settings ();
-  settings->setValue
-    ("filesdockwidget/showLastModified",
-     ! settings->value ("filesdockwidget/showLastModified",false).toBool ());
-  settings->sync ();
-  this->notice_settings (settings);
-}
-
-void files_dock_widget::toggle_headercontextitem_showhidden ()
-{
-  QSettings *settings = resource_manager::get_settings ();
-  settings->setValue
-    ("filesdockwidget/showHiddenFiles",
-     ! settings->value ("filesdockwidget/showHiddenFiles",false).toBool ());
-  settings->sync ();
-  this->notice_settings (settings);
+  switch (col)
+    {
+      case 0:
+      case 1:
+      case 2:
+        // toggle column visibility
+        _file_tree_view->setColumnHidden (col + 1, shown);
+        break;
+      case 3:
+      case 4:
+        // other actions depending on new settings
+        notice_settings (settings);
+        break;
+    }
 }
 
 void
@@ -435,39 +438,23 @@
 {
   QMenu menu (this);
 
+  if (_sig_mapper)
+    delete _sig_mapper;
+  _sig_mapper = new QSignalMapper (this);
+
   QSettings *settings = resource_manager::get_settings ();
 
-  QAction fileSizeAction (tr ("File size"), &menu);
-  fileSizeAction.setCheckable (true);
-  fileSizeAction.setChecked (
-    settings->value ("filesdockwidget/showFileSize",false).toBool ());
-  connect (&fileSizeAction, SIGNAL(triggered ()),
-           this, SLOT (toggle_headercontextitem_filesize ()));
-  menu.addAction (&fileSizeAction);
-
-  QAction fileTypeAction (tr ("File type"), &menu);
-  fileTypeAction.setCheckable (true);
-  fileTypeAction.setChecked (
-    settings->value ("filesdockwidget/showFileType",false).toBool ());
-  connect (&fileTypeAction, SIGNAL(triggered ()),
-           this, SLOT (toggle_headercontextitem_filetype ()));
-  menu.addAction (&fileTypeAction);
+  for (int i = 0; i < _columns_shown.size (); i++)
+    {
+      QAction *action = menu.addAction (_columns_shown.at (i),
+                                        _sig_mapper, SLOT (map ()));
+      _sig_mapper->setMapping(action, i);
+      action->setCheckable (true);
+      action->setChecked (
+            settings->value (_columns_shown_keys.at (i),true).toBool ());
+    }
 
-  QAction dateModifiedAction (tr ("Date modified"), &menu);
-  dateModifiedAction.setCheckable (true);
-  dateModifiedAction.setChecked(
-    settings->value ("filesdockwidget/showLastModified",false).toBool ());
-  connect (&dateModifiedAction, SIGNAL(triggered ()),
-           this, SLOT (toggle_headercontextitem_datemodified ()));
-  menu.addAction (&dateModifiedAction);
-
-  QAction showHiddenAction (tr ("Show hidden"), &menu);
-  showHiddenAction.setCheckable (true);
-  showHiddenAction.setChecked (
-    settings->value ("filesdockwidget/showHiddenFiles",false).toBool ());
-  connect (&showHiddenAction, SIGNAL (triggered ()),
-           this, SLOT (toggle_headercontextitem_showhidden ()));
-  menu.addAction (&showHiddenAction);
+  connect (_sig_mapper, SIGNAL (mapped (int)), this, SLOT (toggle_header (int)));
 
   menu.exec (_file_tree_view->mapToGlobal (mpos));
 }
@@ -499,8 +486,16 @@
       menu.addAction (resource_manager::icon ("document-open"), tr ("Open"),
                       this, SLOT (contextmenu_open (bool)));
 
-      menu.addAction (tr ("Open in Default Application"),
-                      this, SLOT (contextmenu_open_in_app (bool)));
+      if (info.isDir ())
+        {
+          menu.addAction (tr ("Open in System File Explorer"),
+                          this, SLOT (contextmenu_open_in_app (bool)));
+        }
+
+      if (info.isFile ())
+        menu.addAction (tr ("Open in Text Editor"),
+                        this, SLOT (contextmenu_open_in_editor (bool)));
+
 
       menu.addAction (tr ("Copy Selection to Clipboard"),
                       this, SLOT (contextmenu_copy_selection (bool)));
@@ -557,12 +552,23 @@
     {
       QFileInfo file = _file_system_model->fileInfo (*it);
       if (file.exists ())
-        {
-          if (file.isFile ())
-            emit open_file (file.absoluteFilePath ());
-          else
-            set_current_directory (file.absoluteFilePath ());
-        }
+        display_directory (file.absoluteFilePath ());
+    }
+}
+
+
+void
+files_dock_widget::contextmenu_open_in_editor (bool)
+{
+
+  QItemSelectionModel *m = _file_tree_view->selectionModel ();
+  QModelIndexList rows = m->selectedRows ();
+
+  for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
+    {
+      QFileInfo file = _file_system_model->fileInfo (*it);
+      if (file.exists ())
+        emit open_file (file.absoluteFilePath ());
     }
 }
 
@@ -787,25 +793,19 @@
 
   _navigation_tool_bar->setIconSize (QSize (icon_size,icon_size));
 
-  // file names are always shown, other columns can be hidden by settings
-  _file_tree_view->setColumnHidden (0, false);
-  _file_tree_view->setColumnHidden (1,
-    ! settings->value ("filesdockwidget/showFileSize",false).toBool ());
-  _file_tree_view->setColumnHidden (2,
-    ! settings->value ("filesdockwidget/showFileType",false).toBool ());
-  _file_tree_view->setColumnHidden (3,
-    ! settings->value ("filesdockwidget/showLastModified",false).toBool ());
-  _file_tree_view->setAlternatingRowColors (
-    settings->value ("filesdockwidget/useAlternatingRowColors",true).toBool ());
-  if (settings->value ("filesdockwidget/showHiddenFiles",false).toBool ())
-    {
+  // filenames are always shown, other columns can be hidden by settings
+  for (int i = 0; i < 3; i++)
+     _file_tree_view->setColumnHidden (i + 1, ! settings->value (
+                                  _columns_shown_keys.at (i),false).toBool ());
+
+  if (settings->value (_columns_shown_keys.at (3),false).toBool ())
       _file_system_model->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries
                                      | QDir::Hidden);
-    }
   else
-    {
       _file_system_model->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries);
-    }
+
+  _file_tree_view->setAlternatingRowColors (
+    settings->value (_columns_shown_keys.at (4),true).toBool ());
   _file_tree_view->setModel (_file_system_model);
 
   // enable the buttons to sync octave/browser dir
--- a/libgui/src/files-dock-widget.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/files-dock-widget.h	Thu Dec 10 12:50:06 2015 -0800
@@ -35,6 +35,7 @@
 #include <QAction>
 #include <QTreeView>
 #include <QMouseEvent>
+#include <QSignalMapper>
 
 #include <QComboBox>
 #include "octave-dock-widget.h"
@@ -80,18 +81,15 @@
   void notice_settings (const QSettings *settings);
 
 private slots:
+
+  void headercontextmenu_requested (const QPoint& pos);
+  void toggle_header (int col);
+
   /** context menu wanted */
   void contextmenu_requested (const QPoint& pos);
-
-  void toggle_headercontextitem_filesize ();
-  void toggle_headercontextitem_filetype ();
-  void toggle_headercontextitem_datemodified ();
-  void toggle_headercontextitem_showhidden ();
-
-  void headercontextmenu_requested (const QPoint& pos);
-
   /* context menu actions */
   void contextmenu_open (bool);
+  void contextmenu_open_in_editor (bool);
   void contextmenu_open_in_app (bool);
   void contextmenu_copy_selection (bool);
   void contextmenu_run (bool);
@@ -160,6 +158,10 @@
   QString           _octave_dir;         // the actual octave dir
 
   enum { MaxMRUDirs = 10 };
+
+  QStringList _columns_shown;
+  QStringList _columns_shown_keys;
+  QSignalMapper *_sig_mapper;
 };
 
 #endif // FILESDOCKWIDGET_H
--- a/libgui/src/find-files-dialog.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/find-files-dialog.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -159,7 +159,7 @@
            this,          SLOT (close ()));
 
   // name options
-  QGroupBox * name_group = new QGroupBox (tr ("File name/location"));
+  QGroupBox * name_group = new QGroupBox (tr ("Filename/location"));
   QGridLayout * name_layout = new QGridLayout;
   name_group->setLayout (name_layout);
 
--- a/libgui/src/find-files-dialog.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/find-files-dialog.h	Thu Dec 10 12:50:06 2015 -0800
@@ -19,7 +19,7 @@
 <http://www.gnu.org/licenses/>.
 
 */
-#if !defined (octave_find_files_dialog_h)
+#if ! defined (octave_find_files_dialog_h)
 #define octave_find_files_dialog_h
 
 #include <QDialog>
--- a/libgui/src/find-files-model.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/find-files-model.h	Thu Dec 10 12:50:06 2015 -0800
@@ -19,7 +19,7 @@
 <http://www.gnu.org/licenses/>.
 
 */
-#if !defined (octave_find_files_model_h)
+#if ! defined (octave_find_files_model_h)
 #define octave_find_files_model_h
 
 #include <QAbstractListModel>
--- a/libgui/src/history-dock-widget.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/history-dock-widget.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -94,21 +94,29 @@
   set_title (tr ("Command History"));
   setWidget (new QWidget ());
 
-  QVBoxLayout *vbox_layout = new QVBoxLayout ();
-  QHBoxLayout *hbox_layout = new QHBoxLayout ();
-  hbox_layout->addWidget (filter_label);
-  hbox_layout->addWidget (_filter_checkbox);
-  hbox_layout->addWidget (_filter);
-  vbox_layout->addLayout (hbox_layout);
-  vbox_layout->addWidget (_history_list_view);
-  vbox_layout->setMargin (2);
+  _filter_widget = new QWidget (this);
+  QHBoxLayout *filter_layout = new QHBoxLayout ();
+  filter_layout->addWidget (filter_label);
+  filter_layout->addWidget (_filter_checkbox);
+  filter_layout->addWidget (_filter);
+  filter_layout->setMargin(0);
+  _filter_widget->setLayout (filter_layout);
 
-  widget ()->setLayout (vbox_layout);
+  QVBoxLayout *hist_layout = new QVBoxLayout ();
+  hist_layout->addWidget (_filter_widget);
+  hist_layout->addWidget (_history_list_view);
+
+  hist_layout->setMargin (2);
+  widget ()->setLayout (hist_layout);
 
   setFocusProxy (_filter->lineEdit ());
 
   // Init state of the filter
   QSettings *settings = resource_manager::get_settings ();
+
+  _filter_shown = settings->value ("history_dock_widget/filter_shown",true).toBool();
+  _filter_widget->setVisible (_filter_shown);
+
   _filter->addItems (settings->value ("history_dock_widget/mru_list").toStringList ());
 
   bool filter_state =
@@ -142,6 +150,7 @@
 
   settings->setValue ("history_dock_widget/filter_active",
                       _filter_checkbox->isChecked ());
+  settings->setValue ("history_dock_widget/filter_shown", _filter_shown);
 
   QStringList mru;
   for (int i = 0; i < _filter->count (); i++)
@@ -191,8 +200,15 @@
       menu.addAction (resource_manager::icon ("document-new"),
                   tr ("Create script"), this,
                   SLOT (handle_contextmenu_create_script (bool)));
-      menu.exec (_history_list_view->mapToGlobal (xpos));
     }
+  if (_filter_shown)
+    menu.addAction (tr ("Hide filter"), this,
+                    SLOT (handle_contextmenu_filter ()));
+  else
+    menu.addAction (tr ("Show filter"), this,
+                    SLOT (handle_contextmenu_filter ()));
+
+  menu.exec (_history_list_view->mapToGlobal (xpos));
 }
 
 void history_dock_widget::handle_contextmenu_copy (bool)
@@ -250,6 +266,12 @@
     emit command_create_script (text);
 }
 
+void
+history_dock_widget::handle_contextmenu_filter (void)
+{
+  _filter_shown = not _filter_shown;
+  _filter_widget->setVisible (_filter_shown);
+}
 
 void
 history_dock_widget::handle_double_click (QModelIndex modelIndex)
--- a/libgui/src/history-dock-widget.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/history-dock-widget.h	Thu Dec 10 12:50:06 2015 -0800
@@ -67,6 +67,7 @@
   void handle_contextmenu_copy (bool flag);
   void handle_contextmenu_evaluate (bool flag);
   void handle_contextmenu_create_script (bool flag);
+  void handle_contextmenu_filter (void);
   void ctxMenu (const QPoint &pos);
 
   void copyClipboard ();
@@ -86,6 +87,8 @@
 
   QCheckBox *_filter_checkbox;
   QComboBox *_filter;
+  QWidget *_filter_widget;
+  bool _filter_shown;
   enum { MaxFilterHistory = 10 };
 };
 
--- a/libgui/src/m-editor/file-editor-interface.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/m-editor/file-editor-interface.h	Thu Dec 10 12:50:06 2015 -0800
@@ -71,7 +71,9 @@
   virtual void request_new_script (const QString& command = QString ()) = 0;
   virtual void request_new_function (bool) = 0;
   virtual void request_open_file () = 0;
-  virtual void request_open_file (const QString& openFileName, int line = -1,
+  virtual void request_open_file (const QString& openFileName,
+                                  const QString& encoding = QString (),
+                                  int line = -1,
                                   bool debug_pointer = false,
                                   bool breakpoint_marker = false,
                                   bool insert = true) = 0;
--- a/libgui/src/m-editor/file-editor-tab.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/m-editor/file-editor-tab.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -49,6 +49,7 @@
 #include <QInputDialog>
 #include <QPrintDialog>
 #include <QDateTime>
+#include <QTextCodec>
 
 #include "file-editor-tab.h"
 #include "file-editor.h"
@@ -71,6 +72,7 @@
 {
   _lexer_apis = 0;
   _is_octave_file = true;
+  _lines_changed = false;
 
   _ced = directory_arg;
 
@@ -78,35 +80,47 @@
   _file_system_watcher.setObjectName ("_qt_autotest_force_engine_poller");
 
   _edit_area = new octave_qscintilla (this);
+  _line = 0;
+  _col  = 0;
 
   connect (_edit_area, SIGNAL (cursorPositionChanged (int, int)),
            this, SLOT (handle_cursor_moved (int,int)));
 
+  connect (_edit_area, SIGNAL (linesChanged ()),
+           this, SLOT (handle_lines_changed ()));
+
   connect (_edit_area, SIGNAL (context_menu_edit_signal (const QString&)),
            this, SLOT (handle_context_menu_edit (const QString&)));
 
   // create statusbar for row/col indicator and eol mode
   _status_bar = new QStatusBar (this);
 
-  // eol mode
-  QLabel *eol_label = new QLabel (tr ("eol:"), this);
-  _eol_indicator = new QLabel ("",this);
-  QFontMetrics fm = eol_label->fontMetrics ();
-  _eol_indicator->setMinimumSize (5*fm.averageCharWidth (),0);
-  _status_bar->addPermanentWidget (eol_label, 0);
-  _status_bar->addPermanentWidget (_eol_indicator, 0);
-
   // row- and col-indicator
   _row_indicator = new QLabel ("", this);
-  _row_indicator->setMinimumSize (5*fm.averageCharWidth (),0);
+  QFontMetrics fm = _row_indicator->fontMetrics ();
+  _row_indicator->setMinimumSize (4.5*fm.averageCharWidth (),0);
   QLabel *row_label = new QLabel (tr ("line:"), this);
   _col_indicator = new QLabel ("", this);
   _col_indicator->setMinimumSize (4*fm.averageCharWidth (),0);
   QLabel *col_label = new QLabel (tr ("col:"), this);
-  _status_bar->addPermanentWidget (row_label, 0);
-  _status_bar->addPermanentWidget (_row_indicator, 0);
-  _status_bar->addPermanentWidget (col_label, 0);
-  _status_bar->addPermanentWidget (_col_indicator, 0);
+  _status_bar->addWidget (row_label, 0);
+  _status_bar->addWidget (_row_indicator, 0);
+  _status_bar->addWidget (col_label, 0);
+  _status_bar->addWidget (_col_indicator, 0);
+
+  // status bar: encoding
+  QLabel *enc_label = new QLabel (tr ("encoding:"), this);
+  _enc_indicator = new QLabel ("",this);
+  _status_bar->addWidget (enc_label, 0);
+  _status_bar->addWidget (_enc_indicator, 0);
+  _status_bar->addWidget (new QLabel (" ", this), 0);
+
+  // status bar: eol mode
+  QLabel *eol_label = new QLabel (tr ("eol:"), this);
+  _eol_indicator = new QLabel ("",this);
+  _status_bar->addWidget (eol_label, 0);
+  _status_bar->addWidget (_eol_indicator, 0);
+  _status_bar->addWidget (new QLabel (" ", this), 0);
 
   // Leave the find dialog box out of memory until requested.
   _find_dialog = 0;
@@ -164,6 +178,18 @@
     notice_settings (settings, true);
 
   setFocusProxy (_edit_area);
+
+  // encoding, not updated with the settings
+#if defined (Q_OS_WIN32)
+  _encoding = settings->value ("editor/default_encoding","SYSTEM")
+                               .toString ();
+#else
+  _encoding = settings->value ("editor/default_encoding","UTF-8")
+                               .toString ();
+#endif
+  _enc_indicator->setText (_encoding);
+  // no changes in encoding yet
+  _new_encoding = _encoding;
 }
 
 file_editor_tab::~file_editor_tab (void)
@@ -186,6 +212,18 @@
 }
 
 void
+file_editor_tab::set_encoding (const QString& new_encoding)
+{
+  if (new_encoding.isEmpty ())
+    return;
+
+  _encoding = new_encoding;
+  _enc_indicator->setText (_encoding);
+  if (! _edit_area->text ().isEmpty ())
+    set_modified (true);
+}
+
+void
 file_editor_tab::closeEvent (QCloseEvent *e)
 {
   _cancelled = false;  // prevent unwanted interaction of previous
@@ -338,7 +376,7 @@
   emit editor_state_changed (_copy_available, _is_octave_file);
 
   // add the new file to the mru list
-  emit mru_add_file (_file_name);
+  emit mru_add_file (_file_name, _encoding);
 }
 
 // valid_file_name (file): checks whether "file" names a file
@@ -484,12 +522,12 @@
           _prep_apis_file = prep_apis_path + lexer->lexer () + "_k";
 
           if (octave_builtins)
-            _prep_apis_file = _prep_apis_file + "b";  // use builtins, too
+            _prep_apis_file += "b";  // use builtins, too
 
           if (octave_functions)
-            _prep_apis_file = _prep_apis_file + "f";  // use keywords, too
+            _prep_apis_file += "f";  // use keywords, too
 
-          _prep_apis_file = _prep_apis_file + ".pap"; // final name of apis file
+          _prep_apis_file += ".pap"; // final name of apis file
 
           // check whether the APIs info needs to be prepared and saved
           QFileInfo apis_file = QFileInfo (_prep_apis_file);
@@ -713,7 +751,7 @@
     {
       save_file (_file_name);  // save file dialog
       if (! valid_file_name ())
-        return;   // still invalid file name: "save as" was cancelled
+        return;   // still invalid filename: "save as" was cancelled
     }
 
   QFileInfo info (_file_name);
@@ -1348,8 +1386,12 @@
   if (!file.open (QFile::ReadOnly))
     return file.errorString ();
 
+  // read the file
   QTextStream in (&file);
-  in.setCodec("UTF-8");
+  // set the desired codec
+  QTextCodec *codec = QTextCodec::codecForName (_encoding.toAscii ());
+  in.setCodec(codec);
+
   QApplication::setOverrideCursor (Qt::WaitCursor);
   _edit_area->setText (in.readAll ());
   _edit_area->setEolMode (detect_eol_mode ());
@@ -1502,8 +1544,22 @@
     }
 
   // save the contents into the file
+
+  _encoding = _new_encoding;    // consider a possible new encoding
+
+  // set the desired codec (if suitable for contents)
+  QTextCodec *codec = QTextCodec::codecForName (_encoding.toAscii ());
+
+  if (check_valid_codec (codec))
+    {
+      save_file_as (remove_on_success);
+      return;
+    }
+
+  // write the file
   QTextStream out (&file);
-  out.setCodec("UTF-8");
+  out.setCodec (codec);
+
   QApplication::setOverrideCursor (Qt::WaitCursor);
   out << _edit_area->text ();
   out.flush ();
@@ -1515,14 +1571,15 @@
   file_info = QFileInfo (file);
   file_to_save = file_info.canonicalFilePath ();
 
-  // save file name after closing file as set_file_name starts watching again
+  // save filename after closing file as set_file_name starts watching again
   set_file_name (file_to_save);   // make absolute
 
-  // set the window title to actual file name (not modified)
+  // set the window title to actual filename (not modified)
   update_window_title (false);
 
-  // files is save -> not modified
+  // files is save -> not modified, update encoding in statusbar
   _edit_area->setModified (false);
+  _enc_indicator->setText (_encoding);
 
   if (remove_on_success)
     {
@@ -1537,6 +1594,9 @@
   // Simply put up the file chooser dialog box with a slot connection
   // then return control to the system waiting for a file selection.
 
+  // reset _new_encoding
+  _new_encoding = _encoding;
+
   // If the tab is removed in response to a QFileDialog signal, the tab
   // can't be a parent.
   QFileDialog* fileDialog;
@@ -1555,14 +1615,8 @@
   // it had/has no effect on Windows, though)
   fileDialog->setOption(QFileDialog::DontUseNativeDialog, true);
 
-  // get the dialog's layout for adding extra elements
-  QGridLayout *dialog_layout = dynamic_cast<QGridLayout*> (fileDialog->layout ());
-  int rows = dialog_layout->rowCount ();
-
   // define a new grid layout with the extra elements
   QGridLayout *extra = new QGridLayout (fileDialog);
-  QSpacerItem *spacer = new QSpacerItem (1,1,QSizePolicy::Expanding,
-                                             QSizePolicy::Fixed);
   QFrame *separator = new QFrame (fileDialog);
   separator->setFrameShape (QFrame::HLine);   // horizontal line as separator
   separator->setFrameStyle (QFrame::Sunken);
@@ -1576,18 +1630,32 @@
   _save_as_desired_eol = _edit_area->eolMode ();      // init with current eol
   combo_eol->setCurrentIndex (_save_as_desired_eol);
 
-  // track changes in the combo box
+  // combo box for encoding
+  QLabel *label_enc = new QLabel (tr ("File Encoding:"));
+  QComboBox *combo_enc = new QComboBox ();
+  resource_manager::combo_encoding (combo_enc, _encoding);
+
+  // track changes in the combo boxes
   connect (combo_eol, SIGNAL (currentIndexChanged (int)),
            this, SLOT (handle_combo_eol_current_index (int)));
+  connect (combo_enc, SIGNAL (currentIndexChanged (QString)),
+           this, SLOT (handle_combo_enc_current_index (QString)));
 
   // build the extra grid layout
-  extra->addWidget (separator,0,0,1,3);
+  extra->addWidget (separator,0,0,1,6);
   extra->addWidget (label_eol,1,0);
   extra->addWidget (combo_eol,1,1);
-  extra->addItem   (spacer,   1,2);
+  extra->addItem   (new QSpacerItem (1,20,QSizePolicy::Fixed,
+                                          QSizePolicy::Fixed), 1,2);
+  extra->addWidget (label_enc,1,3);
+  extra->addWidget (combo_enc,1,4);
+  extra->addItem   (new QSpacerItem (1,20,QSizePolicy::Expanding,
+                                          QSizePolicy::Fixed), 1,5);
 
   // and add the extra grid layout to the dialog's layout
-  dialog_layout->addLayout (extra,rows,0,1,dialog_layout->columnCount ());
+  QGridLayout *dialog_layout = dynamic_cast<QGridLayout*> (fileDialog->layout ());
+  dialog_layout->addLayout (extra,dialog_layout->rowCount (),0,
+                                  1,dialog_layout->columnCount ());
 
   // add the possible filters and the default suffix
   QStringList filters;
@@ -1647,6 +1715,12 @@
 }
 
 void
+file_editor_tab::handle_combo_enc_current_index (QString text)
+{
+  _new_encoding = text;
+}
+
+void
 file_editor_tab::handle_save_as_filter_selected (const QString& filter)
 {
   QFileDialog *file_dialog = qobject_cast<QFileDialog *> (sender ());
@@ -1672,7 +1746,7 @@
       int ans = QMessageBox::question (0, tr ("Octave Editor"),
          tr ("\"%1\"\n"
              "is not a valid identifier.\n\n"
-             "If you keep this file name, you will not be able to\n"
+             "If you keep this filename, you will not be able to\n"
              "call your script using its name as an Octave command.\n\n"
              "Do you want to choose another name?").arg (base_name),
           QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
@@ -1684,6 +1758,26 @@
   return false;
 }
 
+bool
+file_editor_tab::check_valid_codec (QTextCodec *codec)
+{
+  if (! codec->canEncode (_edit_area->text ()))
+    {
+      int ans = QMessageBox::warning (0,
+            tr ("Octave Editor"),
+            tr ("The current editor contents can not be encoded\n"
+                "with the selected codec %1.\n"
+                "Using it will result in data loss!\n\n"
+                "Do you want to chose another codec?").arg (_encoding),
+            QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+
+      if (ans == QMessageBox::Yes)
+        return true;
+    }
+
+  return false;
+}
+
 void
 file_editor_tab::handle_save_file_as_answer (const QString& saveFileName)
 {
@@ -1692,7 +1786,6 @@
 
   if (saveFileName == _file_name)
     {
-      // same name as actual file, save it as "save" would do
       save_file (saveFileName);
     }
   else
@@ -1716,7 +1809,7 @@
     }
 
   // saveFileName == _file_name can not happen, because we only can get here
-  // when we close a tab and _file_name is not a valid file name yet
+  // when we close a tab and _file_name is not a valid filename yet
 
   // Have editor check for conflict, delete tab after save.
   if (check_valid_identifier (saveFileName))
@@ -1880,6 +1973,7 @@
 
   _edit_area->setAutoIndent
         (settings->value ("editor/auto_indent",true).toBool ());
+  _smart_indent = settings->value ("editor/auto_indent",true).toBool ();
   _edit_area->setTabIndents
         (settings->value ("editor/tab_indents_line",false).toBool ());
   _edit_area->setBackspaceUnindents
@@ -1969,7 +2063,7 @@
 
   // Unnamed files shouldn't be transmitted.
   if (!_file_name.isEmpty ())
-    emit add_filename_to_list (_file_name, this);
+    emit add_filename_to_list (_file_name, _encoding, this);
 }
 
 void
@@ -2065,15 +2159,82 @@
 }
 
 void
+file_editor_tab::handle_lines_changed ()
+{
+  // the related signal is emitted before cursor-move-signal!
+  _lines_changed = true;
+}
+
+void
 file_editor_tab::handle_cursor_moved (int line, int col)
 {
   if (_edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCACTIVE))
     show_auto_completion (this);
 
+  if (_lines_changed)  // check for smart indentation
+    {
+      _lines_changed = false;
+      if (_is_octave_file && _smart_indent && line == _line+1 && col < _col)
+        do_smart_indent ();
+    }
+
+  _line = line;
+  _col  = col;
+
   _row_indicator->setNum (line+1);
   _col_indicator->setNum (col+1);
 }
 
+void
+file_editor_tab::do_smart_indent ()
+{
+  QString prev_line = _edit_area->text (_line);
+
+  QRegExp bkey = QRegExp ("^[\t ]*(if|for|while|switch|case|do|function"
+                          "|unwind_protect|unwind_protect_cleanup|try)"
+                          "[\n\t #%]");
+  if (prev_line.contains (bkey))
+    {
+      _edit_area->indent (_line+1);
+      _edit_area->setCursorPosition (_line+1,
+                                     _edit_area->indentation (_line) +
+                                     _edit_area->indentationWidth ());
+      return;
+    }
+
+  QRegExp mkey = QRegExp ("^[\t ]*(else|elseif|catch)[\t #%\n]");
+  if (prev_line.contains (mkey))
+    {
+      int prev_ind = _edit_area->indentation (_line-1);
+      int act_ind = _edit_area->indentation (_line);
+
+      if (prev_ind == act_ind)
+        _edit_area->unindent (_line);
+      else if (prev_ind > act_ind)
+        {
+          _edit_area->setIndentation (_line+1, prev_ind);
+          _edit_area->setCursorPosition (_line+1, prev_ind);
+        }
+      return;
+    }
+
+  QRegExp ekey = QRegExp ("^[\t ]*(end|endif|endfor|endwhile|until|endfunction"
+                          "|end_try_catch|end_unwind_protext)[\t #%\n(;]");
+  if (prev_line.contains (ekey))
+    {
+      if (_edit_area->indentation (_line-1) <= _edit_area->indentation (_line))
+        {
+          _edit_area->unindent (_line+1);
+          _edit_area->unindent (_line);
+          _edit_area->setCursorPosition (_line+1,
+                                         _edit_area->indentation (_line));
+        }
+      return;
+    }
+
+}
+
+
 QString
 file_editor_tab::get_function_name ()
 {
--- a/libgui/src/m-editor/file-editor-tab.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/m-editor/file-editor-tab.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_file_editor_tab_h)
+#if ! defined (octave_file_editor_tab_h)
 #define octave_file_editor_tab_h 1
 
 #include <QWidget>
@@ -70,7 +70,7 @@
   // Change to a different editor tab by identifier tag.
   void change_editor_state (const QWidget *ID);
 
-  // Simply transmit file name.
+  // Simply transmit filename.
   void file_name_query (const QWidget *ID);
 
   void set_focus (const QWidget *ID);
@@ -120,7 +120,10 @@
 
   void set_modified (bool modified = true);
 
+  void set_encoding (const QString& new_encoding);
+
   QString load_file (const QString& fileName);
+
   void new_file (const QString& commands = QString ());
 
   void file_has_changed (const QString& fileName);
@@ -132,8 +135,8 @@
   void file_name_changed (const QString& fileName, const QString& toolTip);
   void editor_state_changed (bool copy_available, bool is_octave_file);
   void tab_remove_request ();
-  void add_filename_to_list (const QString&, QWidget *);
-  void mru_add_file (const QString& file_name);
+  void add_filename_to_list (const QString&, const QString&, QWidget *);
+  void mru_add_file (const QString& file_name, const QString& encoding);
   void editor_check_conflict_save (const QString& saveFileName,
                                    bool remove_on_success);
   void run_file_signal (const QFileInfo& info);
@@ -165,6 +168,7 @@
   void handle_save_file_as_answer_cancel ();
   void handle_save_as_filter_selected (const QString& filter);
   void handle_combo_eol_current_index (int index);
+  void handle_combo_enc_current_index (QString text);
 
   // When apis preparation has finished and is ready to save
   void save_apis_info ();
@@ -173,6 +177,7 @@
   void auto_margin_width ();
 
   void handle_cursor_moved (int line, int col);
+  void handle_lines_changed (void);
 
 private:
 
@@ -197,6 +202,7 @@
   void save_file (const QString& saveFileName, bool remove_on_success = false);
   void save_file_as (bool remove_on_success = false);
   bool check_valid_identifier (QString file_name);
+  bool check_valid_codec (QTextCodec *codec);
 
   void update_lexer ();
   void request_add_breakpoint (int line);
@@ -216,6 +222,8 @@
   void add_octave_apis (octave_value_list key_ovl);
   QString get_function_name ();
 
+  void do_smart_indent (void);
+
   QsciScintilla::EolMode detect_eol_mode ();
   void update_eol_indicator ();
 
@@ -225,17 +233,21 @@
   QLabel *_row_indicator;
   QLabel *_col_indicator;
   QLabel *_eol_indicator;
+  QLabel *_enc_indicator;
 
   QsciScintilla::EolMode _save_as_desired_eol;
 
   QString _file_name;
   QString _file_name_short;
   QString _ced;
+  QString _encoding;
+  QString _new_encoding;
 
   bool _long_title;
   bool _copy_available;
   bool _is_octave_file;
   bool _always_reload_changed_files;
+  bool _smart_indent;
 
   QFileSystemWatcher _file_system_watcher;
 
@@ -247,6 +259,10 @@
   QString _prep_apis_file;
 
   static bool _cancelled;
+
+  int _line;
+  int _col;
+  bool _lines_changed;
 };
 
 #endif
--- a/libgui/src/m-editor/file-editor.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/m-editor/file-editor.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -57,8 +57,9 @@
   construct ();
 
   setVisible (false);
+  setAcceptDrops(true);
 
-  setAcceptDrops(true);
+  _file_encoding = QString ();  // for selecting an encoding in open dialog
 }
 
 file_editor::~file_editor (void)
@@ -73,21 +74,34 @@
   // Save open files for restoring in next session; this only is possible
   QSettings *settings = resource_manager::get_settings ();
 
-  // Have all file editor tabs signal what their file names are.
+  // Have all file editor tabs signal what their filenames are.
   editor_tab_map.clear ();
   emit fetab_file_name_query (0);
 
-  // save file names (even if last session will not be restored next time)
+  // save filenames (even if last session will not be restored next time)
+  // together with encoding and the tab index
   QStringList fetFileNames;
+  QStringList fet_encodings;
+  QStringList fet_index;
+
+  // over all open tabs
   for (editor_tab_map_const_iterator p = editor_tab_map.begin ();
        p != editor_tab_map.end (); p++)
     {
-      QString file_name = p->first;
-      if (!file_name.isEmpty ())
-        fetFileNames.append (p->first);  // do not append unnamed files
+      QString file_name = p->first;   // get file name of tab
+      if (!file_name.isEmpty ())      // do not append unnamed files
+        {
+          fetFileNames.append (file_name);
+          fet_encodings.append (editor_tab_map[file_name].encoding);
+          QString index;
+          fet_index.append (index.setNum
+             (_tab_widget->indexOf (editor_tab_map[file_name].fet_ID)));
+        }
     }
 
   settings->setValue ("editor/savedSessionTabs", fetFileNames);
+  settings->setValue ("editor/saved_session_encodings", fet_encodings);
+  settings->setValue ("editor/saved_session_tab_index", fet_index);
   settings->sync ();
 
   // Save all tabs with confirmation.
@@ -230,6 +244,34 @@
   // it had/has no effect on Windows, though)
   fileDialog->setOption(QFileDialog::DontUseNativeDialog, true);
 
+  // define a new grid layout with the extra elements
+  QGridLayout *extra = new QGridLayout (fileDialog);
+  QFrame *separator = new QFrame (fileDialog);
+  separator->setFrameShape (QFrame::HLine);   // horizontal line as separator
+  separator->setFrameStyle (QFrame::Sunken);
+
+  // combo box for encoding
+  QLabel *label_enc = new QLabel (tr ("File Encoding:"));
+  QComboBox *combo_enc = new QComboBox ();
+  resource_manager::combo_encoding (combo_enc);
+  _file_encoding = QString ();  // default, no special encoding
+
+  // track changes in the combo boxes
+  connect (combo_enc, SIGNAL (currentIndexChanged (QString)),
+           this, SLOT (handle_combo_enc_current_index (QString)));
+
+  // build the extra grid layout
+  extra->addWidget (separator,0,0,1,3);
+  extra->addWidget (label_enc,1,0);
+  extra->addWidget (combo_enc,1,1);
+  extra->addItem   (new QSpacerItem (1,20,QSizePolicy::Expanding,
+                                          QSizePolicy::Fixed), 1,2);
+
+  // and add the extra grid layout to the dialog's layout
+  QGridLayout *dialog_layout = dynamic_cast<QGridLayout*> (fileDialog->layout ());
+  dialog_layout->addLayout (extra,dialog_layout->rowCount (),0,
+                                  1,dialog_layout->columnCount ());
+
   fileDialog->setAcceptMode (QFileDialog::AcceptOpen);
   fileDialog->setViewMode (QFileDialog::Detail);
   fileDialog->setFileMode (QFileDialog::ExistingFiles);
@@ -243,6 +285,12 @@
   fileDialog->show ();
 }
 
+void
+file_editor::handle_combo_enc_current_index (QString new_encoding)
+{
+  _file_encoding = new_encoding;
+}
+
 // Check whether this file is already open in the editor.
 QWidget *
 file_editor::find_tab_widget (const QString& file) const
@@ -256,7 +304,7 @@
 
       if (same_file (file.toStdString (), tab_file.toStdString ()))
         {
-          retval = p->second;
+          retval = p->second.fet_ID;
           break;
         }
     }
@@ -296,7 +344,8 @@
         }
 
       if (line < 0 && ! file_name.isEmpty ())
-        handle_mru_add_file (QFileInfo (file_name).canonicalFilePath ());
+        handle_mru_add_file (QFileInfo (file_name).canonicalFilePath (),
+                             QString ());
 
       return true;
     }
@@ -321,16 +370,20 @@
   return false;
 }
 
+// The following slot is called after files have been selected in the
+// open file dialog, possibly with a new selected encoding stored in
+// _file_encoding
 void
 file_editor::request_open_files (const QStringList& open_file_names)
 {
   for (int i = 0; i < open_file_names.count (); i++)
-    request_open_file (open_file_names.at (i));
+    request_open_file (open_file_names.at (i), _file_encoding);
 }
 
 void
-file_editor::request_open_file (const QString& openFileName, int line,
-                                bool debug_pointer,
+file_editor::request_open_file (const QString& openFileName,
+                                const QString& encoding,
+                                int line, bool debug_pointer,
                                 bool breakpoint_marker, bool insert)
 {
   if (call_custom_editor (openFileName, line))
@@ -344,7 +397,7 @@
     }
   else
     {
-      // Have all file editor tabs signal what their file names are.
+      // Have all file editor tabs signal what their filenames are.
       editor_tab_map.clear ();
       emit fetab_file_name_query (0);
 
@@ -377,6 +430,7 @@
           file_editor_tab *fileEditorTab = new file_editor_tab ();
           if (fileEditorTab)
             {
+              fileEditorTab->set_encoding (encoding);
               QString result = fileEditorTab->load_file (openFileName);
               if (result == "")
                 {
@@ -386,7 +440,8 @@
                   fileEditorTab->update_window_title (false);
                   // file already loaded, add file to mru list here
                   QFileInfo file_info = QFileInfo (openFileName);
-                  handle_mru_add_file (file_info.canonicalFilePath ());
+                  handle_mru_add_file (file_info.canonicalFilePath (),
+                                       encoding);
 
                   if (line > 0)
                     {
@@ -489,7 +544,8 @@
 {
   if (action)
     {
-      request_open_file (action->data ().toString ());
+      request_open_file (action->data ().toStringList ().at (0),
+                         action->data ().toStringList ().at (1));
     }
 }
 
@@ -498,7 +554,7 @@
 file_editor::check_conflict_save (const QString& saveFileName,
                                   bool remove_on_success)
 {
-  // Have all file editor tabs signal what their file names are.
+  // Have all file editor tabs signal what their filenames are.
   editor_tab_map.clear ();
   emit fetab_file_name_query (0);
 
@@ -563,7 +619,7 @@
 file_editor::handle_insert_debugger_pointer_request (const QString& file,
                                                      int line)
 {
-  request_open_file (file, line, true);
+  request_open_file (file, QString (), line, true); // default encoding
 }
 
 void
@@ -572,7 +628,7 @@
 {
   if (! file.isEmpty ())
     {
-      // Have all file editor tabs signal what their file names are.
+      // Have all file editor tabs signal what their filenames are.
       editor_tab_map.clear ();
       emit fetab_file_name_query (0);
 
@@ -596,7 +652,7 @@
                                                       const QString& file,
                                                       int line)
 {
-  request_open_file (file, line, false, true, insert);
+  request_open_file (file, QString (), line, false, true, insert);
 }
 
 void
@@ -885,13 +941,18 @@
 }
 
 void
-file_editor::handle_mru_add_file (const QString& file_name)
+file_editor::handle_mru_add_file (const QString& file_name,
+                                  const QString& encoding)
 {
-  if (_mru_files.count () && _mru_files.at (0) == file_name)
-    return;  // the first entry is already the actual file name
+  int index;
+  while ((index = _mru_files.indexOf (file_name)) >= 0)
+    {
+      _mru_files.removeAt (index);
+      _mru_files_encodings.removeAt (index);
+    }
 
-  _mru_files.removeAll (file_name);
   _mru_files.prepend (file_name);
+  _mru_files_encodings.prepend (encoding);
 
   mru_menu_update ();
 }
@@ -907,7 +968,11 @@
       QString text = tr ("&%1 %2").
                      arg ((i+1) % int (MaxMRUFiles)).arg (_mru_files.at (i));
       _mru_file_actions[i]->setText (text);
-      _mru_file_actions[i]->setData (_mru_files.at (i));
+
+      QStringList action_data;
+      action_data << _mru_files.at (i) << _mru_files_encodings.at (i);
+      _mru_file_actions[i]->setData (action_data);
+
       _mru_file_actions[i]->setVisible (true);
     }
 
@@ -917,13 +982,16 @@
 
   // delete entries in string-list beyond MaxMRUFiles
   while (_mru_files.size () > MaxMRUFiles)
-    _mru_files.removeLast ();
+    {
+      _mru_files.removeLast ();
+      _mru_files_encodings.removeLast ();
+    }
 
   // save actual mru-list in settings
   QSettings *settings = resource_manager::get_settings ();
 
-  // FIXME: what should happen if settings is 0?
   settings->setValue ("editor/mru_file_list", _mru_files);
+  settings->setValue ("editor/mru_file_encodings", _mru_files_encodings);
   settings->sync ();
 }
 
@@ -1015,11 +1083,12 @@
 }
 
 void
-file_editor::handle_add_filename_to_list (const QString& fileName, QWidget *ID)
+file_editor::handle_add_filename_to_list (const QString& fileName,
+                                          const QString& encoding, QWidget *ID)
 {
   // Should we allow multiple tabs for a single file?
-
-  editor_tab_map[fileName] = ID;
+  editor_tab_map[fileName].fet_ID = ID;
+  editor_tab_map[fileName].encoding = encoding;
 }
 
 // context menu of edit area
@@ -1198,7 +1267,7 @@
   _fileMenu->insertAction (_mru_file_menu->menuAction (), open_action);
   _fileMenu->insertAction (open_action, new_fcn_action);
   _fileMenu->insertAction (new_fcn_action, new_action);
-  _tool_bar->insertAction (_save_action, open_action);
+  _tool_bar->insertAction (_popdown_mru_action, open_action);
   _tool_bar->insertAction (open_action, new_action);
 }
 
@@ -1206,9 +1275,19 @@
 file_editor::add_action (QMenu *menu, const QIcon &icon, const QString &text,
                          const char *member)
 {
-  QAction *a = menu->addAction (icon, text, this, member);
+  QAction *a;
+
+  if (menu)
+    a = menu->addAction (icon, text, this, member);
+  else
+    {
+      a = new QAction (this);
+      connect (a, SIGNAL (triggered ()), this, member);
+    }
+
   addAction (a);  // important for shortcut context
   a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
+
   return a;
 }
 
@@ -1256,7 +1335,7 @@
 #endif
   _tool_bar = new QToolBar (editor_widget);
   _tool_bar->setMovable (true);
-  _tab_widget = new QTabWidget (editor_widget);
+  _tab_widget = new tab_widget (editor_widget);
   _tab_widget->setTabsClosable (true);
 #ifdef HAVE_QTABWIDGET_SETMOVABLE
   _tab_widget->setMovable (true);
@@ -1266,6 +1345,16 @@
   // the mru-list and an empty array of actions
   QSettings *settings = resource_manager::get_settings ();
   _mru_files = settings->value ("editor/mru_file_list").toStringList ();
+  _mru_files_encodings = settings->value ("editor/mru_file_encodings")
+                                   .toStringList ();
+
+  if (_mru_files_encodings.count () != _mru_files.count ())
+    { // encodings don't have the same count -> do not use them!
+      _mru_files_encodings = QStringList ();
+      for (int i = 0; i < _mru_files.count (); i++)
+        _mru_files_encodings << QString ();
+    }
+
   for (int i = 0; i < MaxMRUFiles; ++i)
     {
       _mru_file_actions[i] = new QAction (this);
@@ -1516,9 +1605,28 @@
   _context_doc_action = add_action (_help_menu, QIcon (),
           tr ("&Documentation on Keyword"), SLOT (request_context_doc (bool)));
 
+  // tab navigation (no menu, only actions)
+
+  _switch_left_tab_action = add_action (0, QIcon (), "",
+                                        SLOT (switch_left_tab ()));
+  _switch_right_tab_action = add_action (0, QIcon (), "",
+                                         SLOT (switch_right_tab ()));
+  _move_tab_left_action = add_action (0, QIcon (), "",
+                                      SLOT (move_tab_left ()));
+  _move_tab_right_action = add_action (0, QIcon (), "",
+                                       SLOT (move_tab_right ()));
+
   // toolbar
 
+  // popdown menu with mru files
+  QToolButton *popdown_button = new QToolButton ();
+  popdown_button->setToolTip (tr ("Recent Files"));
+  popdown_button->setMenu (_mru_file_menu);
+  popdown_button->setPopupMode (QToolButton::InstantPopup);
+  popdown_button->setToolButtonStyle (Qt::ToolButtonTextOnly);
+
   // new and open actions are inserted later from main window
+  _popdown_mru_action = _tool_bar->addWidget (popdown_button);
   _tool_bar->addAction (_save_action);
   _tool_bar->addAction (_save_as_action);
   _tool_bar->addSeparator ();
@@ -1576,22 +1684,52 @@
   setWindowIcon (QIcon (":/actions/icons/logo.png"));
   set_title (tr ("Editor"));
 
+  restore_session (settings);
+
+  check_actions ();
+}
+
+void
+file_editor::restore_session (QSettings *settings)
+{
   //restore previous session
-  if (settings->value ("editor/restoreSession", true).toBool ())
-    {
-      QStringList sessionFileNames
-        = settings->value ("editor/savedSessionTabs",
-                           QStringList ()).toStringList ();
+  if (! settings->value ("editor/restoreSession", true).toBool ())
+    return;
+
+  // get the data from the settings file
+  QStringList sessionFileNames = settings->value ("editor/savedSessionTabs",
+                                          QStringList ()).toStringList ();
+  QStringList session_encodings = settings->value ("editor/saved_session_encodings",
+                                          QStringList ()).toStringList ();
+  QStringList session_index = settings->value ("editor/saved_session_tab_index",
+                                          QStringList ()).toStringList ();
 
-      for (int n = 0; n < sessionFileNames.count (); ++n)
-        {
-          QFileInfo file = QFileInfo (sessionFileNames.at (n));
-          if (file.exists ())
-            request_open_file (sessionFileNames.at (n));
-        }
+  // fill a list of the struct and sort it (depending on index)
+  QList<session_data> s_data;
+
+  bool do_encoding = (session_encodings.count () == sessionFileNames.count ());
+  bool do_index    = (session_index.count () == sessionFileNames.count ());
+
+  for (int n = 0; n < sessionFileNames.count (); ++n)
+    {
+      QFileInfo file = QFileInfo (sessionFileNames.at (n));
+      if (! file.exists ())
+        continue;
+
+      session_data item = { QString (), sessionFileNames.at (n), QString ()};
+      if (do_index)
+        item.index = session_index.at (n);
+      if (do_encoding)
+        item.encoding = session_encodings.at (n);
+
+     s_data << item;
     }
 
-  check_actions ();
+  qSort (s_data);
+
+  // finally open the file with the desired encoding in the desired order
+  for (int n = 0; n < s_data.count (); ++n)
+    request_open_file (s_data.at (n).file_name, s_data.at (n).encoding);
 }
 
 void
@@ -1623,14 +1761,16 @@
   connect (f, SIGNAL (tab_remove_request ()),
            this, SLOT (handle_tab_remove_request ()));
 
-  connect (f, SIGNAL (add_filename_to_list (const QString&, QWidget*)),
-           this, SLOT (handle_add_filename_to_list (const QString&, QWidget*)));
+  connect (f, SIGNAL (add_filename_to_list (const QString&,
+                                            const QString&, QWidget*)),
+           this, SLOT (handle_add_filename_to_list (const QString&,
+                                                    const QString&, QWidget*)));
 
   connect (f, SIGNAL (editor_check_conflict_save (const QString&, bool)),
            this, SLOT (check_conflict_save (const QString&, bool)));
 
-  connect (f, SIGNAL (mru_add_file (const QString&)),
-           this, SLOT (handle_mru_add_file (const QString&)));
+  connect (f, SIGNAL (mru_add_file (const QString&, const QString&)),
+           this, SLOT (handle_mru_add_file (const QString&, const QString&)));
 
   connect (f, SIGNAL (run_file_signal (const QFileInfo&)),
            main_win (), SLOT (run_file_in_terminal (const QFileInfo&)));
@@ -1873,6 +2013,12 @@
   shortcut_manager::set_shortcut (_context_help_action, "editor_help:help_keyword");
   shortcut_manager::set_shortcut (_context_doc_action,  "editor_help:doc_keyword");
 
+  // Tab navigation without menu entries
+  shortcut_manager::set_shortcut (_switch_left_tab_action, "editor_tabs:switch_left_tab");
+  shortcut_manager::set_shortcut (_switch_right_tab_action, "editor_tabs:switch_right_tab");
+  shortcut_manager::set_shortcut (_move_tab_left_action, "editor_tabs:move_tab_left");
+  shortcut_manager::set_shortcut (_move_tab_right_action, "editor_tabs:move_tab_right");
+
 }
 
 void
@@ -2000,4 +2146,56 @@
       }
   }
 
+// slots for tab navigation
+void
+file_editor::switch_left_tab ()
+{
+  switch_tab (-1);
+}
+void
+file_editor::switch_right_tab ()
+{
+  switch_tab (1);
+}
+void
+file_editor::move_tab_left ()
+{
+#ifdef HAVE_QTABWIDGET_SETMOVABLE
+  switch_tab (-1, true);
 #endif
+}
+void
+file_editor::move_tab_right ()
+{
+#ifdef HAVE_QTABWIDGET_SETMOVABLE
+  switch_tab (1, true);
+#endif
+}
+void
+file_editor::switch_tab (int direction, bool movetab)
+{
+  int tabs = _tab_widget->count ();
+
+  if (tabs < 2)
+    return;
+
+  int old_pos = _tab_widget->currentIndex ();
+  int new_pos = _tab_widget->currentIndex () + direction;
+
+  if (new_pos < 0 || new_pos >= tabs)
+    new_pos = new_pos - direction*tabs;
+
+  if (movetab)
+    {
+#ifdef HAVE_QTABWIDGET_SETMOVABLE
+      _tab_widget->tabBar ()->moveTab (old_pos, new_pos);
+      _tab_widget->setCurrentIndex (old_pos);
+      _tab_widget->setCurrentIndex (new_pos);
+      focus ();
+#endif
+    }
+  else
+    _tab_widget->setCurrentIndex (new_pos);
+}
+
+#endif
--- a/libgui/src/m-editor/file-editor.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/m-editor/file-editor.h	Thu Dec 10 12:50:06 2015 -0800
@@ -39,14 +39,43 @@
 #include "file-editor-interface.h"
 #include "file-editor-tab.h"
 
+// subclassed QTabWidget for usable tab-bar
+class tab_widget : public QTabWidget
+{
+  Q_OBJECT
+
+public:
+  tab_widget (QWidget *p) : QTabWidget (p) { }
+  ~tab_widget () { }
+  QTabBar* tabBar() const { return (QTabWidget::tabBar()); }
+};
+
 class file_editor : public file_editor_interface
 {
   Q_OBJECT
 
 public:
 
-  typedef std::map<QString, QWidget *>::iterator editor_tab_map_iterator;
-  typedef std::map<QString, QWidget *>::const_iterator editor_tab_map_const_iterator;
+  struct tab_info
+    {
+      QWidget *fet_ID;
+      QString  encoding;
+    };
+
+  typedef std::map<QString, tab_info>::iterator editor_tab_map_iterator;
+  typedef std::map<QString, tab_info>::const_iterator editor_tab_map_const_iterator;
+
+  // struct that allows to sort with respect to the tab index
+  struct session_data
+    {
+      QString index;
+      QString file_name;
+      QString encoding;
+      bool operator<(const session_data &other) const
+        {
+          return index < other.index;
+        }
+    };
 
   file_editor (QWidget *p);
   ~file_editor (void);
@@ -187,10 +216,11 @@
                                  const QString& toolTip);
   void handle_tab_close_request (int index);
   void handle_tab_remove_request (void);
-  void handle_add_filename_to_list (const QString& fileName, QWidget *ID);
+  void handle_add_filename_to_list (const QString& fileName,
+                                    const QString& encoding, QWidget *ID);
   void active_tab_changed (int index);
   void handle_editor_state_changed (bool enableCopy, bool is_octave_file);
-  void handle_mru_add_file (const QString& file_name);
+  void handle_mru_add_file (const QString& file_name, const QString& encoding);
   void check_conflict_save (const QString& fileName, bool remove_on_success);
 
   void handle_insert_debugger_pointer_request (const QString& file, int line);
@@ -218,13 +248,16 @@
 private slots:
 
   void request_open_files (const QStringList&);
-  void request_open_file (const QString& fileName, int line = -1,
-                          bool debug_pointer = false,
+  void request_open_file (const QString& fileName,
+                          const QString& encoding = QString (),
+                          int line = -1, bool debug_pointer = false,
                           bool breakpoint_marker = false, bool insert = true);
   void request_preferences (bool);
   void request_styles_preferences (bool);
   void restore_create_file_setting ();
 
+  void handle_combo_enc_current_index (QString new_encoding);
+
   void show_line_numbers (bool);
   void show_white_space (bool);
   void show_eol_chars (bool);
@@ -234,6 +267,11 @@
   void zoom_out (bool);
   void zoom_normal (bool);
 
+  void switch_left_tab ();
+  void switch_right_tab ();
+  void move_tab_left ();
+  void move_tab_right ();
+
   void create_context_menu (QMenu *);
   void edit_status_update (bool, bool);
 
@@ -253,6 +291,10 @@
 
   void toggle_preference (const QString& preference, bool def);
 
+  void switch_tab (int direction, bool movetab = false);
+
+  void restore_session (QSettings *settings);
+
   bool editor_tab_has_focus ();
 
   QWidget *find_tab_widget (const QString& openFileName) const;
@@ -261,7 +303,7 @@
 
   QMenu* m_add_menu (QMenuBar *p, QString text);
 
-  std::map<QString, QWidget *> editor_tab_map;
+  std::map<QString, tab_info> editor_tab_map;
   QHash<QMenu*, QStringList> _hash_menu_text;
 
   QString ced;
@@ -326,6 +368,7 @@
   QAction *_run_selection_action;
 
   QAction *_edit_function_action;
+  QAction *_popdown_mru_action;
   QAction *_save_action;
   QAction *_save_as_action;
   QAction *_close_action;
@@ -338,6 +381,11 @@
   QAction *_preferences_action;
   QAction *_styles_preferences_action;
 
+  QAction *_switch_left_tab_action;
+  QAction *_switch_right_tab_action;
+  QAction *_move_tab_left_action;
+  QAction *_move_tab_right_action;
+
   QAction *_toggle_breakpoint_action;
   QAction *_next_breakpoint_action;
   QAction *_previous_breakpoint_action;
@@ -349,14 +397,17 @@
   QMenu *_fileMenu;
   QMenu *_view_editor_menu;
 
-  QTabWidget *_tab_widget;
+  tab_widget *_tab_widget;
 
   int _marker_breakpoint;
 
+  QString _file_encoding;
+
   enum { MaxMRUFiles = 10 };
   QMenu *_mru_file_menu;
   QAction *_mru_file_actions[MaxMRUFiles];
   QStringList _mru_files;
+  QStringList _mru_files_encodings;
 };
 
 #endif // FILEEDITORMDISUBWINDOW_H
--- a/libgui/src/m-editor/find-dialog.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/m-editor/find-dialog.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -203,17 +203,19 @@
     _find_result_available = false;
 }
 
-#ifdef HAVE_QSCI_FINDSELECTION
 void
 find_dialog::handle_sel_search_changed (int selected)
 {
+#ifdef HAVE_QSCI_FINDSELECTION
   _from_start_check_box->setEnabled (! selected);
   _find_result_available = false;
+#endif
 }
 
 void
 find_dialog::handle_selection_changed (bool has_selected)
 {
+#ifdef HAVE_QSCI_FINDSELECTION
   if (_rep_active)
     return;
 
@@ -221,8 +223,8 @@
   _find_result_available = false;
   if (! has_selected)
     _search_selection_check_box->setChecked (false);
+#endif
 }
-#endif
 
 // initialize search text with selected text if this is in one single line
 void
--- a/libgui/src/m-editor/find-dialog.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/m-editor/find-dialog.h	Thu Dec 10 12:50:06 2015 -0800
@@ -79,10 +79,9 @@
   void init_search_text ();
 
 private slots:
-#ifdef HAVE_QSCI_FINDSELECTION
   void handle_sel_search_changed (int);
   void handle_selection_changed (bool has_selected);
-#endif
+
   void handle_backward_search_changed (int);
   void handle_search_text_changed (QString new_search_text);
 
--- a/libgui/src/m-editor/octave-qscintilla.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/m-editor/octave-qscintilla.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -183,11 +183,11 @@
     contextmenu_run (true);
 }
 
-#ifdef HAVE_QSCI_VERSION_2_6_0
 // context menu requested
 void
 octave_qscintilla::contextMenuEvent (QContextMenuEvent *e)
 {
+#ifdef HAVE_QSCI_VERSION_2_6_0
   QPoint global_pos, local_pos;                         // the menu's position
   QMenu *context_menu = createStandardContextMenu ();  // standard menu
 
@@ -235,8 +235,8 @@
 
   // finaly show the menu
   context_menu->exec (global_pos);
+#endif
 }
-#endif
 
 
 // handle the menu entry for calling help or doc
--- a/libgui/src/m-editor/octave-qscintilla.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/m-editor/octave-qscintilla.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 // Author: Torsten <ttl@justmail.de>
 
-#if !defined (octave_octave_qscintilla_h)
+#if ! defined (octave_octave_qscintilla_h)
 #define octave_octave_qscintilla_h 1
 
 #include <Qsci/qsciscintilla.h>
@@ -38,9 +38,8 @@
   octave_qscintilla (QWidget *p);
   ~octave_qscintilla ();
 
-#ifdef HAVE_QSCI_VERSION_2_6_0
   virtual void contextMenuEvent (QContextMenuEvent *e);
-#endif
+
   void context_help_doc (bool);
   void context_edit ();
   void context_run ();
--- a/libgui/src/m-editor/octave-txt-lexer.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/m-editor/octave-txt-lexer.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 // Author: Torsten <ttl@justmail.de>
 
-#if !defined (octave_txt_lexer_h)
+#if ! defined (octave_txt_lexer_h)
 #define octave_txt_lexer_h 1
 
 #include <Qsci/qsciscintilla.h>
--- a/libgui/src/main-window.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/main-window.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -747,7 +747,7 @@
         { // if children has a name
           icon = widget_icon_data[icon_set_found].path; // prefix or octave-logo
           if (widget_icon_data[icon_set_found].name != "NONE")
-            icon = icon + name + ".png"; // add widget name and ext.
+            icon += name + ".png"; // add widget name and ext.
           widget->setWindowIcon (QIcon (icon));
         }
     }
@@ -2407,6 +2407,21 @@
     }
 }
 
+QList<octave_dock_widget *>
+main_window::dock_widget_list ()
+{
+  QList<octave_dock_widget *> list = QList<octave_dock_widget *> ();
+  list.append (static_cast<octave_dock_widget *> (command_window));
+  list.append (static_cast<octave_dock_widget *> (history_window));
+  list.append (static_cast<octave_dock_widget *> (file_browser_window));
+  list.append (static_cast<octave_dock_widget *> (doc_browser_window));
+#ifdef HAVE_QSCINTILLA
+  list.append (static_cast<octave_dock_widget *> (editor_window));
+#endif
+  list.append (static_cast<octave_dock_widget *> (workspace_window));
+  return list;
+}
+
 void
 main_window::set_screen_size (int ht, int wd)
 {
--- a/libgui/src/main-window.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/main-window.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_main_window_h)
+#if ! defined (octave_main_window_h)
 #define octave_main_window_h 1
 
 // Qt includes
@@ -306,19 +306,9 @@
   documentation_dock_widget *doc_browser_window;
   file_editor_interface *editor_window;
   workspace_view *workspace_window;
-  QList<octave_dock_widget *> dock_widget_list ()
-  {
-    QList<octave_dock_widget *> list = QList<octave_dock_widget *> ();
-    list.append (static_cast<octave_dock_widget *> (command_window));
-    list.append (static_cast<octave_dock_widget *> (history_window));
-    list.append (static_cast<octave_dock_widget *> (file_browser_window));
-    list.append (static_cast<octave_dock_widget *> (doc_browser_window));
-#ifdef HAVE_QSCINTILLA
-    list.append (static_cast<octave_dock_widget *> (editor_window));
-#endif
-    list.append (static_cast<octave_dock_widget *> (workspace_window));
-    return list;
-  }
+
+  QList<octave_dock_widget *> dock_widget_list ();
+
   octave_dock_widget *_active_dock;
 
   QString _release_notes_icon;
--- a/libgui/src/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,186 +1,201 @@
-EXTRA_DIST += \
-  src/module.mk \
-  src/resource.qrc \
-  $(octave_gui_UI) \
-  $(octave_gui_ICONS)
-
 octave_gui_ICONS = \
-  src/icons/applications-system.png \
-  src/icons/bp-next.png \
-  src/icons/bp-prev.png \
-  src/icons/bp-rm-all.png \
-  src/icons/bp-toggle.png \
-  src/icons/db-cont.png \
-  src/icons/db-step-in.png \
-  src/icons/db-step-out.png \
-  src/icons/db-step.png \
-  src/icons/db-stop.png \
-  src/icons/document-new.png \
-  src/icons/document-open.png \
-  src/icons/document-print.png \
-  src/icons/document-save.png \
-  src/icons/document-save-as.png \
-  src/icons/edit-copy.png \
-  src/icons/edit-cut.png \
-  src/icons/edit-delete.png \
-  src/icons/edit-find.png \
-  src/icons/edit-find-replace.png \
-  src/icons/edit-paste.png \
-  src/icons/edit-redo.png \
-  src/icons/edit-undo.png \
-  src/icons/folder.png \
-  src/icons/folder-new.png \
-  src/icons/go-first.png \
-  src/icons/go-last.png \
-  src/icons/go-up.png \
-  src/icons/graphic_logo_DocumentationDockWidget.png \
-  src/icons/graphic_logo_FileEditor.png \
-  src/icons/graphic_logo_FilesDockWidget.png \
-  src/icons/graphic_logo_HistoryDockWidget.png \
-  src/icons/graphic_logo_NewsDockWidget.png \
-  src/icons/graphic_logo_TerminalDockWidget.png \
-  src/icons/graphic_logo_WorkspaceView.png \
-  src/icons/graphic_logo_ReleaseWidget.png \
-  src/icons/icons_license \
-  src/icons/letter_logo_DocumentationDockWidget.png \
-  src/icons/letter_logo_FileEditor.png \
-  src/icons/letter_logo_FilesDockWidget.png \
-  src/icons/letter_logo_HistoryDockWidget.png \
-  src/icons/letter_logo_NewsDockWidget.png \
-  src/icons/letter_logo_TerminalDockWidget.png \
-  src/icons/letter_logo_WorkspaceView.png \
-  src/icons/letter_logo_ReleaseWidget.png \
-  src/icons/logo.png \
-  src/icons/preferences-system.png \
-  src/icons/system-run.png \
-  src/icons/user-home.png \
-  src/icons/view-refresh.png \
-  src/icons/widget-close.png \
-  src/icons/widget-dock.png \
-  src/icons/widget-undock.png \
-  src/icons/widget-close-light.png \
-  src/icons/widget-dock-light.png \
-  src/icons/widget-undock-light.png \
-  src/icons/zoom-in.png \
-  src/icons/zoom-out.png
+  libgui/src/icons/applications-system.png \
+  libgui/src/icons/bp-next.png \
+  libgui/src/icons/bp-prev.png \
+  libgui/src/icons/bp-rm-all.png \
+  libgui/src/icons/bp-toggle.png \
+  libgui/src/icons/db-cont.png \
+  libgui/src/icons/db-step-in.png \
+  libgui/src/icons/db-step-out.png \
+  libgui/src/icons/db-step.png \
+  libgui/src/icons/db-stop.png \
+  libgui/src/icons/document-new.png \
+  libgui/src/icons/document-open.png \
+  libgui/src/icons/document-print.png \
+  libgui/src/icons/document-save.png \
+  libgui/src/icons/document-save-as.png \
+  libgui/src/icons/edit-copy.png \
+  libgui/src/icons/edit-cut.png \
+  libgui/src/icons/edit-delete.png \
+  libgui/src/icons/edit-find.png \
+  libgui/src/icons/edit-find-replace.png \
+  libgui/src/icons/edit-paste.png \
+  libgui/src/icons/edit-redo.png \
+  libgui/src/icons/edit-undo.png \
+  libgui/src/icons/folder.png \
+  libgui/src/icons/folder-new.png \
+  libgui/src/icons/go-first.png \
+  libgui/src/icons/go-last.png \
+  libgui/src/icons/go-up.png \
+  libgui/src/icons/graphic_logo_DocumentationDockWidget.png \
+  libgui/src/icons/graphic_logo_FileEditor.png \
+  libgui/src/icons/graphic_logo_FilesDockWidget.png \
+  libgui/src/icons/graphic_logo_HistoryDockWidget.png \
+  libgui/src/icons/graphic_logo_NewsDockWidget.png \
+  libgui/src/icons/graphic_logo_TerminalDockWidget.png \
+  libgui/src/icons/graphic_logo_WorkspaceView.png \
+  libgui/src/icons/graphic_logo_ReleaseWidget.png \
+  libgui/src/icons/icons_license \
+  libgui/src/icons/letter_logo_DocumentationDockWidget.png \
+  libgui/src/icons/letter_logo_FileEditor.png \
+  libgui/src/icons/letter_logo_FilesDockWidget.png \
+  libgui/src/icons/letter_logo_HistoryDockWidget.png \
+  libgui/src/icons/letter_logo_NewsDockWidget.png \
+  libgui/src/icons/letter_logo_TerminalDockWidget.png \
+  libgui/src/icons/letter_logo_WorkspaceView.png \
+  libgui/src/icons/letter_logo_ReleaseWidget.png \
+  libgui/src/icons/logo.png \
+  libgui/src/icons/preferences-system.png \
+  libgui/src/icons/system-run.png \
+  libgui/src/icons/user-home.png \
+  libgui/src/icons/view-refresh.png \
+  libgui/src/icons/widget-close.png \
+  libgui/src/icons/widget-dock.png \
+  libgui/src/icons/widget-undock.png \
+  libgui/src/icons/widget-close-light.png \
+  libgui/src/icons/widget-dock-light.png \
+  libgui/src/icons/widget-undock-light.png \
+  libgui/src/icons/zoom-in.png \
+  libgui/src/icons/zoom-out.png
 
 octave_gui_MOC =
 
 if AMCOND_HAVE_QSCINTILLA
-octave_gui_MOC += \
-  src/m-editor/moc-file-editor-interface.cc \
-  src/m-editor/moc-file-editor-tab.cc \
-  src/m-editor/moc-file-editor.cc \
-  src/m-editor/moc-find-dialog.cc \
-  src/m-editor/moc-octave-qscintilla.cc \
-  src/m-editor/moc-octave-txt-lexer.cc
-endif
+
+OCTAVE_GUI_SRC_M_EDITOR_MOC = \
+  libgui/src/m-editor/moc-file-editor-interface.cc \
+  libgui/src/m-editor/moc-file-editor-tab.cc \
+  libgui/src/m-editor/moc-file-editor.cc \
+  libgui/src/m-editor/moc-find-dialog.cc \
+  libgui/src/m-editor/moc-octave-qscintilla.cc \
+  libgui/src/m-editor/moc-octave-txt-lexer.cc
+
+$(OCTAVE_GUI_SRC_M_EDITOR_MOC): | libgui/src/m-editor/$(octave_dirstamp)
 
 octave_gui_MOC += \
-  src/moc-dialog.cc \
-  src/moc-documentation-dock-widget.cc \
-  src/moc-files-dock-widget.cc \
-  src/moc-history-dock-widget.cc \
-  src/moc-main-window.cc \
-  src/moc-octave-interpreter.cc \
-  src/moc-octave-qt-link.cc \
-  src/moc-settings-dialog.cc \
-  src/moc-terminal-dock-widget.cc \
-  src/moc-color-picker.cc \
-  src/moc-resource-manager.cc \
-  src/moc-shortcut-manager.cc \
-  src/moc-welcome-wizard.cc \
-  src/moc-workspace-model.cc \
-  src/moc-workspace-view.cc \
-  src/moc-find-files-dialog.cc \
-  src/moc-find-files-model.cc \
-  src/qtinfo/moc-parser.cc \
-  src/qtinfo/moc-webinfo.cc \
-  src/moc-octave-dock-widget.cc
+  $(OCTAVE_GUI_SRC_M_EDITOR_MOC)
+
+DIRSTAMP_FILES += \
+  libgui/src/m-editor/$(octave_dirstamp)
+
+endif
 
-octave_gui_RC = src/qrc-resource.cc
+OCTAVE_GUI_SRC_MOC = \
+  libgui/src/moc-dialog.cc \
+  libgui/src/moc-documentation-dock-widget.cc \
+  libgui/src/moc-files-dock-widget.cc \
+  libgui/src/moc-history-dock-widget.cc \
+  libgui/src/moc-main-window.cc \
+  libgui/src/moc-octave-interpreter.cc \
+  libgui/src/moc-octave-qt-link.cc \
+  libgui/src/moc-settings-dialog.cc \
+  libgui/src/moc-terminal-dock-widget.cc \
+  libgui/src/moc-color-picker.cc \
+  libgui/src/moc-resource-manager.cc \
+  libgui/src/moc-shortcut-manager.cc \
+  libgui/src/moc-welcome-wizard.cc \
+  libgui/src/moc-workspace-model.cc \
+  libgui/src/moc-workspace-view.cc \
+  libgui/src/moc-find-files-dialog.cc \
+  libgui/src/moc-find-files-model.cc \
+  libgui/src/qtinfo/moc-parser.cc \
+  libgui/src/qtinfo/moc-webinfo.cc \
+  libgui/src/moc-octave-dock-widget.cc
+
+octave_gui_MOC += \
+  $(OCTAVE_GUI_SRC_MOC) \
+  $(OCTAVE_GUI_EDITOR_MOC)
+
+octave_gui_RC = libgui/src/qrc-resource.cc
+
+$(octave_gui_RC): | libgui/src/$(octave_dirstamp)
+
+DIRSTAMP_FILES += \
+  libgui/src/$(octave_dirstamp)
 
 octave_gui_UI = \
-  src/settings-dialog.ui
+  libgui/src/settings-dialog.ui
 
-octave_gui_UI_H = $(patsubst src/%.ui, src/ui-%.h, $(octave_gui_UI))
+octave_gui_UI_H = $(patsubst libgui/src/%.ui, libgui/src/ui-%.h, $(octave_gui_UI))
+
+$(octave_gui_UI_H): | libgui/src/$(octave_dirstamp)
 
 BUILT_SOURCES += $(octave_gui_UI_H)
 
 noinst_HEADERS += \
-  src/dialog.h \
-  src/octave-dock-widget.h \
-  src/documentation-dock-widget.h \
-  src/files-dock-widget.h \
-  src/history-dock-widget.h \
-  src/m-editor/file-editor-interface.h \
-  src/m-editor/file-editor-tab.h \
-  src/m-editor/file-editor.h \
-  src/m-editor/find-dialog.h \
-  src/m-editor/octave-qscintilla.h \
-  src/m-editor/octave-txt-lexer.h \
-  src/main-window.h \
-  src/octave-gui.h \
-  src/octave-cmd.h \
-  src/octave-interpreter.h \
-  src/octave-qt-link.h \
-  src/qtinfo/parser.h \
-  src/qtinfo/webinfo.h \
-  src/resource-manager.h \
-  src/settings-dialog.h \
-  src/shortcut-manager.h \
-  src/thread-manager.h \
-  src/terminal-dock-widget.h \
-  src/color-picker.h \
-  src/welcome-wizard.h \
-  src/find-files-dialog.h \
-  src/find-files-model.h \
-  src/workspace-model.h \
-  src/workspace-view.h
+  libgui/src/dialog.h \
+  libgui/src/octave-dock-widget.h \
+  libgui/src/documentation-dock-widget.h \
+  libgui/src/files-dock-widget.h \
+  libgui/src/history-dock-widget.h \
+  libgui/src/m-editor/file-editor-interface.h \
+  libgui/src/m-editor/file-editor-tab.h \
+  libgui/src/m-editor/file-editor.h \
+  libgui/src/m-editor/find-dialog.h \
+  libgui/src/m-editor/octave-qscintilla.h \
+  libgui/src/m-editor/octave-txt-lexer.h \
+  libgui/src/main-window.h \
+  libgui/src/octave-gui.h \
+  libgui/src/octave-cmd.h \
+  libgui/src/octave-interpreter.h \
+  libgui/src/octave-qt-link.h \
+  libgui/src/qtinfo/parser.h \
+  libgui/src/qtinfo/webinfo.h \
+  libgui/src/resource-manager.h \
+  libgui/src/settings-dialog.h \
+  libgui/src/shortcut-manager.h \
+  libgui/src/thread-manager.h \
+  libgui/src/terminal-dock-widget.h \
+  libgui/src/color-picker.h \
+  libgui/src/welcome-wizard.h \
+  libgui/src/find-files-dialog.h \
+  libgui/src/find-files-model.h \
+  libgui/src/workspace-model.h \
+  libgui/src/workspace-view.h
 
-src_libgui_src_la_SOURCES = \
-  src/dialog.cc \
-  src/documentation-dock-widget.cc \
-  src/files-dock-widget.cc \
-  src/history-dock-widget.cc \
-  src/m-editor/file-editor-tab.cc \
-  src/m-editor/file-editor.cc \
-  src/m-editor/find-dialog.cc \
-  src/m-editor/octave-qscintilla.cc \
-  src/m-editor/octave-txt-lexer.cc \
-  src/main-window.cc \
-  src/octave-cmd.cc \
-  src/octave-dock-widget.cc \
-  src/octave-gui.cc \
-  src/octave-interpreter.cc \
-  src/octave-qt-link.cc \
-  src/qtinfo/parser.cc \
-  src/qtinfo/webinfo.cc \
-  src/resource-manager.cc \
-  src/settings-dialog.cc \
-  src/shortcut-manager.cc \
-  src/thread-manager.cc \
-  src/terminal-dock-widget.cc \
-  src/color-picker.cc \
-  src/welcome-wizard.cc \
-  src/find-files-dialog.cc \
-  src/find-files-model.cc \
-  src/workspace-model.cc \
-  src/workspace-view.cc
+libgui_src_libgui_src_la_SOURCES = \
+  libgui/src/dialog.cc \
+  libgui/src/documentation-dock-widget.cc \
+  libgui/src/files-dock-widget.cc \
+  libgui/src/history-dock-widget.cc \
+  libgui/src/m-editor/file-editor-tab.cc \
+  libgui/src/m-editor/file-editor.cc \
+  libgui/src/m-editor/find-dialog.cc \
+  libgui/src/m-editor/octave-qscintilla.cc \
+  libgui/src/m-editor/octave-txt-lexer.cc \
+  libgui/src/main-window.cc \
+  libgui/src/octave-cmd.cc \
+  libgui/src/octave-dock-widget.cc \
+  libgui/src/octave-gui.cc \
+  libgui/src/octave-interpreter.cc \
+  libgui/src/octave-qt-link.cc \
+  libgui/src/qtinfo/parser.cc \
+  libgui/src/qtinfo/webinfo.cc \
+  libgui/src/resource-manager.cc \
+  libgui/src/settings-dialog.cc \
+  libgui/src/shortcut-manager.cc \
+  libgui/src/thread-manager.cc \
+  libgui/src/terminal-dock-widget.cc \
+  libgui/src/color-picker.cc \
+  libgui/src/welcome-wizard.cc \
+  libgui/src/find-files-dialog.cc \
+  libgui/src/find-files-model.cc \
+  libgui/src/workspace-model.cc \
+  libgui/src/workspace-view.cc
 
-nodist_src_libgui_src_la_SOURCES = $(octave_gui_MOC) $(octave_gui_RC)
+nodist_libgui_src_libgui_src_la_SOURCES = $(octave_gui_MOC) $(octave_gui_RC)
 
-src_libgui_src_la_CPPFLAGS = \
+libgui_src_libgui_src_la_CPPFLAGS = \
   $(AM_CPPFLAGS) \
   $(FT2_CPPFLAGS) \
   $(FONTCONFIG_CPPFLAGS) \
   @OCTGUI_DLL_DEFS@ \
   @QT_CPPFLAGS@ \
-  -I$(srcdir)/qterminal/libqterminal \
-  -Isrc -I$(srcdir)/src \
-  -I$(srcdir)/src/m-editor \
-  -I$(srcdir)/src/qtinfo \
-  -I$(srcdir)/graphics \
+  -I$(srcdir)/libgui/qterminal/libqterminal \
+  -Ilibgui/src -I$(srcdir)/libgui/src \
+  -I$(srcdir)/libgui/src/m-editor \
+  -I$(srcdir)/libgui/src/qtinfo \
+  -I$(srcdir)/libgui/graphics \
   -I$(top_srcdir)/liboctave/cruft/misc \
   -I$(top_srcdir)/liboctave/array \
   -I$(top_builddir)/liboctave/numeric -I$(top_srcdir)/liboctave/numeric \
@@ -193,13 +208,18 @@
   -I$(top_srcdir)/libinterp/octave-value \
   -I$(top_builddir)/libgnu -I$(top_srcdir)/libgnu
 
-src_libgui_src_la_CFLAGS = $(AM_CFLAGS) $(WARN_CFLAGS)
+libgui_src_libgui_src_la_CFLAGS = $(AM_CFLAGS) $(WARN_CFLAGS)
 
-src_libgui_src_la_CXXFLAGS = $(AM_CXXFLAGS) $(WARN_CXXFLAGS)
+libgui_src_libgui_src_la_CXXFLAGS = $(AM_CXXFLAGS) $(WARN_CXXFLAGS)
+
+noinst_LTLIBRARIES += libgui/src/libgui-src.la
 
-noinst_LTLIBRARIES += src/libgui-src.la
+libgui_EXTRA_DIST += \
+  libgui/src/resource.qrc \
+  $(octave_gui_UI) \
+  $(octave_gui_ICONS)
 
-CLEANFILES += \
+libgui_CLEANFILES += \
   $(octave_gui_MOC) \
   $(octave_gui_UI_H) \
   $(octave_gui_RC)
--- a/libgui/src/octave-cmd.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/octave-cmd.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 // Author: Torsten <ttl@justmail.de>
 
-#if !defined (octave_cmd_h)
+#if ! defined (octave_cmd_h)
 #define octave_cmd_h 1
 
 #include <QString>
--- a/libgui/src/octave-dock-widget.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/octave-dock-widget.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -330,6 +330,11 @@
   else
     dock_icon = "widget-undock";
 
+#if defined (Q_OS_MAC)
+  QString alignment = "center";
+#else
+  QString alignment = "center left";
+#endif
   if (_custom_style)
     {
 
@@ -371,7 +376,7 @@
       css = background + QString (" color: %1 ;").arg (fg_col.name ());
 #else
       css = QString ("QDockWidget::title { " + background +
-                     "                     text-align: center left;"
+                     "                     text-align: " + alignment + ";"
                      "                     padding: 0px 0px 0px 4px;}\n"
                      "QDockWidget { color: %1 ; "
                      "  titlebar-close-icon: url(:/actions/icons/widget-close%2.png);"
@@ -387,7 +392,7 @@
 #if defined (Q_OS_WIN32)
       css = QString ("");
 #else
-      css = QString ("QDockWidget::title { text-align: center left;"
+      css = QString ("QDockWidget::title { text-align: " + alignment + ";"
                      "                     padding: 0px 0px 0px 4px;}"
                      "QDockWidget {"
                      "  titlebar-close-icon: url(:/actions/icons/widget-close.png);"
--- a/libgui/src/octave-dock-widget.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/octave-dock-widget.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_octave_dock_widget_h)
+#if ! defined (octave_octave_dock_widget_h)
 #define octave_octave_dock_widget_h 1
 
 #include <QDockWidget>
--- a/libgui/src/octave-gui.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/octave-gui.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_octave_gui_h)
+#if ! defined (octave_octave_gui_h)
 #define octave_octave_gui_h 1
 
 extern OCTGUI_API int octave_start_gui (int argc, char **argv,
--- a/libgui/src/octave-qt-link.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/octave-qt-link.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -490,7 +490,7 @@
 {
   QStringList qt_hist;
 
-  for (octave_idx_type i = 0; i < hist.length (); i++)
+  for (octave_idx_type i = 0; i < hist.numel (); i++)
     qt_hist.append (QString::fromStdString (hist[i]));
 
   emit set_history_signal (qt_hist);
--- a/libgui/src/resource-manager.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/resource-manager.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -31,6 +31,7 @@
 #include <QNetworkProxy>
 #include <QLibraryInfo>
 #include <QMessageBox>
+#include <QTextCodec>
 
 #include "error.h"
 #include "file-ops.h"
@@ -144,7 +145,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create resource_manager object!");
+      error ("unable to create resource_manager object!");
 
       retval = false;
     }
@@ -325,3 +326,52 @@
   else
     return QIcon::fromTheme (icon_name);
 }
+
+// initialize a given combo box with available text encodings
+void
+resource_manager::do_combo_encoding (QComboBox *combo, QString current)
+{
+  // get the codec name for each mib
+  QList<int> all_mibs = QTextCodec::availableMibs ();
+  QStringList all_codecs;
+  foreach (int mib, all_mibs)
+    {
+      QTextCodec *c = QTextCodec::codecForMib (mib);
+      all_codecs << c->name ().toUpper ();
+    }
+  all_codecs.removeDuplicates ();
+  qSort (all_codecs);
+
+  // the default encoding
+#if defined (Q_OS_WIN32)
+  QString def_enc = "SYSTEM";
+#else
+  QString def_enc = "UTF-8";
+#endif
+
+  // get the value from the settings file if no current encoding is given
+  QString enc = current;
+  if (enc.isEmpty ())
+    {
+      enc = settings->value ("editor/default_encoding",def_enc).toString ();
+      if (enc.isEmpty ())  // still empty?
+        enc = def_enc;     // take default
+    }
+
+  // fill the combo box
+  foreach (QString c, all_codecs)
+    combo->addItem (c);
+
+  // prepend the default item
+  combo->insertSeparator (0);
+  combo->insertItem (0, def_enc);
+
+  // select the current/default item
+  int idx = combo->findText (enc);
+  if (idx >= 0)
+    combo->setCurrentIndex (idx);
+  else
+    combo->setCurrentIndex (0);
+
+  combo->setMaxVisibleItems (12);
+}
--- a/libgui/src/resource-manager.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/resource-manager.h	Thu Dec 10 12:50:06 2015 -0800
@@ -25,6 +25,7 @@
 
 #include <QDesktopServices>
 #include <QIcon>
+#include <QComboBox>
 #include <QMap>
 #include <QSettings>
 #include <QTranslator>
@@ -76,6 +77,12 @@
       instance->do_set_settings (file);
   }
 
+  static void combo_encoding (QComboBox *combo, QString current = QString ())
+  {
+    if (instance_ok ())
+      instance->do_combo_encoding (combo, current);
+  }
+
   static QString get_gui_translation_dir (void);
 
   static void config_translators (QTranslator*, QTranslator*, QTranslator*);
@@ -139,6 +146,7 @@
 
   QIcon do_icon (const QString& icon, bool fallback);
 
+  void do_combo_encoding (QComboBox *combo, QString current);
 };
 
 #endif // RESOURCEMANAGER_H
--- a/libgui/src/settings-dialog.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/settings-dialog.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -34,6 +34,7 @@
 #include <QFileDialog>
 #include <QVector>
 #include <QHash>
+#include <QTextCodec>
 
 #ifdef HAVE_QSCINTILLA
 #include "octave-qscintilla.h"
@@ -55,6 +56,206 @@
 #include <Qsci/qscilexerdiff.h>
 #endif
 
+#ifdef HAVE_QSCINTILLA
+
+static const int MaxLexerStyles = 64;
+static const int MaxStyleNumber = 128;
+
+static int
+get_valid_lexer_styles (QsciLexer *lexer, int styles[])
+{
+  int max_style = 0;
+  int actual_style = 0;
+  while (actual_style < MaxStyleNumber && max_style < MaxLexerStyles)
+    {
+      if ((lexer->description (actual_style)) != "")  // valid style
+        styles[max_style++] = actual_style;
+      actual_style++;
+    }
+  return max_style;
+}
+
+static void
+read_lexer_settings (Ui::settings_dialog * ui, QsciLexer *lexer,
+                     QSettings *settings)
+{
+  lexer->readSettings (*settings);
+  int styles[MaxLexerStyles];  // array for saving valid styles
+                               // (enum is not continuous)
+  int max_style = get_valid_lexer_styles (lexer, styles);
+  QGridLayout *style_grid = new QGridLayout ();
+  QVector<QLabel*> description (max_style);
+  QVector<QFontComboBox*> select_font (max_style);
+  QVector<QSpinBox*> font_size (max_style);
+  QVector<QCheckBox*> attrib_font (3 * max_style);
+  QVector<color_picker*> color (max_style);
+  QVector<color_picker*> bg_color (max_style);
+  int default_size = 10;
+  QFont default_font = QFont ();
+  int label_width;
+  QColor default_color = QColor ();
+  QColor dummy_color = QColor (255,0,255);
+
+  for (int i = 0; i < max_style; i++)  // create dialog elements for all styles
+    {
+      QString actual_name = lexer->description (styles[i]);
+      QFont   actual_font = lexer->font (styles[i]);
+      description[i] = new QLabel (actual_name);
+      description[i]->setWordWrap (true);
+      label_width = 24*description[i]->fontMetrics ().averageCharWidth ();
+      description[i]->setMaximumSize (label_width,QWIDGETSIZE_MAX);
+      description[i]->setMinimumSize (label_width,1);
+      select_font[i] = new QFontComboBox ();
+      select_font[i]->setObjectName (actual_name+"_font");
+      select_font[i]->setMaximumSize (label_width,QWIDGETSIZE_MAX);
+      select_font[i]->setMinimumSize (label_width,1);
+      font_size[i] = new QSpinBox ();
+      font_size[i]->setObjectName (actual_name+"_size");
+      if (styles[i] == 0) // the default
+        {
+          select_font[i]->setCurrentFont (actual_font);
+          default_font = actual_font;
+          font_size[i]->setRange (6,24);
+          default_size = actual_font.pointSize ();
+          font_size[i]->setValue (default_size);
+          default_color = lexer->defaultPaper ();
+          bg_color[i] = new color_picker (default_color);
+        }
+      else   // other styles
+        {
+          select_font[i]->setCurrentFont (actual_font);
+          if (actual_font.family () == default_font.family ())
+            select_font[i]->setEditText (lexer->description (0));
+          font_size[i]->setRange (-4,4);
+          font_size[i]->setValue (actual_font.pointSize ()-default_size);
+          font_size[i]->setToolTip (QObject::tr ("Difference to the default size"));
+          if (lexer->paper (styles[i]) == default_color)
+            bg_color[i] = new color_picker (dummy_color);
+          else
+            bg_color[i] = new color_picker (lexer->paper (styles[i]));
+          bg_color[i]->setToolTip
+            (QObject::tr ("Background color, pink (255,0,255) means default"));
+        }
+      attrib_font[0+3*i] = new QCheckBox (QObject::tr ("b", "short form for bold"));
+      attrib_font[1+3*i] = new QCheckBox (QObject::tr ("i", "short form for italic"));
+      attrib_font[2+3*i] = new QCheckBox (QObject::tr ("u", "short form for underlined"));
+      attrib_font[0+3*i]->setChecked (Qt::Checked && actual_font.bold ());
+      attrib_font[0+3*i]->setObjectName (actual_name+"_bold");
+      attrib_font[1+3*i]->setChecked (Qt::Checked && actual_font.italic ());
+      attrib_font[1+3*i]->setObjectName (actual_name+"_italic");
+      attrib_font[2+3*i]->setChecked (Qt::Checked && actual_font.underline ());
+      attrib_font[2+3*i]->setObjectName (actual_name+"_underline");
+      color[i] = new color_picker (lexer->color (styles[i]));
+      color[i]->setObjectName (actual_name+"_color");
+      bg_color[i]->setObjectName (actual_name+"_bg_color");
+      int column = 1;
+      style_grid->addWidget (description[i],     i, column++);
+      style_grid->addWidget (select_font[i],     i, column++);
+      style_grid->addWidget (font_size[i],       i, column++);
+      style_grid->addWidget (attrib_font[0+3*i], i, column++);
+      style_grid->addWidget (attrib_font[1+3*i], i, column++);
+      style_grid->addWidget (attrib_font[2+3*i], i, column++);
+      style_grid->addWidget (color[i],           i, column++);
+      style_grid->addWidget (bg_color[i],        i, column++);
+    }
+  // place grid with elements into the tab
+  QScrollArea *scroll_area = new QScrollArea ();
+  QWidget *scroll_area_contents = new QWidget ();
+  scroll_area_contents->setObjectName (QString (lexer->language ())+"_styles");
+  scroll_area_contents->setLayout (style_grid);
+  scroll_area->setWidget (scroll_area_contents);
+  ui->tabs_editor_lexers->addTab (scroll_area,lexer->language ());
+
+  ui->tabs_editor_lexers->setCurrentIndex (
+    settings->value ("settings/last_editor_styles_tab",0).toInt ());
+}
+
+static void
+write_lexer_settings (Ui::settings_dialog * ui, QsciLexer *lexer,
+                      QSettings *settings)
+{
+  QWidget *tab = ui->tabs_editor_lexers->
+                 findChild <QWidget *>(QString (lexer->language ())+"_styles");
+  int styles[MaxLexerStyles];  // array for saving valid styles
+                               // (enum is not continuous)
+  int max_style = get_valid_lexer_styles (lexer, styles);
+  QFontComboBox *select_font;
+  QSpinBox *font_size;
+  QCheckBox *attrib_font[3];
+  color_picker *color;
+  color_picker *bg_color;
+  int default_size = 10;
+  QFont default_font = QFont ("Courier New",10,-1,0);
+  QColor default_color = QColor ();
+  QColor dummy_color = QColor (255,0,255);
+
+  for (int i = 0; i < max_style; i++)  // get dialog elements and their contents
+    {
+      QString actual_name = lexer->description (styles[i]);
+      select_font    = tab->findChild <QFontComboBox *>(actual_name+"_font");
+      font_size      = tab->findChild <QSpinBox *>(actual_name+"_size");
+      attrib_font[0] = tab->findChild <QCheckBox *>(actual_name+"_bold");
+      attrib_font[1] = tab->findChild <QCheckBox *>(actual_name+"_italic");
+      attrib_font[2] = tab->findChild <QCheckBox *>(actual_name+"_underline");
+      color          = tab->findChild <color_picker *>(actual_name+"_color");
+      bg_color       = tab->findChild <color_picker *>(actual_name+"_bg_color");
+      QFont new_font = default_font;
+      if (select_font)
+        {
+          new_font = select_font->currentFont ();
+          if (styles[i] == 0)
+            default_font = new_font;
+          else if (select_font->currentText () == lexer->description (0))
+            new_font = default_font;
+        }
+      if (font_size)
+        {
+          if (styles[i] == 0)
+            {
+              default_size = font_size->value ();
+              new_font.setPointSize (font_size->value ());
+            }
+          else
+            new_font.setPointSize (font_size->value ()+default_size);
+        }
+      if (attrib_font[0])
+        new_font.setBold (attrib_font[0]->isChecked ());
+      if (attrib_font[1])
+        new_font.setItalic (attrib_font[1]->isChecked ());
+      if (attrib_font[2])
+        new_font.setUnderline (attrib_font[2]->isChecked ());
+      lexer->setFont (new_font,styles[i]);
+      if (styles[i] == 0)
+        lexer->setDefaultFont (new_font);
+      if (color)
+        lexer->setColor (color->color (),styles[i]);
+      if (bg_color)
+        {
+          if (styles[i] == 0)
+            {
+              default_color = bg_color->color ();
+              lexer->setPaper (default_color,styles[i]);
+              lexer->setDefaultPaper (default_color);
+            }
+          else
+            {
+              if (bg_color->color () == dummy_color)
+                lexer->setPaper (default_color,styles[i]);
+              else
+                lexer->setPaper (bg_color->color (),styles[i]);
+            }
+        }
+    }
+
+  lexer->writeSettings (*settings);
+
+  settings->setValue (
+    "settings/last_editor_styles_tab",ui->tabs_editor_lexers->currentIndex ());
+  settings->sync ();
+}
+
+#endif
+
 settings_dialog::settings_dialog (QWidget *p, const QString& desired_tab):
   QDialog (p), ui (new Ui::settings_dialog)
 {
@@ -165,7 +366,9 @@
   connect (ui->pb_octave_dir, SIGNAL (pressed ()),
            this, SLOT (get_octave_dir ()));
 
+  //
   // editor
+  //
   ui->useCustomFileEditor->setChecked (settings->value ("useCustomFileEditor",
                                                         false).toBool ());
   ui->customFileEditor->setText (
@@ -173,6 +376,8 @@
   ui->editor_showLineNumbers->setChecked (
     settings->value ("editor/showLineNumbers",true).toBool ());
 
+  resource_manager::combo_encoding (ui->editor_combo_encoding);
+
   default_var = QColor (240, 240, 240);
   QColor setting_color = settings->value ("editor/highlight_current_line_color",
                                           default_var).value<QColor> ();
@@ -296,16 +501,6 @@
     ui->terminal_cursorType->setCurrentIndex (2);
 
   // file browser
-  ui->showFileSize->setChecked (
-    settings->value ("filesdockwidget/showFileSize", false).toBool ());
-  ui->showFileType->setChecked (
-    settings->value ("filesdockwidget/showFileType", false).toBool ());
-  ui->showLastModified->setChecked (
-    settings->value ("filesdockwidget/showLastModified",false).toBool ());
-  ui->showHiddenFiles->setChecked (
-    settings->value ("filesdockwidget/showHiddenFiles",false).toBool ());
-  ui->useAlternatingRowColors->setChecked (
-    settings->value ("filesdockwidget/useAlternatingRowColors",true).toBool ());
   connect (ui->sync_octave_directory, SIGNAL (toggled (bool)),
            this, SLOT (set_disabled_pref_file_browser_dir (bool)));
   ui->sync_octave_directory->setChecked (
@@ -316,6 +511,9 @@
     settings->value ("filesdockwidget/startup_dir").toString ());
   connect (ui->pb_file_browser_dir, SIGNAL (pressed ()),
            this, SLOT (get_file_browser_dir ()));
+  ui->le_file_browser_extensions->setText (
+    settings->value ("filesdockwidget/txt_file_extensions", "m;c;cc;cpp;h;txt")
+    .toString ());
 
   ui->checkbox_allow_web_connect->setChecked (
     settings->value ("news/allow_web_connection",false).toBool ());
@@ -350,22 +548,17 @@
 
   ui->cb_prevent_readline_conflicts->setChecked (
     settings->value ("shortcuts/prevent_readline_conflicts", true).toBool ());
-  int set = settings->value ("shortcuts/set",0).toInt ();
-  ui->rb_sc_set1->setChecked (set == 0);
-  ui->rb_sc_set2->setChecked (set == 1);
 
   // initialize the tree view with all shortcut data
   shortcut_manager::fill_treewidget (ui->shortcuts_treewidget);
 
   // connect the buttons for import/export of the shortcut sets
-  connect (ui->btn_import_shortcut_set1, SIGNAL (clicked ()),
-           this, SLOT (import_shortcut_set1 ()));
-  connect (ui->btn_export_shortcut_set1, SIGNAL (clicked ()),
-           this, SLOT (export_shortcut_set1 ()));
-  connect (ui->btn_import_shortcut_set2, SIGNAL (clicked ()),
-           this, SLOT (import_shortcut_set2 ()));
-  connect (ui->btn_export_shortcut_set2, SIGNAL (clicked ()),
-           this, SLOT (export_shortcut_set2 ()));
+  connect (ui->btn_import_shortcut_set, SIGNAL (clicked ()),
+           this, SLOT (import_shortcut_set ()));
+  connect (ui->btn_export_shortcut_set, SIGNAL (clicked ()),
+           this, SLOT (export_shortcut_set ()));
+  connect (ui->btn_default_shortcut_set, SIGNAL (clicked ()),
+           this, SLOT (default_shortcut_set ()));
 
 
 #ifdef HAVE_QSCINTILLA
@@ -373,30 +566,30 @@
   QsciLexer *lexer;
 #if defined (HAVE_LEXER_OCTAVE)
   lexer = new QsciLexerOctave ();
-  read_lexer_settings (lexer,settings);
+  read_lexer_settings (ui, lexer, settings);
   delete lexer;
 #elif defined (HAVE_LEXER_MATLAB)
   lexer = new QsciLexerMatlab ();
-  read_lexer_settings (lexer,settings);
+  read_lexer_settings (ui, lexer, settings);
   delete lexer;
 #endif
   lexer = new QsciLexerCPP ();
-  read_lexer_settings (lexer,settings);
+  read_lexer_settings (ui, lexer, settings);
   delete lexer;
   lexer = new QsciLexerPerl ();
-  read_lexer_settings (lexer,settings);
+  read_lexer_settings (ui, lexer, settings);
   delete lexer;
   lexer = new QsciLexerBatch ();
-  read_lexer_settings (lexer,settings);
+  read_lexer_settings (ui, lexer, settings);
   delete lexer;
   lexer = new QsciLexerDiff ();
-  read_lexer_settings (lexer,settings);
+  read_lexer_settings (ui, lexer, settings);
   delete lexer;
   lexer = new QsciLexerBash ();
-  read_lexer_settings (lexer,settings);
+  read_lexer_settings (ui, lexer, settings);
   delete lexer;
   lexer = new octave_txt_lexer ();
-  read_lexer_settings (lexer,settings);
+  read_lexer_settings (ui, lexer, settings);
   delete lexer;
 #endif
 
@@ -432,116 +625,6 @@
     }
 }
 
-#ifdef HAVE_QSCINTILLA
-int
-settings_dialog::get_valid_lexer_styles (QsciLexer *lexer, int styles[])
-{
-  int max_style = 0;
-  int actual_style = 0;
-  while (actual_style < MaxStyleNumber && max_style < MaxLexerStyles)
-    {
-      if ((lexer->description (actual_style)) != "")  // valid style
-        styles[max_style++] = actual_style;
-      actual_style++;
-    }
-  return max_style;
-}
-
-void
-settings_dialog::read_lexer_settings (QsciLexer *lexer, QSettings *settings)
-{
-  lexer->readSettings (*settings);
-  int styles[MaxLexerStyles];  // array for saving valid styles
-                               // (enum is not continuous)
-  int max_style = get_valid_lexer_styles (lexer, styles);
-  QGridLayout *style_grid = new QGridLayout ();
-  QVector<QLabel*> description (max_style);
-  QVector<QFontComboBox*> select_font (max_style);
-  QVector<QSpinBox*> font_size (max_style);
-  QVector<QCheckBox*> attrib_font (3 * max_style);
-  QVector<color_picker*> color (max_style);
-  QVector<color_picker*> bg_color (max_style);
-  int default_size = 10;
-  QFont default_font = QFont ();
-  int label_width;
-  QColor default_color = QColor ();
-  QColor dummy_color = QColor (255,0,255);
-
-  for (int i = 0; i < max_style; i++)  // create dialog elements for all styles
-    {
-      QString actual_name = lexer->description (styles[i]);
-      QFont   actual_font = lexer->font (styles[i]);
-      description[i] = new QLabel (actual_name);
-      description[i]->setWordWrap (true);
-      label_width = 24*description[i]->fontMetrics ().averageCharWidth ();
-      description[i]->setMaximumSize (label_width,QWIDGETSIZE_MAX);
-      description[i]->setMinimumSize (label_width,1);
-      select_font[i] = new QFontComboBox ();
-      select_font[i]->setObjectName (actual_name+"_font");
-      select_font[i]->setMaximumSize (label_width,QWIDGETSIZE_MAX);
-      select_font[i]->setMinimumSize (label_width,1);
-      font_size[i] = new QSpinBox ();
-      font_size[i]->setObjectName (actual_name+"_size");
-      if (styles[i] == 0) // the default
-        {
-          select_font[i]->setCurrentFont (actual_font);
-          default_font = actual_font;
-          font_size[i]->setRange (6,24);
-          default_size = actual_font.pointSize ();
-          font_size[i]->setValue (default_size);
-          default_color = lexer->defaultPaper ();
-          bg_color[i] = new color_picker (default_color);
-        }
-      else   // other styles
-        {
-          select_font[i]->setCurrentFont (actual_font);
-          if (actual_font.family () == default_font.family ())
-            select_font[i]->setEditText (lexer->description (0));
-          font_size[i]->setRange (-4,4);
-          font_size[i]->setValue (actual_font.pointSize ()-default_size);
-          font_size[i]->setToolTip (tr ("Difference to the default size"));
-          if (lexer->paper (styles[i]) == default_color)
-            bg_color[i] = new color_picker (dummy_color);
-          else
-            bg_color[i] = new color_picker (lexer->paper (styles[i]));
-          bg_color[i]->setToolTip
-          (tr ("Background color, pink (255,0,255) means default"));
-        }
-      attrib_font[0+3*i] = new QCheckBox (tr ("b", "short form for bold"));
-      attrib_font[1+3*i] = new QCheckBox (tr ("i", "short form for italic"));
-      attrib_font[2+3*i] = new QCheckBox (tr ("u", "short form for underlined"));
-      attrib_font[0+3*i]->setChecked (Qt::Checked && actual_font.bold ());
-      attrib_font[0+3*i]->setObjectName (actual_name+"_bold");
-      attrib_font[1+3*i]->setChecked (Qt::Checked && actual_font.italic ());
-      attrib_font[1+3*i]->setObjectName (actual_name+"_italic");
-      attrib_font[2+3*i]->setChecked (Qt::Checked && actual_font.underline ());
-      attrib_font[2+3*i]->setObjectName (actual_name+"_underline");
-      color[i] = new color_picker (lexer->color (styles[i]));
-      color[i]->setObjectName (actual_name+"_color");
-      bg_color[i]->setObjectName (actual_name+"_bg_color");
-      int column = 1;
-      style_grid->addWidget (description[i],     i, column++);
-      style_grid->addWidget (select_font[i],     i, column++);
-      style_grid->addWidget (font_size[i],       i, column++);
-      style_grid->addWidget (attrib_font[0+3*i], i, column++);
-      style_grid->addWidget (attrib_font[1+3*i], i, column++);
-      style_grid->addWidget (attrib_font[2+3*i], i, column++);
-      style_grid->addWidget (color[i],           i, column++);
-      style_grid->addWidget (bg_color[i],        i, column++);
-    }
-  // place grid with elements into the tab
-  QScrollArea *scroll_area = new QScrollArea ();
-  QWidget *scroll_area_contents = new QWidget ();
-  scroll_area_contents->setObjectName (QString (lexer->language ())+"_styles");
-  scroll_area_contents->setLayout (style_grid);
-  scroll_area->setWidget (scroll_area_contents);
-  ui->tabs_editor_lexers->addTab (scroll_area,lexer->language ());
-
-  ui->tabs_editor_lexers->setCurrentIndex (
-    settings->value ("settings/last_editor_styles_tab",0).toInt ());
-}
-#endif
-
 void
 settings_dialog::read_workspace_colors (QSettings *settings)
 {
@@ -720,6 +803,8 @@
                       ui->cb_show_hscrollbar->isChecked ());
   settings->setValue ("editor/default_eol_mode",
                       ui->combo_eol_mode->currentIndex ());
+  settings->setValue ("editor/default_encoding",
+                      ui->editor_combo_encoding->currentText ());
   settings->setValue ("editor/auto_indent",
                       ui->editor_auto_ind_checkbox->isChecked ());
   settings->setValue ("editor/tab_indents_line",
@@ -750,23 +835,15 @@
   settings->setValue ("terminal/fontName",
                       ui->terminal_fontName->currentFont ().family ());
 
-  settings->setValue ("filesdockwidget/showFileSize",
-                      ui->showFileSize->isChecked ());
-  settings->setValue ("filesdockwidget/showFileType",
-                      ui->showFileType->isChecked ());
-  settings->setValue ("filesdockwidget/showLastModified",
-                      ui->showLastModified->isChecked ());
-  settings->setValue ("filesdockwidget/showHiddenFiles",
-                      ui->showHiddenFiles->isChecked ());
-  settings->setValue ("filesdockwidget/useAlternatingRowColors",
-                      ui->useAlternatingRowColors->isChecked ());
+  // file browser
   settings->setValue ("filesdockwidget/sync_octave_directory",
                       ui->sync_octave_directory->isChecked ());
   settings->setValue ("filesdockwidget/restore_last_dir",
                       ui->cb_restore_file_browser_dir->isChecked ());
   settings->setValue ("filesdockwidget/startup_dir",
                       ui->le_file_browser_dir->text ());
-
+  settings->setValue ("filesdockwidget/txt_file_extensions",
+                      ui->le_file_browser_extensions->text ());
 
   settings->setValue ("news/allow_web_connection",
                       ui->checkbox_allow_web_connect->isChecked ());
@@ -802,30 +879,30 @@
   QsciLexer *lexer;
 #if defined (HAVE_LEXER_OCTAVE)
   lexer = new QsciLexerOctave ();
-  write_lexer_settings (lexer,settings);
+  write_lexer_settings (ui, lexer, settings);
   delete lexer;
 #elif defined (HAVE_LEXER_MATLAB)
   lexer = new QsciLexerMatlab ();
-  write_lexer_settings (lexer,settings);
+  write_lexer_settings (ui, lexer, settings);
   delete lexer;
 #endif
   lexer = new QsciLexerCPP ();
-  write_lexer_settings (lexer,settings);
+  write_lexer_settings (ui, lexer, settings);
   delete lexer;
   lexer = new QsciLexerPerl ();
-  write_lexer_settings (lexer,settings);
+  write_lexer_settings (ui, lexer, settings);
   delete lexer;
   lexer = new QsciLexerBatch ();
-  write_lexer_settings (lexer,settings);
+  write_lexer_settings (ui, lexer, settings);
   delete lexer;
   lexer = new QsciLexerDiff ();
-  write_lexer_settings (lexer,settings);
+  write_lexer_settings (ui, lexer, settings);
   delete lexer;
   lexer = new QsciLexerBash ();
-  write_lexer_settings (lexer,settings);
+  write_lexer_settings (ui, lexer, settings);
   delete lexer;
   lexer = new octave_txt_lexer ();
-  write_lexer_settings (lexer,settings);
+  write_lexer_settings (ui, lexer, settings);
   delete lexer;
 #endif
 
@@ -841,11 +918,7 @@
   // shortcuts
   settings->setValue ("shortcuts/prevent_readline_conflicts",
                       ui->cb_prevent_readline_conflicts->isChecked ());
-  int set = 0;
-  if (ui->rb_sc_set2->isChecked ())
-    set = 1;
-  settings->setValue ("shortcuts/set",set);
-  shortcut_manager::write_shortcuts (0, settings, closing); // 0: write both sets
+  shortcut_manager::write_shortcuts (settings, closing);
 
   // settings dialog's geometry
   settings->setValue ("settings/last_tab",ui->tabWidget->currentIndex ());
@@ -854,91 +927,6 @@
   settings->sync ();
 }
 
-#ifdef HAVE_QSCINTILLA
-void
-settings_dialog::write_lexer_settings (QsciLexer *lexer, QSettings *settings)
-{
-  QWidget *tab = ui->tabs_editor_lexers->
-                 findChild <QWidget *>(QString (lexer->language ())+"_styles");
-  int styles[MaxLexerStyles];  // array for saving valid styles
-                               // (enum is not continuous)
-  int max_style = get_valid_lexer_styles (lexer, styles);
-  QFontComboBox *select_font;
-  QSpinBox *font_size;
-  QCheckBox *attrib_font[3];
-  color_picker *color;
-  color_picker *bg_color;
-  int default_size = 10;
-  QFont default_font = QFont ("Courier New",10,-1,0);
-  QColor default_color = QColor ();
-  QColor dummy_color = QColor (255,0,255);
-
-  for (int i = 0; i < max_style; i++)  // get dialog elements and their contents
-    {
-      QString actual_name = lexer->description (styles[i]);
-      select_font    = tab->findChild <QFontComboBox *>(actual_name+"_font");
-      font_size      = tab->findChild <QSpinBox *>(actual_name+"_size");
-      attrib_font[0] = tab->findChild <QCheckBox *>(actual_name+"_bold");
-      attrib_font[1] = tab->findChild <QCheckBox *>(actual_name+"_italic");
-      attrib_font[2] = tab->findChild <QCheckBox *>(actual_name+"_underline");
-      color          = tab->findChild <color_picker *>(actual_name+"_color");
-      bg_color       = tab->findChild <color_picker *>(actual_name+"_bg_color");
-      QFont new_font = default_font;
-      if (select_font)
-        {
-          new_font = select_font->currentFont ();
-          if (styles[i] == 0)
-            default_font = new_font;
-          else if (select_font->currentText () == lexer->description (0))
-            new_font = default_font;
-        }
-      if (font_size)
-        {
-          if (styles[i] == 0)
-            {
-              default_size = font_size->value ();
-              new_font.setPointSize (font_size->value ());
-            }
-          else
-            new_font.setPointSize (font_size->value ()+default_size);
-        }
-      if (attrib_font[0])
-        new_font.setBold (attrib_font[0]->isChecked ());
-      if (attrib_font[1])
-        new_font.setItalic (attrib_font[1]->isChecked ());
-      if (attrib_font[2])
-        new_font.setUnderline (attrib_font[2]->isChecked ());
-      lexer->setFont (new_font,styles[i]);
-      if (styles[i] == 0)
-        lexer->setDefaultFont (new_font);
-      if (color)
-        lexer->setColor (color->color (),styles[i]);
-      if (bg_color)
-        {
-          if (styles[i] == 0)
-            {
-              default_color = bg_color->color ();
-              lexer->setPaper (default_color,styles[i]);
-              lexer->setDefaultPaper (default_color);
-            }
-          else
-            {
-              if (bg_color->color () == dummy_color)
-                lexer->setPaper (default_color,styles[i]);
-              else
-                lexer->setPaper (bg_color->color (),styles[i]);
-            }
-        }
-    }
-
-  lexer->writeSettings (*settings);
-
-  settings->setValue (
-    "settings/last_editor_styles_tab",ui->tabs_editor_lexers->currentIndex ());
-  settings->sync ();
-}
-#endif
-
 void
 settings_dialog::write_workspace_colors (QSettings *settings)
 {
@@ -1036,25 +1024,19 @@
 
 // slots for import/export of shortcut sets
 void
-settings_dialog::import_shortcut_set1 ()
+settings_dialog::import_shortcut_set ()
 {
-  shortcut_manager::import_export (true,1);
+  shortcut_manager::import_export (shortcut_manager::OSC_IMPORT);
 }
 
 void
-settings_dialog::export_shortcut_set1 ()
+settings_dialog::export_shortcut_set ()
 {
-  shortcut_manager::import_export (false,1);
+  shortcut_manager::import_export (shortcut_manager::OSC_EXPORT);
 }
 
 void
-settings_dialog::import_shortcut_set2 ()
+settings_dialog::default_shortcut_set ()
 {
-  shortcut_manager::import_export (true,2);
-}
-
-void
-settings_dialog::export_shortcut_set2 ()
-{
-  shortcut_manager::import_export (false,2);
-}
+  shortcut_manager::import_export (shortcut_manager::OSC_DEFAULT);
+}
\ No newline at end of file
--- a/libgui/src/settings-dialog.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/settings-dialog.h	Thu Dec 10 12:50:06 2015 -0800
@@ -29,10 +29,6 @@
 
 #include "color-picker.h"
 
-#ifdef HAVE_QSCINTILLA
-class QsciLexer;
-#endif
-
 namespace Ui
 {
   class settings_dialog;
@@ -59,20 +55,12 @@
   void button_clicked (QAbstractButton *button);
 
   // slots for import/export-buttons of shortcut sets
-  void import_shortcut_set1 ();
-  void export_shortcut_set1 ();
-  void import_shortcut_set2 ();
-  void export_shortcut_set2 ();
+  void import_shortcut_set ();
+  void export_shortcut_set ();
+  void default_shortcut_set ();
 
 private:
   Ui::settings_dialog * ui;
-#ifdef HAVE_QSCINTILLA
-  void read_lexer_settings (QsciLexer *lexer, QSettings *settings);
-  void write_lexer_settings (QsciLexer *lexer, QSettings *settings);
-  int  get_valid_lexer_styles (QsciLexer *lexer, int styles[]);
-  enum { MaxLexerStyles = 64,
-         MaxStyleNumber = 128 };
-#endif
 
   void write_changed_settings (bool closing);
 
--- a/libgui/src/settings-dialog.ui	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/settings-dialog.ui	Thu Dec 10 12:50:06 2015 -0800
@@ -9,8 +9,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>720</width>
-    <height>480</height>
+    <width>700</width>
+    <height>673</height>
    </rect>
   </property>
   <property name="minimumSize">
@@ -51,9 +51,9 @@
           <property name="geometry">
            <rect>
             <x>0</x>
-            <y>-4</y>
-            <width>662</width>
-            <height>382</height>
+            <y>0</y>
+            <width>658</width>
+            <height>571</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_17">
@@ -498,9 +498,9 @@
           <property name="geometry">
            <rect>
             <x>0</x>
-            <y>0</y>
-            <width>662</width>
-            <height>751</height>
+            <y>-237</y>
+            <width>642</width>
+            <height>813</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_16">
@@ -827,61 +827,6 @@
                   </property>
                  </widget>
                 </item>
-                <item row="4" column="2">
-                 <layout class="QHBoxLayout" name="horizontalLayout_17">
-                  <item>
-                   <widget class="QLabel" name="label_22">
-                    <property name="text">
-                     <string>Default EOL mode</string>
-                    </property>
-                   </widget>
-                  </item>
-                  <item>
-                   <widget class="QComboBox" name="combo_eol_mode">
-                    <property name="sizePolicy">
-                     <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-                      <horstretch>0</horstretch>
-                      <verstretch>0</verstretch>
-                     </sizepolicy>
-                    </property>
-                    <property name="sizeAdjustPolicy">
-                     <enum>QComboBox::AdjustToContents</enum>
-                    </property>
-                    <property name="minimumContentsLength">
-                     <number>7</number>
-                    </property>
-                    <item>
-                     <property name="text">
-                      <string>Windows (CRLF)</string>
-                     </property>
-                    </item>
-                    <item>
-                     <property name="text">
-                      <string>Mac (CR)</string>
-                     </property>
-                    </item>
-                    <item>
-                     <property name="text">
-                      <string>Unix (LF)</string>
-                     </property>
-                    </item>
-                   </widget>
-                  </item>
-                  <item>
-                   <spacer name="horizontalSpacer_17">
-                    <property name="orientation">
-                     <enum>Qt::Horizontal</enum>
-                    </property>
-                    <property name="sizeHint" stdset="0">
-                     <size>
-                      <width>40</width>
-                      <height>20</height>
-                     </size>
-                    </property>
-                   </spacer>
-                  </item>
-                 </layout>
-                </item>
                 <item row="9" column="0">
                  <widget class="QCheckBox" name="cb_show_hscrollbar">
                   <property name="enabled">
@@ -1335,37 +1280,129 @@
                  <number>0</number>
                 </property>
                 <item>
-                 <widget class="QCheckBox" name="editor_restoreSession">
-                  <property name="sizePolicy">
-                   <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
-                    <horstretch>0</horstretch>
-                    <verstretch>0</verstretch>
-                   </sizepolicy>
-                  </property>
-                  <property name="text">
-                   <string>Restore editor tabs from previous session on startup</string>
+                 <layout class="QGridLayout" name="gridLayout_11">
+                  <property name="topMargin">
+                   <number>0</number>
                   </property>
-                 </widget>
-                </item>
-                <item>
-                 <widget class="QCheckBox" name="editor_create_new file">
-                  <property name="sizePolicy">
-                   <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
-                    <horstretch>0</horstretch>
-                    <verstretch>0</verstretch>
-                   </sizepolicy>
-                  </property>
-                  <property name="text">
-                   <string>Create nonexistent files without prompting</string>
-                  </property>
-                 </widget>
-                </item>
-                <item>
-                 <widget class="QCheckBox" name="editor_reload_changed_files">
-                  <property name="text">
-                   <string>Reload externally changed files without prompt</string>
-                  </property>
-                 </widget>
+                  <item row="4" column="0">
+                   <widget class="QCheckBox" name="editor_reload_changed_files">
+                    <property name="text">
+                     <string>Reload externally changed files without prompt</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="1" column="0">
+                   <widget class="QCheckBox" name="editor_restoreSession">
+                    <property name="sizePolicy">
+                     <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+                      <horstretch>0</horstretch>
+                      <verstretch>0</verstretch>
+                     </sizepolicy>
+                    </property>
+                    <property name="text">
+                     <string>Restore editor tabs from previous session on startup</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="3" column="0">
+                   <widget class="QCheckBox" name="editor_create_new file">
+                    <property name="sizePolicy">
+                     <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+                      <horstretch>0</horstretch>
+                      <verstretch>0</verstretch>
+                     </sizepolicy>
+                    </property>
+                    <property name="text">
+                     <string>Create nonexistent files without prompting</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="5" column="0">
+                   <layout class="QHBoxLayout" name="horizontalLayout_2">
+                    <property name="topMargin">
+                     <number>0</number>
+                    </property>
+                    <item>
+                     <widget class="QLabel" name="label_22">
+                      <property name="text">
+                       <string>Default EOL mode</string>
+                      </property>
+                     </widget>
+                    </item>
+                    <item>
+                     <widget class="QComboBox" name="combo_eol_mode">
+                      <property name="sizePolicy">
+                       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                        <horstretch>0</horstretch>
+                        <verstretch>0</verstretch>
+                       </sizepolicy>
+                      </property>
+                      <property name="sizeAdjustPolicy">
+                       <enum>QComboBox::AdjustToContents</enum>
+                      </property>
+                      <property name="minimumContentsLength">
+                       <number>7</number>
+                      </property>
+                      <item>
+                       <property name="text">
+                        <string>Windows (CRLF)</string>
+                       </property>
+                      </item>
+                      <item>
+                       <property name="text">
+                        <string>Mac (CR)</string>
+                       </property>
+                      </item>
+                      <item>
+                       <property name="text">
+                        <string>Unix (LF)</string>
+                       </property>
+                      </item>
+                     </widget>
+                    </item>
+                    <item>
+                     <spacer name="horizontalSpacer_18">
+                      <property name="orientation">
+                       <enum>Qt::Horizontal</enum>
+                      </property>
+                      <property name="sizeHint" stdset="0">
+                       <size>
+                        <width>40</width>
+                        <height>20</height>
+                       </size>
+                      </property>
+                     </spacer>
+                    </item>
+                   </layout>
+                  </item>
+                  <item row="7" column="0">
+                   <layout class="QHBoxLayout" name="horizontalLayout_16">
+                    <item>
+                     <widget class="QLabel" name="label_16">
+                      <property name="text">
+                       <string>Text encoding used for loading and saving</string>
+                      </property>
+                     </widget>
+                    </item>
+                    <item>
+                     <widget class="QComboBox" name="editor_combo_encoding"/>
+                    </item>
+                    <item>
+                     <spacer name="horizontalSpacer_32">
+                      <property name="orientation">
+                       <enum>Qt::Horizontal</enum>
+                      </property>
+                      <property name="sizeHint" stdset="0">
+                       <size>
+                        <width>40</width>
+                        <height>20</height>
+                       </size>
+                      </property>
+                     </spacer>
+                    </item>
+                   </layout>
+                  </item>
+                 </layout>
                 </item>
                </layout>
               </item>
@@ -1461,8 +1498,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>678</width>
-            <height>378</height>
+            <width>658</width>
+            <height>571</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_7">
@@ -1749,79 +1786,74 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>678</width>
-            <height>378</height>
+            <width>658</width>
+            <height>571</height>
            </rect>
           </property>
-          <layout class="QVBoxLayout" name="verticalLayout_18">
-           <item>
-            <widget class="QGroupBox" name="groupBox_3">
-             <property name="title">
-              <string>Display</string>
-             </property>
-             <layout class="QVBoxLayout" name="verticalLayout_23">
-              <item>
-               <layout class="QGridLayout" name="gridLayout_11">
-                <property name="topMargin">
-                 <number>0</number>
-                </property>
-                <item row="1" column="0">
-                 <widget class="QCheckBox" name="showFileType">
-                  <property name="text">
-                   <string>Show file type</string>
-                  </property>
-                 </widget>
-                </item>
-                <item row="3" column="0">
-                 <widget class="QCheckBox" name="showHiddenFiles">
-                  <property name="text">
-                   <string>Show hidden files</string>
-                  </property>
-                 </widget>
-                </item>
-                <item row="0" column="0">
-                 <widget class="QCheckBox" name="showFileSize">
-                  <property name="text">
-                   <string>Show file size</string>
-                  </property>
-                 </widget>
-                </item>
-                <item row="2" column="0">
-                 <widget class="QCheckBox" name="showLastModified">
-                  <property name="text">
-                   <string>Show date of last modification</string>
-                  </property>
-                 </widget>
-                </item>
-                <item row="4" column="0">
-                 <widget class="QCheckBox" name="useAlternatingRowColors">
-                  <property name="text">
-                   <string>Alternating row colors</string>
-                  </property>
-                 </widget>
-                </item>
-               </layout>
-              </item>
-             </layout>
-            </widget>
-           </item>
-           <item>
+          <layout class="QGridLayout" name="gridLayout_8">
+           <item row="0" column="0">
             <widget class="QGroupBox" name="groupBox_4">
              <property name="title">
               <string>Behavior</string>
              </property>
-             <layout class="QVBoxLayout" name="verticalLayout_24">
-              <item>
-               <layout class="QGridLayout" name="gridLayout_8">
-                <item row="4" column="0">
+             <layout class="QGridLayout" name="gridLayout_2">
+              <item row="0" column="0">
+               <layout class="QVBoxLayout" name="verticalLayout_18">
+                <item>
                  <widget class="QCheckBox" name="sync_octave_directory">
                   <property name="text">
                    <string>Synchronize Octave working directory with file browser</string>
                   </property>
                  </widget>
                 </item>
-                <item row="5" column="0">
+                <item>
                  <layout class="QGridLayout" name="lo_file_browser_startup">
+                  <item row="1" column="3">
+                   <spacer name="horizontalSpacer_30">
+                    <property name="orientation">
+                     <enum>Qt::Horizontal</enum>
+                    </property>
+                    <property name="sizeHint" stdset="0">
+                     <size>
+                      <width>40</width>
+                      <height>20</height>
+                     </size>
+                    </property>
+                   </spacer>
+                  </item>
+                  <item row="0" column="1">
+                   <widget class="QCheckBox" name="cb_restore_file_browser_dir">
+                    <property name="text">
+                     <string>Restore last directory of previous session</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="0" column="3">
+                   <spacer name="horizontalSpacer_29">
+                    <property name="orientation">
+                     <enum>Qt::Horizontal</enum>
+                    </property>
+                    <property name="sizeHint" stdset="0">
+                     <size>
+                      <width>40</width>
+                      <height>20</height>
+                     </size>
+                    </property>
+                   </spacer>
+                  </item>
+                  <item row="1" column="2">
+                   <widget class="QPushButton" name="pb_file_browser_dir">
+                    <property name="sizePolicy">
+                     <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+                      <horstretch>0</horstretch>
+                      <verstretch>0</verstretch>
+                     </sizepolicy>
+                    </property>
+                    <property name="text">
+                     <string>Browse</string>
+                    </property>
+                   </widget>
+                  </item>
                   <item row="0" column="0">
                    <widget class="QLabel" name="lbl_file_browser_dir">
                     <property name="text">
@@ -1839,51 +1871,23 @@
                     </property>
                    </widget>
                   </item>
-                  <item row="0" column="1">
-                   <widget class="QCheckBox" name="cb_restore_file_browser_dir">
+                 </layout>
+                </item>
+                <item>
+                 <layout class="QVBoxLayout" name="verticalLayout_9">
+                  <item>
+                   <widget class="QLabel" name="lbl_file_browser_extensions">
                     <property name="text">
-                     <string>Restore last directory of previous session</string>
-                    </property>
-                   </widget>
-                  </item>
-                  <item row="1" column="2">
-                   <widget class="QPushButton" name="pb_file_browser_dir">
-                    <property name="sizePolicy">
-                     <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
-                      <horstretch>0</horstretch>
-                      <verstretch>0</verstretch>
-                     </sizepolicy>
-                    </property>
-                    <property name="text">
-                     <string>Browse</string>
+                     <string>Extensions of files to be opened in the default text editor (separated by &quot;;&quot;):</string>
                     </property>
                    </widget>
                   </item>
-                  <item row="0" column="3">
-                   <spacer name="horizontalSpacer_29">
-                    <property name="orientation">
-                     <enum>Qt::Horizontal</enum>
-                    </property>
-                    <property name="sizeHint" stdset="0">
-                     <size>
-                      <width>40</width>
-                      <height>20</height>
-                     </size>
+                  <item>
+                   <widget class="QLineEdit" name="le_file_browser_extensions">
+                    <property name="text">
+                     <string/>
                     </property>
-                   </spacer>
-                  </item>
-                  <item row="1" column="3">
-                   <spacer name="horizontalSpacer_30">
-                    <property name="orientation">
-                     <enum>Qt::Horizontal</enum>
-                    </property>
-                    <property name="sizeHint" stdset="0">
-                     <size>
-                      <width>40</width>
-                      <height>20</height>
-                     </size>
-                    </property>
-                   </spacer>
+                   </widget>
                   </item>
                  </layout>
                 </item>
@@ -1892,7 +1896,7 @@
              </layout>
             </widget>
            </item>
-           <item>
+           <item row="1" column="0">
             <spacer name="verticalSpacer_2">
              <property name="orientation">
               <enum>Qt::Vertical</enum>
@@ -1926,8 +1930,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>678</width>
-            <height>378</height>
+            <width>658</width>
+            <height>571</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_19">
@@ -1995,8 +1999,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>678</width>
-            <height>378</height>
+            <width>658</width>
+            <height>571</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_25">
@@ -2037,52 +2041,10 @@
                <property name="topMargin">
                 <number>10</number>
                </property>
-               <item row="3" column="0">
-                <layout class="QHBoxLayout" name="horizontalLayout_16">
-                 <property name="topMargin">
-                  <number>0</number>
-                 </property>
-                </layout>
-               </item>
-               <item row="1" column="2">
-                <widget class="QRadioButton" name="rb_sc_set2">
-                 <property name="text">
-                  <string>Use this set</string>
-                 </property>
-                </widget>
-               </item>
-               <item row="0" column="0">
-                <widget class="QLabel" name="label_23">
-                 <property name="text">
-                  <string>Set 1:</string>
-                 </property>
-                </widget>
-               </item>
-               <item row="1" column="4">
-                <widget class="QPushButton" name="btn_export_shortcut_set2">
-                 <property name="text">
-                  <string>Export</string>
-                 </property>
-                </widget>
-               </item>
-               <item row="1" column="3">
-                <widget class="QPushButton" name="btn_import_shortcut_set2">
-                 <property name="text">
-                  <string>Import</string>
-                 </property>
-                </widget>
-               </item>
-               <item row="0" column="2">
-                <widget class="QRadioButton" name="rb_sc_set1">
-                 <property name="text">
-                  <string>Use this set</string>
-                 </property>
-                 <property name="checked">
-                  <bool>true</bool>
-                 </property>
-                </widget>
-               </item>
-               <item row="0" column="5">
+               <property name="bottomMargin">
+                <number>10</number>
+               </property>
+               <item row="0" column="3">
                 <spacer name="horizontalSpacer_26">
                  <property name="orientation">
                   <enum>Qt::Horizontal</enum>
@@ -2095,42 +2057,35 @@
                  </property>
                 </spacer>
                </item>
-               <item row="0" column="4">
-                <widget class="QPushButton" name="btn_export_shortcut_set1">
-                 <property name="text">
-                  <string>Export</string>
+               <item row="0" column="0">
+                <widget class="QPushButton" name="btn_import_shortcut_set">
+                 <property name="toolTip">
+                  <string>Import shortcut set</string>
                  </property>
-                </widget>
-               </item>
-               <item row="0" column="3">
-                <widget class="QPushButton" name="btn_import_shortcut_set1">
                  <property name="text">
                   <string>Import</string>
                  </property>
                 </widget>
                </item>
-               <item row="1" column="0">
-                <widget class="QLabel" name="label_24">
+               <item row="0" column="1">
+                <widget class="QPushButton" name="btn_export_shortcut_set">
+                 <property name="toolTip">
+                  <string>Export current shortcut set</string>
+                 </property>
                  <property name="text">
-                  <string>Set 2:</string>
+                  <string>Export</string>
                  </property>
                 </widget>
                </item>
-               <item row="0" column="1">
-                <spacer name="horizontalSpacer_33">
-                 <property name="orientation">
-                  <enum>Qt::Horizontal</enum>
-                 </property>
-                 <property name="sizeType">
-                  <enum>QSizePolicy::Fixed</enum>
+               <item row="0" column="2">
+                <widget class="QPushButton" name="btn_default_shortcut_set">
+                 <property name="toolTip">
+                  <string>Reset shortcuts to their defaults</string>
                  </property>
-                 <property name="sizeHint" stdset="0">
-                  <size>
-                   <width>20</width>
-                   <height>20</height>
-                  </size>
+                 <property name="text">
+                  <string>Default</string>
                  </property>
-                </spacer>
+                </widget>
                </item>
               </layout>
              </item>
@@ -2179,7 +2134,7 @@
                   <bool>false</bool>
                  </property>
                  <property name="columnCount">
-                  <number>5</number>
+                  <number>3</number>
                  </property>
                  <attribute name="headerCascadingSectionResizes">
                   <bool>false</bool>
@@ -2208,27 +2163,12 @@
                  </column>
                  <column>
                   <property name="text">
-                   <string>Set 1 Default</string>
-                  </property>
-                 </column>
-                 <column>
-                  <property name="text">
-                   <string>Set 1 Actual</string>
+                   <string>Default</string>
                   </property>
                  </column>
                  <column>
                   <property name="text">
-                   <string>Set 2 Default</string>
-                  </property>
-                  <property name="font">
-                   <font>
-                    <italic>false</italic>
-                   </font>
-                  </property>
-                 </column>
-                 <column>
-                  <property name="text">
-                   <string>Set 2 Actual</string>
+                   <string>Actual</string>
                   </property>
                  </column>
                 </widget>
@@ -2258,8 +2198,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>678</width>
-            <height>378</height>
+            <width>658</width>
+            <height>571</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_20">
--- a/libgui/src/shortcut-manager.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/shortcut-manager.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -75,7 +75,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create shortcut_manager object!");
+      error ("unable to create shortcut_manager object!");
 
       retval = false;
     }
@@ -316,34 +316,37 @@
         QKeySequence::HelpContents);
   init (tr ("Document on Keyword"), "editor_help:doc_keyword",
         QKeySequence (Qt::SHIFT + Qt::Key_F1));
+
+  // tab navigation
+  init (tr ("Switch to Left Tab"), "editor_tabs:switch_left_tab",
+        QKeySequence (ctrl + Qt::Key_PageDown));
+  init (tr ("Switch to Right Tab"), "editor_tabs:switch_right_tab",
+        QKeySequence (ctrl + Qt::Key_PageUp));
+  init (tr ("Move Tab Left"), "editor_tabs:move_tab_left",
+        QKeySequence (Qt::AltModifier + Qt::Key_PageDown));
+  init (tr ("Move Tab Right"), "editor_tabs:move_tab_right",
+        QKeySequence (Qt::AltModifier + Qt::Key_PageUp));
+
 }
 
 void
 shortcut_manager::init (QString description, QString key, QKeySequence def_sc)
 {
-  QKeySequence actual_0
+  QKeySequence actual
     = QKeySequence (_settings->value ("shortcuts/"+key, def_sc).toString ());
-  QKeySequence actual_1
-    = QKeySequence (_settings->value ("shortcuts/"+key+"_1", def_sc).toString ());
 
   // append the new shortcut to the list
   shortcut_t shortcut_info;
   shortcut_info.description = description;
   shortcut_info.settings_key = key;
-  shortcut_info.actual_sc [0] = actual_0;
-  shortcut_info.actual_sc [1] = actual_1;
-  shortcut_info.default_sc [0] = def_sc;
-  shortcut_info.default_sc [1] = def_sc;  // TODO: Different defaults
+  shortcut_info.actual_sc = actual;
+  shortcut_info.default_sc = def_sc;
   _sc << shortcut_info;
 
   // insert shortcut prepended by widget in order check for duplicates later
   QString widget = key.section ('_',0,0);  // get widget that uses the shortcut
-  if (! actual_0.isEmpty ())
-    _shortcut_hash[widget + ":" + actual_0.toString ()] =
-      _sc.count ();  // offset of 1 to avoid 0
-  if (! actual_1.isEmpty ())
-    _shortcut_hash[widget + "_1:" + actual_1.toString ()] =
-      _sc.count ();  // offset of 1 to avoid 0
+  if (! actual.isEmpty ())
+    _shortcut_hash[widget + ":" + actual.toString ()] = _sc.count ();  // offset of 1 to avoid 0
   _action_hash[key] = _sc.count ();  // offset of 1 to avoid 0
 }
 
@@ -393,6 +396,8 @@
   editor_run->setText (0, tr ("Run"));
   QTreeWidgetItem *editor_help = new QTreeWidgetItem (editor);
   editor_help->setText (0, tr ("Help"));
+  QTreeWidgetItem *editor_tabs = new QTreeWidgetItem (editor);
+  editor_tabs->setText (0, tr ("Tabs"));
 
   _level_hash["editor_file"] = editor_file;
   _level_hash["editor_edit"] = editor_edit;
@@ -400,6 +405,7 @@
   _level_hash["editor_debug"] = editor_debug;
   _level_hash["editor_run"] = editor_run;
   _level_hash["editor_help"] = editor_help;
+  _level_hash["editor_tabs"] = editor_tabs;
 
   connect (tree_view, SIGNAL (itemDoubleClicked (QTreeWidgetItem*, int)),
            this, SLOT (handle_double_clicked (QTreeWidgetItem*, int)));
@@ -415,14 +421,11 @@
       QColor fg = QColor (tree_item->foreground (1).color ());
       fg.setAlpha (128);
       tree_item->setForeground (1, QBrush (fg));
-      tree_item->setForeground (3, QBrush (fg));
 
       // write the shortcuts
       tree_item->setText (0, sc.description);
-      tree_item->setText (1, sc.default_sc [0]);
-      tree_item->setText (2, sc.actual_sc [0]);
-      tree_item->setText (3, sc.default_sc [1]);
-      tree_item->setText (4, sc.actual_sc [1]);
+      tree_item->setText (1, sc.default_sc);
+      tree_item->setText (2, sc.actual_sc);
 
       _item_index_hash[tree_item] = i + 1; // index+1 to avoid 0
       _index_item_hash[i] = tree_item;
@@ -432,36 +435,18 @@
 
 // write one or all actual shortcut set(s) into a settings file
 void
-shortcut_manager::do_write_shortcuts (int set, QSettings* settings,
+shortcut_manager::do_write_shortcuts (QSettings* settings,
                                       bool closing)
 {
-  if (set)
-    {
-      // set is not zero, only write the desired set (index = set-1)
-      // into the settings file that the user has selected for this export
-      for (int i = 0; i < _sc.count (); i++)  // loop over all shortcuts
-        {
-          settings->setValue("shortcuts/"+_sc.at (i).settings_key,
-                             _sc.at (i).actual_sc[set-1].toString ());
-        }
-    }
-  else
+  for (int i = 0; i < _sc.count (); i++)  // loop over all shortcuts
     {
-      // set is zero, write all sets into the normal octave settings file
-      // (this is only the case when called from the closing settings dialog)
-      for (int i = 0; i < _sc.count (); i++)  // loop over all shortcuts
-        {
-          settings->setValue("shortcuts/"+_sc.at (i).settings_key,
-                             _sc.at (i).actual_sc[0].toString ());
-          settings->setValue("shortcuts/"+_sc.at (i).settings_key+"_1",
-                             _sc.at (i).actual_sc[1].toString ());
-        }
-
-      if (closing)
-        {
-          delete _dialog;  // the dialog for key sequences can be removed now
-          _dialog = 0;     // make sure it is zero again
-        }
+      settings->setValue("shortcuts/"+_sc.at (i).settings_key,
+                             _sc.at (i).actual_sc.toString ());
+    }
+  if (closing)
+    {
+      delete _dialog;  // the dialog for key sequences can be removed now
+      _dialog = 0;     // make sure it is zero again
     }
 
   settings->sync ();    // sync the settings file
@@ -470,35 +455,22 @@
 void
 shortcut_manager::do_set_shortcut (QAction* action, const QString& key)
 {
-  int set = _settings->value ("shortcuts/set",0).toInt ();
   int index;
 
   index = _action_hash[key] - 1;
 
-  QString key_set = key;
-  if (set == 1)
-    key_set = key+"_1";
-
   if (index > -1 && index < _sc.count ())
     action->setShortcut (QKeySequence (
-      _settings->value ("shortcuts/" + key_set, _sc.at (index).default_sc[set]).toString ()));
+      _settings->value ("shortcuts/" + key, _sc.at (index).default_sc).toString ()));
   else
-    qDebug () << "Key: " << key_set << " not found in _action_hash";
+    qDebug () << "Key: " << key << " not found in _action_hash";
 }
 
 void
 shortcut_manager::handle_double_clicked (QTreeWidgetItem* item, int col)
 {
-  switch (col)
-    {
-    case 2:
-    case 4:
-      _selected_set = col/2 - 1;
-      break;
-
-    default:
-      return;
-    }
+  if (col != 2)
+    return;
 
   int i = _item_index_hash[item];
   if (i == 0)
@@ -514,8 +486,7 @@
     {
       _dialog = new QDialog (this);
 
-      _dialog->setWindowTitle (tr ("Enter new Shortcut for Set %1")
-                               .arg (_selected_set + 1));
+      _dialog->setWindowTitle (tr ("Enter new Shortcut"));
 
       QVBoxLayout *box = new QVBoxLayout(_dialog);
 
@@ -569,8 +540,8 @@
 
     }
 
-  _edit_actual->setText (_sc.at (index).actual_sc[_selected_set]);
-  _label_default->setText (_sc.at (index).default_sc[_selected_set]);
+  _edit_actual->setText (_sc.at (index).actual_sc);
+  _label_default->setText (_sc.at (index).default_sc);
   _handled_index = index;
 
   _edit_actual->setFocus ();
@@ -590,8 +561,6 @@
   QString widget = _sc.at (_handled_index).settings_key.section ('_',0,0);
   // and look for shortcut
   QString sep = ":";
-  if (_selected_set)
-    sep = "_1:";
 
   int double_index = _shortcut_hash[widget + sep + _edit_actual->text()] - 1;
 
@@ -609,26 +578,25 @@
       if (ret == QMessageBox::Yes)
         {
           shortcut_t double_shortcut = _sc.at (double_index);
-          double_shortcut.actual_sc[_selected_set] = QKeySequence ();
+          double_shortcut.actual_sc = QKeySequence ();
           _sc.replace (double_index, double_shortcut);
-          _index_item_hash[double_index]->setText ((_selected_set + 1)*2, QKeySequence ());
+          _index_item_hash[double_index]->setText (2, QKeySequence ());
         }
       else
         return;
     }
 
   shortcut_t shortcut = _sc.at (_handled_index);
-  if (! shortcut.actual_sc[_selected_set].isEmpty ())
+  if (! shortcut.actual_sc.isEmpty ())
     _shortcut_hash.remove (widget + sep +
-                           shortcut.actual_sc[_selected_set].toString ());
-  shortcut.actual_sc[_selected_set] = _edit_actual->text();
+                           shortcut.actual_sc.toString ());
+  shortcut.actual_sc = _edit_actual->text();
   _sc.replace (_handled_index, shortcut);
 
-  _index_item_hash[_handled_index]->setText ((_selected_set + 1)*2,
-                                             shortcut.actual_sc[_selected_set]);
+  _index_item_hash[_handled_index]->setText (2, shortcut.actual_sc);
 
-  if (! shortcut.actual_sc[_selected_set].isEmpty ())
-    _shortcut_hash[widget + sep + shortcut.actual_sc[_selected_set].toString ()] =
+  if (! shortcut.actual_sc.isEmpty ())
+    _shortcut_hash[widget + sep + shortcut.actual_sc.toString ()] =
       _handled_index + 1;
 }
 
@@ -638,60 +606,115 @@
   _edit_actual->setText (_label_default->text ());
 }
 
-// import a shortcut set from a given settings file and refresh the tree view
+// import a shortcut set from a given settings file or reset to
+// the defaults (settings = 0) and refresh the tree view
 void
-shortcut_manager::import_shortcuts (int set, QSettings *settings)
+shortcut_manager::import_shortcuts (QSettings *settings)
 {
   for (int i = 0; i < _sc.count (); i++)
     {
       // update the list of all shortcuts
       shortcut_t sc = _sc.at (i);           // make a copy
-      sc.actual_sc[set-1] = QKeySequence (  // get new shortcut from settings
-        settings->value ("shortcuts/"+sc.settings_key,sc.actual_sc[set-1]).
-                        toString ());       // and use the old one as default
+
+      if (settings)
+        sc.actual_sc = QKeySequence (         // get new shortcut from settings
+          settings->value ("shortcuts/"+sc.settings_key,sc.actual_sc).
+                          toString ());       // and use the old one as default
+      else
+        sc.actual_sc = QKeySequence (sc.default_sc); // get default shortcut
+
       _sc.replace (i,sc);                   // replace the old with the new one
 
       // update the tree view
       QTreeWidgetItem* tree_item = _index_item_hash[i]; // get related tree item
-      tree_item->setText (2*set, sc.actual_sc [set-1]); // display new shortcut
+      tree_item->setText (2, sc.actual_sc); // display new shortcut
     }
 }
 
+// ask the user whether to save the current shortcut set;
+// returns true to proceed with import action, false to abort it
+bool
+shortcut_manager::overwrite_all_shortcuts ()
+{
+  QMessageBox msg_box;
+  msg_box.setWindowTitle(tr ("Overwriting Shortcuts"));
+  msg_box.setIcon (QMessageBox::Warning);
+  msg_box.setText(tr ("You are about to overwrite all shortcuts.\n"
+     "Would you like to save the current shortcut set or cancel the action?"));
+  msg_box.setStandardButtons(QMessageBox::Save | QMessageBox::Cancel);
+  QPushButton *discard = msg_box.addButton (tr ("Don't save"),
+                                            QMessageBox::DestructiveRole);
+  msg_box.setDefaultButton(QMessageBox::Save);
+
+  int ret = msg_box.exec ();
+
+  if (msg_box.clickedButton () == discard)
+    return true;  // do not save and go ahead
+
+  if (ret == QMessageBox::Save)
+    {
+      if (do_import_export (OSC_EXPORT))
+        return true;  // go ahead
+    }
+
+  return false; // abort the import
+}
+
 // import or export of shortcut sets,
-// called from settings dialog when related buttons are clicked
-void
-shortcut_manager::do_import_export (bool import, int set)
+// called from settings dialog when related buttons are clicked;
+// returns true on success, false otherwise
+bool
+shortcut_manager::do_import_export (int action)
 {
-  QString file;
+  // ask to save the current shortcuts, maybe abort import
+  if (action == OSC_DEFAULT || action == OSC_IMPORT)
+    {
+      if (! overwrite_all_shortcuts ())
+        return false;
+    }
+
+  // get the filename to read or write the shortcuts,
+  // the default extension is .osc (octave shortcuts)
+  if (action != OSC_DEFAULT)
+    {
+      QString file;
 
-  // get the file name to read or write the shortcuts,
-  // the default extension is .osc (octave shortcuts)
-  if (import)
-    {
-      file = QFileDialog::getOpenFileName (this,
-              tr ("Import shortcut set %1 from file ...").arg (set), QString (),
-              tr ("Octave Shortcut Files (*.osc);;All Files (*)"));
+      if (action == OSC_IMPORT)
+        file  = QFileDialog::getOpenFileName (this,
+                    tr ("Import shortcuts from file ..."), QString (),
+                    tr ("Octave Shortcut Files (*.osc);;All Files (*)"),
+                    0,QFileDialog::DontUseNativeDialog);
+      else if (action == OSC_EXPORT)
+        file = QFileDialog::getSaveFileName (this,
+                    tr ("Export shortcuts into file ..."), QString (),
+                    tr ("Octave Shortcut Files (*.osc);;All Files (*)"),
+                    0,QFileDialog::DontUseNativeDialog);
+
+      if (file.isEmpty ())
+          return false;
+
+      QSettings *osc_settings = new QSettings (file, QSettings::IniFormat);
+
+      if (! osc_settings)
+        {
+          qWarning () << tr ("Failed to open %1 as octave shortcut file")
+                         .arg (file);
+          return false;
+        }
+      else
+        {
+          if (action == OSC_IMPORT)
+            import_shortcuts (osc_settings);   // import (special action)
+          else if (action == OSC_EXPORT)
+            do_write_shortcuts (osc_settings, false); // export, (save settings)
+        }
     }
   else
     {
-      file = QFileDialog::getSaveFileName (this,
-              tr ("Export shortcut set %1 into file ...").arg (set), QString (),
-              tr ("Octave Shortcut Files (*.osc);;All Files (*)"));
+      import_shortcuts (0);
     }
 
-  // create a settings object related to this file
-  QSettings *osc_settings = new QSettings (file, QSettings::IniFormat);
-  if (osc_settings)
-    {
-      // the settings object was successfully created: carry on
-      if (import)
-        import_shortcuts (set, osc_settings);   // import (special action)
-      else
-        do_write_shortcuts (set, osc_settings, false); // export, (saving settings)
-    }
-  else
-    qWarning () << tr ("Failed to open %1 as octave shortcut file"). arg (file);
-
+  return true;
 }
 
 
--- a/libgui/src/shortcut-manager.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/shortcut-manager.h	Thu Dec 10 12:50:06 2015 -0800
@@ -54,6 +54,14 @@
   Q_OBJECT
 
 public:
+
+  enum
+  {
+    OSC_IMPORT  = 0,
+    OSC_EXPORT  = 1,
+    OSC_DEFAULT = 2
+  };
+
   shortcut_manager ();
   ~shortcut_manager ();
 
@@ -63,10 +71,10 @@
       instance->do_init_data ();
   }
 
-  static void write_shortcuts (int set, QSettings *settings, bool closing)
+  static void write_shortcuts (QSettings *settings, bool closing)
   {
     if (instance_ok ())
-      instance->do_write_shortcuts (set, settings, closing);
+      instance->do_write_shortcuts (settings, closing);
   }
 
   static void set_shortcut (QAction *action, const QString& key)
@@ -81,10 +89,10 @@
       instance->do_fill_treewidget (tree_view);
   }
 
-  static void import_export (bool import, int set)
+  static void import_export (int action)
   {
     if (instance_ok ())
-      instance->do_import_export (import, set);
+      instance->do_import_export (action);
   }
 
 public slots:
@@ -113,12 +121,13 @@
 
   void init (QString, QString, QKeySequence);
   void do_init_data ();
-  void do_write_shortcuts (int set, QSettings *settings, bool closing);
+  void do_write_shortcuts (QSettings *settings, bool closing);
   void do_set_shortcut (QAction *action, const QString& key);
   void do_fill_treewidget (QTreeWidget *tree_view);
-  void do_import_export (bool import, int set);
+  bool do_import_export (int action);
   void shortcut_dialog (int);
-  void import_shortcuts (int set, QSettings *settings);
+  void import_shortcuts (QSettings *settings);
+  bool overwrite_all_shortcuts (void);
 
   class shortcut_t
   {
@@ -126,25 +135,15 @@
 
     shortcut_t (void)
       : tree_item (0), description (), settings_key (),
-        actual_sc (new QKeySequence[2]), default_sc (new QKeySequence[2])
-    {
-      actual_sc[0] = QKeySequence ();
-      actual_sc[1] = QKeySequence ();
-
-      default_sc[0] = QKeySequence ();
-      default_sc[1] = QKeySequence ();
-    }
+        actual_sc (QKeySequence ()), default_sc (QKeySequence ())
+    {  }
 
     shortcut_t (const shortcut_t& x)
       : tree_item (x.tree_item), description (x.description),
-        settings_key (x.settings_key),
-        actual_sc (new QKeySequence[2]), default_sc (new QKeySequence[2])
+        settings_key (x.settings_key)
     {
-      actual_sc[0] = x.actual_sc[0];
-      actual_sc[1] = x.actual_sc[1];
-
-      default_sc[0] = x.default_sc[0];
-      default_sc[1] = x.default_sc[1];
+      actual_sc = x.actual_sc;
+      default_sc = x.default_sc;
     }
 
     shortcut_t& operator = (const shortcut_t& x)
@@ -155,14 +154,11 @@
           description = x.description;
           settings_key = x.settings_key;
 
-          actual_sc = new QKeySequence[2];
-          default_sc = new QKeySequence[2];
+          actual_sc = QKeySequence ();
+          default_sc = QKeySequence ();
 
-          actual_sc[0] = x.actual_sc[0];
-          actual_sc[1] = x.actual_sc[1];
-
-          default_sc[0] = x.default_sc[0];
-          default_sc[1] = x.default_sc[1];
+          actual_sc = x.actual_sc;
+          default_sc = x.default_sc;
         }
 
       return *this;
@@ -170,15 +166,13 @@
 
     ~shortcut_t (void)
     {
-      delete [] actual_sc;
-      delete [] default_sc;
     }
 
     QTreeWidgetItem *tree_item;
     QString description;
     QString settings_key;
-    QKeySequence *actual_sc;
-    QKeySequence *default_sc;
+    QKeySequence actual_sc;
+    QKeySequence default_sc;
   };
 
   QList<shortcut_t> _sc;
@@ -194,7 +188,6 @@
   int _handled_index;
 
   QSettings *_settings;
-  int _selected_set;
 
 };
 
--- a/libgui/src/thread-manager.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/thread-manager.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_thread_manager_h)
+#if ! defined (octave_thread_manager_h)
 #define octave_thread_manager_h 1
 
 class octave_base_thread_manager
--- a/libgui/src/workspace-model.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/workspace-model.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_workspace_model_h)
+#if ! defined (octave_workspace_model_h)
 #define octave_workspace_model_h 1
 
 #include <QAbstractTableModel>
--- a/libgui/src/workspace-view.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/workspace-view.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -37,6 +37,7 @@
 #include <QMenu>
 #include <QLabel>
 #include <QCompleter>
+#include <QSignalMapper>
 
 #include "workspace-view.h"
 #include "resource-manager.h"
@@ -75,23 +76,32 @@
   // Set an empty widget, so we can assign a layout to it.
   setWidget (new QWidget (this));
 
-  // Create a new layout and add widgets to it.
-  QVBoxLayout *vbox_layout = new QVBoxLayout ();
-  QHBoxLayout *hbox_layout = new QHBoxLayout ();
-  hbox_layout->addWidget (filter_label);
-  hbox_layout->addWidget (_filter_checkbox);
-  hbox_layout->addWidget (_filter);
-  vbox_layout->addLayout (hbox_layout);
-  vbox_layout->addWidget (view);
-  vbox_layout->setMargin (2);
+  // Create the layouts
+  _filter_widget = new QWidget (this);
+  QHBoxLayout *filter_layout = new QHBoxLayout ();
+
+  filter_layout->addWidget (filter_label);
+  filter_layout->addWidget (_filter_checkbox);
+  filter_layout->addWidget (_filter);
+  filter_layout->setMargin(0);
+  _filter_widget->setLayout (filter_layout);
+
+  QVBoxLayout *ws_layout = new QVBoxLayout ();
+  ws_layout->addWidget (_filter_widget);
+  ws_layout->addWidget (view);
+
+  QSettings *settings = resource_manager::get_settings ();
+
+  _filter_shown = settings->value ("workspaceview/filter_shown",true).toBool();
+  _filter_widget->setVisible (_filter_shown);
+
+  ws_layout->setMargin (2);
 
   // Set the empty widget to have our layout.
-  widget ()->setLayout (vbox_layout);
+  widget ()->setLayout (ws_layout);
 
   // Initialize collapse/expand state of the workspace subcategories.
 
-  QSettings *settings = resource_manager::get_settings ();
-
   //enable sorting (setting column and order after model was set)
   view->setSortingEnabled (true);
   // Initialize column order and width of the workspace
@@ -107,6 +117,11 @@
   );
   view->horizontalHeader ()->setSortIndicatorShown (true);
 
+  view->horizontalHeader ()->setContextMenuPolicy (Qt::CustomContextMenu);
+  connect (view->horizontalHeader (),
+           SIGNAL (customContextMenuRequested (const QPoint &)),
+           this, SLOT (header_contextmenu_requested (const QPoint &)));
+
   // Init state of the filter
   _filter->addItems (settings->value ("workspaceview/mru_list").toStringList ());
 
@@ -129,7 +144,6 @@
 
   connect (this, SIGNAL (command_requested (const QString&)),
            p, SLOT (execute_command_in_terminal (const QString&)));
-
 }
 
 workspace_view::~workspace_view (void)
@@ -146,6 +160,7 @@
 
   settings->setValue ("workspaceview/filter_active",
                       _filter_checkbox->isChecked ());
+  settings->setValue ("workspaceview/filter_shown", _filter_shown);
 
   QStringList mru;
   for (int i = 0; i < _filter->count (); i++)
@@ -153,6 +168,9 @@
   settings->setValue ("workspaceview/mru_list", mru);
 
   settings->sync ();
+
+  if (_sig_mapper)
+    delete _sig_mapper;
 }
 
 void workspace_view::setModel (workspace_model *model)
@@ -223,6 +241,46 @@
 }
 
 void
+workspace_view::header_contextmenu_requested (const QPoint& mpos)
+{
+  QMenu menu (this);
+
+  if (_sig_mapper)
+    delete _sig_mapper;
+  _sig_mapper = new QSignalMapper (this);
+
+  QSettings *settings = resource_manager::get_settings ();
+
+  for (int i = 0; i < _columns_shown.size (); i++)
+    {
+      QAction *action = menu.addAction (_columns_shown.at (i),
+                                        _sig_mapper, SLOT (map ()));
+      _sig_mapper->setMapping(action, i);
+      action->setCheckable (true);
+      action->setChecked (
+            settings->value (_columns_shown_keys.at (i),true).toBool ());
+    }
+
+  connect (_sig_mapper, SIGNAL (mapped (int)), this, SLOT (toggle_header (int)));
+
+  menu.exec (view->mapToGlobal (mpos));
+}
+
+void
+workspace_view::toggle_header (int col)
+{
+  QSettings *settings = resource_manager::get_settings ();
+
+  QString key = _columns_shown_keys.at (col);
+  bool shown = settings->value (key,true).toBool ();
+
+  view->setColumnHidden (col + 1, shown);
+
+  settings->setValue (key, ! shown);
+  settings->sync ();
+}
+
+void
 workspace_view::contextmenu_requested (const QPoint& qpos)
 {
   QMenu menu (this);
@@ -263,8 +321,18 @@
       menu.addAction ("stem (" + var_name + ")", this,
                       SLOT (handle_contextmenu_stem ()));
 
-      menu.exec (view->mapToGlobal (qpos));
+      menu.addSeparator ();
+
     }
+
+  if (_filter_shown)
+    menu.addAction (tr ("Hide filter"), this,
+                    SLOT (handle_contextmenu_filter ()));
+  else
+    menu.addAction (tr ("Show filter"), this,
+                    SLOT (handle_contextmenu_filter ()));
+
+  menu.exec (view->mapToGlobal (qpos));
 }
 
 void
@@ -359,6 +427,13 @@
 }
 
 void
+workspace_view::handle_contextmenu_filter (void)
+{
+  _filter_shown = not _filter_shown;
+  _filter_widget->setVisible (_filter_shown);
+}
+
+void
 workspace_view::handle_model_changed (void)
 {
 //  view->resizeRowsToContents ();
@@ -375,15 +450,23 @@
 void
 workspace_view::notice_settings (const QSettings *settings)
 {
+  int i;
+
   _model->notice_settings (settings); // update colors of model first
 
+  for (i = 0; i < _columns_shown_keys.size (); i++)
+    {
+      view->setColumnHidden ( i + 1,
+            ! settings->value (_columns_shown_keys.at (i),true).toBool ());
+    }
+
   QString tool_tip;
 
   if (!settings->value ("workspaceview/hide_tool_tips",false).toBool ())
     {
       tool_tip  = QString (tr ("View the variables in the active workspace.<br>"));
       tool_tip += QString (tr ("Colors for variable attributes:"));
-      for (int i = 0; i < resource_manager::storage_class_chars ().length (); i++)
+      for (i = 0; i < resource_manager::storage_class_chars ().length (); i++)
         {
           tool_tip +=
             QString ("<div style=\"background-color:%1;color:#000000\">%2</div>")
@@ -394,6 +477,19 @@
 
   setToolTip (tool_tip);
 
+  _columns_shown = QStringList ();
+  _columns_shown.append (tr ("Class"));
+  _columns_shown.append (tr ("Dimension"));
+  _columns_shown.append (tr ("Value"));
+  _columns_shown.append (tr ("Attribute"));
+
+  _columns_shown_keys = QStringList ();
+  _columns_shown_keys.append ("workspaceview/show_class");
+  _columns_shown_keys.append ("workspaceview/show_dimension");
+  _columns_shown_keys.append ("workspaceview/show_value");
+  _columns_shown_keys.append ("workspaceview/show_attribute");
+
+  _sig_mapper = 0;
 }
 
 void
--- a/libgui/src/workspace-view.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libgui/src/workspace-view.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_workspace_view_h)
+#if ! defined (octave_workspace_view_h)
 #define octave_workspace_view_h 1
 
 #include <QItemDelegate>
@@ -30,6 +30,7 @@
 #include <QComboBox>
 #include <QSortFilterProxyModel>
 #include <QCheckBox>
+#include <QSignalMapper>
 
 #include "octave-dock-widget.h"
 #include "workspace-model.h"
@@ -70,6 +71,10 @@
   void handle_contextmenu_disp (void);
   void handle_contextmenu_plot (void);
   void handle_contextmenu_stem (void);
+  void handle_contextmenu_filter (void);
+
+  void header_contextmenu_requested (const QPoint& mpos);
+  void toggle_header (int column);
 
   void handle_model_changed (void);
 
@@ -92,7 +97,14 @@
   QSortFilterProxyModel _filter_model;
   QCheckBox *_filter_checkbox;
   QComboBox *_filter;
+  QWidget *_filter_widget;
+  bool _filter_shown;
+
   enum { MaxFilterHistory = 10 };
+
+  QStringList _columns_shown;
+  QStringList _columns_shown_keys;
+  QSignalMapper *_sig_mapper;
 };
 
 #endif
--- a/libinterp/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,398 +0,0 @@
-# Makefile for Octave's libinterp directory
-#
-# Copyright (C) 1993-2015 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 $(top_srcdir)/build-aux/common.mk
-
-## Search local directories before those specified by the user.
-AM_CPPFLAGS = \
-  -I$(top_srcdir)/liboctave/cruft/misc \
-  -I$(top_srcdir)/liboctave/array \
-  -I$(top_builddir)/liboctave/numeric -I$(top_srcdir)/liboctave/numeric \
-  -I$(top_builddir)/liboctave/operators -I$(top_srcdir)/liboctave/operators \
-  -I$(top_srcdir)/liboctave/system \
-  -I$(top_srcdir)/liboctave/util \
-  -I$(srcdir)/octave-value \
-  -I$(srcdir)/operators \
-  -Iparse-tree -I$(srcdir)/parse-tree \
-  -Icorefcn -I$(srcdir)/corefcn \
-  -I$(top_builddir)/libgnu -I$(top_srcdir)/libgnu \
-  $(HDF5_CPPFLAGS)
-
-AM_CFLAGS += $(WARN_CFLAGS)
-
-AM_CXXFLAGS += $(WARN_CXXFLAGS)
-
-octlib_LTLIBRARIES = liboctinterp.la
-
-## This is the subset of $(BUILT_SOURCES) that may be included by source
-## files that are preprocessed to make $(DEF_FILES).  This ensures that
-## files in $(BUILT_SOURCES) are built in the right dependency order.
-GENERATED_MAKE_BUILTINS_INCS = \
-  corefcn/defaults.h \
-  corefcn/graphics-props.cc \
-  corefcn/graphics.h \
-  corefcn/mxarray.h \
-  oct-conf-features.h \
-  oct-conf.h \
-  parse-tree/oct-gperf.h \
-  parse-tree/oct-parse.h \
-  version.h
-
-BUILT_SOURCES = \
-  $(GENERATED_MAKE_BUILTINS_INCS) \
-  builtin-defun-decls.h \
-  builtins.cc \
-  corefcn/oct-errno.cc \
-  corefcn/oct-tex-lexer.cc \
-  corefcn/oct-tex-parser.cc \
-  corefcn/oct-tex-symbols.cc \
-  operators/ops.cc \
-  parse-tree/lex.cc \
-  parse-tree/oct-parse.cc
-
-ULT_PARSER_SRC := \
-  corefcn/oct-tex-lexer.in.ll \
-  corefcn/oct-tex-parser.in.yy \
-  parse-tree/oct-parse.in.yy
-
-GENERATED_PARSER_FILES := \
-  corefcn/oct-tex-lexer.ll \
-  corefcn/oct-tex-parser.yy \
-  parse-tree/oct-parse.yy
-
-BUILT_DISTFILES = \
-  $(GENERATED_PARSER_FILES) \
-  corefcn/oct-tex-parser.h \
-  corefcn/oct-tex-symbols.cc \
-  parse-tree/oct-gperf.h \
-  parse-tree/oct-parse.h
-
-## Files that are created during build process and installed,
-## BUT not distributed in tarball.
-BUILT_NODISTFILES = \
-  corefcn/mxarray.h \
-  corefcn/oct-errno.cc \
-  corefcn/defaults.h \
-  corefcn/graphics.h \
-  builtin-defun-decls.h \
-  operators/ops.cc \
-  oct-conf.h \
-  oct-conf-features.h \
-  version.h \
-  $(OPT_HANDLERS) \
-  $(OPT_INC) \
-  $(ALL_DEF_FILES) \
-  builtins.cc
-
-EXTRA_DIST = \
-  Makefile.in \
-  DOCSTRINGS \
-  config-features.sh \
-  find-defun-files.sh \
-  gendoc.pl \
-  genprops.awk \
-  mk-errno-list \
-  mk-pkg-add \
-  mkbuiltins \
-  mkdefs \
-  mkops \
-  oct-conf.in.h \
-  version.in.h \
-  $(BUILT_DISTFILES)
-
-octinclude_HEADERS = \
-  corefcn/graphics-props.cc \
-  parse-tree/oct-gperf.h \
-  builtins.h \
-  builtin-defun-decls.h \
-  octave.h \
-  options-usage.h \
-  $(OCTAVE_VALUE_INC) \
-  $(PARSE_TREE_INC) \
-  $(PARSER_INC) \
-  $(OPERATORS_INC) \
-  $(COREFCN_INC)
-
-nodist_octinclude_HEADERS = \
-  corefcn/mxarray.h \
-  corefcn/defaults.h \
-  corefcn/graphics.h \
-  oct-conf.h \
-  version.h
-
-DIST_SRC = \
-  octave.cc \
-  version.cc \
-  $(OCTAVE_VALUE_SRC) \
-  $(PARSE_TREE_SRC) \
-  $(PARSER_SRC) \
-  $(COREFCN_SRC) \
-  $(TEX_PARSER_SRC)
-
-noinst_LTLIBRARIES =
-
-include parse-tree/module.mk
-include octave-value/module.mk
-include operators/module.mk
-include template-inst/module.mk
-include corefcn/module.mk
-include dldfcn/module.mk
-
-$(srcdir)/dldfcn/module.mk: $(srcdir)/dldfcn/config-module.sh $(srcdir)/dldfcn/config-module.awk $(srcdir)/dldfcn/module-files
-	$(srcdir)/dldfcn/config-module.sh $(top_srcdir)
-
-if AMCOND_ENABLE_DYNAMIC_LINKING
-  OCT_FILES = $(DLDFCN_LIBS:.la=.oct)
-  DLD_LIBOCTINTERP_LIBADD = liboctinterp.la
-else
-  OCT_FILES =
-  DLD_LIBOCTINTERP_LIBADD =
-endif
-
-liboctinterp_la_SOURCES = \
-  octave.cc \
-  version.cc \
-  $(OPERATORS_SRC) \
-  $(TEMPLATE_INST_SRC)
-
-nodist_liboctinterp_la_SOURCES = \
-  corefcn/mxarray.h \
-  corefcn/oct-errno.cc \
-  corefcn/defaults.h \
-  corefcn/graphics.h \
-  operators/ops.cc \
-  builtin-defun-decls.h \
-  builtins.cc \
-  oct-conf.h \
-  oct-conf-features.h \
-  version.h \
-  $(OPT_INC)
-
-liboctinterp_la_CPPFLAGS = @OCTINTERP_DLL_DEFS@ $(AM_CPPFLAGS)
-
-include link-deps.mk
-
-liboctinterp_la_LIBADD = \
-  octave-value/liboctave-value.la \
-  parse-tree/libparse-tree.la \
-  parse-tree/libparser.la \
-  corefcn/libcorefcn.la \
-  corefcn/libtex_parser.la \
-  $(top_builddir)/liboctave/liboctave.la \
-  $(LIBOCTINTERP_LINK_DEPS)
-
-# Increment these as needed and according to the rules in the libtool manual:
-liboctinterp_current = 3
-liboctinterp_revision = 0
-liboctinterp_age = 0
-
-liboctinterp_version_info = $(liboctinterp_current):$(liboctinterp_revision):$(liboctinterp_age)
-
-liboctinterp_la_LDFLAGS = \
-  -version-info $(liboctinterp_version_info) \
-  $(NO_UNDEFINED_LDFLAG) \
-  -bindir $(bindir) \
-  $(LIBOCTINTERP_LINK_OPTS)
-
-## Section for defining and creating DEF_FILES
-
-ULT_DIST_SRC := \
-  $(filter-out $(GENERATED_PARSER_FILES), $(DIST_SRC)) $(ULT_PARSER_SRC)
-
-SRC_DEF_FILES := $(shell $(srcdir)/find-defun-files.sh "$(srcdir)" $(ULT_DIST_SRC))
-
-DLDFCN_DEF_FILES = $(DLDFCN_SRC:.cc=.df)
-
-## builtins.cc depends on $(DEF_FILES), so DEF_FILES should only include
-## .df files that correspond to sources included in liboctave.
-if AMCOND_ENABLE_DYNAMIC_LINKING
-  DEF_FILES = $(SRC_DEF_FILES)
-else
-  DEF_FILES = $(SRC_DEF_FILES) $(DLDFCN_DEF_FILES)
-endif
-
-ALL_DEF_FILES = $(SRC_DEF_FILES) $(DLDFCN_DEF_FILES)
-
-$(SRC_DEF_FILES): mkdefs Makefile
-
-$(DEF_FILES): $(OPT_HANDLERS) $(OPT_INC)
-
-## FIXME: The following two variables are deprecated and should be removed
-##        in Octave version 3.12.
-DLL_CDEFS = @OCTINTERP_DLL_DEFS@
-DLL_CXXDEFS = @OCTINTERP_DLL_DEFS@
-
-## Rule to build a DEF file from a .cc file
-## See also module.mk files for overrides when speciall CPPFLAGS are needed.
-## FIXME: Shouldn't the build stop if CPP fails here?  Yes (10/31/2013)
-%.df: %.cc $(GENERATED_MAKE_BUILTINS_INCS)
-	$(AM_V_GEN)rm -f $@-t $@-t1 $@ && \
-	$(CXXCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	  $(AM_CPPFLAGS) $(LLVM_CPPFLAGS) $(CPPFLAGS) \
-	  $(AM_CXXFLAGS) $(CXXFLAGS) \
-	  -DMAKE_BUILTINS $< > $@-t1 && \
-	$(srcdir)/mkdefs $(srcdir) $< < $@-t1 > $@-t && \
-	mv $@-t $@ && \
-	rm -f $@-t1
-
-## Rules to build test files
-
-TST_FILES_SRC := $(shell $(top_srcdir)/build-aux/find-files-with-tests.sh "$(srcdir)" $(ULT_DIST_SRC) $(DLDFCN_SRC))
-
-TST_FILES := $(addsuffix -tst,$(TST_FILES_SRC))
-
-libinterptestsdir := $(octtestsdir)/libinterp
-
-nobase_libinterptests_DATA = $(TST_FILES)
-
-## Override Automake's rule that forces a .hh extension on us even
-## though we don't want it.  It would be super awesome if automake
-## would allow users to choose the header file extension.
-.yy.cc:
-	$(AM_V_YACC)$(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE)
-
-## Special rules:
-## Mostly for sources which must be built before rest of compilation.
-
-## 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.
-oct-conf.h: oct-conf.in.h Makefile
-	$(AM_V_GEN)$(do_subst_config_vals)
-
-oct-conf-features.h: $(top_builddir)/config.h config-features.sh
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/config-features.sh $< > $@-t && \
-	mv $@-t $@
-
-version.h: version.in.h Makefile
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(SED) < $< \
-	  -e "s|%NO_EDIT_WARNING%|DO NOT EDIT!  Generated automatically from $(<F) by Make.|" \
-	  -e "s|%OCTAVE_API_VERSION%|\"${OCTAVE_API_VERSION}\"|" \
-	  -e "s|%OCTAVE_COPYRIGHT%|\"${OCTAVE_COPYRIGHT}\"|" \
-          -e "s|%OCTAVE_MAJOR_VERSION%|${OCTAVE_MAJOR_VERSION}|" \
-          -e "s|%OCTAVE_MINOR_VERSION%|${OCTAVE_MINOR_VERSION}|" \
-          -e "s|%OCTAVE_PATCH_VERSION%|${OCTAVE_PATCH_VERSION}|" \
-	  -e "s|%OCTAVE_RELEASE_DATE%|\"${OCTAVE_RELEASE_DATE}\"|" \
-	  -e "s|%OCTAVE_VERSION%|\"${OCTAVE_VERSION}\"|" > $@-t && \
-	mv $@-t $@
-
-builtins.cc: $(DEF_FILES) mkbuiltins
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mkbuiltins --source $(DEF_FILES) > $@-t && \
-	mv $@-t $@
-
-builtin-defun-decls.h: $(SRC_DEF_FILES) mkbuiltins
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mkbuiltins --header $(SRC_DEF_FILES) > $@-t && \
-	mv $@-t $@
-
-if AMCOND_ENABLE_DYNAMIC_LINKING
-DLDFCN_PKG_ADD_FILE = dldfcn/PKG_ADD
-
-dldfcn/PKG_ADD: $(DLDFCN_DEF_FILES) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(DLDFCN_DEF_FILES) > $@-t && \
-	mv $@-t $@
-endif
-
-if AMCOND_BUILD_DOCS
-.DOCSTRINGS: $(ALL_DEF_FILES) gendoc.pl
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	if [ "x$(srcdir)" != "x." ] && [ -f $(srcdir)/DOCSTRINGS ] && [ ! -f DOCSTRINGS ]; then \
-		cp $(srcdir)/DOCSTRINGS DOCSTRINGS; \
-		touch -r $(srcdir)/DOCSTRINGS DOCSTRINGS; \
-	fi && \
-	$(PERL) $(srcdir)/gendoc.pl $(ALL_DEF_FILES) > $@-t && \
-	mv $@-t $@ && \
-	$(top_srcdir)/build-aux/move-if-change $@ DOCSTRINGS && \
-	touch $@
-
-all-local: $(OCT_FILES) $(DLDFCN_PKG_ADD_FILE) .DOCSTRINGS
-else
-all-local: $(OCT_FILES) $(DLDFCN_PKG_ADD_FILE)
-endif
-
-if AMCOND_BUILD_DOCS
-install-data-hook: install-oct install-built-in-docstrings
-else
-install-data-hook: install-oct uninstall-built-in-docstrings
-endif
-
-uninstall-local: uninstall-oct uninstall-built-in-docstrings
-
-if AMCOND_ENABLE_DYNAMIC_LINKING
-install-oct:
-	$(MKDIR_P) $(DESTDIR)$(octfiledir)
-	if [ -n "`cat $(DLDFCN_PKG_ADD_FILE)`" ]; then \
-	  $(INSTALL_DATA) $(DLDFCN_PKG_ADD_FILE) $(DESTDIR)$(octfiledir)/PKG_ADD; \
-	fi
-	cd $(DESTDIR)$(octlibdir) && \
-	for ltlib in $(DLDFCN_LIBS); do \
-	  f=`echo $$ltlib | $(SED) 's,.*/,,'`; \
-	  dl=`$(SED) -n -e "s/dlname='\([^']*\)'/\1/p" < $$f`; \
-	  if [ -n "$$dl" ]; then \
-	    $(INSTALL_PROGRAM) $$dl $(DESTDIR)$(octfiledir)/`echo $$f | $(SED) 's,^lib,,; s,\.la$$,.oct,'`; \
-	  else \
-	    echo "error: dlname is empty in $$ltlib!"; \
-	    exit 1; \
-	  fi; \
-	  lnames=`$(SED) -n -e "s/library_names='\([^']*\)'/\1/p" < $$f`; \
-	  if [ -n "$$lnames" ]; then \
-	    rm -f $$f $$lnames $$dl; \
-	  fi \
-	done
-
-uninstall-oct:
-	for f in $(notdir $(OCT_FILES)); do \
-	  rm -f $(DESTDIR)$(octfiledir)/$$f; \
-	done
-	rm -f $(DESTDIR)$(octfiledir)/PKG_ADD
-endif
-.PHONY: install-oct uninstall-oct
-
-if AMCOND_BUILD_DOCS
-install-built-in-docstrings:
-	$(MKDIR_P) $(DESTDIR)$(octetcdir)
-	$(INSTALL_DATA) DOCSTRINGS $(DESTDIR)$(octetcdir)/built-in-docstrings
-
-uninstall-built-in-docstrings:
-	rm -f $(DESTDIR)$(octetcdir)/built-in-docstrings
-endif
-.PHONY: install-built-in-docstrings uninstall-built-in-docstrings
-
-CLEANFILES = \
-  $(DLDFCN_PKG_ADD_FILE) \
-  corefcn/graphics-props.cc \
-  corefcn/oct-tex-parser.output \
-  parse-tree/oct-parse.output
-
-DISTCLEANFILES = \
-  .DOCSTRINGS \
-  DOCSTRINGS \
-  $(BUILT_NODISTFILES) \
-  $(OCT_FILES) \
-  $(TST_FILES)
-
-MAINTAINERCLEANFILES = \
-  $(BUILT_DISTFILES)
-
--- a/libinterp/builtins.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/builtins.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,10 +20,10 @@
 
 */
 
-#if !defined (octave_builtins_h)
+#if ! defined (octave_builtins_h)
 #define octave_builtins_h 1
 
-#if !defined (MAKE_BUILTINS)
+#if ! defined (MAKE_BUILTINS)
 #include "builtin-defun-decls.h"
 #endif
 
--- a/libinterp/corefcn/Cell.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/Cell.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -40,7 +40,7 @@
 Cell::Cell (const string_vector& sv, bool trim)
   : Array<octave_value> ()
 {
-  octave_idx_type n = sv.length ();
+  octave_idx_type n = sv.numel ();
 
   if (n > 0)
     {
@@ -99,7 +99,7 @@
 Cell::Cell (const dim_vector& dv, const string_vector& sv, bool trim)
   : Array<octave_value> (dv, Matrix ())
 {
-  octave_idx_type n = sv.length ();
+  octave_idx_type n = sv.numel ();
 
   if (n > 0)
     {
@@ -162,51 +162,56 @@
 
   octave_idx_type n = idx_arg.length ();
 
-  switch (n)
+  // If we catch an indexing error in index_vector, we flag an error
+  // in index k.  Ensure it is the right value befor each idx_vector
+  // call.  Same variable as used in for loop in default case.
+
+  octave_idx_type k = 0;
+
+  try
     {
-    case 0:
-      retval = *this;
-      break;
-
-    case 1:
-      {
-        idx_vector i = idx_arg(0).index_vector ();
+      switch (n)
+        {
+        case 0:
+          retval = *this;
+          break;
 
-        if (! error_state)
-          retval = Array<octave_value>::index (i, resize_ok, Matrix ());
-      }
-      break;
+        case 1:
+          {
+            idx_vector i = idx_arg(0).index_vector ();
 
-    case 2:
-      {
-        idx_vector i = idx_arg(0).index_vector ();
+            retval = Array<octave_value>::index (i, resize_ok, Matrix ());
+          }
+          break;
 
-        if (! error_state)
+        case 2:
           {
+            idx_vector i = idx_arg(0).index_vector ();
+
+            k = 1;
             idx_vector j = idx_arg(1).index_vector ();
 
-            if (! error_state)
-              retval = Array<octave_value>::index (i, j, resize_ok, Matrix ());
+            retval = Array<octave_value>::index (i, j, resize_ok, Matrix ());
           }
-      }
-      break;
+          break;
 
-    default:
-      {
-        Array<idx_vector> iv (dim_vector (n, 1));
+        default:
+          {
+            Array<idx_vector> iv (dim_vector (n, 1));
+
+            for (k = 0; k < n; k++)
+              iv(k) = idx_arg(k).index_vector ();
 
-        for (octave_idx_type i = 0; i < n; i++)
-          {
-            iv(i) = idx_arg(i).index_vector ();
-
-            if (error_state)
-              break;
+            retval = Array<octave_value>::index (iv, resize_ok, Matrix ());
           }
-
-        if (!error_state)
-          retval = Array<octave_value>::index (iv, resize_ok, Matrix ());
-      }
-      break;
+          break;
+        }
+    }
+  catch (index_exception& e)
+    {
+      // Rethrow to allow more info to be reported later.
+      e.set_pos_if_unset (n, k+1);
+      throw;
     }
 
   return retval;
@@ -228,7 +233,18 @@
   Array<idx_vector> ra_idx (dim_vector (len, 1));
 
   for (octave_idx_type i = 0; i < len; i++)
-    ra_idx(i) = idx_arg(i).index_vector ();
+    {
+      try
+        {
+          ra_idx(i) = idx_arg(i).index_vector ();
+        }
+      catch (index_exception& e)
+        {
+          // Rethrow to allow more info to be reported later.
+          e.set_pos (len, i+1);
+          throw;
+        }
+    }
 
   Array<octave_value>::assign (ra_idx, rhs, fill_val);
 }
@@ -242,7 +258,16 @@
   Array<idx_vector> ra_idx (dim_vector (len, 1));
 
   for (octave_idx_type i = 0; i < len; i++)
-    ra_idx.xelem (i) = idx_arg(i).index_vector ();
+    try
+      {
+        ra_idx.xelem (i) = idx_arg(i).index_vector ();
+      }
+    catch (index_exception& e)
+        {
+          // Rethrow to allow more info to be reported later.
+          e.set_pos (len, i+1);
+          throw;
+        }
 
   Array<octave_value>::delete_elements (ra_idx);
 }
@@ -269,18 +294,16 @@
     {
       if (i < 0 || i >= cols ())
         error ("invalid column selection");
-      else
-        {
-          octave_idx_type nr = rows ();
+
+      octave_idx_type nr = rows ();
 
-          retval.resize (dim_vector (nr, 1));
+      retval.resize (dim_vector (nr, 1));
 
-          for (octave_idx_type j = 0; j < nr; j++)
-            retval.xelem (j) = elem (j, i);
-        }
+      for (octave_idx_type j = 0; j < nr; j++)
+        retval.xelem (j) = elem (j, i);
     }
   else
-    error ("Cell::column: requires 2-d cell array");
+    error ("Cell::column: requires 2-D cell array");
 
   return retval;
 }
--- a/libinterp/corefcn/Cell.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/Cell.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_Cell_h)
+#if ! defined (octave_Cell_h)
 #define octave_Cell_h 1
 
 #include <string>
--- a/libinterp/corefcn/__contourc__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/__contourc__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -44,6 +44,7 @@
 #include "error.h"
 #include "oct-obj.h"
 
+// FIXME: this looks like trouble...
 static Matrix this_contour;
 static Matrix contourc;
 static int elem;
@@ -303,33 +304,22 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 4)
-    {
-      RowVector X = args(0).row_vector_value ();
-      RowVector Y = args(1).row_vector_value ();
-      Matrix Z = args(2).matrix_value ();
-      RowVector L = args(3).row_vector_value ();
-
-      if (! error_state)
-        {
-          contourc.resize (2, 0);
-
-          for (int i = 0; i < L.length (); i++)
-            cntr (X, Y, Z, L (i));
-
-          end_contour ();
-
-          retval = contourc;
-        }
-      else
-        error ("__contourc__: invalid argument values");
-    }
-  else
+  if (args.length () != 4)
     print_usage ();
 
-  return retval;
+  RowVector X = args(0).row_vector_value ();
+  RowVector Y = args(1).row_vector_value ();
+  Matrix Z = args(2).matrix_value ();
+  RowVector L = args(3).row_vector_value ();
+
+  contourc.resize (2, 0);
+
+  for (int i = 0; i < L.numel (); i++)
+    cntr (X, Y, Z, L (i));
+
+  end_contour ();
+
+  return octave_value (contourc);
 }
 
 /*
--- a/libinterp/corefcn/__dispatch__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/__dispatch__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -46,86 +46,59 @@
 
   int nargin = args.length ();
 
+  if (nargin < 1 || nargin > 3)
+    print_usage ();
+
   std::string f, r, t;
 
-  if (nargin > 0 && nargin < 4)
-    {
-      if (nargin > 0)
-        {
-          f = args(0).string_value ();
+  f = args(0).xstring_value ("__dispatch__: first argument must be a function name");
 
-          if (error_state)
-            {
-              error ("__dispatch__: first argument must be a function name");
-              return retval;
-            }
-        }
+  if (nargin > 1)
+    r = args(1).xstring_value ("__dispatch__: second argument must be a function name");
 
-      if (nargin > 1)
-        {
-          r = args(1).string_value ();
+  if (nargin > 2)
+    t = args(2).xstring_value ("__dispatch__: third argument must be a type name");
 
-          if (error_state)
-            {
-              error ("__dispatch__: second argument must be a function name");
-              return retval;
-            }
-        }
-
-      if (nargin > 2)
+  if (nargin == 1)
+    {
+      if (nargout > 0)
         {
-          t = args(2).string_value ();
+          symbol_table::fcn_info::dispatch_map_type dm
+            = symbol_table::get_dispatch (f);
 
-          if (error_state)
-            {
-              error ("__dispatch__: third argument must be a type name");
-              return retval;
-            }
-        }
+          size_t len = dm.size ();
 
-      if (nargin == 1)
-        {
-          if (nargout > 0)
-            {
-              symbol_table::fcn_info::dispatch_map_type dm
-                = symbol_table::get_dispatch (f);
+          Cell type_field (len, 1);
+          Cell name_field (len, 1);
 
-              size_t len = dm.size ();
-
-              Cell type_field (len, 1);
-              Cell name_field (len, 1);
-
-              symbol_table::fcn_info::dispatch_map_type::const_iterator p
-                = dm.begin ();
+          symbol_table::fcn_info::dispatch_map_type::const_iterator p
+            = dm.begin ();
 
-              for (size_t i = 0; i < len; i++)
-                {
-                  type_field(i) = p->first;
-                  name_field(i) = p->second;
-
-                  p++;
-                }
-
-              octave_scalar_map m;
+          for (size_t i = 0; i < len; i++)
+            {
+              type_field(i) = p->first;
+              name_field(i) = p->second;
 
-              m.assign ("type", type_field);
-              m.assign ("name", name_field);
-
-              retval = m;
+              p++;
             }
-          else
-            symbol_table::print_dispatch (octave_stdout, f);
-        }
-      else if (nargin == 2)
-        {
-          t = r;
-          symbol_table::clear_dispatch (f, t);
+
+          octave_scalar_map m;
+
+          m.assign ("type", type_field);
+          m.assign ("name", name_field);
+
+          retval = m;
         }
       else
-        symbol_table::add_dispatch (f, t, r);
+        symbol_table::print_dispatch (octave_stdout, f);
+    }
+  else if (nargin == 2)
+    {
+      t = r;
+      symbol_table::clear_dispatch (f, t);
     }
   else
-    print_usage ();
+    symbol_table::add_dispatch (f, t, r);
 
   return retval;
 }
--- a/libinterp/corefcn/__dsearchn__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/__dsearchn__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -40,32 +40,26 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  int nargin = args.length ();
   octave_value_list retval;
 
-  if (nargin != 2)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 2)
+    print_usage ();
 
   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)
+    error ("__dsearch__: number of rows of X and XI must match");
+  else
     {
-      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 ();
-          ColumnVector dist (nxi);
-          double *pdist = dist.fortran_vec ();
+      ColumnVector idx (nxi);
+      double *pidx = idx.fortran_vec ();
+      ColumnVector dist (nxi);
+      double *pdist = dist.fortran_vec ();
 
 #define DIST(dd, y, yi, m) \
   dd = 0.; \
@@ -76,34 +70,33 @@
    } \
   dd = sqrt (dd);
 
-          const double *pxi = xi.fortran_vec ();
-          for (octave_idx_type i = 0; i < nxi; i++)
+      const double *pxi = xi.fortran_vec ();
+      for (octave_idx_type i = 0; i < nxi; i++)
+        {
+          double d0;
+          const double *px = x.fortran_vec ();
+          DIST(d0, px, pxi, n);
+          *pidx = 1.;
+          for (octave_idx_type j = 1; j < nx; j++)
             {
-              double d0;
-              const double *px = x.fortran_vec ();
-              DIST(d0, px, pxi, n);
-              *pidx = 1.;
-              for (octave_idx_type j = 1; j < nx; j++)
+              px += n;
+              double d;
+              DIST (d, px, pxi, n);
+              if (d < d0)
                 {
-                  px += n;
-                  double d;
-                  DIST (d, px, pxi, n);
-                  if (d < d0)
-                    {
-                      d0 = d;
-                      *pidx = static_cast<double>(j + 1);
-                    }
-                  OCTAVE_QUIT;
+                  d0 = d;
+                  *pidx = static_cast<double>(j + 1);
                 }
-
-              *pdist++ = d0;
-              pidx++;
-              pxi += n;
+              OCTAVE_QUIT;
             }
 
-          retval(1) = dist;
-          retval(0) = idx;
+          *pdist++ = d0;
+          pidx++;
+          pxi += n;
         }
+
+      retval(1) = dist;
+      retval(0) = idx;
     }
 
   return retval;
--- a/libinterp/corefcn/__ichol__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/__ichol__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -52,25 +52,18 @@
 bool ichol_checkpivot_complex (Complex pivot)
 {
   if (pivot.imag () != 0)
-    {
-      error ("ichol: non-real pivot encountered.  The matrix must be hermitian.");
-      return false;
-    }
+    error ("ichol: non-real pivot encountered.  The matrix must be hermitian.");
   else if (pivot.real () < 0)
-    {
-      error ("ichol: negative pivot encountered");
-      return false;
-    }
+    error ("ichol: negative pivot encountered");
+
   return true;
 }
 
 bool ichol_checkpivot_real (double pivot)
 {
   if (pivot < 0)
-    {
-      error ("ichol: negative pivot encountered");
-      return false;
-    }
+    error ("ichol: negative pivot encountered");
+
   return true;
 }
 
@@ -156,10 +149,7 @@
         data[j1] += dropsums[k];
 
       if (ridx[j1] != k)
-        {
-          error ("ichol: encountered a pivot equal to 0");
-          break;
-        }
+        error ("ichol: encountered a pivot equal to 0");
 
       if (! ichol_checkpivot (data[j1]))
         break;
@@ -202,10 +192,7 @@
   std::string michol = "off";
 
   if (nargout > 1 || nargin < 1 || nargin > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   if (nargin == 2)
     michol = args(1).string_value ();
@@ -221,8 +208,8 @@
       sm = feval ("tril", param_list)(0).sparse_matrix_value ();
       ichol_0 <SparseMatrix, double, ichol_mult_real,
                ichol_checkpivot_real> (sm, michol);
-      if (! error_state)
-        retval(0) = sm;
+
+      retval(0) = sm;
     }
   else
     {
@@ -231,8 +218,8 @@
       sm = feval ("tril", param_list)(0).sparse_complex_matrix_value ();
       ichol_0 <SparseComplexMatrix, Complex, ichol_mult_complex,
                ichol_checkpivot_complex> (sm, michol);
-      if (! error_state)
-        retval(0) = sm;
+
+      retval(0) = sm;
     }
 
   return retval;
@@ -392,11 +379,9 @@
         data_l[total_len] += col_drops[k];
 
       if (data_l[total_len] == zero)
-        {
-          error ("ichol: encountered a pivot equal to 0");
-          break;
-        }
-      else if (! ichol_checkpivot (data_l[total_len]))
+        error ("ichol: encountered a pivot equal to 0");
+
+      if (! ichol_checkpivot (data_l[total_len]))
         break;
 
       // Once elements are dropped and compensation of column sums are done,
@@ -408,10 +393,8 @@
       // Check if there are too many elements to be indexed with
       // octave_idx_type type due to fill-in during the process.
       if (total_len < 0)
-        {
-          error ("ichol: integer overflow.  Too many fill-in elements in L");
-          break;
-        }
+        error ("ichol: integer overflow.  Too many fill-in elements in L");
+
       cidx_l[k+1] = cidx_l[k] - cidx_l[0] + w_len;
 
       // Update Llist and Lfirst with the k-column information.
@@ -428,17 +411,16 @@
         }
     }
 
-  if (! error_state)
+  // Build the output matrices
+  L = octave_matrix_t (n, n, total_len);
+
+  for (i = 0; i <= n; i++)
+    L.cidx (i) = cidx_l[i];
+
+  for (i = 0; i < total_len; i++)
     {
-      // Build the output matrices
-      L = octave_matrix_t (n, n, total_len);
-      for (i = 0; i <= n; i++)
-        L.cidx (i) = cidx_l[i];
-      for (i = 0; i < total_len; i++)
-        {
-          L.ridx (i) = ridx_l[i];
-          L.data (i) = data_l[i];
-        }
+      L.ridx (i) = ridx_l[i];
+      L.data (i) = data_l[i];
     }
 }
 
@@ -457,10 +439,7 @@
   double droptol = 0;
 
   if (nargout > 1 || nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   // Don't repeat input validation of arguments done in ichol.m
 
@@ -486,8 +465,8 @@
       ichol_t <SparseMatrix,
                double, ichol_mult_real, ichol_checkpivot_real>
                (sm_l, L, cols_norm.fortran_vec (), droptol, michol);
-      if (! error_state)
-        retval(0) = L;
+
+      retval(0) = L;
     }
   else
     {
@@ -505,8 +484,8 @@
                Complex, ichol_mult_complex, ichol_checkpivot_complex>
                (sm_l, L, cols_norm.fortran_vec (),
                 Complex (droptol), michol);
-      if (! error_state)
-        retval(0) = L;
+
+      retval(0) = L;
     }
 
   return retval;
--- a/libinterp/corefcn/__ilu__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/__ilu__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -140,10 +140,7 @@
   std::string milu;
 
   if (nargout > 2 || nargin < 1 || nargin > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   // In ILU0 algorithm the zero-pattern of the input matrix is preserved so
   // it's structure does not change during the algorithm.  The same input
@@ -153,34 +150,28 @@
     {
       SparseMatrix sm = args(0).sparse_matrix_value ();
       ilu_0 <SparseMatrix, double> (sm, milu);
-      if (!error_state)
-        {
-          param_list.append (sm);
-          retval(1) = feval ("triu", param_list)(0).sparse_matrix_value ();
-          SparseMatrix eye =
-            feval ("speye", octave_value_list (
-                     octave_value (sm.cols ())))(0).sparse_matrix_value ();
-          param_list.append (-1);
-          retval(0) = eye +
-                      feval ("tril", param_list)(0).sparse_matrix_value ();
-        }
+
+      param_list.append (sm);
+      retval(1) = feval ("triu", param_list)(0).sparse_matrix_value ();
+      SparseMatrix eye =
+        feval ("speye", octave_value_list (octave_value (sm.cols ())))(0).sparse_matrix_value ();
+      param_list.append (-1);
+      retval(0) = eye +
+        feval ("tril", param_list)(0).sparse_matrix_value ();
     }
   else
     {
       SparseComplexMatrix sm = args(0).sparse_complex_matrix_value ();
       ilu_0 <SparseComplexMatrix, Complex> (sm, milu);
-      if (! error_state)
-        {
-          param_list.append (sm);
-          retval(1) =
-            feval ("triu", param_list)(0).sparse_complex_matrix_value ();
-          SparseComplexMatrix eye =
-            feval ("speye", octave_value_list (
-                     octave_value (sm.cols ())))(0).sparse_complex_matrix_value ();
-          param_list.append (-1);
-          retval(0) =
-            eye + feval ("tril", param_list)(0).sparse_complex_matrix_value ();
-        }
+
+      param_list.append (sm);
+      retval(1) =
+        feval ("triu", param_list)(0).sparse_complex_matrix_value ();
+      SparseComplexMatrix eye =
+        feval ("speye", octave_value_list (octave_value (sm.cols ())))(0).sparse_complex_matrix_value ();
+      param_list.append (-1);
+      retval(0) =
+        eye + feval ("tril", param_list)(0).sparse_complex_matrix_value ();
     }
 
   return retval;
@@ -446,27 +437,29 @@
         }
     }
 
-  if (! error_state)
+  // Build the output matrices
+  L = octave_matrix_t (n, n, total_len_l);
+  U = octave_matrix_t (n, n, total_len_u);
+
+  for (i = 0; i <= n; i++)
+    L.cidx (i) = cidx_l[i];
+
+  for (i = 0; i < total_len_l; i++)
     {
-      // Build the output matrices
-      L = octave_matrix_t (n, n, total_len_l);
-      U = octave_matrix_t (n, n, total_len_u);
-      for (i = 0; i <= n; i++)
-        L.cidx (i) = cidx_l[i];
-      for (i = 0; i < total_len_l; i++)
-        {
-          L.ridx (i) = ridx_l[i];
-          L.data (i) = data_l[i];
-        }
-      for (i = 0; i <= n; i++)
-        U.cidx (i) = cidx_u[i];
-      for (i = 0; i < total_len_u; i++)
-        {
-          U.ridx (i) = ridx_u[i];
-          U.data (i) = data_u[i];
-        }
-      U = U.transpose ();
+      L.ridx (i) = ridx_l[i];
+      L.data (i) = data_l[i];
     }
+
+  for (i = 0; i <= n; i++)
+    U.cidx (i) = cidx_u[i];
+
+  for (i = 0; i < total_len_u; i++)
+    {
+      U.ridx (i) = ridx_u[i];
+      U.data (i) = data_u[i];
+    }
+
+  U = U.transpose ();
 }
 
 DEFUN (__iluc__, args, nargout,
@@ -484,10 +477,7 @@
   double droptol = 0;
 
   if (nargout != 2 || nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   // Don't repeat input validation of arguments done in ilu.m
   if (nargin >= 2)
@@ -515,24 +505,21 @@
                                         cols_norm.fortran_vec (),
                                         rows_norm.fortran_vec (),
                                         droptol, milu);
-      if (! error_state)
-        {
-          param_list.append (octave_value (L.cols ()));
-          SparseMatrix eye =
-            feval ("speye", param_list)(0).sparse_matrix_value ();
-          retval(1) = U;
-          retval(0) = L + eye;
-        }
+      param_list.append (octave_value (L.cols ()));
+      SparseMatrix eye =
+        feval ("speye", param_list)(0).sparse_matrix_value ();
+      retval(1) = U;
+      retval(0) = L + eye;
     }
   else
     {
       Array<Complex> cols_norm, rows_norm;
       param_list.append (args(0).sparse_complex_matrix_value ());
       SparseComplexMatrix sm_u =
-        feval("triu", param_list)(0).sparse_complex_matrix_value ();
+        feval ("triu", param_list)(0).sparse_complex_matrix_value ();
       param_list.append (-1);
       SparseComplexMatrix sm_l =
-        feval("tril", param_list)(0).sparse_complex_matrix_value ();
+        feval ("tril", param_list)(0).sparse_complex_matrix_value ();
       param_list(1) = "rows";
       rows_norm = feval ("norm", param_list)(0).complex_vector_value ();
       param_list(1) = "cols";
@@ -543,14 +530,12 @@
       ilu_crout < SparseComplexMatrix, Complex >
                 (sm_l, sm_u, L, U, cols_norm.fortran_vec () ,
                  rows_norm.fortran_vec (), Complex (droptol), milu);
-      if (! error_state)
-        {
-          param_list.append (octave_value (L.cols ()));
-          SparseComplexMatrix eye =
-            feval ("speye", param_list)(0).sparse_complex_matrix_value ();
-          retval(1) = U;
-          retval(0) = L + eye;
-        }
+
+      param_list.append (octave_value (L.cols ()));
+      SparseComplexMatrix eye =
+        feval ("speye", param_list)(0).sparse_complex_matrix_value ();
+      retval(1) = U;
+      retval(0) = L + eye;
     }
 
   return retval;
@@ -584,7 +569,7 @@
 
   // That is necessary for the JKI (milu = "row") variant.
   if (opt == ROW)
-    sm = sm.transpose();
+    sm = sm.transpose ();
 
   // Extract pointers to the arrays for faster access inside loops
   octave_idx_type* cidx_in = sm.cidx ();
@@ -613,7 +598,7 @@
   Array <octave_idx_type> ridx_out_u (dim_vector (max_len_u, 1));
   octave_idx_type* ridx_u = ridx_out_u.fortran_vec ();
   Array <T> data_out_u (dim_vector (max_len_u, 1));
-  T* data_u = data_out_u.fortran_vec();
+  T* data_u = data_out_u.fortran_vec ();
 
   // Working arrays and permutation arrays
   octave_idx_type w_len_u, w_len_l;
@@ -873,81 +858,78 @@
       iw_u.clear ();
     }
 
-  if (! error_state)
+  octave_matrix_t *L_ptr;
+  octave_matrix_t *U_ptr;
+  octave_matrix_t diag (n, n, n);
+
+  // L and U are interchanged if milu = 'row'.  It is a matter
+  // of nomenclature to re-use code with both IKJ and JKI
+  // versions of the algorithm.
+  if (opt == ROW)
     {
-      octave_matrix_t *L_ptr;
-      octave_matrix_t *U_ptr;
-      octave_matrix_t diag (n, n, n);
+      L_ptr = &U;
+      U_ptr = &L;
+      L = octave_matrix_t (n, n, total_len_u - n);
+      U = octave_matrix_t (n, n, total_len_l);
+    }
+  else
+    {
+      L_ptr = &L;
+      U_ptr = &U;
+      L = octave_matrix_t (n, n, total_len_l);
+      U = octave_matrix_t (n, n, total_len_u);
+    }
 
-      // L and U are interchanged if milu = 'row'.  It is a matter
-      // of nomenclature to re-use code with both IKJ and JKI
-      // versions of the algorithm.
+  for (i = 0; i <= n; i++)
+    {
+      L_ptr->cidx (i) = cidx_l[i];
+      U_ptr->cidx (i) = cidx_u[i];
       if (opt == ROW)
-        {
-          L_ptr = &U;
-          U_ptr = &L;
-          L = octave_matrix_t (n, n, total_len_u - n);
-          U = octave_matrix_t (n, n, total_len_l);
-        }
-      else
-        {
-          L_ptr = &L;
-          U_ptr = &U;
-          L = octave_matrix_t (n, n, total_len_l);
-          U = octave_matrix_t (n, n, total_len_u);
-        }
+        U_ptr->cidx (i) -= i;
+    }
 
-      for (i = 0; i <= n; i++)
-        {
-          L_ptr->cidx (i) = cidx_l[i];
-          U_ptr->cidx (i) = cidx_u[i];
-          if (opt == ROW)
-            U_ptr->cidx (i) -= i;
-        }
-
-      for (i = 0; i < n; i++)
-        {
-          if (opt == ROW)
-            diag.elem (i,i) = data_u[uptr[i]];
-          j = cidx_l[i];
+  for (i = 0; i < n; i++)
+    {
+      if (opt == ROW)
+        diag.elem (i,i) = data_u[uptr[i]];
+      j = cidx_l[i];
 
-          while (j < cidx_l[i+1])
+      while (j < cidx_l[i+1])
+        {
+          L_ptr->ridx (j) = ridx_l[j];
+          L_ptr->data (j) = data_l[j];
+          j++;
+        }
+      j = cidx_u[i];
+
+      while (j < cidx_u[i+1])
+        {
+          c = j;
+          if (opt == ROW)
             {
-              L_ptr->ridx (j) = ridx_l[j];
-              L_ptr->data (j) = data_l[j];
-              j++;
-            }
-          j = cidx_u[i];
-
-          while (j < cidx_u[i+1])
-            {
-              c = j;
-              if (opt == ROW)
+              // The diagonal is removed from L if milu = 'row'.
+              // That is because is convenient to have it inside
+              // the L part to carry out the process.
+              if (ridx_u[j] == i)
                 {
-                  // The diagonal is removed from L if milu = 'row'.
-                  // That is because is convenient to have it inside
-                  // the L part to carry out the process.
-                  if (ridx_u[j] == i)
-                    {
-                      j++;
-                      continue;
-                    }
-                  else
-                    c -= i;
+                  j++;
+                  continue;
                 }
-              U_ptr->data (c) = data_u[j];
-              U_ptr->ridx (c) = ridx_u[j];
-              j++;
+              else
+                c -= i;
             }
+          U_ptr->data (c) = data_u[j];
+          U_ptr->ridx (c) = ridx_u[j];
+          j++;
         }
+    }
 
-      if (opt == ROW)
-        {
-          U = U.transpose ();
-          // The diagonal, conveniently permuted is added to U
-          U += diag.index (idx_vector::colon, perm_vec);
-          L = L.transpose ();
-        }
+  if (opt == ROW)
+    {
+      U = U.transpose ();
+      // The diagonal, conveniently permuted is added to U
+      U += diag.index (idx_vector::colon, perm_vec);
+      L = L.transpose ();
     }
 }
 
@@ -966,14 +948,12 @@
 
   int nargin = args.length ();
   std::string milu = "";
-  double droptol = 0, thresh = 1;
+  double droptol = 0;
+  double thresh = 1;
   double udiag = 0;
 
   if (nargout < 2 || nargout > 3 || nargin < 1 || nargin > 5)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   // Don't repeat input validation of arguments done in ilu.m
   if (nargin >= 2)
@@ -1010,35 +990,32 @@
       ilu_tp <SparseMatrix, double> (sm, L, U, nnz_u, nnz_l,
                                      rc_norm.fortran_vec (),
                                      perm, droptol, thresh, milu, udiag);
-      if (! error_state)
+      param_list.append (octave_value (L.cols ()));
+      SparseMatrix eye =
+        feval ("speye", param_list)(0).sparse_matrix_value ();
+      if (milu == "row")
         {
-          param_list.append (octave_value (L.cols ()));
-          SparseMatrix eye =
-            feval ("speye", param_list)(0).sparse_matrix_value ();
-          if (milu == "row")
+          if (nargout == 3)
             {
-              if (nargout == 3)
-                {
-                  retval(2) = eye.index (idx_vector::colon, perm);
-                  retval(1) = U.index (idx_vector::colon, perm);
-                }
-              else if (nargout == 2)
-                retval(1) = U;
-              retval(0) = L + eye;
+              retval(2) = eye.index (idx_vector::colon, perm);
+              retval(1) = U.index (idx_vector::colon, perm);
+            }
+          else if (nargout == 2)
+            retval(1) = U;
+          retval(0) = L + eye;
+        }
+      else
+        {
+          if (nargout == 3)
+            {
+              retval(2) = eye.index (perm, idx_vector::colon);
+              retval(1) = U;
+              retval(0) = L.index (perm, idx_vector::colon) + eye;
             }
           else
             {
-              if (nargout == 3)
-                {
-                  retval(2) = eye.index (perm, idx_vector::colon);
-                  retval(1) = U;
-                  retval(0) = L.index (perm, idx_vector::colon) + eye;
-                }
-              else
-                {
-                  retval(1) = U;
-                  retval(0) = L + eye.index (perm, idx_vector::colon);
-                }
+              retval(1) = U;
+              retval(0) = L + eye.index (perm, idx_vector::colon);
             }
         }
     }
@@ -1065,35 +1042,32 @@
               (sm, L, U, nnz_u, nnz_l, rc_norm.fortran_vec (), perm,
                Complex (droptol), Complex (thresh), milu, udiag);
 
-      if (! error_state)
+      param_list.append (octave_value (L.cols ()));
+      SparseComplexMatrix eye =
+        feval ("speye", param_list)(0).sparse_complex_matrix_value ();
+      if (milu == "row")
         {
-          param_list.append (octave_value (L.cols ()));
-          SparseComplexMatrix eye =
-            feval ("speye", param_list)(0).sparse_complex_matrix_value ();
-          if (milu == "row")
+          if (nargout == 3)
             {
-              if (nargout == 3)
-                {
-                  retval(2) = eye.index (idx_vector::colon, perm);
-                  retval(1) = U.index (idx_vector::colon, perm);
-                }
-              else if (nargout == 2)
-                retval(1) = U;
-              retval(0) = L + eye;
+              retval(2) = eye.index (idx_vector::colon, perm);
+              retval(1) = U.index (idx_vector::colon, perm);
+            }
+          else if (nargout == 2)
+            retval(1) = U;
+          retval(0) = L + eye;
+        }
+      else
+        {
+          if (nargout == 3)
+            {
+              retval(2) = eye.index (perm, idx_vector::colon);
+              retval(1) = U;
+              retval(0) = L.index (perm, idx_vector::colon) + eye;
             }
           else
             {
-              if (nargout == 3)
-                {
-                  retval(2) = eye.index (perm, idx_vector::colon);
-                  retval(1) = U;
-                  retval(0) = L.index (perm, idx_vector::colon) + eye;
-                }
-              else
-                {
-                  retval(1) = U;
-                  retval(0) = L + eye.index (perm, idx_vector::colon);
-                }
+              retval(1) = U;
+              retval(0) = L + eye.index (perm, idx_vector::colon);
             }
         }
     }
--- a/libinterp/corefcn/__lin_interpn__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/__lin_interpn__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -222,31 +222,23 @@
       for (int i = 0; i < n; i++)
         {
           if (X[i].dims () != V.dims ())
-            {
-              error ("interpn: incompatible size of argument number %d", i+1);
-              return retval;
-            }
-          else
-            {
-              M tmp = M (dim_vector (size[i], 1));
+            error ("interpn: incompatible size of argument number %d", i+1);
+
+          M tmp = M (dim_vector (size[i], 1));
 
-              for (octave_idx_type j = 0; j < size[i]; j++)
-                tmp(j) =  X[i](scale[i]*j);
+          for (octave_idx_type j = 0; j < size[i]; j++)
+            tmp(j) =  X[i](scale[i]*j);
 
-              X[i] = tmp;
-            }
+          X[i] = tmp;
         }
     }
 
   for (int i = 0; i < n; i++)
     {
       if (! isvector (X[i]) && X[i].numel () != size[i])
-        {
-          error ("interpn: incompatible size of argument number %d", i+1);
-          return retval;
-        }
-      else
-        x[i] = X[i].data ();
+        error ("interpn: incompatible size of argument number %d", i+1);
+
+      x[i] = X[i].data ();
     }
 
   lin_interpn (n, size, scale, Ni, extrapval, x, v, y, vi);
@@ -277,11 +269,8 @@
 
   int nargin = args.length ();
 
-  if (nargin < 2 ||  nargin % 2 == 0)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin < 2 || nargin % 2 == 0)
+    print_usage ();
 
   // dimension of the problem
   int n = (nargin-1)/2;
@@ -293,28 +282,13 @@
 
       const FloatNDArray V = args(n).float_array_value ();
 
-      if (error_state)
-        {
-          print_usage ();
-          return retval;
-        }
-
       for (int i = 0; i < n; i++)
         {
           X[i] = args(i).float_array_value ();
           Y[i] = args(n+i+1).float_array_value ();
 
-          if (error_state)
-            {
-              print_usage ();
-              return retval;
-            }
-
           if (Y[0].dims () != Y[i].dims ())
-            {
-              error ("interpn: incompatible size of argument number %d", n+i+2);
-              return retval;
-            }
+            error ("interpn: incompatible size of argument number %d", n+i+2);
         }
 
       retval = lin_interpn<float, FloatNDArray> (n, X, V, Y);
@@ -326,28 +300,13 @@
 
       const NDArray V = args(n).array_value ();
 
-      if (error_state)
-        {
-          print_usage ();
-          return retval;
-        }
-
       for (int i = 0; i < n; i++)
         {
           X[i] = args(i).array_value ();
           Y[i] = args(n+i+1).array_value ();
 
-          if (error_state)
-            {
-              print_usage ();
-              return retval;
-            }
-
           if (Y[0].dims () != Y[i].dims ())
-            {
-              error ("interpn: incompatible size of argument number %d", n+i+2);
-              return retval;
-            }
+            error ("interpn: incompatible size of argument number %d", n+i+2);
         }
 
       retval = lin_interpn<double, NDArray> (n, X, V, Y);
--- a/libinterp/corefcn/__pchip_deriv__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/__pchip_deriv__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -68,22 +68,16 @@
           FloatColumnVector xvec (args(0).float_vector_value ());
           FloatMatrix ymat (args(1).float_matrix_value ());
 
-          octave_idx_type nx = xvec.length ();
+          octave_idx_type nx = xvec.numel ();
 
           if (nx < 2)
-            {
-              error ("__pchip_deriv__: X must be at least of length 2");
-              return retval;
-            }
+            error ("__pchip_deriv__: X must be at least of length 2");
 
           octave_idx_type nyr = ymat.rows ();
           octave_idx_type nyc = ymat.columns ();
 
           if (nx != (rows ? nyc : nyr))
-            {
-              error ("__pchip_deriv__: X and Y dimension mismatch");
-              return retval;
-            }
+            error ("__pchip_deriv__: X and Y dimension mismatch");
 
           FloatMatrix dmat (nyr, nyc);
 
@@ -102,10 +96,7 @@
               k++;
 
               if (ierr < 0)
-                {
-                  error ("__pchip_deriv__: PCHIM failed with ierr = %i", ierr);
-                  return retval;
-                }
+                error ("__pchip_deriv__: PCHIM failed with ierr = %i", ierr);
             }
 
           retval = dmat;
@@ -115,22 +106,16 @@
           ColumnVector xvec (args(0).vector_value ());
           Matrix ymat (args(1).matrix_value ());
 
-          octave_idx_type nx = xvec.length ();
+          octave_idx_type nx = xvec.numel ();
 
           if (nx < 2)
-            {
-              error ("__pchip_deriv__: X must be at least of length 2");
-              return retval;
-            }
+            error ("__pchip_deriv__: X must be at least of length 2");
 
           octave_idx_type nyr = ymat.rows ();
           octave_idx_type nyc = ymat.columns ();
 
           if (nx != (rows ? nyc : nyr))
-            {
-              error ("__pchip_deriv__: X and Y dimension mismatch");
-              return retval;
-            }
+            error ("__pchip_deriv__: X and Y dimension mismatch");
 
           Matrix dmat (nyr, nyc);
 
@@ -148,10 +133,7 @@
               k++;
 
               if (ierr < 0)
-                {
-                  error ("__pchip_deriv__: DPCHIM failed with ierr = %i", ierr);
-                  return retval;
-                }
+                error ("__pchip_deriv__: DPCHIM failed with ierr = %i", ierr);
             }
 
           retval = dmat;
--- a/libinterp/corefcn/__qp__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/__qp__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -62,7 +62,7 @@
 
       double tol = tmp * s(0) * std::numeric_limits<double>::epsilon ();
 
-      octave_idx_type n = s.length ();
+      octave_idx_type n = s.numel ();
 
       for (octave_idx_type i = 0; i < n; i++)
         {
@@ -97,11 +97,11 @@
   double rtol = sqrt (std::numeric_limits<double>::epsilon ());
 
   // Problem dimension.
-  octave_idx_type n = x.length ();
+  octave_idx_type n = x.numel ();
 
   // Dimension of constraints.
-  octave_idx_type n_eq = beq.length ();
-  octave_idx_type n_in = bin.length ();
+  octave_idx_type n_eq = beq.numel ();
+  octave_idx_type n_in = bin.numel ();
 
   // Filling the current active set.
 
@@ -136,12 +136,15 @@
 
   // Computing the ???
 
-  EIG eigH (H);
+  EIG eigH;
 
-  if (error_state)
+  try
     {
-      error ("qp: failed to compute eigenvalues of H");
-      return -1;
+      eigH = EIG (H);
+    }
+  catch (octave_execution_exception& e)
+    {
+      error (e, "qp: failed to compute eigenvalues of H");
     }
 
   ColumnVector eigenvalH = real (eigH.eigenvalues ());
@@ -281,12 +284,15 @@
 
               // Searching for the most negative curvature.
 
-              EIG eigrH (rH);
+              EIG eigrH;
 
-              if (error_state)
+              try
                 {
-                  error ("qp: failed to compute eigenvalues of rH");
-                  return -1;
+                  eigrH = EIG (rH);
+                }
+              catch (octave_execution_exception& e)
+                {
+                  error (e, "qp: failed to compute eigenvalues of rH");
                 }
 
               ColumnVector eigenvalrH = real (eigrH.eigenvalues ());
@@ -487,44 +493,32 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 8)
-    {
-      const ColumnVector x0  (args(0) . vector_value ());
-      const Matrix H         (args(1) . matrix_value ());
-      const ColumnVector q   (args(2) . vector_value ());
-      const Matrix Aeq       (args(3) . matrix_value ());
-      const ColumnVector beq (args(4) . vector_value ());
-      const Matrix Ain       (args(5) . matrix_value ());
-      const ColumnVector bin (args(6) . vector_value ());
-      const int maxit        (args(7) . int_value ());
+  if (args.length () != 8)
+    print_usage ();
 
-      if (! error_state)
-        {
-          int iter = 0;
-
-          // Copying the initial guess in the working variable
-          ColumnVector x = x0;
+  const ColumnVector x0  (args(0) . vector_value ());
+  const Matrix H         (args(1) . matrix_value ());
+  const ColumnVector q   (args(2) . vector_value ());
+  const Matrix Aeq       (args(3) . matrix_value ());
+  const ColumnVector beq (args(4) . vector_value ());
+  const Matrix Ain       (args(5) . matrix_value ());
+  const ColumnVector bin (args(6) . vector_value ());
+  const int maxit        (args(7) . int_value ());
 
-          // Reordering the Lagrange multipliers
-          ColumnVector lambda;
+  int iter = 0;
 
-          int info = qp (H, q, Aeq, beq, Ain, bin, maxit, x, lambda, iter);
+  // Copying the initial guess in the working variable
+  ColumnVector x = x0;
 
-          if (! error_state)
-            {
-              retval(3) = iter;
-              retval(2) = info;
-              retval(1) = lambda;
-              retval(0) = x;
-            }
-          else
-            error ("qp: internal error");
-        }
-      else
-        error ("__qp__: invalid arguments");
-    }
-  else
-    print_usage ();
+  // Reordering the Lagrange multipliers
+  ColumnVector lambda;
+
+  int info = qp (H, q, Aeq, beq, Ain, bin, maxit, x, lambda, iter);
+
+  retval(3) = iter;
+  retval(2) = info;
+  retval(1) = lambda;
+  retval(0) = x;
 
   return retval;
 }
--- a/libinterp/corefcn/balance.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/balance.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -96,10 +96,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3 || nargout < 0 || nargout > 4)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   // determine if it's AEP or GEP
   bool AEPcase = nargin == 1 || args(1).is_string ();
@@ -140,9 +137,6 @@
         aa = args(0).matrix_value ();
     }
 
-  if (error_state)
-    return retval;
-
   // Treat AEP/GEP cases.
   if (AEPcase)
     {
@@ -246,13 +240,8 @@
       // Generalized eigenvalue problem.
       if (nargin == 2)
         bal_job = "B";
-      else if (args(2).is_string ())
-        bal_job = args(2).string_value ();
       else
-        {
-          error ("balance: OPT argument must be a string");
-          return retval;
-        }
+        bal_job = args(2).xstring_value ("balance: OPT argument must be a string");
 
       if ((nn != args(1).columns ()) || (nn != args(1).rows ()))
         {
--- a/libinterp/corefcn/besselj.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/besselj.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -29,7 +29,6 @@
 
 #include "defun.h"
 #include "error.h"
-#include "gripes.h"
 #include "oct-obj.h"
 #include "utils.h"
 
@@ -78,12 +77,6 @@
     } \
   while (0)
 
-static void
-gripe_bessel_arg (const char *fn, const char *arg)
-{
-  error ("%s: expecting scalar or matrix as %s argument", fn, arg);
-}
-
 octave_value_list
 do_bessel (enum bessel_type type, const char *fn,
            const octave_value_list& args, int nargout)
@@ -92,311 +85,226 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  bool scaled = false;
+  if (nargin == 3)
     {
-      bool scaled = false;
-      if (nargin == 3)
+      octave_value opt_arg = args(2);
+      bool rpt_error = false;
+
+      if (! opt_arg.is_scalar_type ())
+        rpt_error = true;
+      else if (opt_arg.is_numeric_type ())
         {
-          octave_value opt_arg = args(2);
-          bool rpt_error = false;
-
-          if (! opt_arg.is_scalar_type ())
+          double opt_val = opt_arg.double_value ();
+          if (opt_val != 0.0 && opt_val != 1.0)
             rpt_error = true;
-          else if (opt_arg.is_numeric_type ())
-            {
-              double opt_val = opt_arg.double_value ();
-              if (opt_val != 0.0 && opt_val != 1.0)
-                rpt_error = true;
-              scaled = (opt_val == 1.0);
-            }
-          else if (opt_arg.is_bool_type ())
-            scaled = opt_arg.bool_value ();
-
-          if (rpt_error)
-            {
-              error ("%s: OPT must be 0 (or false) or 1 (or true)", fn);
-              return retval;
-            }
+          scaled = (opt_val == 1.0);
         }
-
-      octave_value alpha_arg = args(0);
-      octave_value x_arg = args(1);
-
-      if (alpha_arg.is_single_type () || x_arg.is_single_type ())
-        {
-          if (alpha_arg.is_scalar_type ())
-            {
-              float alpha = args(0).float_value ();
+      else if (opt_arg.is_bool_type ())
+        scaled = opt_arg.bool_value ();
 
-              if (! error_state)
-                {
-                  if (x_arg.is_scalar_type ())
-                    {
-                      FloatComplex x = x_arg.float_complex_value ();
+      if (rpt_error)
+        error ("%s: OPT must be 0 (or false) or 1 (or true)", fn);
+    }
 
-                      if (! error_state)
-                        {
-                          octave_idx_type ierr;
-                          octave_value result;
+  octave_value alpha_arg = args(0);
+  octave_value x_arg = args(1);
 
-                          DO_BESSEL (type, alpha, x, scaled, ierr, result);
-
-                          if (nargout > 1)
-                            retval(1) = static_cast<float> (ierr);
+  if (alpha_arg.is_single_type () || x_arg.is_single_type ())
+    {
+      if (alpha_arg.is_scalar_type ())
+        {
+          float alpha = args(0).xfloat_value ("%s: ALPHA must be a scalar or matrix", fn);
 
-                          retval(0) = result;
-                        }
-                      else
-                        gripe_bessel_arg (fn, "second");
-                    }
-                  else
-                    {
-                      FloatComplexNDArray x
-                        = x_arg.float_complex_array_value ();
+          if (x_arg.is_scalar_type ())
+            {
+              FloatComplex x = x_arg.xfloat_complex_value ("%s: X must be a scalar or matrix", fn);
+
+              octave_idx_type ierr;
+              octave_value result;
 
-                      if (! error_state)
-                        {
-                          Array<octave_idx_type> ierr;
-                          octave_value result;
-
-                          DO_BESSEL (type, alpha, x, scaled, ierr, result);
+              DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
-                          if (nargout > 1)
-                            retval(1) = NDArray (ierr);
+              if (nargout > 1)
+                retval(1) = static_cast<float> (ierr);
 
-                          retval(0) = result;
-                        }
-                      else
-                        gripe_bessel_arg (fn, "second");
-                    }
-                }
-              else
-                gripe_bessel_arg (fn, "first");
+              retval(0) = result;
             }
           else
             {
-              dim_vector dv0 = args(0).dims ();
-              dim_vector dv1 = args(1).dims ();
-
-              bool args0_is_row_vector = (dv0 (1) == dv0.numel ());
-              bool args1_is_col_vector = (dv1 (0) == dv1.numel ());
-
-              if (args0_is_row_vector && args1_is_col_vector)
-                {
-                  FloatRowVector ralpha = args(0).float_row_vector_value ();
-
-                  if (! error_state)
-                    {
-                      FloatComplexColumnVector cx =
-                        x_arg.float_complex_column_vector_value ();
+              FloatComplexNDArray x
+                = x_arg.xfloat_complex_array_value ("%s: X must be a scalar or matrix", fn);
 
-                      if (! error_state)
-                        {
-                          Array<octave_idx_type> ierr;
-                          octave_value result;
-
-                          DO_BESSEL (type, ralpha, cx, scaled, ierr, result);
-
-                          if (nargout > 1)
-                            retval(1) = NDArray (ierr);
-
-                          retval(0) = result;
-                        }
-                      else
-                        gripe_bessel_arg (fn, "second");
-                    }
-                  else
-                    gripe_bessel_arg (fn, "first");
-                }
-              else
-                {
-                  FloatNDArray alpha = args(0).float_array_value ();
+              Array<octave_idx_type> ierr;
+              octave_value result;
 
-                  if (! error_state)
-                    {
-                      if (x_arg.is_scalar_type ())
-                        {
-                          FloatComplex x = x_arg.float_complex_value ();
-
-                          if (! error_state)
-                            {
-                              Array<octave_idx_type> ierr;
-                              octave_value result;
-
-                              DO_BESSEL (type, alpha, x, scaled, ierr, result);
-
-                              if (nargout > 1)
-                                retval(1) = NDArray (ierr);
+              DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
-                              retval(0) = result;
-                            }
-                          else
-                            gripe_bessel_arg (fn, "second");
-                        }
-                      else
-                        {
-                          FloatComplexNDArray x
-                            = x_arg.float_complex_array_value ();
-
-                          if (! error_state)
-                            {
-                              Array<octave_idx_type> ierr;
-                              octave_value result;
+              if (nargout > 1)
+                retval(1) = NDArray (ierr);
 
-                              DO_BESSEL (type, alpha, x, scaled, ierr, result);
-
-                              if (nargout > 1)
-                                retval(1) = NDArray (ierr);
-
-                              retval(0) = result;
-                            }
-                          else
-                            gripe_bessel_arg (fn, "second");
-                        }
-                    }
-                  else
-                    gripe_bessel_arg (fn, "first");
-                }
+              retval(0) = result;
             }
         }
       else
         {
-          if (alpha_arg.is_scalar_type ())
-            {
-              double alpha = args(0).double_value ();
-
-              if (! error_state)
-                {
-                  if (x_arg.is_scalar_type ())
-                    {
-                      Complex x = x_arg.complex_value ();
+          dim_vector dv0 = args(0).dims ();
+          dim_vector dv1 = args(1).dims ();
 
-                      if (! error_state)
-                        {
-                          octave_idx_type ierr;
-                          octave_value result;
+          bool args0_is_row_vector = (dv0(1) == dv0.numel ());
+          bool args1_is_col_vector = (dv1(0) == dv1.numel ());
 
-                          DO_BESSEL (type, alpha, x, scaled, ierr, result);
-
-                          if (nargout > 1)
-                            retval(1) = static_cast<double> (ierr);
+          if (args0_is_row_vector && args1_is_col_vector)
+            {
+              FloatRowVector ralpha = args(0).xfloat_row_vector_value ("%s: ALPHA must be a scalar or matrix", fn);
 
-                          retval(0) = result;
-                        }
-                      else
-                        gripe_bessel_arg (fn, "second");
-                    }
-                  else
-                    {
-                      ComplexNDArray x = x_arg.complex_array_value ();
+              FloatComplexColumnVector cx =
+                x_arg.xfloat_complex_column_vector_value ("%s: X must be a scalar or matrix", fn);
 
-                      if (! error_state)
-                        {
-                          Array<octave_idx_type> ierr;
-                          octave_value result;
+              Array<octave_idx_type> ierr;
+              octave_value result;
 
-                          DO_BESSEL (type, alpha, x, scaled, ierr, result);
-
-                          if (nargout > 1)
-                            retval(1) = NDArray (ierr);
+              DO_BESSEL (type, ralpha, cx, scaled, ierr, result);
 
-                          retval(0) = result;
-                        }
-                      else
-                        gripe_bessel_arg (fn, "second");
-                    }
-                }
-              else
-                gripe_bessel_arg (fn, "first");
+              if (nargout > 1)
+                retval(1) = NDArray (ierr);
+
+              retval(0) = result;
             }
           else
             {
-              dim_vector dv0 = args(0).dims ();
-              dim_vector dv1 = args(1).dims ();
-
-              bool args0_is_row_vector = (dv0 (1) == dv0.numel ());
-              bool args1_is_col_vector = (dv1 (0) == dv1.numel ());
+              FloatNDArray alpha = args(0).xfloat_array_value ("%s: ALPHA must be a scalar or matrix", fn);
 
-              if (args0_is_row_vector && args1_is_col_vector)
+              if (x_arg.is_scalar_type ())
                 {
-                  RowVector ralpha = args(0).row_vector_value ();
-
-                  if (! error_state)
-                    {
-                      ComplexColumnVector cx =
-                        x_arg.complex_column_vector_value ();
+                  FloatComplex x = x_arg.xfloat_complex_value ("%s: X must be a scalar or matrix", fn);
 
-                      if (! error_state)
-                        {
-                          Array<octave_idx_type> ierr;
-                          octave_value result;
+                  Array<octave_idx_type> ierr;
+                  octave_value result;
 
-                          DO_BESSEL (type, ralpha, cx, scaled, ierr, result);
+                  DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
-                          if (nargout > 1)
-                            retval(1) = NDArray (ierr);
+                  if (nargout > 1)
+                    retval(1) = NDArray (ierr);
 
-                          retval(0) = result;
-                        }
-                      else
-                        gripe_bessel_arg (fn, "second");
-                    }
-                  else
-                    gripe_bessel_arg (fn, "first");
+                  retval(0) = result;
                 }
               else
                 {
-                  NDArray alpha = args(0).array_value ();
-
-                  if (! error_state)
-                    {
-                      if (x_arg.is_scalar_type ())
-                        {
-                          Complex x = x_arg.complex_value ();
+                  FloatComplexNDArray x
+                    = x_arg.xfloat_complex_array_value ("%s: X must be a scalar or matrix", fn);
 
-                          if (! error_state)
-                            {
-                              Array<octave_idx_type> ierr;
-                              octave_value result;
-
-                              DO_BESSEL (type, alpha, x, scaled, ierr, result);
-
-                              if (nargout > 1)
-                                retval(1) = NDArray (ierr);
+                  Array<octave_idx_type> ierr;
+                  octave_value result;
 
-                              retval(0) = result;
-                            }
-                          else
-                            gripe_bessel_arg (fn, "second");
-                        }
-                      else
-                        {
-                          ComplexNDArray x = x_arg.complex_array_value ();
-
-                          if (! error_state)
-                            {
-                              Array<octave_idx_type> ierr;
-                              octave_value result;
+                  DO_BESSEL (type, alpha, x, scaled, ierr, result);
 
-                              DO_BESSEL (type, alpha, x, scaled, ierr, result);
-
-                              if (nargout > 1)
-                                retval(1) = NDArray (ierr);
+                  if (nargout > 1)
+                    retval(1) = NDArray (ierr);
 
-                              retval(0) = result;
-                            }
-                          else
-                            gripe_bessel_arg (fn, "second");
-                        }
-                    }
-                  else
-                    gripe_bessel_arg (fn, "first");
+                  retval(0) = result;
                 }
             }
         }
     }
   else
-    print_usage ();
+    {
+      if (alpha_arg.is_scalar_type ())
+        {
+          double alpha = args(0).xdouble_value ("%s: ALPHA must be a scalar or matrix", fn);
+
+          if (x_arg.is_scalar_type ())
+            {
+              Complex x = x_arg.xcomplex_value ("%s: X must be a scalar or matrix", fn);
+
+              octave_idx_type ierr;
+              octave_value result;
+
+              DO_BESSEL (type, alpha, x, scaled, ierr, result);
+
+              if (nargout > 1)
+                retval(1) = static_cast<double> (ierr);
+
+              retval(0) = result;
+            }
+          else
+            {
+              ComplexNDArray x = x_arg.xcomplex_array_value ("%s: X must be a scalar or matrix", fn);
+
+              Array<octave_idx_type> ierr;
+              octave_value result;
+
+              DO_BESSEL (type, alpha, x, scaled, ierr, result);
+
+              if (nargout > 1)
+                retval(1) = NDArray (ierr);
+
+              retval(0) = result;
+            }
+        }
+      else
+        {
+          dim_vector dv0 = args(0).dims ();
+          dim_vector dv1 = args(1).dims ();
+
+          bool args0_is_row_vector = (dv0(1) == dv0.numel ());
+          bool args1_is_col_vector = (dv1(0) == dv1.numel ());
+
+          if (args0_is_row_vector && args1_is_col_vector)
+            {
+              RowVector ralpha = args(0).xrow_vector_value ("%s: ALPHA must be a scalar or matrix", fn);
+
+              ComplexColumnVector cx =
+                x_arg.xcomplex_column_vector_value ("%s: X must be a scalar or matrix", fn);
+
+              Array<octave_idx_type> ierr;
+              octave_value result;
+
+              DO_BESSEL (type, ralpha, cx, scaled, ierr, result);
+
+              if (nargout > 1)
+                retval(1) = NDArray (ierr);
+
+              retval(0) = result;
+            }
+          else
+            {
+              NDArray alpha = args(0).xarray_value ("%s: ALPHA must be a scalar or matrix", fn);
+
+              if (x_arg.is_scalar_type ())
+                {
+                  Complex x = x_arg.xcomplex_value ("%s: X must be a scalar or matrix", fn);
+
+                  Array<octave_idx_type> ierr;
+                  octave_value result;
+
+                  DO_BESSEL (type, alpha, x, scaled, ierr, result);
+
+                  if (nargout > 1)
+                    retval(1) = NDArray (ierr);
+
+                  retval(0) = result;
+                }
+              else
+                {
+                  ComplexNDArray x = x_arg.xcomplex_array_value ("%s: X must be a scalar or matrix", fn);
+
+                  Array<octave_idx_type> ierr;
+                  octave_value result;
+
+                  DO_BESSEL (type, alpha, x, scaled, ierr, result);
+
+                  if (nargout > 1)
+                    retval(1) = NDArray (ierr);
+
+                  retval(0) = result;
+                }
+            }
+        }
+    }
 
   return retval;
 }
@@ -512,36 +420,32 @@
 
   int nargin = args.length ();
 
+  if (nargin < 2 || nargin > 4)
+    print_usage ();
+
   if (nargin == 2)
     {
       retval = do_bessel (BESSEL_H1, "besselh", args, nargout);
     }
-  else if (nargin == 3 || nargin == 4)
+  else
     {
-      octave_idx_type kind = args(1).int_value ();
+      octave_idx_type kind = args(1).xint_value ("besselh: invalid value of K");
 
-      if (! error_state)
-        {
-          octave_value_list tmp_args;
+      octave_value_list tmp_args;
 
-          if (nargin == 4)
-            tmp_args(2) = args(3);
+      if (nargin == 4)
+        tmp_args(2) = args(3);
 
-          tmp_args(1) = args(2);
-          tmp_args(0) = args(0);
+      tmp_args(1) = args(2);
+      tmp_args(0) = args(0);
 
-          if (kind == 1)
-            retval = do_bessel (BESSEL_H1, "besselh", tmp_args, nargout);
-          else if (kind == 2)
-            retval = do_bessel (BESSEL_H2, "besselh", tmp_args, nargout);
-          else
-            error ("besselh: expecting K = 1 or 2");
-        }
+      if (kind == 1)
+        retval = do_bessel (BESSEL_H1, "besselh", tmp_args, nargout);
+      else if (kind == 2)
+        retval = do_bessel (BESSEL_H2, "besselh", tmp_args, nargout);
       else
-        error ("besselh: invalid value of K");
+        error ("besselh: K must be 1 or 2");
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -597,77 +501,57 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0 && nargin < 4)
-    {
-      bool scale = (nargin == 3);
+  if (nargin < 1 || nargin > 3)
+    print_usage ();
 
-      int kind = 0;
+  bool scale = (nargin == 3);
 
-      if (nargin > 1)
-        {
-          kind = args(0).int_value ();
+  int kind = 0;
 
-          if (! error_state)
-            {
-              if (kind < 0 || kind > 3)
-                error ("airy: expecting K = 0, 1, 2, or 3");
-            }
-          else
-            error ("airy: K must be an integer value");
-        }
+  if (nargin > 1)
+    {
+      kind = args(0).xint_value ("airy: K must be an integer value");
 
-      if (! error_state)
-        {
-          int idx = nargin == 1 ? 0 : 1;
+      if (kind < 0 || kind > 3)
+        error ("airy: K must be 0, 1, 2, or 3");
+    }
 
-          if (args(idx).is_single_type ())
-            {
-              FloatComplexNDArray z = args(idx).float_complex_array_value ();
-
-              if (! error_state)
-                {
-                  Array<octave_idx_type> ierr;
-                  octave_value result;
+  int idx = nargin == 1 ? 0 : 1;
 
-                  if (kind > 1)
-                    result = biry (z, kind == 3, scale, ierr);
-                  else
-                    result = airy (z, kind == 1, scale, ierr);
-
-                  if (nargout > 1)
-                    retval(1) = NDArray (ierr);
+  if (args(idx).is_single_type ())
+    {
+      FloatComplexNDArray z = args(idx).xfloat_complex_array_value ("airy: Z must be a complex matrix");
 
-                  retval(0) = result;
-                }
-              else
-                error ("airy: Z must be a complex matrix");
-            }
-          else
-            {
-              ComplexNDArray z = args(idx).complex_array_value ();
+      Array<octave_idx_type> ierr;
+      octave_value result;
 
-              if (! error_state)
-                {
-                  Array<octave_idx_type> ierr;
-                  octave_value result;
-
-                  if (kind > 1)
-                    result = biry (z, kind == 3, scale, ierr);
-                  else
-                    result = airy (z, kind == 1, scale, ierr);
+      if (kind > 1)
+        result = biry (z, kind == 3, scale, ierr);
+      else
+        result = airy (z, kind == 1, scale, ierr);
 
-                  if (nargout > 1)
-                    retval(1) = NDArray (ierr);
+      if (nargout > 1)
+        retval(1) = NDArray (ierr);
 
-                  retval(0) = result;
-                }
-              else
-                error ("airy: Z must be a complex matrix");
-            }
-        }
+      retval(0) = result;
     }
   else
-    print_usage ();
+    {
+      ComplexNDArray z = args(idx).xcomplex_array_value ("airy: Z must be a complex matrix");
+
+      Array<octave_idx_type> ierr;
+      octave_value result;
+
+      if (kind > 1)
+        result = biry (z, kind == 3, scale, ierr);
+      else
+        result = airy (z, kind == 1, scale, ierr);
+
+      if (nargout > 1)
+        retval(1) = NDArray (ierr);
+
+      retval(0) = result;
+    }
 
   return retval;
 }
--- a/libinterp/corefcn/betainc.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/betainc.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -67,221 +67,177 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
+  if (args.length () != 3)
+    print_usage ();
 
-  if (nargin == 3)
-    {
-      octave_value x_arg = args(0);
-      octave_value a_arg = args(1);
-      octave_value b_arg = args(2);
+  octave_value x_arg = args(0);
+  octave_value a_arg = args(1);
+  octave_value b_arg = args(2);
 
-      // FIXME: Can we make a template version of the duplicated code below
-      if (x_arg.is_single_type () || a_arg.is_single_type ()
-          || b_arg.is_single_type ())
+  // FIXME: Can we make a template version of the duplicated code below
+  if (x_arg.is_single_type () || a_arg.is_single_type ()
+      || b_arg.is_single_type ())
+    {
+      if (x_arg.is_scalar_type ())
         {
-          if (x_arg.is_scalar_type ())
+          float x = x_arg.float_value ();
+
+          if (a_arg.is_scalar_type ())
             {
-              float x = x_arg.float_value ();
+              float a = a_arg.float_value ();
 
-              if (a_arg.is_scalar_type ())
+              if (b_arg.is_scalar_type ())
                 {
-                  float a = a_arg.float_value ();
-
-                  if (! error_state)
-                    {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          float b = b_arg.float_value ();
+                  float b = b_arg.float_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<float> b = b_arg.float_array_value ();
-
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                    }
+                  retval = betainc (x, a, b);
                 }
               else
                 {
-                  Array<float> a = a_arg.float_array_value ();
-
-                  if (! error_state)
-                    {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          float b = b_arg.float_value ();
+                  Array<float> b = b_arg.float_array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<float> b = b_arg.float_array_value ();
-
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                    }
+                  retval = betainc (x, a, b);
                 }
             }
           else
             {
-              Array<float> x = x_arg.float_array_value ();
-
-              if (a_arg.is_scalar_type ())
-                {
-                  float a = a_arg.float_value ();
-
-                  if (! error_state)
-                    {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          float b = b_arg.float_value ();
+              Array<float> a = a_arg.float_array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<float> b = b_arg.float_array_value ();
+              if (b_arg.is_scalar_type ())
+                {
+                  float b = b_arg.float_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                    }
+                  retval = betainc (x, a, b);
                 }
               else
                 {
-                  Array<float> a = a_arg.float_array_value ();
-
-                  if (! error_state)
-                    {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          float b = b_arg.float_value ();
+                  Array<float> b = b_arg.float_array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<float> b = b_arg.float_array_value ();
-
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                    }
+                  retval = betainc (x, a, b);
                 }
             }
         }
       else
         {
-          if (x_arg.is_scalar_type ())
-            {
-              double x = x_arg.double_value ();
+          Array<float> x = x_arg.float_array_value ();
 
-              if (a_arg.is_scalar_type ())
-                {
-                  double a = a_arg.double_value ();
+          if (a_arg.is_scalar_type ())
+            {
+              float a = a_arg.float_value ();
 
-                  if (! error_state)
-                    {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          double b = b_arg.double_value ();
+              if (b_arg.is_scalar_type ())
+                {
+                  float b = b_arg.float_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<double> b = b_arg.array_value ();
-
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                    }
+                  retval = betainc (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 ();
+                  Array<float> b = b_arg.float_array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<double> b = b_arg.array_value ();
-
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                    }
+                  retval = betainc (x, a, b);
                 }
             }
           else
             {
-              Array<double> x = x_arg.array_value ();
-
-              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 ();
+              Array<float> a = a_arg.float_array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<double> b = b_arg.array_value ();
+              if (b_arg.is_scalar_type ())
+                {
+                  float b = b_arg.float_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                    }
+                  retval = betainc (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 ();
+                  Array<float> b = b_arg.float_array_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<double> b = b_arg.array_value ();
-
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                    }
+                  retval = betainc (x, a, b);
                 }
             }
         }
     }
   else
-    print_usage ();
+    {
+      if (x_arg.is_scalar_type ())
+        {
+          double x = x_arg.double_value ();
+
+          if (a_arg.is_scalar_type ())
+            {
+              double a = a_arg.double_value ();
+
+              if (b_arg.is_scalar_type ())
+                {
+                  double b = b_arg.double_value ();
+
+                  retval = betainc (x, a, b);
+                }
+              else
+                {
+                  Array<double> b = b_arg.array_value ();
+
+                  retval = betainc (x, a, b);
+                }
+            }
+          else
+            {
+              Array<double> a = a_arg.array_value ();
+
+              if (b_arg.is_scalar_type ())
+                {
+                  double b = b_arg.double_value ();
+
+                  retval = betainc (x, a, b);
+                }
+              else
+                {
+                  Array<double> b = b_arg.array_value ();
+
+                  retval = betainc (x, a, b);
+                }
+            }
+        }
+      else
+        {
+          Array<double> x = x_arg.array_value ();
+
+          if (a_arg.is_scalar_type ())
+            {
+              double a = a_arg.double_value ();
+
+              if (b_arg.is_scalar_type ())
+                {
+                  double b = b_arg.double_value ();
+
+                  retval = betainc (x, a, b);
+                }
+              else
+                {
+                  Array<double> b = b_arg.array_value ();
+
+                  retval = betainc (x, a, b);
+                }
+            }
+          else
+            {
+              Array<double> a = a_arg.array_value ();
+
+              if (b_arg.is_scalar_type ())
+                {
+                  double b = b_arg.double_value ();
+
+                  retval = betainc (x, a, b);
+                }
+              else
+                {
+                  Array<double> b = b_arg.array_value ();
+
+                  retval = betainc (x, a, b);
+                }
+            }
+        }
+    }
 
   return retval;
 }
@@ -344,125 +300,102 @@
 {
   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 (args.length () != 3)
+    print_usage ();
 
-      if (x_arg.is_scalar_type ())
-        {
-          double x = x_arg.double_value ();
-
-          if (a_arg.is_scalar_type ())
-            {
-              double a = a_arg.double_value ();
+  octave_value x_arg = args(0);
+  octave_value a_arg = args(1);
+  octave_value b_arg = args(2);
 
-              if (! error_state)
-                {
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+  if (x_arg.is_scalar_type ())
+    {
+      double x = x_arg.double_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
-                  else
-                    {
-                      Array<double> b = b_arg.array_value ();
+      if (a_arg.is_scalar_type ())
+        {
+          double a = a_arg.double_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
-                }
+          if (b_arg.is_scalar_type ())
+            {
+              double b = b_arg.double_value ();
+
+              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 ();
+              Array<double> b = b_arg.array_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);
-                    }
-                }
+              retval = betaincinv (x, a, b);
             }
         }
       else
         {
-          Array<double> x = x_arg.array_value ();
+          Array<double> a = a_arg.array_value ();
 
-          if (a_arg.is_scalar_type ())
+          if (b_arg.is_scalar_type ())
             {
-              double a = a_arg.double_value ();
+              double b = b_arg.double_value ();
 
-              if (! error_state)
-                {
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+              retval = betaincinv (x, a, b);
+            }
+          else
+            {
+              Array<double> b = b_arg.array_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
-                  else
-                    {
-                      Array<double> b = b_arg.array_value ();
+              retval = betaincinv (x, a, b);
+            }
+        }
+    }
+  else
+    {
+      Array<double> x = x_arg.array_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
-                }
+      if (a_arg.is_scalar_type ())
+        {
+          double a = a_arg.double_value ();
+
+          if (b_arg.is_scalar_type ())
+            {
+              double b = b_arg.double_value ();
+
+              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 ();
+              Array<double> b = b_arg.array_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);
-                    }
-                }
+              retval = betaincinv (x, a, b);
             }
         }
+      else
+        {
+          Array<double> a = a_arg.array_value ();
 
-      // 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 ());
+          if (b_arg.is_scalar_type ())
+            {
+              double b = b_arg.double_value ();
+
+              retval = betaincinv (x, a, b);
+            }
+          else
+            {
+              Array<double> b = b_arg.array_value ();
+
+              retval = betaincinv (x, a, b);
+            }
         }
     }
-  else
-    print_usage ();
+
+  // 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 ());
+    }
+
 
   return retval;
 }
--- a/libinterp/corefcn/bitfcns.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/bitfcns.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -47,7 +47,7 @@
 
 #include <functional>
 
-#if !defined (HAVE_CXX_BITWISE_OP_TEMPLATES)
+#if ! defined (HAVE_CXX_BITWISE_OP_TEMPLATES)
 namespace std
 {
   template <typename T>
@@ -156,209 +156,205 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
+  if (args.length () != 2)
+    print_usage ();
 
-  if (nargin == 2)
+  if (args(0).class_name () == octave_scalar::static_class_name ()
+      || args(0).class_name () == octave_float_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_float_scalar::static_class_name ()
+      || args(1).class_name () == octave_bool::static_class_name ())
     {
-      if (args(0).class_name () == octave_scalar::static_class_name ()
-          || args(0).class_name () == octave_float_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_float_scalar::static_class_name ()
-          || args(1).class_name () == octave_bool::static_class_name ())
+      bool arg0_is_int = bitop_arg_is_int (args(0));
+      bool arg1_is_int = bitop_arg_is_int (args(1));
+
+      bool arg0_is_bool = bitop_arg_is_bool (args(0));
+      bool arg1_is_bool = bitop_arg_is_bool (args(1));
+
+      bool arg0_is_float = bitop_arg_is_float (args(0));
+      bool arg1_is_float = bitop_arg_is_float (args(1));
+
+      if (! (arg0_is_int || arg1_is_int))
         {
-          bool arg0_is_int = bitop_arg_is_int (args(0));
-          bool arg1_is_int = bitop_arg_is_int (args(1));
-
-          bool arg0_is_bool = bitop_arg_is_bool (args(0));
-          bool arg1_is_bool = bitop_arg_is_bool (args(1));
-
-          bool arg0_is_float = bitop_arg_is_float (args(0));
-          bool arg1_is_float = bitop_arg_is_float (args(1));
-
-          if (! (arg0_is_int || arg1_is_int))
+          if (arg0_is_bool && arg1_is_bool)
             {
-              if (arg0_is_bool && arg1_is_bool)
-                {
-                  boolNDArray x (args(0).bool_array_value ());
-                  boolNDArray y (args(1).bool_array_value ());
-                  if (! error_state)
-                    retval = bitopx (fname, x, y).bool_array_value ();
-                }
-              else if (arg0_is_float && arg1_is_float)
-                {
-                  uint64NDArray x (args(0).float_array_value ());
-                  uint64NDArray y (args(1).float_array_value ());
-                  if (! error_state)
-                    retval = bitopx (fname, x, y).float_array_value ();
-                }
-              else if (! (arg0_is_float || arg1_is_float))
-                {
-                  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_float ? 1 : 0);
-                  int q = (arg0_is_float ? 0 : 1);
+              boolNDArray x (args(0).bool_array_value ());
+              boolNDArray y (args(1).bool_array_value ());
 
-                  uint64NDArray x (args(p).array_value ());
-                  uint64NDArray y (args(q).float_array_value ());
-                  if (! error_state)
-                    retval = bitopx (fname, x, y).float_array_value ();
-                }
+              retval = bitopx (fname, x, y).bool_array_value ();
+            }
+          else if (arg0_is_float && arg1_is_float)
+            {
+              uint64NDArray x (args(0).float_array_value ());
+              uint64NDArray y (args(1).float_array_value ());
+
+              retval = bitopx (fname, x, y).float_array_value ();
+            }
+          else if (! (arg0_is_float || arg1_is_float))
+            {
+              uint64NDArray x (args(0).array_value ());
+              uint64NDArray y (args(1).array_value ());
+
+              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 ();
+              int p = (arg0_is_float ? 1 : 0);
+              int q = (arg0_is_float ? 0 : 1);
 
-              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 ());
+              uint64NDArray x (args(p).array_value ());
+              uint64NDArray y (args(q).float_array_value ());
+
+              retval = bitopx (fname, x, y).float_array_value ();
             }
         }
-      else if (args(0).class_name () == args(1).class_name ())
+      else
         {
-          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 ())
+          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 ())
             {
-              uint32NDArray x = args(0).uint32_array_value ();
-              uint32NDArray y = args(1).uint32_array_value ();
-              if (! error_state)
-                retval = bitopx (fname, x, y);
+              uint64NDArray x (dx);
+              uint64NDArray y = args(q).uint64_array_value ();
+
+              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 ())
+          else if (args(q).type_id () == octave_uint32_matrix::static_type_id ()
+                   || args(q).type_id () == octave_uint32_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);
+              uint32NDArray x (dx);
+              uint32NDArray y = args(q).uint32_array_value ();
+
+              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 ())
+          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 ();
+
+              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 = args(0).uint8_array_value ();
-              uint8NDArray y = args(1).uint8_array_value ();
-              if (! error_state)
-                retval = bitopx (fname, x, y);
+              uint8NDArray x (dx);
+              uint8NDArray y = args(q).uint8_array_value ();
+
+              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 ())
+          else if (args(q).type_id () == octave_int64_matrix::static_type_id ()
+                   || args(q).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);
+              int64NDArray x (dx);
+              int64NDArray y = args(q).int64_array_value ();
+
+              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 ())
+          else if (args(q).type_id () == octave_int32_matrix::static_type_id ()
+                   || args(q).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);
+              int32NDArray x (dx);
+              int32NDArray y = args(q).int32_array_value ();
+
+              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 ())
+          else if (args(q).type_id () == octave_int16_matrix::static_type_id ()
+                   || args(q).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);
+              int16NDArray x (dx);
+              int16NDArray y = args(q).int16_array_value ();
+
+              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 ())
+          else if (args(q).type_id () == octave_int8_matrix::static_type_id ()
+                   || args(q).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);
+              int8NDArray x (dx);
+              int8NDArray y = args(q).int8_array_value ();
+
+              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 ();
+
+          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 ();
+
+          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 ();
+
+          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 ();
+
+          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 ();
+
+          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 ();
+
+          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 ();
+
+          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 ();
+
+          retval = bitopx (fname, x, y);
+        }
       else
-        error ("%s: must have matching operand types", fname.c_str ());
+        error ("%s: invalid operand type", fname.c_str ());
     }
   else
-    print_usage ();
+    error ("%s: must have matching operand types", fname.c_str ());
 
   return retval;
 }
@@ -368,8 +364,8 @@
 @deftypefn {Built-in Function} {} bitand (@var{x}, @var{y})\n\
 Return the bitwise AND of non-negative integers.\n\
 \n\
-@var{x}, @var{y} must be in the range [0,bitmax]\n\
-@seealso{bitor, bitxor, bitset, bitget, bitcmp, bitshift, bitmax}\n\
+@var{x}, @var{y} must be in the range [0,intmax]\n\
+@seealso{bitor, bitxor, bitset, bitget, bitcmp, bitshift, intmax, flintmax}\n\
 @end deftypefn")
 {
   return bitop ("bitand", args);
@@ -378,10 +374,9 @@
 DEFUN (bitor, args, ,
        "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} bitor (@var{x}, @var{y})\n\
-Return the bitwise OR of non-negative integers.\n\
+Return the bitwise OR of non-negative integers @var{x} and @var{y}.\n\
 \n\
-@var{x}, @var{y} must be in the range [0,bitmax]\n\
-@seealso{bitor, bitxor, bitset, bitget, bitcmp, bitshift, bitmax}\n\
+@seealso{bitor, bitxor, bitset, bitget, bitcmp, bitshift, intmax, flintmax}\n\
 @end deftypefn")
 {
   return bitop ("bitor", args);
@@ -390,10 +385,9 @@
 DEFUN (bitxor, args, ,
        "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} bitxor (@var{x}, @var{y})\n\
-Return the bitwise XOR of non-negative integers.\n\
+Return the bitwise XOR of non-negative integers @var{x} and @var{y}.\n\
 \n\
-@var{x}, @var{y} must be in the range [0,bitmax]\n\
-@seealso{bitand, bitor, bitset, bitget, bitcmp, bitshift, bitmax}\n\
+@seealso{bitand, bitor, bitset, bitget, bitcmp, bitshift, intmax, flintmax}\n\
 @end deftypefn")
 {
   return bitop ("bitxor", args);
@@ -462,52 +456,49 @@
 // shift.
 
 #define DO_BITSHIFT(T) \
-  if (! error_state) \
-    { \
-      double d1, d2; \
+  double d1, d2; \
  \
-      if (n.all_integers (d1, d2)) \
-        { \
-          int m_nel = m.numel (); \
-          int n_nel = n.numel (); \
+  if (n.all_integers (d1, d2)) \
+    { \
+      int m_nel = m.numel (); \
+      int n_nel = n.numel (); \
+ \
+      bool is_scalar_op = (m_nel == 1 || n_nel == 1); \
  \
-          bool is_scalar_op = (m_nel == 1 || n_nel == 1); \
- \
-          dim_vector m_dv = m.dims (); \
-          dim_vector n_dv = n.dims (); \
+      dim_vector m_dv = m.dims (); \
+      dim_vector n_dv = n.dims (); \
  \
-          bool is_array_op = (m_dv == n_dv); \
+      bool is_array_op = (m_dv == n_dv); \
  \
-          if (is_array_op || is_scalar_op) \
-            { \
-              T ## NDArray result; \
+      if (is_array_op || is_scalar_op) \
+        { \
+          T ## NDArray result; \
  \
-              if (m_nel != 1) \
-                result.resize (m_dv); \
-              else \
-                result.resize (n_dv); \
+          if (m_nel != 1) \
+            result.resize (m_dv); \
+          else \
+            result.resize (n_dv); \
  \
-              for (int i = 0; i < m_nel; i++) \
-                if (is_scalar_op) \
-                  for (int k = 0; k < n_nel; k++) \
-                    if (static_cast<int> (n(k)) >= bits_in_type) \
-                      result(i+k) = 0; \
-                    else \
-                      result(i+k) = bitshift (m(i), static_cast<int> (n(k)), mask); \
+          for (int i = 0; i < m_nel; i++) \
+            if (is_scalar_op) \
+              for (int k = 0; k < n_nel; k++) \
+                if (static_cast<int> (n(k)) >= bits_in_type) \
+                  result(i+k) = 0; \
                 else \
-                  if (static_cast<int> (n(i)) >= bits_in_type) \
-                    result(i) = 0;                                      \
-                  else                                          \
-                    result(i) = bitshift (m(i), static_cast<int> (n(i)), mask); \
+                  result(i+k) = bitshift (m(i), static_cast<int> (n(k)), mask); \
+            else \
+              if (static_cast<int> (n(i)) >= bits_in_type) \
+                result(i) = 0; \
+              else \
+                result(i) = bitshift (m(i), static_cast<int> (n(i)), mask); \
  \
-              retval = result; \
-            } \
-          else \
-            error ("bitshift: size of A and N must match, or one operand must be a scalar"); \
+          retval = result; \
         } \
       else \
-        error ("bitshift: expecting integer as second argument"); \
-    }
+        error ("bitshift: size of A and N must match, or one operand must be a scalar"); \
+    } \
+  else \
+    error ("bitshift: K must be a scalar or array of integers"); \
 
 #define DO_UBITSHIFT(T, N) \
   do \
@@ -546,8 +537,8 @@
 \n\
 A positive @var{k} leads to a left shift; A negative value to a right shift.\n\
 \n\
-If @var{n} is omitted it defaults to log2(bitmax)+1.\n\
-@var{n} must be in the range [1,log2(bitmax)+1] usually [1,33].\n\
+If @var{n} is omitted it defaults to 64.\n\
+@var{n} must be in the range [1,64].\n\
 \n\
 @example\n\
 @group\n\
@@ -568,99 +559,87 @@
 @c @result{} 4  8\n\
 @end group\n\
 @end example\n\
-@seealso{bitand, bitor, bitxor, bitset, bitget, bitcmp, bitmax}\n\
+@seealso{bitand, bitor, bitxor, bitset, bitget, bitcmp, intmax, flintmax}\n\
 @end deftypefn")
 {
   octave_value retval;
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
-    {
-      int nbits = 64;
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  int nbits = 64;
+
+  NDArray n = args(1).xarray_value ("bitshift: K must be a scalar or array of integers");
 
-      NDArray n = args(1).array_value ();
-
-      if (error_state)
-        error ("bitshift: expecting integer as second argument");
+  if (nargin == 3)
+    {
+      // FIXME: for compatibility, we should accept an array
+      // or a scalar as the third argument.
+      if (args(2).numel () > 1)
+        error ("bitshift: N must be a scalar integer");
       else
         {
-          if (nargin == 3)
-            {
-              // FIXME: for compatibility, we should accept an array
-              // or a scalar as the third argument.
-              if (args(2).numel () > 1)
-                error ("bitshift: N must be a scalar integer");
-              else
-                {
-                  nbits = args(2).int_value ();
+          nbits = args(2).xint_value ("bitshift: N must be an integer");
 
-                  if (error_state)
-                    error ("bitshift: N must be an integer");
-                  else if (nbits < 0)
-                    error ("bitshift: N must be positive");
-                }
-            }
+          if (nbits < 0)
+            error ("bitshift: N must be positive");
         }
+    }
 
-      if (error_state)
-        return retval;
-
-      octave_value m_arg = args(0);
-      std::string cname = m_arg.class_name ();
+  octave_value m_arg = args(0);
+  std::string cname = m_arg.class_name ();
 
-      if (cname == "uint8")
-        DO_UBITSHIFT (uint8, nbits < 8 ? nbits : 8);
-      else if (cname == "uint16")
-        DO_UBITSHIFT (uint16, nbits < 16 ? nbits : 16);
-      else if (cname == "uint32")
-        DO_UBITSHIFT (uint32, nbits < 32 ? nbits : 32);
-      else if (cname == "uint64")
-        DO_UBITSHIFT (uint64, nbits < 64 ? nbits : 64);
-      else if (cname == "int8")
-        DO_SBITSHIFT (int8, nbits < 8 ? nbits : 8);
-      else if (cname == "int16")
-        DO_SBITSHIFT (int16, nbits < 16 ? nbits : 16);
-      else if (cname == "int32")
-        DO_SBITSHIFT (int32, nbits < 32 ? nbits : 32);
-      else if (cname == "int64")
-        DO_SBITSHIFT (int64, nbits < 64 ? nbits : 64);
-      else if (cname == "double")
-        {
-          static const int bits_in_mantissa
-            = std::numeric_limits<double>::digits;
+  if (cname == "uint8")
+    DO_UBITSHIFT (uint8, nbits < 8 ? nbits : 8);
+  else if (cname == "uint16")
+    DO_UBITSHIFT (uint16, nbits < 16 ? nbits : 16);
+  else if (cname == "uint32")
+    DO_UBITSHIFT (uint32, nbits < 32 ? nbits : 32);
+  else if (cname == "uint64")
+    DO_UBITSHIFT (uint64, nbits < 64 ? nbits : 64);
+  else if (cname == "int8")
+    DO_SBITSHIFT (int8, nbits < 8 ? nbits : 8);
+  else if (cname == "int16")
+    DO_SBITSHIFT (int16, nbits < 16 ? nbits : 16);
+  else if (cname == "int32")
+    DO_SBITSHIFT (int32, nbits < 32 ? nbits : 32);
+  else if (cname == "int64")
+    DO_SBITSHIFT (int64, nbits < 64 ? nbits : 64);
+  else if (cname == "double")
+    {
+      static const int bits_in_mantissa
+        = std::numeric_limits<double>::digits;
 
-          nbits = (nbits < bits_in_mantissa ? nbits : bits_in_mantissa);
-          int64_t mask = max_mantissa_value<double> ();
-          if (nbits < bits_in_mantissa)
-            mask = mask >> (bits_in_mantissa - nbits);
-          else if (nbits < 1)
-            mask = 0;
-          int bits_in_type = sizeof (double)
-                             * std::numeric_limits<unsigned char>::digits;
-          NDArray m = m_arg.array_value ();
-          DO_BITSHIFT ();
-        }
-      else if (cname == "single")
-        {
-          static const int bits_in_mantissa
-            = std::numeric_limits<float>::digits;
-          nbits = (nbits < bits_in_mantissa ? nbits : bits_in_mantissa);
-          int64_t mask = max_mantissa_value<float> ();
-          if (nbits < bits_in_mantissa)
-            mask = mask >> (bits_in_mantissa - nbits);
-          else if (nbits < 1)
-            mask = 0;
-          int bits_in_type = sizeof (float)
-                             * std::numeric_limits<unsigned char>::digits;
-          FloatNDArray m = m_arg.float_array_value ();
-          DO_BITSHIFT (Float);
-        }
-      else
-        error ("bitshift: not defined for %s objects", cname.c_str ());
+      nbits = (nbits < bits_in_mantissa ? nbits : bits_in_mantissa);
+      int64_t mask = max_mantissa_value<double> ();
+      if (nbits < bits_in_mantissa)
+        mask = mask >> (bits_in_mantissa - nbits);
+      else if (nbits < 1)
+        mask = 0;
+      int bits_in_type = sizeof (double)
+        * std::numeric_limits<unsigned char>::digits;
+      NDArray m = m_arg.array_value ();
+      DO_BITSHIFT ();
+    }
+  else if (cname == "single")
+    {
+      static const int bits_in_mantissa
+        = std::numeric_limits<float>::digits;
+      nbits = (nbits < bits_in_mantissa ? nbits : bits_in_mantissa);
+      int64_t mask = max_mantissa_value<float> ();
+      if (nbits < bits_in_mantissa)
+        mask = mask >> (bits_in_mantissa - nbits);
+      else if (nbits < 1)
+        mask = 0;
+      int bits_in_type = sizeof (float)
+        * std::numeric_limits<unsigned char>::digits;
+      FloatNDArray m = m_arg.float_array_value ();
+      DO_BITSHIFT (Float);
     }
   else
-    print_usage ();
+    error ("bitshift: not defined for %s objects", cname.c_str ());
 
   return retval;
 }
@@ -672,49 +651,12 @@
 %!assert (bitshift (uint64 (16), 4), uint64 (256))
 %!assert (bitshift (uint8 (255), 1), uint8 (254))
 
-%!error <expecting integer as second argument> bitshift (16, 1.5)
+%!error <K must be a scalar or array of integers> bitshift (16, 1.5)
 %!error bitshift (16, {1})
 %!error <N must be a scalar integer> bitshift (10, [-2 -1 0 1 2], [1 1 1 1 1])
 %!error <N must be positive> bitshift (10, [-2 -1 0 1 2], -1)
 */
 
-DEFUN (bitmax, args, ,
-       "-*- texinfo -*-\n\
-@deftypefn  {Built-in Function} {} bitmax ()\n\
-@deftypefnx {Built-in Function} {} bitmax (\"double\")\n\
-@deftypefnx {Built-in Function} {} bitmax (\"single\")\n\
-Return the largest integer that can be represented within a floating point\n\
-value.\n\
-\n\
-The default class is @qcode{\"double\"}, but @qcode{\"single\"} is a\n\
-valid option.  On IEEE 754 compatible systems, @code{bitmax} is\n\
-@w{@math{2^{53} - 1}} for @qcode{\"double\"} and @w{@math{2^{24} -1}} for\n\
-@qcode{\"single\"}.\n\
-@seealso{flintmax, intmax, realmax, realmin}\n\
-@end deftypefn")
-{
-  octave_value retval;
-  std::string cname = "double";
-  int nargin = args.length ();
-
-  if (nargin == 1 && args(0).is_string ())
-    cname = args(0).string_value ();
-  else if (nargin != 0)
-    {
-      print_usage ();
-      return retval;
-    }
-
-  if (cname == "double")
-    retval = (static_cast<double> (max_mantissa_value<double> ()));
-  else if (cname == "single")
-    retval = (static_cast<float> (max_mantissa_value<float> ()));
-  else
-    error ("bitmax: not defined for class '%s'", cname.c_str ());
-
-  return retval;
-}
-
 DEFUN (flintmax, args, ,
        "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {} flintmax ()\n\
@@ -726,20 +668,20 @@
 The default class is @qcode{\"double\"}, but @qcode{\"single\"} is a valid\n\
 option.  On IEEE 754 compatible systems, @code{flintmax} is @w{@math{2^{53}}}\n\
 for @qcode{\"double\"} and @w{@math{2^{24}}} for @qcode{\"single\"}.\n\
-@seealso{bitmax, intmax, realmax, realmin}\n\
+@seealso{intmax, realmax, realmin}\n\
 @end deftypefn")
 {
   octave_value retval;
+
   std::string cname = "double";
+
   int nargin = args.length ();
 
-  if (nargin == 1 && args(0).is_string ())
-    cname = args(0).string_value ();
-  else if (nargin != 0)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin > 1)
+    print_usage ();
+
+  if (nargin == 1)
+    cname = args(0).xstring_value ("flintmax: argument must be a string");
 
   if (cname == "double")
     retval = (static_cast<double> (max_mantissa_value<double> () + 1));
@@ -785,20 +727,20 @@
 @end table\n\
 \n\
 The default for @var{type} is @code{int32}.\n\
-@seealso{intmin, flintmax, bitmax}\n\
+@seealso{intmin, flintmax}\n\
 @end deftypefn")
 {
   octave_value retval;
+
   std::string cname = "int32";
+
   int nargin = args.length ();
 
-  if (nargin == 1 && args(0).is_string ())
-    cname = args(0).string_value ();
-  else if (nargin != 0)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin > 1)
+    print_usage ();
+
+  if (nargin == 1)
+    cname = args(0).xstring_value ("intmax: argument must be a string");
 
   if (cname == "uint8")
     retval = octave_uint8 (std::numeric_limits<uint8_t>::max ());
@@ -856,20 +798,20 @@
 @end table\n\
 \n\
 The default for @var{type} is @code{int32}.\n\
-@seealso{intmax, flintmax, bitmax}\n\
+@seealso{intmax, flintmax}\n\
 @end deftypefn")
 {
   octave_value retval;
+
   std::string cname = "int32";
+
   int nargin = args.length ();
 
-  if (nargin == 1 && args(0).is_string ())
-    cname = args(0).string_value ();
-  else if (nargin != 0)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin > 1)
+    print_usage ();
+
+  if (nargin == 1)
+    cname = args(0).xstring_value ("intmin: argument must be a string");
 
   if (cname == "uint8")
     retval = octave_uint8 (std::numeric_limits<uint8_t>::min ());
@@ -905,12 +847,8 @@
 @seealso{intmax}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 0)
-    retval = octave_int<octave_idx_type> (dim_vector::dim_max ());
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_int<octave_idx_type> (dim_vector::dim_max ()));
 }
--- a/libinterp/corefcn/bsxfun.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/bsxfun.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -135,8 +135,10 @@
 
 #define REGISTER_OP_HANDLER(OP, BTYP, NDA, FUNOP) \
   bsxfun_handler_table[OP][BTYP] = bsxfun_forward_op<NDA, FUNOP>
+
 #define REGISTER_REL_HANDLER(REL, BTYP, NDA, FUNREL) \
   bsxfun_handler_table[REL][BTYP] = bsxfun_forward_rel<NDA, FUNREL>
+
 #define REGISTER_STD_HANDLERS(BTYP, NDA) \
   REGISTER_OP_HANDLER (bsxfun_builtin_plus, BTYP, NDA, bsxfun_add); \
   REGISTER_OP_HANDLER (bsxfun_builtin_minus, BTYP, NDA, bsxfun_sub); \
@@ -237,12 +239,12 @@
       idx(0) = octave_value (':');
       for (octave_idx_type j = 1; j < nd; j++)
         {
-          if (dva (j) == 1)
+          if (dva(j) == 1)
             idx(j) = octave_value (1);
           else
             idx(j) = octave_value ((i % dvc(j)) + 1);
 
-          i = i / dvc (j);
+          i /= dvc(j);
         }
 
       Ac = A;
@@ -256,14 +258,14 @@
       octave_idx_type k1 = i - 1;
       for (octave_idx_type j = 1; j < nd; j++)
         {
-          if (dva(j) != 1 && k % dvc (j) != k1 % dvc (j))
+          if (dva(j) != 1 && k % dvc(j) != k1 % dvc(j))
             {
               idx (j) = octave_value ((k % dvc(j)) + 1);
               is_changed = true;
             }
 
-          k = k / dvc (j);
-          k1 = k1 / dvc (j);
+          k /= dvc(j);
+          k1 /= dvc(j);
         }
 
       if (is_changed)
@@ -294,8 +296,8 @@
     {
       for (octave_idx_type j = 1; j < nd; j++)
         {
-          idx (j) = octave_value (i % dv (j) + 1);
-          i = i / dv (j);
+          idx (j) = octave_value (i % dv(j) + 1);
+          i /= dv(j);
         }
     }
 }
@@ -309,8 +311,8 @@
   idx(0) = 0;
   for (octave_idx_type j = 1; j < nd; j++)
     {
-      idx (j) = i % dv (j);
-      i = i / dv (j);
+      idx(j) = i % dv(j);
+      i /= dv(j);
     }
 }
 
@@ -333,336 +335,324 @@
 @seealso{arrayfun, cellfun}\n\
 @end deftypefn")
 {
-  int nargin = args.length ();
   octave_value_list retval;
 
-  if (nargin != 3)
+  if (args.length () != 3)
     print_usage ();
-  else
-    {
-      octave_value func = args(0);
+
+  octave_value func = args(0);
 
-      if (func.is_string ())
-        {
-          std::string name = func.string_value ();
-          func = symbol_table::find_function (name);
-          if (func.is_undefined ())
-            error ("bsxfun: invalid function name: %s", name.c_str ());
-        }
-      else if (! (args(0).is_function_handle ()
-               || args(0).is_inline_function ()))
-        error ("bsxfun: F must be a string or function handle");
+  if (func.is_string ())
+    {
+      std::string name = func.string_value ();
+      func = symbol_table::find_function (name);
+      if (func.is_undefined ())
+        error ("bsxfun: invalid function name: %s", name.c_str ());
+    }
+  else if (! (args(0).is_function_handle ()
+              || args(0).is_inline_function ()))
+    error ("bsxfun: F must be a string or function handle");
+
+  const octave_value A = args(1);
+  const octave_value B = args(2);
 
-      const octave_value A = args(1);
-      const octave_value B = args(2);
-
-      if (func.is_builtin_function ()
-          || (func.is_function_handle ()
-              && ! A.is_object () && ! B.is_object ()))
+  if (func.is_builtin_function ()
+      || (func.is_function_handle ()
+          && ! A.is_object () && ! B.is_object ()))
+    {
+      // This may break if the default behavior is overridden.  But if you
+      // override arithmetic operators for builtin classes, you should
+      // expect mayhem anyway (constant folding etc).  Querying
+      // is_overloaded() may not be exactly what we need here.
+      octave_function *fcn_val = func.function_value ();
+      if (fcn_val)
         {
-          // This may break if the default behavior is overridden.  But if you
-          // override arithmetic operators for builtin classes, you should
-          // expect mayhem anyway (constant folding etc).  Querying
-          // is_overloaded() may not be exactly what we need here.
-          octave_function *fcn_val = func.function_value ();
-          if (fcn_val)
-            {
-              octave_value tmp = maybe_optimized_builtin (fcn_val->name (),
-                                                          A, B);
-              if (tmp.is_defined ())
-                retval(0) = tmp;
-            }
+          octave_value tmp = maybe_optimized_builtin (fcn_val->name (),
+                                                      A, B);
+          if (tmp.is_defined ())
+            retval(0) = tmp;
+        }
+    }
+
+  if (retval.empty ())
+    {
+      dim_vector dva = A.dims ();
+      octave_idx_type nda = dva.length ();
+      dim_vector dvb = B.dims ();
+      octave_idx_type ndb = dvb.length ();
+      octave_idx_type nd = nda;
+
+      if (nda > ndb)
+        dvb.resize (nda, 1);
+      else if (nda < ndb)
+        {
+          dva.resize (ndb, 1);
+          nd = ndb;
         }
 
-      if (! error_state && retval.empty ())
-        {
-          dim_vector dva = A.dims ();
-          octave_idx_type nda = dva.length ();
-          dim_vector dvb = B.dims ();
-          octave_idx_type ndb = dvb.length ();
-          octave_idx_type nd = nda;
+      for (octave_idx_type i = 0; i < nd; i++)
+        if (dva(i) != dvb(i) && dva(i) != 1 && dvb(i) != 1)
+          {
+            error ("bsxfun: dimensions of A and B must match");
+            break;
+          }
+
+      // Find the size of the output
+      dim_vector dvc;
+      dvc.resize (nd);
+
+      for (octave_idx_type i = 0; i < nd; i++)
+        dvc(i) = (dva(i) < 1 ? dva(i)
+                  : (dvb(i) < 1 ? dvb(i)
+                     : (dva(i) > dvb(i)
+                        ? dva(i) : dvb(i))));
 
-          if (nda > ndb)
-            dvb.resize (nda, 1);
-          else if (nda < ndb)
-            {
-              dva.resize (ndb, 1);
-              nd = ndb;
-            }
+      if (dva == dvb || dva.numel () == 1 || dvb.numel () == 1)
+        {
+          octave_value_list inputs;
+          inputs (0) = A;
+          inputs (1) = B;
+          retval = func.do_multi_index_op (1, inputs);
+        }
+      else if (dvc.numel () < 1)
+        {
+          octave_value_list inputs;
+          inputs (0) = A.resize (dvc);
+          inputs (1) = B.resize (dvc);
+          retval = func.do_multi_index_op (1, inputs);
+        }
+      else
+        {
+          octave_idx_type ncount = 1;
+          for (octave_idx_type i = 1; i < nd; i++)
+            ncount *= dvc(i);
 
-          for (octave_idx_type i = 0; i < nd; i++)
-            if (dva (i) != dvb (i) && dva (i) != 1 && dvb (i) != 1)
-              {
-                error ("bsxfun: dimensions of A and B must match");
-                break;
-              }
+#define BSXDEF(T) \
+  T result_ ## T; \
+  bool have_ ## T = false;
+
+          BSXDEF(NDArray);
+          BSXDEF(ComplexNDArray);
+          BSXDEF(FloatNDArray);
+          BSXDEF(FloatComplexNDArray);
+          BSXDEF(boolNDArray);
+          BSXDEF(int8NDArray);
+          BSXDEF(int16NDArray);
+          BSXDEF(int32NDArray);
+          BSXDEF(int64NDArray);
+          BSXDEF(uint8NDArray);
+          BSXDEF(uint16NDArray);
+          BSXDEF(uint32NDArray);
+          BSXDEF(uint64NDArray);
+
+          octave_value Ac ;
+          octave_value_list idxA;
+          octave_value Bc;
+          octave_value_list idxB;
+          octave_value C;
+          octave_value_list inputs;
+          Array<int> ra_idx (dim_vector (dvc.length (), 1), 0);
+
 
-          if (!error_state)
+          for (octave_idx_type i = 0; i < ncount; i++)
             {
-              // Find the size of the output
-              dim_vector dvc;
-              dvc.resize (nd);
+              if (maybe_update_column (Ac, A, dva, dvc, i, idxA))
+                inputs (0) = Ac;
+
+              if (maybe_update_column (Bc, B, dvb, dvc, i, idxB))
+                inputs (1) = Bc;
 
-              for (octave_idx_type i = 0; i < nd; i++)
-                dvc (i) = (dva (i) < 1 ? dva (i)
-                                       : (dvb (i) < 1 ? dvb (i)
-                                                      : (dva (i) > dvb (i)
-                                                        ? dva (i) : dvb (i))));
+              octave_value_list tmp = func.do_multi_index_op (1,
+                                                              inputs);
+
+#define BSXINIT(T, CLS, EXTRACTOR) \
+  (result_type == CLS) \
+    { \
+      have_ ## T = true; \
+      result_ ## T = tmp (0). EXTRACTOR ## _array_value (); \
+      result_ ## T .resize (dvc); \
+    }
 
-              if (dva == dvb || dva.numel () == 1 || dvb.numel () == 1)
+              if (i == 0)
                 {
-                  octave_value_list inputs;
-                  inputs (0) = A;
-                  inputs (1) = B;
-                  retval = func.do_multi_index_op (1, inputs);
-                }
-              else if (dvc.numel () < 1)
-                {
-                  octave_value_list inputs;
-                  inputs (0) = A.resize (dvc);
-                  inputs (1) = B.resize (dvc);
-                  retval = func.do_multi_index_op (1, inputs);
+                  if (! tmp(0).is_sparse_type ())
+                    {
+                      std::string result_type = tmp(0).class_name ();
+                      if (result_type == "double")
+                        {
+                          if (tmp(0).is_real_type ())
+                            {
+                              have_NDArray = true;
+                              result_NDArray = tmp(0).array_value ();
+                              result_NDArray.resize (dvc);
+                            }
+                          else
+                            {
+                              have_ComplexNDArray = true;
+                              result_ComplexNDArray =
+                                tmp(0).complex_array_value ();
+                              result_ComplexNDArray.resize (dvc);
+                            }
+                        }
+                      else if (result_type == "single")
+                        {
+                          if (tmp(0).is_real_type ())
+                            {
+                              have_FloatNDArray = true;
+                              result_FloatNDArray
+                                = tmp(0).float_array_value ();
+                              result_FloatNDArray.resize (dvc);
+                            }
+                          else
+                            {
+                              have_ComplexNDArray = true;
+                              result_ComplexNDArray =
+                                tmp(0).complex_array_value ();
+                              result_ComplexNDArray.resize (dvc);
+                            }
+                        }
+                      else if BSXINIT(boolNDArray, "logical", bool)
+                        else if BSXINIT(int8NDArray, "int8", int8)
+                          else if BSXINIT(int16NDArray, "int16", int16)
+                            else if BSXINIT(int32NDArray, "int32", int32)
+                              else if BSXINIT(int64NDArray, "int64", int64)
+                                else if BSXINIT(uint8NDArray, "uint8", uint8)
+                                  else if BSXINIT(uint16NDArray, "uint16", uint16)
+                                    else if BSXINIT(uint32NDArray, "uint32", uint32)
+                                      else if BSXINIT(uint64NDArray, "uint64", uint64)
+                                        else
+                                          {
+                                            C = tmp (0);
+                                            C = C.resize (dvc);
+                                          }
+                    }
                 }
               else
                 {
-                  octave_idx_type ncount = 1;
-                  for (octave_idx_type i = 1; i < nd; i++)
-                    ncount *= dvc (i);
-
-#define BSXDEF(T) \
-                  T result_ ## T; \
-                  bool have_ ## T = false;
-
-                  BSXDEF(NDArray);
-                  BSXDEF(ComplexNDArray);
-                  BSXDEF(FloatNDArray);
-                  BSXDEF(FloatComplexNDArray);
-                  BSXDEF(boolNDArray);
-                  BSXDEF(int8NDArray);
-                  BSXDEF(int16NDArray);
-                  BSXDEF(int32NDArray);
-                  BSXDEF(int64NDArray);
-                  BSXDEF(uint8NDArray);
-                  BSXDEF(uint16NDArray);
-                  BSXDEF(uint32NDArray);
-                  BSXDEF(uint64NDArray);
+                  update_index (ra_idx, dvc, i);
 
-                  octave_value Ac ;
-                  octave_value_list idxA;
-                  octave_value Bc;
-                  octave_value_list idxB;
-                  octave_value C;
-                  octave_value_list inputs;
-                  Array<int> ra_idx (dim_vector (dvc.length (), 1), 0);
-
-
-                  for (octave_idx_type i = 0; i < ncount; i++)
+                  if (have_FloatNDArray
+                      || have_FloatComplexNDArray)
                     {
-                      if (maybe_update_column (Ac, A, dva, dvc, i, idxA))
-                        inputs (0) = Ac;
-
-                      if (maybe_update_column (Bc, B, dvb, dvc, i, idxB))
-                        inputs (1) = Bc;
-
-                      octave_value_list tmp = func.do_multi_index_op (1,
-                                                                      inputs);
-
-                      if (error_state)
-                        break;
-
-#define BSXINIT(T, CLS, EXTRACTOR) \
-                      (result_type == CLS) \
-                        { \
-                            have_ ## T = true; \
-                            result_ ## T = \
-                                tmp (0). EXTRACTOR ## _array_value (); \
-                            result_ ## T .resize (dvc); \
+                      if (! tmp(0).is_float_type ())
+                        {
+                          if (have_FloatNDArray)
+                            {
+                              have_FloatNDArray = false;
+                              C = result_FloatNDArray;
+                            }
+                          else
+                            {
+                              have_FloatComplexNDArray = false;
+                              C = result_FloatComplexNDArray;
+                            }
+                          C = do_cat_op (C, tmp(0), ra_idx);
                         }
-
-                      if (i == 0)
+                      else if (tmp(0).is_double_type ())
                         {
-                          if (! tmp(0).is_sparse_type ())
+                          if (tmp(0).is_complex_type ()
+                              && have_FloatNDArray)
                             {
-                              std::string result_type = tmp(0).class_name ();
-                              if (result_type == "double")
-                                {
-                                  if (tmp(0).is_real_type ())
-                                    {
-                                      have_NDArray = true;
-                                      result_NDArray = tmp(0).array_value ();
-                                      result_NDArray.resize (dvc);
-                                    }
-                                  else
-                                    {
-                                      have_ComplexNDArray = true;
-                                      result_ComplexNDArray =
-                                        tmp(0).complex_array_value ();
-                                      result_ComplexNDArray.resize (dvc);
-                                    }
-                                }
-                              else if (result_type == "single")
-                                {
-                                  if (tmp(0).is_real_type ())
-                                    {
-                                      have_FloatNDArray = true;
-                                      result_FloatNDArray
-                                        = tmp(0).float_array_value ();
-                                      result_FloatNDArray.resize (dvc);
-                                    }
-                                  else
-                                    {
-                                      have_ComplexNDArray = true;
-                                      result_ComplexNDArray =
-                                        tmp(0).complex_array_value ();
-                                      result_ComplexNDArray.resize (dvc);
-                                    }
-                                }
-                              else if BSXINIT(boolNDArray, "logical", bool)
-                              else if BSXINIT(int8NDArray, "int8", int8)
-                              else if BSXINIT(int16NDArray, "int16", int16)
-                              else if BSXINIT(int32NDArray, "int32", int32)
-                              else if BSXINIT(int64NDArray, "int64", int64)
-                              else if BSXINIT(uint8NDArray, "uint8", uint8)
-                              else if BSXINIT(uint16NDArray, "uint16", uint16)
-                              else if BSXINIT(uint32NDArray, "uint32", uint32)
-                              else if BSXINIT(uint64NDArray, "uint64", uint64)
-                              else
-                                {
-                                  C = tmp (0);
-                                  C = C.resize (dvc);
-                                }
+                              result_ComplexNDArray =
+                                ComplexNDArray (result_FloatNDArray);
+                              result_ComplexNDArray.insert
+                                (tmp(0).complex_array_value (), ra_idx);
+                              have_FloatComplexNDArray = false;
+                              have_ComplexNDArray = true;
+                            }
+                          else
+                            {
+                              result_NDArray =
+                                NDArray (result_FloatNDArray);
+                              result_NDArray.insert
+                                (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);
                       else
                         {
-                          update_index (ra_idx, dvc, i);
-
-                          if (have_FloatNDArray
-                              || have_FloatComplexNDArray)
-                            {
-                              if (! tmp(0).is_float_type ())
-                                {
-                                  if (have_FloatNDArray)
-                                    {
-                                      have_FloatNDArray = false;
-                                      C = result_FloatNDArray;
-                                    }
-                                  else
-                                    {
-                                      have_FloatComplexNDArray = false;
-                                      C = result_FloatComplexNDArray;
-                                    }
-                                  C = do_cat_op (C, tmp(0), ra_idx);
-                                }
-                              else if (tmp(0).is_double_type ())
-                                {
-                                  if (tmp(0).is_complex_type ()
-                                      && have_FloatNDArray)
-                                    {
-                                      result_ComplexNDArray =
-                                        ComplexNDArray (result_FloatNDArray);
-                                      result_ComplexNDArray.insert
-                                        (tmp(0).complex_array_value (), ra_idx);
-                                      have_FloatComplexNDArray = false;
-                                      have_ComplexNDArray = true;
-                                    }
-                                  else
-                                    {
-                                      result_NDArray =
-                                        NDArray (result_FloatNDArray);
-                                      result_NDArray.insert
-                                        (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);
-                              else
-                                {
-                                  result_FloatComplexNDArray =
-                                    FloatComplexNDArray (result_FloatNDArray);
-                                  result_FloatComplexNDArray.insert
-                                    (tmp(0).float_complex_array_value (),
-                                     ra_idx);
-                                  have_FloatNDArray = false;
-                                  have_FloatComplexNDArray = true;
-                                }
-                            }
-                          else if (have_NDArray)
-                            {
-                              if (! tmp(0).is_float_type ())
-                                {
-                                  have_NDArray = false;
-                                  C = result_NDArray;
-                                  C = do_cat_op (C, tmp(0), ra_idx);
-                                }
-                              else if (tmp(0).is_real_type ())
-                                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);
-                                  have_NDArray = false;
-                                  have_ComplexNDArray = true;
-                                }
-                            }
-
-#define BSXLOOP(T, CLS, EXTRACTOR) \
-                        (have_ ## T) \
-                          { \
-                            if (tmp (0).class_name () != CLS) \
-                              { \
-                                have_ ## T = false; \
-                                C = result_ ## T; \
-                                C = do_cat_op (C, tmp (0), ra_idx); \
-                              } \
-                            else \
-                              result_ ## T .insert \
-                                (tmp(0). EXTRACTOR ## _array_value (), \
-                                ra_idx); \
-                          }
-
-                          else if BSXLOOP(ComplexNDArray, "double", complex)
-                          else if BSXLOOP(boolNDArray, "logical", bool)
-                          else if BSXLOOP(int8NDArray, "int8", int8)
-                          else if BSXLOOP(int16NDArray, "int16", int16)
-                          else if BSXLOOP(int32NDArray, "int32", int32)
-                          else if BSXLOOP(int64NDArray, "int64", int64)
-                          else if BSXLOOP(uint8NDArray, "uint8", uint8)
-                          else if BSXLOOP(uint16NDArray, "uint16", uint16)
-                          else if BSXLOOP(uint32NDArray, "uint32", uint32)
-                          else if BSXLOOP(uint64NDArray, "uint64", uint64)
-                          else
-                            C = do_cat_op (C, tmp(0), ra_idx);
+                          result_FloatComplexNDArray =
+                            FloatComplexNDArray (result_FloatNDArray);
+                          result_FloatComplexNDArray.insert
+                            (tmp(0).float_complex_array_value (),
+                             ra_idx);
+                          have_FloatNDArray = false;
+                          have_FloatComplexNDArray = true;
+                        }
+                    }
+                  else if (have_NDArray)
+                    {
+                      if (! tmp(0).is_float_type ())
+                        {
+                          have_NDArray = false;
+                          C = result_NDArray;
+                          C = do_cat_op (C, tmp(0), ra_idx);
+                        }
+                      else if (tmp(0).is_real_type ())
+                        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);
+                          have_NDArray = false;
+                          have_ComplexNDArray = true;
                         }
                     }
 
-#define BSXEND(T) \
-                  (have_ ## T) \
-                    retval(0) = result_ ## T;
+#define BSXLOOP(T, CLS, EXTRACTOR) \
+  (have_ ## T) \
+    { \
+      if (tmp (0).class_name () != CLS) \
+        { \
+          have_ ## T = false; \
+          C = result_ ## T; \
+          C = do_cat_op (C, tmp (0), ra_idx); \
+        } \
+      else \
+        result_ ## T .insert (tmp(0). EXTRACTOR ## _array_value (), ra_idx); \
+    }
 
-                  if BSXEND(NDArray)
-                  else if BSXEND(ComplexNDArray)
-                  else if BSXEND(FloatNDArray)
-                  else if BSXEND(FloatComplexNDArray)
-                  else if BSXEND(boolNDArray)
-                  else if BSXEND(int8NDArray)
-                  else if BSXEND(int16NDArray)
-                  else if BSXEND(int32NDArray)
-                  else if BSXEND(int64NDArray)
-                  else if BSXEND(uint8NDArray)
-                  else if BSXEND(uint16NDArray)
-                  else if BSXEND(uint32NDArray)
-                  else if BSXEND(uint64NDArray)
+                  else if BSXLOOP(ComplexNDArray, "double", complex)
+                  else if BSXLOOP(boolNDArray, "logical", bool)
+                  else if BSXLOOP(int8NDArray, "int8", int8)
+                  else if BSXLOOP(int16NDArray, "int16", int16)
+                  else if BSXLOOP(int32NDArray, "int32", int32)
+                  else if BSXLOOP(int64NDArray, "int64", int64)
+                  else if BSXLOOP(uint8NDArray, "uint8", uint8)
+                  else if BSXLOOP(uint16NDArray, "uint16", uint16)
+                  else if BSXLOOP(uint32NDArray, "uint32", uint32)
+                  else if BSXLOOP(uint64NDArray, "uint64", uint64)
                   else
-                    retval(0) = C;
+                    C = do_cat_op (C, tmp(0), ra_idx);
                 }
             }
+
+#define BSXEND(T) \
+  (have_ ## T) \
+    retval(0) = result_ ## T;
+
+          if BSXEND(NDArray)
+          else if BSXEND(ComplexNDArray)
+          else if BSXEND(FloatNDArray)
+          else if BSXEND(FloatComplexNDArray)
+          else if BSXEND(boolNDArray)
+          else if BSXEND(int8NDArray)
+          else if BSXEND(int16NDArray)
+          else if BSXEND(int32NDArray)
+          else if BSXEND(int64NDArray)
+          else if BSXEND(uint8NDArray)
+          else if BSXEND(uint16NDArray)
+          else if BSXEND(uint32NDArray)
+          else if BSXEND(uint64NDArray)
+          else
+            retval(0) = C;
         }
     }
 
--- a/libinterp/corefcn/c-file-ptr-stream.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/c-file-ptr-stream.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_c_file_ptr_stream_h)
+#if ! defined (octave_c_file_ptr_stream_h)
 #define octave_c_file_ptr_stream_h 1
 
 #include <cstdio>
@@ -32,7 +32,7 @@
 {
 public:
 
-#if !defined (CXX_ISO_COMPLIANT_LIBRARY)
+#if ! defined (CXX_ISO_COMPLIANT_LIBRARY)
   typedef int int_type;
 #else
   typedef std::streambuf::int_type int_type;
@@ -152,7 +152,7 @@
 {
 public:
 
-#if !defined (CXX_ISO_COMPLIANT_LIBRARY)
+#if ! defined (CXX_ISO_COMPLIANT_LIBRARY)
   typedef int int_type;
 #else
   typedef std::streambuf::int_type int_type;
--- a/libinterp/corefcn/cdisplay.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/cdisplay.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_cdisplay_h)
+#if ! defined (octave_cdisplay_h)
 #define octave_cdisplay_h 1
 
 #ifdef __cplusplus
--- a/libinterp/corefcn/cellfun.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/cellfun.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -41,25 +41,26 @@
 #include "defun.h"
 #include "parse.h"
 #include "variables.h"
-#include "ov-colon.h"
 #include "unwind-prot.h"
 #include "gripes.h"
+#include "toplev.h"
 #include "utils.h"
 
+#include "ov-bool.h"
 #include "ov-class.h"
-#include "ov-scalar.h"
-#include "ov-float.h"
+#include "ov-colon.h"
 #include "ov-complex.h"
+#include "ov-float.h"
 #include "ov-flt-complex.h"
-#include "ov-bool.h"
-#include "ov-int8.h"
 #include "ov-int16.h"
 #include "ov-int32.h"
 #include "ov-int64.h"
-#include "ov-uint8.h"
+#include "ov-int8.h"
+#include "ov-scalar.h"
 #include "ov-uint16.h"
 #include "ov-uint32.h"
 #include "ov-uint64.h"
+#include "ov-uint8.h"
 
 #include "ov-fcn-handle.h"
 
@@ -70,17 +71,26 @@
                  octave_value& error_handler)
 {
   octave_value_list tmp;
+
+  bool execution_error = false;
+
   try
     {
       tmp = func.do_multi_index_op (nargout, inputlist);
     }
-  catch (octave_execution_exception)
+  catch (const octave_execution_exception& e)
     {
       if (error_handler.is_defined ())
-        error_state = 1;
+        {
+          recover_from_exception ();
+
+          execution_error = true;
+        }
+      else
+        throw e;
     }
 
-  if (error_state)
+  if (execution_error)
     {
       if (error_handler.is_defined ())
         {
@@ -96,14 +106,7 @@
 
           buffer_error_messages--;
 
-          error_state = 0;
-
           tmp = error_handler.do_multi_index_op (nargout, errlist);
-
-          buffer_error_messages++;
-
-          if (error_state)
-            tmp.clear ();
         }
       else
         tmp.clear ();
@@ -185,19 +188,18 @@
           if (d < 0)
             error ("cellfun: K must be a positive integer");
 
-          if (! error_state)
+          NDA result (f_args.dims ());
+
+          for (octave_idx_type count = 0; count < k; count++)
             {
-              NDA result (f_args.dims ());
-              for (octave_idx_type count = 0; count < k; count++)
-                {
-                  dim_vector dv = f_args.elem (count).dims ();
-                  if (d < dv.length ())
-                    result(count) = static_cast<double> (dv(d));
-                  else
-                    result(count) = 1.0;
-                }
-              retval(0) = result;
+              dim_vector dv = f_args.elem (count).dims ();
+              if (d < dv.length ())
+                result(count) = static_cast<double> (dv(d));
+              else
+                result(count) = 1.0;
             }
+
+          retval(0) = result;
         }
       else
         error ("cellfun: not enough arguments for \"size\"");
@@ -246,24 +248,14 @@
               error_handler = symbol_table::find_function (err_name);
 
               if (error_handler.is_undefined ())
-                {
-                  error ("cellfun: invalid function NAME: %s",
-                         err_name.c_str ());
-                  break;
-                }
+                error ("cellfun: invalid function NAME: %s",
+                       err_name.c_str ());
             }
           else
-            {
-              error ("cellfun: invalid value for 'ErrorHandler' function");
-              break;
-            }
+            error ("cellfun: invalid value for 'ErrorHandler' function");
         }
       else
-        {
-          error ("cellfun: unrecognized parameter %s",
-                 arg.c_str ());
-          break;
-        }
+        error ("cellfun: unrecognized parameter %s", arg.c_str ());
 
       nargin -= 2;
     }
@@ -414,26 +406,18 @@
   int nargout1 = (nargout < 1 ? 1 : nargout);
 
   if (nargin < 2)
-    {
-      error ("cellfun: function requires at least 2 arguments");
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value func = args(0);
 
   if (! args(1).is_cell ())
-    {
-      error ("cellfun: C must be a cell array");
-
-      return retval;
-    }
+    error ("cellfun: C must be a cell array");
 
   if (func.is_string ())
     {
       retval = try_cellfun_internal_ops<boolNDArray,NDArray>(args, nargin);
 
-      if (error_state || ! retval.empty ())
+      if (! retval.empty ())
         return retval;
 
       // See if we can convert the string into a function.
@@ -449,7 +433,7 @@
             = extract_function (args(0), "cellfun", fcn_name,
                                 fname, "; endfunction");
 
-          if (ptr_func && ! error_state)
+          if (ptr_func)
             func = octave_value (ptr_func, true);
         }
       else
@@ -460,7 +444,7 @@
             error ("cellfun: invalid function NAME: %s", name.c_str ());
         }
 
-      if (error_state || ! retval.empty ())
+      if (! retval.empty ())
         return retval;
     }
 
@@ -509,7 +493,7 @@
                   retval =
                     try_cellfun_internal_ops<Cell, Cell> (tmp_args, nargin);
 
-                if (error_state || ! retval.empty ())
+                if (! retval.empty ())
                   return retval;
               }
 
@@ -519,11 +503,9 @@
             func = f;
           }
       }
+
     nevermind:
 
-      if (error_state)
-        return octave_value_list ();
-
       // Extract cell arguments.
 
       octave_value_list inputlist (nargin, octave_value ());
@@ -544,10 +526,7 @@
       for (int j = 0; j < nargin; j++)
         {
           if (! args(j+1).is_cell ())
-            {
-              error ("cellfun: arguments must be cells");
-              return octave_value_list ();
-            }
+            error ("cellfun: arguments must be cells");
 
           inputs[j] = args(j+1).cell_value ();
           mask[j] = inputs[j].numel () != 1;
@@ -564,10 +543,7 @@
               for (int i = j+1; i < nargin; i++)
                 {
                   if (mask[i] && inputs[i].dims () != fdims)
-                    {
-                      error ("cellfun: dimensions mismatch");
-                      return octave_value_list ();
-                    }
+                    error ("cellfun: dimensions mismatch");
                 }
               break;
             }
@@ -601,14 +577,8 @@
                 = get_output_list (count, nargout, inputlist, func,
                                    error_handler);
 
-              if (error_state)
-                return retval;
-
               if (nargout > 0 && tmp.length () < nargout)
-                {
-                  error ("cellfun: function returned fewer than nargout values");
-                  return retval;
-                }
+                error ("cellfun: function returned fewer than nargout values");
 
               if  (nargout > 0
                    || (nargout == 0
@@ -630,10 +600,7 @@
                               if (val.numel () == 1)
                                 retv[j] = val.resize (fdims);
                               else
-                                {
-                                  error ("cellfun: all values must be scalars when UniformOutput = true");
-                                  break;
-                                }
+                                error ("cellfun: all values must be scalars when UniformOutput = true");
                             }
                         }
                     }
@@ -652,23 +619,14 @@
                                       idx_list.front ()(0) = count + 1.0;
                                       retv[j].assign (octave_value::op_asn_eq,
                                                       idx_type, idx_list, val);
-
-                                      if (error_state)
-                                        break;
                                     }
                                   else
-                                    {
-                                      error ("cellfun: all values must be scalars when UniformOutput = true");
-                                      break;
-                                    }
+                                    error ("cellfun: all values must be scalars when UniformOutput = true");
                                 }
                             }
                         }
                     }
                 }
-
-              if (error_state)
-                break;
             }
 
           retval.resize (nargout1);
@@ -702,14 +660,8 @@
                 = get_output_list (count, nargout, inputlist, func,
                                    error_handler);
 
-              if (error_state)
-                return retval;
-
               if (nargout > 0 && tmp.length () < nargout)
-                {
-                  error ("cellfun: function returned fewer than nargout values");
-                  return retval;
-                }
+                error ("cellfun: function returned fewer than nargout values");
 
               if  (nargout > 0
                    || (nargout == 0
@@ -1179,12 +1131,7 @@
   int nargout1 = (nargout < 1 ? 1 : nargout);
 
   if (nargin < 2)
-    {
-      error_with_id ("Octave:invalid-fun-call",
-                     "arrayfun: function requires at least 2 arguments");
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value func = args(0);
   bool symbol_table_lookup = false;
@@ -1204,7 +1151,7 @@
             = extract_function (args(0), "arrayfun", fcn_name,
                                 fname, "; endfunction");
 
-          if (ptr_func && ! error_state)
+          if (ptr_func)
             func = octave_value (ptr_func, true);
         }
       else
@@ -1218,9 +1165,6 @@
 
           symbol_table_lookup = true;
         }
-
-      if (error_state)
-        return retval;
     }
 
   if (func.is_function_handle () || func.is_inline_function ()
@@ -1258,9 +1202,6 @@
 
       get_mapper_fun_options (args, nargin, uniform_output, error_handler);
 
-      if (error_state)
-        return octave_value_list ();
-
       octave_value_list inputlist (nargin, octave_value ());
 
       OCTAVE_LOCAL_BUFFER (octave_value, inputs, nargin);
@@ -1327,18 +1268,12 @@
                 {
                   if (mask[j])
                     inputlist.xelem (j) = inputs[j].do_index_op (idx_list);
-
-                  if (error_state)
-                    return retval;
                 }
 
               const octave_value_list tmp
                 = get_output_list (count, nargout, inputlist, func,
                                    error_handler);
 
-              if (error_state)
-                return retval;
-
               if (nargout > 0 && tmp.length () < nargout)
                 {
                   error_with_id ("Octave:invalid-fun-call",
@@ -1389,9 +1324,6 @@
                                       idx_list.front ()(0) = count + 1.0;
                                       retv[j].assign (octave_value::op_asn_eq,
                                                       idx_type, idx_list, val);
-
-                                      if (error_state)
-                                        break;
                                     }
                                   else
                                     {
@@ -1404,9 +1336,6 @@
                         }
                     }
                 }
-
-              if (error_state)
-                break;
             }
 
           retval.resize (nargout1);
@@ -1440,18 +1369,12 @@
                 {
                   if (mask[j])
                     inputlist.xelem (j) = inputs[j].do_index_op (idx_list);
-
-                  if (error_state)
-                    return retval;
                 }
 
               const octave_value_list tmp
                 = get_output_list (count, nargout, inputlist, func,
                                    error_handler);
 
-              if (error_state)
-                return retval;
-
               if (nargout > 0 && tmp.length () < nargout)
                 {
                   error_with_id ("Octave:invalid-fun-call",
@@ -1714,7 +1637,7 @@
                     dim_vector& celldv, dim_vector& arraydv,
                     Array<int>& perm)
 {
-  int dvl = dimv.length ();
+  int dvl = dimv.numel ();
   int maxd = dv.length ();
   celldv = dv;
   for (int i = 0; i < dvl; i++)
@@ -1730,15 +1653,10 @@
     {
       int k = dimv(i) - 1;
       if (k < 0)
-        {
-          error ("num2cell: dimension indices must be positive");
-          return;
-        }
-      else if (i > 0 && k < dimv(i-1) - 1)
-        {
-          error ("num2cell: dimension indices must be strictly increasing");
-          return;
-        }
+        error ("num2cell: dimension indices must be positive");
+
+      if (i > 0 && k < dimv(i-1) - 1)
+        error ("num2cell: dimension indices must be strictly increasing");
 
       sing[k] = true;
       perm(i) = k;
@@ -1783,8 +1701,6 @@
       dim_vector celldv, arraydv;
       Array<int> perm;
       do_num2cell_helper (array.dims (), dimv, celldv, arraydv, perm);
-      if (error_state)
-        return Cell ();
 
       NDA parray = array.permute (perm);
 
@@ -1836,29 +1752,21 @@
     {
       dim_vector dv = get_object_dims (array);
 
-      if (! error_state)
-        {
-          retval.resize (dv);
+      retval.resize (dv);
 
-          octave_value_list idx (1);
+      octave_value_list idx (1);
 
-          for (octave_idx_type i = 0; i < dv.numel (); i++)
-            {
-              octave_quit ();
-
-              idx(0) = double (i+1);
+      for (octave_idx_type i = 0; i < dv.numel (); i++)
+        {
+          octave_quit ();
 
-              retval.xelem (i) = array.single_subsref ("(", idx);
+          idx(0) = double (i+1);
 
-              if (error_state)
-                break;
-            }
+          retval.xelem (i) = array.single_subsref ("(", idx);
         }
     }
   else
-    {
-      error ("num2cell (A, dim) not implemented for class objects");
-    }
+    error ("num2cell (A, dim) not implemented for class objects");
 
   return retval;
 }
@@ -1899,71 +1807,68 @@
 @seealso{mat2cell}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
   int nargin =  args.length ();
-  octave_value retval;
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
-  else
-    {
-      octave_value array = args(0);
-      Array<int> dimv;
-      if (nargin > 1)
-        dimv = args(1).int_vector_value (true);
+
+  octave_value array = args(0);
+
+  Array<int> dimv;
+
+  if (nargin > 1)
+    dimv = args(1).int_vector_value (true);
 
-      if (error_state)
-        ;
-      else if (array.is_bool_type ())
-        retval = do_num2cell (array.bool_array_value (), dimv);
-      else if (array.is_char_matrix ())
-        retval = do_num2cell (array.char_array_value (), dimv);
-      else if (array.is_numeric_type ())
+  if (array.is_bool_type ())
+    retval = do_num2cell (array.bool_array_value (), dimv);
+  else if (array.is_char_matrix ())
+    retval = do_num2cell (array.char_array_value (), dimv);
+  else if (array.is_numeric_type ())
+    {
+      if (array.is_integer_type ())
         {
-          if (array.is_integer_type ())
-            {
-              if (array.is_int8_type ())
-                retval = do_num2cell (array.int8_array_value (), dimv);
-              else if (array.is_int16_type ())
-                retval = do_num2cell (array.int16_array_value (), dimv);
-              else if (array.is_int32_type ())
-                retval = do_num2cell (array.int32_array_value (), dimv);
-              else if (array.is_int64_type ())
-                retval = do_num2cell (array.int64_array_value (), dimv);
-              else if (array.is_uint8_type ())
-                retval = do_num2cell (array.uint8_array_value (), dimv);
-              else if (array.is_uint16_type ())
-                retval = do_num2cell (array.uint16_array_value (), dimv);
-              else if (array.is_uint32_type ())
-                retval = do_num2cell (array.uint32_array_value (), dimv);
-              else if (array.is_uint64_type ())
-                retval = do_num2cell (array.uint64_array_value (), dimv);
-            }
-          else if (array.is_complex_type ())
-            {
-              if (array.is_single_type ())
-                retval = do_num2cell (array.float_complex_array_value (), dimv);
-              else
-                retval = do_num2cell (array.complex_array_value (), dimv);
-            }
+          if (array.is_int8_type ())
+            retval = do_num2cell (array.int8_array_value (), dimv);
+          else if (array.is_int16_type ())
+            retval = do_num2cell (array.int16_array_value (), dimv);
+          else if (array.is_int32_type ())
+            retval = do_num2cell (array.int32_array_value (), dimv);
+          else if (array.is_int64_type ())
+            retval = do_num2cell (array.int64_array_value (), dimv);
+          else if (array.is_uint8_type ())
+            retval = do_num2cell (array.uint8_array_value (), dimv);
+          else if (array.is_uint16_type ())
+            retval = do_num2cell (array.uint16_array_value (), dimv);
+          else if (array.is_uint32_type ())
+            retval = do_num2cell (array.uint32_array_value (), dimv);
+          else if (array.is_uint64_type ())
+            retval = do_num2cell (array.uint64_array_value (), dimv);
+        }
+      else if (array.is_complex_type ())
+        {
+          if (array.is_single_type ())
+            retval = do_num2cell (array.float_complex_array_value (), dimv);
           else
-            {
-              if (array.is_single_type ())
-                retval = do_num2cell (array.float_array_value (), dimv);
-              else
-                retval = do_num2cell (array.array_value (), dimv);
-            }
+            retval = do_num2cell (array.complex_array_value (), dimv);
+        }
+      else
+        {
+          if (array.is_single_type ())
+            retval = do_num2cell (array.float_array_value (), dimv);
+          else
+            retval = do_num2cell (array.array_value (), dimv);
         }
-      else if (array.is_object ())
-        retval = do_object2cell (array, dimv);
-      else if (array.is_map ())
-        retval = do_num2cell (array.map_value (), dimv);
-      else if (array.is_cell ())
-        retval = do_num2cell (array.cell_value (), dimv);
-      else if (array.is_object ())
-        retval = do_num2cell (array.cell_value (), dimv);
-      else
-        gripe_wrong_type_arg ("num2cell", array);
     }
+  else if (array.is_object ())
+    retval = do_object2cell (array, dimv);
+  else if (array.is_map ())
+    retval = do_num2cell (array.map_value (), dimv);
+  else if (array.is_cell ())
+    retval = do_num2cell (array.cell_value (), dimv);
+  else
+    gripe_wrong_type_arg ("num2cell", array);
 
   return retval;
 }
@@ -1981,17 +1886,13 @@
   for (int i = 0; i < nd; i++)
     {
       octave_idx_type s = 0;
-      for (octave_idx_type j = 0; j < d[i].length (); j++)
+      for (octave_idx_type j = 0; j < d[i].numel (); j++)
         s += d[i](j);
 
       octave_idx_type r = i < dv.length () ? dv(i) : 1;
 
       if (s != r)
-        {
-          error ("mat2cell: mismatch on %d-th dimension (%d != %d)",
-                 i+1, r, s);
-          return true;
-        }
+        error ("mat2cell: mismatch on %d-th dimension (%d != %d)", i+1, r, s);
     }
 
   return false;
@@ -2031,8 +1932,8 @@
   if (mat2cell_mismatch (a.dims (), d, nd))
     return retval;
 
-  octave_idx_type nridx = d[0].length ();
-  octave_idx_type ncidx = nd == 1 ? 1 : d[1].length ();
+  octave_idx_type nridx = d[0].numel ();
+  octave_idx_type ncidx = nd == 1 ? 1 : d[1].numel ();
   retval.clear (nridx, ncidx);
 
   int ivec = -1;
@@ -2092,7 +1993,7 @@
   octave_idx_type idxtot = 0;
   for (int i = 0; i < nd; i++)
     {
-      rdv(i) = nidx[i] = d[i].length ();
+      rdv(i) = nidx[i] = d[i].numel ();
       idxtot += nidx[i];
     }
 
@@ -2156,7 +2057,7 @@
   octave_idx_type idxtot = 0;
   for (int i = 0; i < nd; i++)
     {
-      rdv(i) = nidx[i] = d[i].length ();
+      rdv(i) = nidx[i] = d[i].numel ();
       idxtot += nidx[i];
     }
 
@@ -2186,9 +2087,6 @@
 
       retval(j) = a.do_index_op (ra_idx);
 
-      if (error_state)
-        break;
-
       rdv.increment_index (ridx);
     }
 
@@ -2240,79 +2138,76 @@
 @seealso{num2cell, cell2mat}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
   int nargin = args.length ();
-  octave_value retval;
 
   if (nargin < 2)
     print_usage ();
-  else
-    {
-      // Prepare indices.
-      OCTAVE_LOCAL_BUFFER (Array<octave_idx_type>, d, nargin-1);
+
+  // Prepare indices.
+  OCTAVE_LOCAL_BUFFER (Array<octave_idx_type>, d, nargin-1);
+
+  for (int i = 1; i < nargin; i++)
+    d[i-1] = args(i).octave_idx_type_vector_value (true);
 
-      for (int i = 1; i < nargin; i++)
-        {
-          d[i-1] = args(i).octave_idx_type_vector_value (true);
-          if (error_state)
-            return retval;
-        }
+  octave_value a = args(0);
+  bool sparse = a.is_sparse_type ();
+  if (sparse && nargin > 3)
+    error ("mat2cell: sparse arguments only support 2-D indexing");
 
-      octave_value a = args(0);
-      bool sparse = a.is_sparse_type ();
-      if (sparse && nargin > 3)
-        {
-          error ("mat2cell: sparse arguments only support 2-D indexing");
-          return retval;
-        }
+  switch (a.builtin_type ())
+    {
+    case btyp_double:
+      {
+        if (sparse)
+          retval = do_mat2cell_2d (a.sparse_matrix_value (), d, nargin-1);
+        else
+          retval = do_mat2cell (a.array_value (), d, nargin - 1);
+      }
+      break;
 
-      switch (a.builtin_type ())
-        {
-        case btyp_double:
-          {
-            if (sparse)
-              retval = do_mat2cell_2d (a.sparse_matrix_value (), d, nargin-1);
-            else
-              retval = do_mat2cell (a.array_value (), d, nargin - 1);
-            break;
-          }
-        case btyp_complex:
-          {
-            if (sparse)
-              retval = do_mat2cell_2d (a.sparse_complex_matrix_value (), d,
-                                       nargin-1);
-            else
-              retval = do_mat2cell (a.complex_array_value (), d, nargin - 1);
-            break;
-          }
-#define BTYP_BRANCH(X,Y) \
-        case btyp_ ## X: \
-            retval = do_mat2cell (a.Y ## _value (), d, nargin - 1); \
-          break
+    case btyp_complex:
+      {
+        if (sparse)
+          retval = do_mat2cell_2d (a.sparse_complex_matrix_value (), d,
+                                   nargin-1);
+        else
+          retval = do_mat2cell (a.complex_array_value (), d, nargin - 1);
+      }
+      break;
+
+#define BTYP_BRANCH(X, Y) \
+  case btyp_ ## X: \
+    retval = do_mat2cell (a.Y ## _value (), d, nargin - 1); \
+    break
 
-        BTYP_BRANCH (float, float_array);
-        BTYP_BRANCH (float_complex, float_complex_array);
-        BTYP_BRANCH (bool, bool_array);
-        BTYP_BRANCH (char, char_array);
+      BTYP_BRANCH (float, float_array);
+      BTYP_BRANCH (float_complex, float_complex_array);
+      BTYP_BRANCH (bool, bool_array);
+      BTYP_BRANCH (char, char_array);
 
-        BTYP_BRANCH (int8,  int8_array);
-        BTYP_BRANCH (int16, int16_array);
-        BTYP_BRANCH (int32, int32_array);
-        BTYP_BRANCH (int64, int64_array);
-        BTYP_BRANCH (uint8,  uint8_array);
-        BTYP_BRANCH (uint16, uint16_array);
-        BTYP_BRANCH (uint32, uint32_array);
-        BTYP_BRANCH (uint64, uint64_array);
+      BTYP_BRANCH (int8,  int8_array);
+      BTYP_BRANCH (int16, int16_array);
+      BTYP_BRANCH (int32, int32_array);
+      BTYP_BRANCH (int64, int64_array);
+      BTYP_BRANCH (uint8,  uint8_array);
+      BTYP_BRANCH (uint16, uint16_array);
+      BTYP_BRANCH (uint32, uint32_array);
+      BTYP_BRANCH (uint64, uint64_array);
 
-        BTYP_BRANCH (cell, cell);
-        BTYP_BRANCH (struct, map);
+      BTYP_BRANCH (cell, cell);
+      BTYP_BRANCH (struct, map);
+
 #undef BTYP_BRANCH
 
-        case btyp_func_handle:
-          gripe_wrong_type_arg ("mat2cell", a);
-          break;
-        default:
-          retval = do_mat2cell (a, d, nargin-1);
-        }
+    case btyp_func_handle:
+      gripe_wrong_type_arg ("mat2cell", a);
+      break;
+
+    default:
+      retval = do_mat2cell (a, d, nargin-1);
+      break;
     }
 
   return retval;
@@ -2339,13 +2234,13 @@
                    const Array<octave_idx_type>& ub,
                    int dim = -1)
 {
-  octave_idx_type n = lb.length ();
+  octave_idx_type n = lb.numel ();
   Cell retval (1, n);
   if (array.is_vector () && (dim == -1
                              || (dim == 0 && array.columns () == 1)
                              || (dim == 1 && array.rows () == 1)))
     {
-      for (octave_idx_type i = 0; i < n && ! error_state; i++)
+      for (octave_idx_type i = 0; i < n; i++)
         retval(i) = array.index (idx_vector (lb(i) - 1, ub(i)));
     }
   else
@@ -2358,7 +2253,7 @@
 
       Array<idx_vector> idx (dim_vector (ndims, 1), idx_vector::colon);
 
-      for (octave_idx_type i = 0; i < n && ! error_state; i++)
+      for (octave_idx_type i = 0; i < n; i++)
         {
           idx(dim) = idx_vector (lb(i) - 1, ub(i));
           retval(i) = array.index (idx);
@@ -2392,109 +2287,100 @@
 @seealso{cell2mat, cellindexmat, cellfun}\n\
 @end deftypefn")
 {
-  octave_value retval;
   int nargin = args.length ();
-  if (nargin == 3 || nargin == 4)
+
+  if (nargin < 3 || nargin > 4)
+    print_usage ();
+
+  octave_value x = args(0);
+  Array<octave_idx_type> lb = args(1).octave_idx_type_vector_value ();
+  Array<octave_idx_type> ub = args(2).octave_idx_type_vector_value ();
+  int dim = -1;
+  if (nargin == 4)
     {
-      octave_value x = args(0);
-      Array<octave_idx_type> lb = args(1).octave_idx_type_vector_value ();
-      Array<octave_idx_type> ub = args(2).octave_idx_type_vector_value ();
-      int dim = -1;
-      if (nargin == 4)
+      dim = args(3).int_value () - 1;
+      if (dim < 0)
+        error ("cellslices: DIM must be a valid dimension");
+    }
+
+  if (lb.numel () != ub.numel ())
+    error ("cellslices: the lengths of LB and UB must match");
+
+  Cell retcell;
+  if (! x.is_sparse_type () && x.is_matrix_type ())
+    {
+      // specialize for some dense arrays.
+      if (x.is_bool_type ())
+        retcell = do_cellslices_nda (x.bool_array_value (),
+                                     lb, ub, dim);
+      else if (x.is_char_matrix ())
+        retcell = do_cellslices_nda (x.char_array_value (),
+                                     lb, ub, dim);
+      else if (x.is_integer_type ())
         {
-          dim = args(3).int_value () - 1;
-          if (dim < 0)
-            error ("cellslices: DIM must be a valid dimension");
+          if (x.is_int8_type ())
+            retcell = do_cellslices_nda (x.int8_array_value (),
+                                         lb, ub, dim);
+          else if (x.is_int16_type ())
+            retcell = do_cellslices_nda (x.int16_array_value (),
+                                         lb, ub, dim);
+          else if (x.is_int32_type ())
+            retcell = do_cellslices_nda (x.int32_array_value (),
+                                         lb, ub, dim);
+          else if (x.is_int64_type ())
+            retcell = do_cellslices_nda (x.int64_array_value (),
+                                         lb, ub, dim);
+          else if (x.is_uint8_type ())
+            retcell = do_cellslices_nda (x.uint8_array_value (),
+                                         lb, ub, dim);
+          else if (x.is_uint16_type ())
+            retcell = do_cellslices_nda (x.uint16_array_value (),
+                                         lb, ub, dim);
+          else if (x.is_uint32_type ())
+            retcell = do_cellslices_nda (x.uint32_array_value (),
+                                         lb, ub, dim);
+          else if (x.is_uint64_type ())
+            retcell = do_cellslices_nda (x.uint64_array_value (),
+                                         lb, ub, dim);
         }
-
-      if (! error_state)
+      else if (x.is_complex_type ())
         {
-          if (lb.length () != ub.length ())
-            error ("cellslices: the lengths of LB and UB must match");
+          if (x.is_single_type ())
+            retcell = do_cellslices_nda (x.float_complex_array_value (),
+                                         lb, ub, dim);
           else
-            {
-              Cell retcell;
-              if (! x.is_sparse_type () && x.is_matrix_type ())
-                {
-                  // specialize for some dense arrays.
-                  if (x.is_bool_type ())
-                    retcell = do_cellslices_nda (x.bool_array_value (),
-                                                 lb, ub, dim);
-                  else if (x.is_char_matrix ())
-                    retcell = do_cellslices_nda (x.char_array_value (),
-                                                 lb, ub, dim);
-                  else if (x.is_integer_type ())
-                    {
-                      if (x.is_int8_type ())
-                        retcell = do_cellslices_nda (x.int8_array_value (),
-                                                     lb, ub, dim);
-                      else if (x.is_int16_type ())
-                        retcell = do_cellslices_nda (x.int16_array_value (),
-                                                     lb, ub, dim);
-                      else if (x.is_int32_type ())
-                        retcell = do_cellslices_nda (x.int32_array_value (),
-                                                     lb, ub, dim);
-                      else if (x.is_int64_type ())
-                        retcell = do_cellslices_nda (x.int64_array_value (),
-                                                     lb, ub, dim);
-                      else if (x.is_uint8_type ())
-                        retcell = do_cellslices_nda (x.uint8_array_value (),
-                                                     lb, ub, dim);
-                      else if (x.is_uint16_type ())
-                        retcell = do_cellslices_nda (x.uint16_array_value (),
-                                                     lb, ub, dim);
-                      else if (x.is_uint32_type ())
-                        retcell = do_cellslices_nda (x.uint32_array_value (),
-                                                     lb, ub, dim);
-                      else if (x.is_uint64_type ())
-                        retcell = do_cellslices_nda (x.uint64_array_value (),
-                                                     lb, ub, dim);
-                    }
-                  else if (x.is_complex_type ())
-                    {
-                      if (x.is_single_type ())
-                        retcell = do_cellslices_nda (x.float_complex_array_value (),
-                                                     lb, ub, dim);
-                      else
-                        retcell = do_cellslices_nda (x.complex_array_value (),
-                                                     lb, ub, dim);
-                    }
-                  else
-                    {
-                      if (x.is_single_type ())
-                        retcell = do_cellslices_nda (x.float_array_value (),
-                                                     lb, ub, dim);
-                      else
-                        retcell = do_cellslices_nda (x.array_value (),
-                                                     lb, ub, dim);
-                    }
-                }
-              else
-                {
-                  // generic code.
-                  octave_idx_type n = lb.length ();
-                  retcell = Cell (1, n);
-                  const dim_vector dv = x.dims ();
-                  int ndims = dv.length ();
-                  if (dim < 0)
-                    dim = dv.first_non_singleton ();
-                  ndims = std::max (ndims, dim + 1);
-                  octave_value_list idx (ndims, octave_value::magic_colon_t);
-                  for (octave_idx_type i = 0; i < n && ! error_state; i++)
-                    {
-                      idx(dim) = Range (lb(i), ub(i));
-                      retcell(i) = x.do_index_op (idx);
-                    }
-                }
-              if (! error_state)
-                retval = retcell;
-            }
+            retcell = do_cellslices_nda (x.complex_array_value (),
+                                         lb, ub, dim);
+        }
+      else
+        {
+          if (x.is_single_type ())
+            retcell = do_cellslices_nda (x.float_array_value (),
+                                         lb, ub, dim);
+          else
+            retcell = do_cellslices_nda (x.array_value (),
+                                         lb, ub, dim);
         }
     }
   else
-    print_usage ();
+    {
+      // generic code.
+      octave_idx_type n = lb.numel ();
+      retcell = Cell (1, n);
+      const dim_vector dv = x.dims ();
+      int ndims = dv.length ();
+      if (dim < 0)
+        dim = dv.first_non_singleton ();
+      ndims = std::max (ndims, dim + 1);
+      octave_value_list idx (ndims, octave_value::magic_colon_t);
+      for (octave_idx_type i = 0; i < n; i++)
+        {
+          idx(dim) = Range (lb(i), ub(i));
+          retcell(i) = x.do_index_op (idx);
+        }
+    }
 
-  return retval;
+  return octave_value (retcell);
 }
 
 /*
@@ -2522,32 +2408,22 @@
 @seealso{cellslices, cellfun}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () >= 1)
-    {
-      if (args(0).is_cell ())
-        {
-          const Cell x = args(0).cell_value ();
-          NoAlias<Cell> y(x.dims ());
-          octave_idx_type nel = x.numel ();
-          octave_value_list idx = args.slice (1, args.length () - 1);
-
-          for (octave_idx_type i = 0; i < nel; i++)
-            {
-              octave_quit ();
-              octave_value tmp = x(i);
-              y(i) = tmp.do_index_op (idx);
-              if (error_state)
-                break;
-            }
-
-          retval = y;
-        }
-      else
-        error ("cellindexmat: X must be a cell");
-    }
-  else
+  if (args.length () == 0)
     print_usage ();
 
-  return retval;
+  const Cell x = args(0).xcell_value ("cellindexmat: X must be a cell");
+  NoAlias<Cell> y(x.dims ());
+  octave_idx_type nel = x.numel ();
+  octave_value_list idx = args.slice (1, args.length () - 1);
+
+  for (octave_idx_type i = 0; i < nel; i++)
+    {
+      octave_quit ();
+
+      octave_value tmp = x(i);
+
+      y(i) = tmp.do_index_op (idx);
+    }
+
+  return octave_value (y);
 }
--- a/libinterp/corefcn/colloc.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/colloc.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -48,34 +48,19 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   if (! args(0).is_scalar_type ())
-    {
-      error ("colloc: N must be a scalar");
-      return retval;
-    }
+    error ("colloc: N must be a scalar");
 
   double tmp = args(0).double_value ();
 
-  if (error_state)
-    return retval;
-
   if (xisnan (tmp))
-    {
-      error ("colloc: N cannot be NaN");
-      return retval;
-    }
+    error ("colloc: N cannot be NaN");
 
   octave_idx_type ncol = NINTbig (tmp);
   if (ncol < 0)
-    {
-      error ("colloc: N must be positive");
-      return retval;
-    }
+    error ("colloc: N must be positive");
 
   octave_idx_type ntot = ncol;
   octave_idx_type left = 0;
@@ -83,45 +68,25 @@
 
   for (int i = 1; i < nargin; i++)
     {
-      if (args(i).is_defined ())
-        {
-          if (! args(i).is_string ())
-            {
-              error ("colloc: expecting string argument \"left\" or \"right\"");
-              return retval;
-            }
-
-          std::string s = args(i).string_value ();
+      std::string s = args(i).xstring_value ("colloc: optional arguments must be strings");
 
-          if ((s.length () == 1 && (s[0] == 'R' || s[0] == 'r'))
-              || s == "right")
-            {
-              right = 1;
-            }
-          else if ((s.length () == 1 && (s[0] == 'L' || s[0] == 'l'))
-                   || s == "left")
-            {
-              left = 1;
-            }
-          else
-            {
-              error ("colloc: unrecognized argument");
-              return retval;
-            }
+      if ((s.length () == 1 && (s[0] == 'R' || s[0] == 'r'))
+          || s == "right")
+        {
+          right = 1;
+        }
+      else if ((s.length () == 1 && (s[0] == 'L' || s[0] == 'l'))
+               || s == "left")
+        {
+          left = 1;
         }
       else
-        {
-          error ("colloc: unexpected empty argument");
-          return retval;
-        }
+        error ("colloc: string argument must be \"left\" or \"right\"");
     }
 
   ntot += left + right;
   if (ntot < 1)
-    {
-      error ("colloc: the total number of roots must be positive");
-      return retval;
-    }
+    error ("colloc: the total number of roots must be positive");
 
   CollocWt wts (ncol, left, right);
 
--- a/libinterp/corefcn/comment-list.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/comment-list.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_comment_list_h)
+#if ! defined (octave_comment_list_h)
 #define octave_comment_list_h 1
 
 #include <string>
--- a/libinterp/corefcn/conv2.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/conv2.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -69,31 +69,26 @@
   int nargin = args.length ();
   std::string shape = "full";   // default
   bool separable = false;
-  convn_type ct;
+  convn_type ct = convn_full;
 
-  if (nargin < 2)
-    {
-      print_usage ();
-      return retval;
-    }
-  else if (nargin == 3)
+  if (nargin < 2 || nargin > 4)
+    print_usage ();
+
+  if (nargin == 3)
     {
       if (args(2).is_string ())
         shape = args(2).string_value ();
       else
         separable = true;
     }
-  else if (nargin >= 4)
+  else if (nargin == 4)
     {
       separable = true;
       shape = args(3).string_value ();
     }
 
   if (args(0).ndims () > 2 || args(1).ndims () > 2)
-    {
-      error ("conv2: A and B must be 1-D vectors or 2-D matrices");
-      return retval;
-    }
+    error ("conv2: A and B must be 1-D vectors or 2-D matrices");
 
   if (shape == "full")
     ct = convn_full;
@@ -102,11 +97,7 @@
   else if (shape == "valid")
     ct = convn_valid;
   else
-    {
-      error ("conv2: SHAPE type not valid");
-      print_usage ();
-      return retval;
-    }
+    error ("conv2: SHAPE type not valid");
 
   if (separable)
     {
@@ -114,10 +105,7 @@
 
       if (! (1 == args(0).rows () || 1 == args(0).columns ())
           || ! (1 == args(1).rows () || 1 == args(1).columns ()))
-        {
-          print_usage ();
-          return retval;
-        }
+        error ("conv2: arguments must be vectors for separable option");
 
       if (args(0).is_single_type () || args(1).is_single_type ()
           || args(2).is_single_type ())
@@ -321,23 +309,13 @@
   octave_value tmp;
   int nargin = args.length ();
   std::string shape = "full";   // default
-  convn_type ct;
+  convn_type ct = convn_full;
 
   if (nargin < 2 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
-  else if (nargin == 3)
-    {
-      if (args(2).is_string ())
-        shape = args(2).string_value ();
-      else
-        {
-          error ("convn: SHAPE must be a string");
-          return retval;
-        }
-    }
+    print_usage ();
+
+  if (nargin == 3)
+    shape = args(2).xstring_value ("convn: SHAPE must be a string");
 
   if (shape == "full")
     ct = convn_full;
@@ -346,11 +324,7 @@
   else if (shape == "valid")
     ct = convn_valid;
   else
-    {
-      error ("convn: SHAPE type not valid");
-      print_usage ();
-      return retval;
-    }
+    error ("convn: SHAPE type not valid");
 
   if (args(0).is_single_type () || args(1).is_single_type ())
     {
--- a/libinterp/corefcn/cutils.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/cutils.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_cutils_h)
+#if ! defined (octave_cutils_h)
 #define octave_cutils_h 1
 
 #include <stdarg.h>
--- a/libinterp/corefcn/daspk.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/daspk.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -63,7 +63,7 @@
 {
   ColumnVector retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -73,12 +73,15 @@
 
   if (daspk_fcn)
     {
-      octave_value_list tmp = daspk_fcn->do_multi_index_op (1, args);
+      octave_value_list tmp;
 
-      if (error_state)
+      try
         {
-          gripe_user_supplied_eval ("daspk");
-          return retval;
+          tmp = daspk_fcn->do_multi_index_op (1, args);
+        }
+      catch (octave_execution_exception& e)
+        {
+          gripe_user_supplied_eval (e, "daspk");
         }
 
       int tlen = tmp.length ();
@@ -90,12 +93,12 @@
               warned_fcn_imaginary = true;
             }
 
-          retval = ColumnVector (tmp(0).vector_value ());
+          retval = tmp(0).vector_value ();
 
           if (tlen > 1)
             ires = tmp(1).int_value ();
 
-          if (error_state || retval.length () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("daspk");
         }
       else
@@ -111,7 +114,7 @@
 {
   Matrix retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -122,12 +125,15 @@
 
   if (daspk_jac)
     {
-      octave_value_list tmp = daspk_jac->do_multi_index_op (1, args);
+      octave_value_list tmp;
 
-      if (error_state)
+      try
         {
-          gripe_user_supplied_eval ("daspk");
-          return retval;
+          tmp = daspk_jac->do_multi_index_op (1, args);
+        }
+      catch (octave_execution_exception& e)
+        {
+          gripe_user_supplied_eval (e, "daspk");
         }
 
       int tlen = tmp.length ();
@@ -141,7 +147,7 @@
 
           retval = tmp(0).matrix_value ();
 
-          if (error_state || retval.length () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("daspk");
         }
       else
@@ -157,7 +163,7 @@
 #define DASPK_ABORT1(msg) \
   do \
     { \
-      ::error ("daspk: " msg); \
+      error ("daspk: " msg); \
       DASPK_ABORT (); \
     } \
   while (0)
@@ -165,7 +171,7 @@
 #define DASPK_ABORT2(fmt, arg) \
   do \
     { \
-      ::error ("daspk: " fmt, arg); \
+      error ("daspk: " fmt, arg); \
       DASPK_ABORT (); \
     } \
   while (0)
@@ -286,195 +292,175 @@
 
   int nargin = args.length ();
 
-  if (nargin > 3 && nargin < 6)
+  if (nargin < 4 || nargin > 5)
+    print_usage ();
+
+  std::string fcn_name, fname, jac_name, jname;
+  daspk_fcn = 0;
+  daspk_jac = 0;
+
+  octave_value f_arg = args(0);
+
+  if (f_arg.is_cell ())
     {
-      std::string fcn_name, fname, jac_name, jname;
-      daspk_fcn = 0;
-      daspk_jac = 0;
-
-      octave_value f_arg = args(0);
+      Cell c = f_arg.cell_value ();
+      if (c.numel () == 1)
+        f_arg = c(0);
+      else if (c.numel () == 2)
+        {
+          if (c(0).is_function_handle () || c(0).is_inline_function ())
+            daspk_fcn = c(0).function_value ();
+          else
+            {
+              fcn_name = unique_symbol_name ("__daspk_fcn__");
+              fname = "function y = ";
+              fname.append (fcn_name);
+              fname.append (" (x, xdot, t) y = ");
+              daspk_fcn = extract_function
+                (c(0), "daspk", fcn_name, fname, "; endfunction");
+            }
 
-      if (f_arg.is_cell ())
+          if (daspk_fcn)
+            {
+              if (c(1).is_function_handle () || c(1).is_inline_function ())
+                daspk_jac = c(1).function_value ();
+              else
+                {
+                  jac_name = unique_symbol_name ("__daspk_jac__");
+                  jname = "function jac = ";
+                  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 ())
+                        clear_function (fcn_name);
+                      daspk_fcn = 0;
+                    }
+                }
+            }
+        }
+      else
+        DASPK_ABORT1 ("incorrect number of elements in cell array");
+    }
+
+  if (!daspk_fcn && ! f_arg.is_cell ())
+    {
+      if (f_arg.is_function_handle () || f_arg.is_inline_function ())
+        daspk_fcn = f_arg.function_value ();
+      else
         {
-          Cell c = f_arg.cell_value ();
-          if (c.length () == 1)
-            f_arg = c(0);
-          else if (c.length () == 2)
+          switch (f_arg.rows ())
             {
-              if (c(0).is_function_handle () || c(0).is_inline_function ())
-                daspk_fcn = c(0).function_value ();
-              else
+            case 1:
+              do
                 {
                   fcn_name = unique_symbol_name ("__daspk_fcn__");
                   fname = "function y = ";
                   fname.append (fcn_name);
                   fname.append (" (x, xdot, t) y = ");
-                  daspk_fcn = extract_function
-                              (c(0), "daspk", fcn_name, fname, "; endfunction");
+                  daspk_fcn = extract_function (f_arg, "daspk", fcn_name,
+                                                fname, "; endfunction");
                 }
+              while (0);
+              break;
 
-              if (daspk_fcn)
-                {
-                  if (c(1).is_function_handle () || c(1).is_inline_function ())
-                    daspk_jac = c(1).function_value ();
-                  else
-                    {
-                      jac_name = unique_symbol_name ("__daspk_jac__");
-                      jname = "function jac = ";
-                      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 ())
-                            clear_function (fcn_name);
-                          daspk_fcn = 0;
-                        }
-                    }
-                }
-            }
-          else
-            DASPK_ABORT1 ("incorrect number of elements in cell array");
-        }
+            case 2:
+              {
+                string_vector tmp = f_arg.all_strings ();
 
-      if (!daspk_fcn && ! f_arg.is_cell ())
-        {
-          if (f_arg.is_function_handle () || f_arg.is_inline_function ())
-            daspk_fcn = f_arg.function_value ();
-          else
-            {
-              switch (f_arg.rows ())
-                {
-                case 1:
-                  do
-                    {
-                      fcn_name = unique_symbol_name ("__daspk_fcn__");
-                      fname = "function y = ";
-                      fname.append (fcn_name);
-                      fname.append (" (x, xdot, t) y = ");
-                      daspk_fcn = extract_function (f_arg, "daspk", fcn_name,
-                                                    fname, "; endfunction");
-                    }
-                  while (0);
-                  break;
-
-                case 2:
-                  {
-                    string_vector tmp = f_arg.all_strings ();
+                fcn_name = unique_symbol_name ("__daspk_fcn__");
+                fname = "function y = ";
+                fname.append (fcn_name);
+                fname.append (" (x, xdot, t) y = ");
+                daspk_fcn = extract_function (tmp(0), "daspk", fcn_name,
+                                              fname, "; endfunction");
 
-                    if (! error_state)
-                      {
-                        fcn_name = unique_symbol_name ("__daspk_fcn__");
-                        fname = "function y = ";
-                        fname.append (fcn_name);
-                        fname.append (" (x, xdot, t) y = ");
-                        daspk_fcn = extract_function (tmp(0), "daspk", fcn_name,
-                                                      fname, "; endfunction");
+                if (daspk_fcn)
+                  {
+                    jac_name = unique_symbol_name ("__daspk_jac__");
+                    jname = "function jac = ";
+                    jname.append (jac_name);
+                    jname.append (" (x, xdot, t, cj) jac = ");
+                    daspk_jac = extract_function (tmp(1), "daspk",
+                                                  jac_name, jname,
+                                                  "; endfunction");
 
-                        if (daspk_fcn)
-                          {
-                            jac_name = unique_symbol_name ("__daspk_jac__");
-                            jname = "function jac = ";
-                            jname.append (jac_name);
-                            jname.append (" (x, xdot, t, cj) jac = ");
-                            daspk_jac = extract_function (tmp(1), "daspk",
-                                                          jac_name, jname,
-                                                          "; endfunction");
-
-                            if (!daspk_jac)
-                              {
-                                if (fcn_name.length ())
-                                  clear_function (fcn_name);
-                                daspk_fcn = 0;
-                              }
-                          }
+                    if (!daspk_jac)
+                      {
+                        if (fcn_name.length ())
+                          clear_function (fcn_name);
+                        daspk_fcn = 0;
                       }
                   }
-                }
-            }
-        }
-
-      if (error_state || ! daspk_fcn)
-        DASPK_ABORT ();
-
-      ColumnVector state = ColumnVector (args(1).vector_value ());
-
-      if (error_state)
-        DASPK_ABORT1 ("expecting state vector as second argument");
-
-      ColumnVector deriv (args(2).vector_value ());
-
-      if (error_state)
-        DASPK_ABORT1 ("expecting derivative vector as third argument");
-
-      ColumnVector out_times (args(3).vector_value ());
-
-      if (error_state)
-        DASPK_ABORT1 ("expecting output time vector as fourth argument");
-
-      ColumnVector crit_times;
-      int crit_times_set = 0;
-      if (nargin > 4)
-        {
-          crit_times = ColumnVector (args(4).vector_value ());
-
-          if (error_state)
-            DASPK_ABORT1 ("expecting critical time vector as fifth argument");
-
-          crit_times_set = 1;
-        }
-
-      if (state.capacity () != deriv.capacity ())
-        DASPK_ABORT1 ("x and xdot must have the same size");
-
-      double tzero = out_times (0);
-
-      DAEFunc func (daspk_user_function);
-      if (daspk_jac)
-        func.set_jacobian_function (daspk_user_jacobian);
-
-      DASPK dae (state, deriv, tzero, func);
-      dae.set_options (daspk_opts);
-
-      Matrix output;
-      Matrix deriv_output;
-
-      if (crit_times_set)
-        output = dae.integrate (out_times, deriv_output, crit_times);
-      else
-        output = dae.integrate (out_times, deriv_output);
-
-      if (fcn_name.length ())
-        clear_function (fcn_name);
-      if (jac_name.length ())
-        clear_function (jac_name);
-
-      if (! error_state)
-        {
-          std::string msg = dae.error_message ();
-
-          retval(3) = msg;
-          retval(2) = static_cast<double> (dae.integration_state ());
-
-          if (dae.integration_ok ())
-            {
-              retval(1) = deriv_output;
-              retval(0) = output;
-            }
-          else
-            {
-              retval(1) = Matrix ();
-              retval(0) = Matrix ();
-
-              if (nargout < 3)
-                error ("daspk: %s", msg.c_str ());
+              }
             }
         }
     }
+
+  if (! daspk_fcn)
+    DASPK_ABORT ();
+
+  ColumnVector state = args(1).xvector_value ("daspk: initial state X_0 must be a vector");
+
+  ColumnVector deriv = args(2).xvector_value ("daspk: initial derivatives XDOT_0 must be a vector");
+
+  ColumnVector out_times = args(3).xvector_value ("daspk: output time variable T must be a vector");
+
+  ColumnVector crit_times;
+  int crit_times_set = 0;
+  if (nargin > 4)
+    {
+      crit_times = args(4).xvector_value ("daspk: list of critical times T_CRIT must be a vector");
+
+      crit_times_set = 1;
+    }
+
+  if (state.numel () != deriv.numel ())
+    DASPK_ABORT1 ("X_0 and XDOT_0 must have the same size");
+
+  double tzero = out_times (0);
+
+  DAEFunc func (daspk_user_function);
+  if (daspk_jac)
+    func.set_jacobian_function (daspk_user_jacobian);
+
+  DASPK dae (state, deriv, tzero, func);
+  dae.set_options (daspk_opts);
+
+  Matrix output;
+  Matrix deriv_output;
+
+  if (crit_times_set)
+    output = dae.integrate (out_times, deriv_output, crit_times);
   else
-    print_usage ();
+    output = dae.integrate (out_times, deriv_output);
+
+  if (fcn_name.length ())
+    clear_function (fcn_name);
+  if (jac_name.length ())
+    clear_function (jac_name);
+
+  std::string msg = dae.error_message ();
+
+  retval(3) = msg;
+  retval(2) = static_cast<double> (dae.integration_state ());
+
+  if (dae.integration_ok ())
+    {
+      retval(1) = deriv_output;
+      retval(0) = output;
+    }
+  else
+    {
+      retval(1) = Matrix ();
+      retval(0) = Matrix ();
+
+      if (nargout < 3)
+        error ("daspk: %s", msg.c_str ());
+    }
 
   return retval;
 }
--- a/libinterp/corefcn/dasrt.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/dasrt.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -63,7 +63,7 @@
 {
   ColumnVector retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -73,12 +73,15 @@
 
   if (dasrt_f)
     {
-      octave_value_list tmp = dasrt_f->do_multi_index_op (1, args);
+      octave_value_list tmp;
 
-      if (error_state)
+      try
         {
-          gripe_user_supplied_eval ("dasrt");
-          return retval;
+          tmp = dasrt_f->do_multi_index_op (1, args);
+        }
+      catch (octave_execution_exception& e)
+        {
+          gripe_user_supplied_eval (e, "dasrt");
         }
 
       if (tmp.length () > 0 && tmp(0).is_defined ())
@@ -89,9 +92,9 @@
               warned_fcn_imaginary = true;
             }
 
-          retval = ColumnVector (tmp(0).vector_value ());
+          retval = tmp(0).vector_value ();
 
-          if (error_state || retval.length () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("dasrt");
         }
       else
@@ -113,12 +116,15 @@
 
   if (dasrt_cf)
     {
-      octave_value_list tmp = dasrt_cf->do_multi_index_op (1, args);
+      octave_value_list tmp;
 
-      if (error_state)
+      try
         {
-          gripe_user_supplied_eval ("dasrt");
-          return retval;
+          tmp = dasrt_cf->do_multi_index_op (1, args);
+        }
+      catch (octave_execution_exception& e)
+        {
+          gripe_user_supplied_eval (e, "dasrt");
         }
 
       if (tmp.length () > 0 && tmp(0).is_defined ())
@@ -129,9 +135,9 @@
               warned_cf_imaginary = true;
             }
 
-          retval = ColumnVector (tmp(0).vector_value ());
+          retval = tmp(0).vector_value ();
 
-          if (error_state || retval.length () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("dasrt");
         }
       else
@@ -147,7 +153,7 @@
 {
   Matrix retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -158,12 +164,15 @@
 
   if (dasrt_j)
     {
-      octave_value_list tmp = dasrt_j->do_multi_index_op (1, args);
+      octave_value_list tmp;
 
-      if (error_state)
+      try
         {
-          gripe_user_supplied_eval ("dasrt");
-          return retval;
+          tmp = dasrt_j->do_multi_index_op (1, args);
+        }
+      catch (octave_execution_exception& e)
+        {
+          gripe_user_supplied_eval (e, "dasrt");
         }
 
       int tlen = tmp.length ();
@@ -177,7 +186,7 @@
 
           retval = tmp(0).matrix_value ();
 
-          if (error_state || retval.length () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("dasrt");
         }
       else
@@ -193,7 +202,7 @@
 #define DASRT_ABORT1(msg) \
   do \
     { \
-      ::error ("dasrt: " msg); \
+      error ("dasrt: " msg); \
       DASRT_ABORT; \
     } \
   while (0)
@@ -201,7 +210,7 @@
 #define DASRT_ABORT2(fmt, arg) \
   do \
     { \
-      ::error ("dasrt: " fmt, arg); \
+      error ("dasrt: " fmt, arg); \
       DASRT_ABORT; \
     } \
   while (0)
@@ -361,16 +370,12 @@
   if (call_depth > 1)
     DASRT_ABORT1 ("invalid recursive call");
 
-  int argp = 0;
-
   int nargin = args.length ();
 
   if (nargin < 4 || nargin > 6)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
+  int argp = 0;
   std::string fcn_name, fname, jac_name, jname;
   dasrt_f = 0;
   dasrt_j = 0;
@@ -385,9 +390,9 @@
   if (f_arg.is_cell ())
     {
       Cell c = f_arg.cell_value ();
-      if (c.length () == 1)
+      if (c.numel () == 1)
         f_arg = c(0);
-      else if (c.length () == 2)
+      else if (c.numel () == 2)
         {
           if (c(0).is_function_handle () || c(0).is_inline_function ())
             dasrt_f = c(0).function_value ();
@@ -448,27 +453,24 @@
               {
                 string_vector tmp = args(0).all_strings ();
 
-                if (! error_state)
-                  {
-                    fcn_name = unique_symbol_name ("__dasrt_fcn__");
-                    fname = "function y = ";
-                    fname.append (fcn_name);
-                    fname.append (" (x, xdot, t) y = ");
-                    dasrt_f = extract_function (tmp(0), "dasrt", fcn_name,
-                                                fname, "; endfunction");
+                fcn_name = unique_symbol_name ("__dasrt_fcn__");
+                fname = "function y = ";
+                fname.append (fcn_name);
+                fname.append (" (x, xdot, t) y = ");
+                dasrt_f = extract_function (tmp(0), "dasrt", fcn_name,
+                                            fname, "; endfunction");
 
-                    if (dasrt_f)
-                      {
-                        jac_name = unique_symbol_name ("__dasrt_jac__");
-                        jname = "function jac = ";
-                        jname.append (jac_name);
-                        jname.append (" (x, xdot, t, cj) jac = ");
-                        dasrt_j = extract_function (tmp(1), "dasrt", jac_name,
-                                                    jname, "; endfunction");
+                if (dasrt_f)
+                  {
+                    jac_name = unique_symbol_name ("__dasrt_jac__");
+                    jname = "function jac = ";
+                    jname.append (jac_name);
+                    jname.append (" (x, xdot, t, cj) jac = ");
+                    dasrt_j = extract_function (tmp(1), "dasrt", jac_name,
+                                                jname, "; endfunction");
 
-                        if (! dasrt_j)
-                          dasrt_f = 0;
-                      }
+                    if (! dasrt_j)
+                      dasrt_f = 0;
                   }
               }
               break;
@@ -480,7 +482,7 @@
         }
     }
 
-  if (error_state || (! dasrt_f))
+  if (! dasrt_f)
     DASRT_ABORT;
 
   DAERTFunc func (dasrt_user_f);
@@ -492,7 +494,7 @@
       dasrt_cf = args(1).function_value ();
 
       if (! dasrt_cf)
-        DASRT_ABORT1 ("expecting function name as argument 2");
+        DASRT_ABORT1 ("invalid constraint function G");
 
       argp++;
 
@@ -502,28 +504,20 @@
     {
       dasrt_cf = is_valid_function (args(1), "dasrt", true);
       if (! dasrt_cf)
-        DASRT_ABORT1 ("expecting function name as argument 2");
+        DASRT_ABORT1 ("invalid constraint function G");
 
       argp++;
 
       func.set_constraint_function (dasrt_user_cf);
     }
 
-  ColumnVector state (args(argp++).vector_value ());
-
-  if (error_state)
-    DASRT_ABORT2 ("expecting state vector as argument %d", argp);
-
-  ColumnVector stateprime (args(argp++).vector_value ());
+  ColumnVector state = args(argp).xvector_value ("dasrt: initial state X_0 must be a vector");
 
-  if (error_state)
-    DASRT_ABORT2 ("expecting time derivative of state vector as argument %d",
-                  argp);
+  ColumnVector stateprime = args(argp).xvector_value ("dasrt: initial derivatives XDOT_0 must be a vector");
+  argp++;
 
-  ColumnVector out_times (args(argp++).vector_value ());
-
-  if (error_state)
-    DASRT_ABORT2 ("expecting output time vector as %s argument %d", argp);
+  ColumnVector out_times = args(argp).xvector_value ("dasrt: output time variable T must be a vector");
+  argp++;
 
   double tzero = out_times (0);
 
@@ -533,10 +527,8 @@
 
   if (argp < nargin)
     {
-      crit_times = ColumnVector (args(argp++).vector_value ());
-
-      if (error_state)
-        DASRT_ABORT2 ("expecting critical time vector as argument %d", argp);
+      crit_times = args(argp).xvector_value ("dasrt: list of critical times T_CRIT must be a vector");
+      argp++;
 
       crit_times_set = true;
     }
@@ -560,28 +552,25 @@
   if (jac_name.length ())
     clear_function (jac_name);
 
-  if (! error_state)
-    {
-      std::string msg = dae.error_message ();
+  std::string msg = dae.error_message ();
 
-      retval(4) = msg;
-      retval(3) = static_cast<double> (dae.integration_state ());
+  retval(4) = msg;
+  retval(3) = static_cast<double> (dae.integration_state ());
 
-      if (dae.integration_ok ())
-        {
-          retval(2) = output.times ();
-          retval(1) = output.deriv ();
-          retval(0) = output.state ();
-        }
-      else
-        {
-          retval(2) = Matrix ();
-          retval(1) = Matrix ();
-          retval(0) = Matrix ();
+  if (dae.integration_ok ())
+    {
+      retval(2) = output.times ();
+      retval(1) = output.deriv ();
+      retval(0) = output.state ();
+    }
+  else
+    {
+      retval(2) = Matrix ();
+      retval(1) = Matrix ();
+      retval(0) = Matrix ();
 
-          if (nargout < 4)
-            error ("dasrt: %s", msg.c_str ());
-        }
+      if (nargout < 4)
+        error ("dasrt: %s", msg.c_str ());
     }
 
   return retval;
--- a/libinterp/corefcn/dassl.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/dassl.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -63,7 +63,7 @@
 {
   ColumnVector retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -73,12 +73,15 @@
 
   if (dassl_fcn)
     {
-      octave_value_list tmp = dassl_fcn->do_multi_index_op (1, args);
+      octave_value_list tmp;
 
-      if (error_state)
+      try
         {
-          gripe_user_supplied_eval ("dassl");
-          return retval;
+          tmp = dassl_fcn->do_multi_index_op (1, args);
+        }
+      catch (octave_execution_exception& e)
+        {
+          gripe_user_supplied_eval (e, "dassl");
         }
 
       int tlen = tmp.length ();
@@ -90,12 +93,12 @@
               warned_fcn_imaginary = true;
             }
 
-          retval = ColumnVector (tmp(0).vector_value ());
+          retval = tmp(0).vector_value ();
 
           if (tlen > 1)
             ires = tmp(1).int_value ();
 
-          if (error_state || retval.length () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("dassl");
         }
       else
@@ -111,7 +114,7 @@
 {
   Matrix retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -122,12 +125,15 @@
 
   if (dassl_jac)
     {
-      octave_value_list tmp = dassl_jac->do_multi_index_op (1, args);
+      octave_value_list tmp;
 
-      if (error_state)
+      try
         {
-          gripe_user_supplied_eval ("dassl");
-          return retval;
+          tmp = dassl_jac->do_multi_index_op (1, args);
+        }
+      catch (octave_execution_exception& e)
+        {
+          gripe_user_supplied_eval (e, "dassl");
         }
 
       int tlen = tmp.length ();
@@ -141,7 +147,7 @@
 
           retval = tmp(0).matrix_value ();
 
-          if (error_state || retval.length () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("dassl");
         }
       else
@@ -157,7 +163,7 @@
 #define DASSL_ABORT1(msg) \
   do \
     { \
-      ::error ("dassl: " msg); \
+      error ("dassl: " msg); \
       DASSL_ABORT (); \
     } \
   while (0)
@@ -165,7 +171,7 @@
 #define DASSL_ABORT2(fmt, arg) \
   do \
     { \
-      ::error ("dassl: " fmt, arg); \
+      error ("dassl: " fmt, arg); \
       DASSL_ABORT (); \
     } \
   while (0)
@@ -287,196 +293,176 @@
 
   int nargin = args.length ();
 
-  if (nargin > 3 && nargin < 6 && nargout < 5)
+  if (nargin < 4 || nargin > 5 || nargout > 4)
+    print_usage ();
+
+  std::string fcn_name, fname, jac_name, jname;
+  dassl_fcn = 0;
+  dassl_jac = 0;
+
+  octave_value f_arg = args(0);
+
+  if (f_arg.is_cell ())
     {
-      std::string fcn_name, fname, jac_name, jname;
-      dassl_fcn = 0;
-      dassl_jac = 0;
-
-      octave_value f_arg = args(0);
+      Cell c = f_arg.cell_value ();
+      if (c.numel () == 1)
+        f_arg = c(0);
+      else if (c.numel () == 2)
+        {
+          if (c(0).is_function_handle () || c(0).is_inline_function ())
+            dassl_fcn = c(0).function_value ();
+          else
+            {
+              fcn_name = unique_symbol_name ("__dassl_fcn__");
+              fname = "function y = ";
+              fname.append (fcn_name);
+              fname.append (" (x, xdot, t) y = ");
+              dassl_fcn = extract_function (c(0), "dassl", fcn_name, fname,
+                                            "; endfunction");
+            }
 
-      if (f_arg.is_cell ())
+          if (dassl_fcn)
+            {
+              if (c(1).is_function_handle () || c(1).is_inline_function ())
+                dassl_jac = c(1).function_value ();
+              else
+                {
+                  jac_name = unique_symbol_name ("__dassl_jac__");
+                  jname = "function jac = ";
+                  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 ())
+                        clear_function (fcn_name);
+                      dassl_fcn = 0;
+                    }
+                }
+            }
+        }
+      else
+        DASSL_ABORT1 ("incorrect number of elements in cell array");
+    }
+
+  if (!dassl_fcn && ! f_arg.is_cell ())
+    {
+      if (f_arg.is_function_handle () || f_arg.is_inline_function ())
+        dassl_fcn = f_arg.function_value ();
+      else
         {
-          Cell c = f_arg.cell_value ();
-          if (c.length () == 1)
-            f_arg = c(0);
-          else if (c.length () == 2)
+          switch (f_arg.rows ())
             {
-              if (c(0).is_function_handle () || c(0).is_inline_function ())
-                dassl_fcn = c(0).function_value ();
-              else
+            case 1:
+              do
                 {
                   fcn_name = unique_symbol_name ("__dassl_fcn__");
                   fname = "function y = ";
                   fname.append (fcn_name);
                   fname.append (" (x, xdot, t) y = ");
-                  dassl_fcn = extract_function (c(0), "dassl", fcn_name, fname,
-                                                "; endfunction");
+                  dassl_fcn = extract_function (f_arg, "dassl", fcn_name,
+                                                fname, "; endfunction");
                 }
+              while (0);
+              break;
 
-              if (dassl_fcn)
-                {
-                  if (c(1).is_function_handle () || c(1).is_inline_function ())
-                    dassl_jac = c(1).function_value ();
-                  else
-                    {
-                      jac_name = unique_symbol_name ("__dassl_jac__");
-                      jname = "function jac = ";
-                      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 ())
-                            clear_function (fcn_name);
-                          dassl_fcn = 0;
-                        }
-                    }
-                }
-            }
-          else
-            DASSL_ABORT1 ("incorrect number of elements in cell array");
-        }
+            case 2:
+              {
+                string_vector tmp = f_arg.all_strings ();
 
-      if (!dassl_fcn && ! f_arg.is_cell ())
-        {
-          if (f_arg.is_function_handle () || f_arg.is_inline_function ())
-            dassl_fcn = f_arg.function_value ();
-          else
-            {
-              switch (f_arg.rows ())
-                {
-                case 1:
-                  do
-                    {
-                      fcn_name = unique_symbol_name ("__dassl_fcn__");
-                      fname = "function y = ";
-                      fname.append (fcn_name);
-                      fname.append (" (x, xdot, t) y = ");
-                      dassl_fcn = extract_function (f_arg, "dassl", fcn_name,
-                                                    fname, "; endfunction");
-                    }
-                  while (0);
-                  break;
-
-                case 2:
-                  {
-                    string_vector tmp = f_arg.all_strings ();
+                fcn_name = unique_symbol_name ("__dassl_fcn__");
+                fname = "function y = ";
+                fname.append (fcn_name);
+                fname.append (" (x, xdot, t) y = ");
+                dassl_fcn = extract_function (tmp(0), "dassl", fcn_name,
+                                              fname, "; endfunction");
 
-                    if (! error_state)
-                      {
-                        fcn_name = unique_symbol_name ("__dassl_fcn__");
-                        fname = "function y = ";
-                        fname.append (fcn_name);
-                        fname.append (" (x, xdot, t) y = ");
-                        dassl_fcn = extract_function (tmp(0), "dassl", fcn_name,
-                                                      fname, "; endfunction");
+                if (dassl_fcn)
+                  {
+                    jac_name = unique_symbol_name ("__dassl_jac__");
+                    jname = "function jac = ";
+                    jname.append (jac_name);
+                    jname.append (" (x, xdot, t, cj) jac = ");
+                    dassl_jac = extract_function (tmp(1), "dassl",
+                                                  jac_name, jname,
+                                                  "; endfunction");
 
-                        if (dassl_fcn)
-                          {
-                            jac_name = unique_symbol_name ("__dassl_jac__");
-                            jname = "function jac = ";
-                            jname.append (jac_name);
-                            jname.append (" (x, xdot, t, cj) jac = ");
-                            dassl_jac = extract_function (tmp(1), "dassl",
-                                                          jac_name, jname,
-                                                          "; endfunction");
-
-                            if (!dassl_jac)
-                              {
-                                if (fcn_name.length ())
-                                  clear_function (fcn_name);
-                                dassl_fcn = 0;
-                              }
-                          }
+                    if (!dassl_jac)
+                      {
+                        if (fcn_name.length ())
+                          clear_function (fcn_name);
+                        dassl_fcn = 0;
                       }
                   }
-                }
-            }
-        }
-
-      if (error_state || ! dassl_fcn)
-        DASSL_ABORT ();
-
-      ColumnVector state = ColumnVector (args(1).vector_value ());
-
-      if (error_state)
-        DASSL_ABORT1 ("expecting state vector as second argument");
-
-      ColumnVector deriv (args(2).vector_value ());
-
-      if (error_state)
-        DASSL_ABORT1 ("expecting derivative vector as third argument");
-
-      ColumnVector out_times (args(3).vector_value ());
-
-      if (error_state)
-        DASSL_ABORT1 ("expecting output time vector as fourth argument");
-
-      ColumnVector crit_times;
-      int crit_times_set = 0;
-      if (nargin > 4)
-        {
-          crit_times = ColumnVector (args(4).vector_value ());
-
-          if (error_state)
-            DASSL_ABORT1 ("expecting critical time vector as fifth argument");
-
-          crit_times_set = 1;
-        }
-
-      if (state.capacity () != deriv.capacity ())
-        DASSL_ABORT1 ("x and xdot must have the same size");
-
-      double tzero = out_times (0);
-
-      DAEFunc func (dassl_user_function);
-      if (dassl_jac)
-        func.set_jacobian_function (dassl_user_jacobian);
-
-      DASSL dae (state, deriv, tzero, func);
-
-      dae.set_options (dassl_opts);
-
-      Matrix output;
-      Matrix deriv_output;
-
-      if (crit_times_set)
-        output = dae.integrate (out_times, deriv_output, crit_times);
-      else
-        output = dae.integrate (out_times, deriv_output);
-
-      if (fcn_name.length ())
-        clear_function (fcn_name);
-      if (jac_name.length ())
-        clear_function (jac_name);
-
-      if (! error_state)
-        {
-          std::string msg = dae.error_message ();
-
-          retval(3) = msg;
-          retval(2) = static_cast<double> (dae.integration_state ());
-
-          if (dae.integration_ok ())
-            {
-              retval(1) = deriv_output;
-              retval(0) = output;
-            }
-          else
-            {
-              retval(1) = Matrix ();
-              retval(0) = Matrix ();
-
-              if (nargout < 3)
-                error ("dassl: %s", msg.c_str ());
+              }
             }
         }
     }
+
+  if (! dassl_fcn)
+    DASSL_ABORT ();
+
+  ColumnVector state = args(1).xvector_value ("dassl: initial state X_0 must be a vector");
+
+  ColumnVector deriv = args(2).xvector_value ("dassl: initial derivatives XDOT_0 must be a vector");
+
+  ColumnVector out_times = args(3).xvector_value ("dassl: output time variable T must be a vector");
+
+  ColumnVector crit_times;
+  int crit_times_set = 0;
+  if (nargin > 4)
+    {
+      crit_times = args(4).xvector_value ("dassl: list of critical times T_CRIT must be a vector");
+
+      crit_times_set = 1;
+    }
+
+  if (state.numel () != deriv.numel ())
+    DASSL_ABORT1 ("X and XDOT_0 must have the same size");
+
+  double tzero = out_times (0);
+
+  DAEFunc func (dassl_user_function);
+  if (dassl_jac)
+    func.set_jacobian_function (dassl_user_jacobian);
+
+  DASSL dae (state, deriv, tzero, func);
+
+  dae.set_options (dassl_opts);
+
+  Matrix output;
+  Matrix deriv_output;
+
+  if (crit_times_set)
+    output = dae.integrate (out_times, deriv_output, crit_times);
   else
-    print_usage ();
+    output = dae.integrate (out_times, deriv_output);
+
+  if (fcn_name.length ())
+    clear_function (fcn_name);
+  if (jac_name.length ())
+    clear_function (jac_name);
+
+  std::string msg = dae.error_message ();
+
+  retval(3) = msg;
+  retval(2) = static_cast<double> (dae.integration_state ());
+
+  if (dae.integration_ok ())
+    {
+      retval(1) = deriv_output;
+      retval(0) = output;
+    }
+  else
+    {
+      retval(1) = Matrix ();
+      retval(0) = Matrix ();
+
+      if (nargout < 3)
+        error ("dassl: %s", msg.c_str ());
+    }
 
   return retval;
 }
--- a/libinterp/corefcn/data.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/data.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -82,28 +82,27 @@
 #define HAVE_HYPOTF 1
 #endif
 
+static void
+index_error (const char *fmt, const std::string& idx, const std::string& msg)
+{
+  error (fmt, idx.c_str (), msg.c_str ());
+}
+
 #define ANY_ALL(FCN) \
  \
   octave_value retval; \
  \
   int nargin = args.length (); \
  \
-  if (nargin == 1 || nargin == 2) \
-    { \
-      int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
+  if (nargin < 1 || nargin > 2) \
+    print_usage (); \
+ \
+  int dim = (nargin == 1 ? -1 : args(1).int_value (#FCN ": DIM must be an integer") - 1); \
  \
-      if (! error_state) \
-        { \
-          if (dim >= -1) \
-            retval = args(0).FCN (dim); \
-          else \
-            error (#FCN ": invalid dimension argument = %d", dim + 1); \
-        } \
-      else \
-        error (#FCN ": expecting dimension argument to be an integer"); \
-    } \
+  if (dim >= -1) \
+    retval = args(0).FCN (dim); \
   else \
-    print_usage (); \
+    error (#FCN ": invalid dimension argument = %d", dim + 1); \
  \
   return retval
 
@@ -222,47 +221,43 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 2)
+  if (args.length () != 2)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    gripe_wrong_type_arg ("atan2", args(0));
+  else if (! args(1).is_numeric_type ())
+    gripe_wrong_type_arg ("atan2", args(1));
+  else if (args(0).is_complex_type () || args(1).is_complex_type ())
+    error ("atan2: not defined for complex numbers");
+  else if (args(0).is_single_type () || args(1).is_single_type ())
     {
-      if (! args(0).is_numeric_type ())
-        gripe_wrong_type_arg ("atan2", args(0));
-      else if (! args(1).is_numeric_type ())
-        gripe_wrong_type_arg ("atan2", args(1));
-      else if (args(0).is_complex_type () || args(1).is_complex_type ())
-        error ("atan2: not defined for complex numbers");
-      else if (args(0).is_single_type () || args(1).is_single_type ())
+      if (args(0).is_scalar_type () && args(1).is_scalar_type ())
+        retval = atan2f (args(0).float_value (), args(1).float_value ());
+      else
         {
-          if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-            retval = atan2f (args(0).float_value (), args(1).float_value ());
-          else
-            {
-              FloatNDArray a0 = args(0).float_array_value ();
-              FloatNDArray a1 = args(1).float_array_value ();
-              retval = binmap<float> (a0, a1, ::atan2f, "atan2");
-            }
+          FloatNDArray a0 = args(0).float_array_value ();
+          FloatNDArray a1 = args(1).float_array_value ();
+          retval = binmap<float> (a0, a1, ::atan2f, "atan2");
+        }
+    }
+  else
+    {
+      if (args(0).is_scalar_type () && args(1).is_scalar_type ())
+        retval = atan2 (args(0).scalar_value (), args(1).scalar_value ());
+      else if (args(0).is_sparse_type ())
+        {
+          SparseMatrix m0 = args(0).sparse_matrix_value ();
+          SparseMatrix m1 = args(1).sparse_matrix_value ();
+          retval = binmap<double> (m0, m1, ::atan2, "atan2");
         }
       else
         {
-          if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-            retval = atan2 (args(0).scalar_value (), args(1).scalar_value ());
-          else if (args(0).is_sparse_type ())
-            {
-              SparseMatrix m0 = args(0).sparse_matrix_value ();
-              SparseMatrix m1 = args(1).sparse_matrix_value ();
-              retval = binmap<double> (m0, m1, ::atan2, "atan2");
-            }
-          else
-            {
-              NDArray a0 = args(0).array_value ();
-              NDArray a1 = args(1).array_value ();
-              retval = binmap<double> (a0, a1, ::atan2, "atan2");
-            }
+          NDArray a0 = args(0).array_value ();
+          NDArray a1 = args(1).array_value ();
+          retval = binmap<double> (a0, a1, ::atan2, "atan2");
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -406,18 +401,18 @@
 
   int nargin = args.length ();
 
+  if (nargin < 2)
+    print_usage ();
+
   if (nargin == 2)
-    {
-      retval = do_hypot (args(0), args(1));
-    }
-  else if (nargin >= 3)
+    retval = do_hypot (args(0), args(1));
+  else
     {
       retval = args(0);
-      for (int i = 1; i < nargin && ! error_state; i++)
+
+      for (int i = 1; i < nargin; i++)
         retval = do_hypot (retval, args(i));
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -501,58 +496,56 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 1)
+  if (args.length () != 1)
+    print_usage ();
+
+  if (nargout < 2)
+    retval(0) = args(0).log2 ();
+  else if (args(0).is_single_type ())
     {
-      if (nargout < 2)
-        retval(0) = args(0).log2 ();
-      else if (args(0).is_single_type ())
+      if (args(0).is_real_type ())
         {
-          if (args(0).is_real_type ())
-            {
-              FloatNDArray f;
-              FloatNDArray x = args(0).float_array_value ();
-              // FIXME: should E be an int value?
-              FloatMatrix e;
-              map_2_xlog2 (x, f, e);
-              retval(1) = e;
-              retval(0) = f;
-            }
-          else if (args(0).is_complex_type ())
-            {
-              FloatComplexNDArray f;
-              FloatComplexNDArray x = args(0).float_complex_array_value ();
-              // FIXME: should E be an int value?
-              FloatNDArray e;
-              map_2_xlog2 (x, f, e);
-              retval(1) = e;
-              retval(0) = f;
-            }
-        }
-      else if (args(0).is_real_type ())
-        {
-          NDArray f;
-          NDArray x = args(0).array_value ();
+          FloatNDArray f;
+          FloatNDArray x = args(0).float_array_value ();
           // FIXME: should E be an int value?
-          Matrix e;
+          FloatMatrix e;
           map_2_xlog2 (x, f, e);
           retval(1) = e;
           retval(0) = f;
         }
       else if (args(0).is_complex_type ())
         {
-          ComplexNDArray f;
-          ComplexNDArray x = args(0).complex_array_value ();
+          FloatComplexNDArray f;
+          FloatComplexNDArray x = args(0).float_complex_array_value ();
           // FIXME: should E be an int value?
-          NDArray e;
+          FloatNDArray e;
           map_2_xlog2 (x, f, e);
           retval(1) = e;
           retval(0) = f;
         }
-      else
-        gripe_wrong_type_arg ("log2", args(0));
+    }
+  else if (args(0).is_real_type ())
+    {
+      NDArray f;
+      NDArray x = args(0).array_value ();
+      // FIXME: should E be an int value?
+      Matrix e;
+      map_2_xlog2 (x, f, e);
+      retval(1) = e;
+      retval(0) = f;
+    }
+  else if (args(0).is_complex_type ())
+    {
+      ComplexNDArray f;
+      ComplexNDArray x = args(0).complex_array_value ();
+      // FIXME: should E be an int value?
+      NDArray e;
+      map_2_xlog2 (x, f, e);
+      retval(1) = e;
+      retval(0) = f;
     }
   else
-    print_usage ();
+    gripe_wrong_type_arg ("log2", args(0));
 
   return retval;
 }
@@ -590,92 +583,110 @@
 @end example\n\
 \n\
 An error message is printed if the dimensions of the arguments do not agree,\n\
-or if either of the arguments is complex.\n\
+or if either argument is complex.\n\
+\n\
+Programming Notes: Floating point numbers within a few eps of an integer will\n\
+be rounded to an integer before computation for compatibility with\n\
+@sc{matlab}.\n\
+\n\
+By convention,\n\
+\n\
+@example\n\
+@group\n\
+rem (@var{x}, 0) = NaN  if @var{x} is a floating point variable\n\
+rem (@var{x}, 0) = 0    if @var{x} is an integer variable\n\
+rem (@var{x}, @var{y})        returns a value with the signbit from @var{x}\n\
+@end group\n\
+@end example\n\
+\n\
+For the opposite conventions see the @code{mod} function.  In general,\n\
+@code{rem} is best when computing the remainder after division of two\n\
+@emph{positive} numbers.  For negative numbers, or when the values are\n\
+periodic, @code{mod} is a better choice.\n\
 @seealso{mod}\n\
 @end deftypefn")
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 2)
+  if (args.length () != 2)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    gripe_wrong_type_arg ("rem", args(0));
+  else if (! args(1).is_numeric_type ())
+    gripe_wrong_type_arg ("rem", args(1));
+  else if (args(0).is_complex_type () || args(1).is_complex_type ())
+    error ("rem: not defined for complex numbers");
+  else if (args(0).is_integer_type () || args(1).is_integer_type ())
     {
-      if (! args(0).is_numeric_type ())
-        gripe_wrong_type_arg ("rem", args(0));
-      else if (! args(1).is_numeric_type ())
-        gripe_wrong_type_arg ("rem", args(1));
-      else if (args(0).is_complex_type () || args(1).is_complex_type ())
-        error ("rem: not defined for complex numbers");
-      else if (args(0).is_integer_type () || args(1).is_integer_type ())
+      builtin_type_t btyp0 = args(0).builtin_type ();
+      builtin_type_t btyp1 = args(1).builtin_type ();
+      if (btyp0 == btyp_double || btyp0 == btyp_float)
+        btyp0 = btyp1;
+      if (btyp1 == btyp_double || btyp1 == btyp_float)
+        btyp1 = btyp0;
+
+      if (btyp0 == btyp1)
         {
-          builtin_type_t btyp0 = args(0).builtin_type ();
-          builtin_type_t btyp1 = args(1).builtin_type ();
-          if (btyp0 == btyp_double || btyp0 == btyp_float)
-            btyp0 = btyp1;
-          if (btyp1 == btyp_double || btyp1 == btyp_float)
-            btyp1 = btyp0;
-
-          if (btyp0 == btyp1)
+          switch (btyp0)
             {
-              switch (btyp0)
-                {
 #define MAKE_INT_BRANCH(X) \
-                case btyp_ ## X: \
-                    { \
-                    X##NDArray a0 = args(0).X##_array_value (); \
-                    X##NDArray a1 = args(1).X##_array_value (); \
-                    retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, rem, "rem"); \
-                    } \
-                  break;
-                MAKE_INT_BRANCH (int8);
-                MAKE_INT_BRANCH (int16);
-                MAKE_INT_BRANCH (int32);
-                MAKE_INT_BRANCH (int64);
-                MAKE_INT_BRANCH (uint8);
-                MAKE_INT_BRANCH (uint16);
-                MAKE_INT_BRANCH (uint32);
-                MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    { \
+      X##NDArray a0 = args(0).X##_array_value (); \
+      X##NDArray a1 = args(1).X##_array_value (); \
+      retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, rem, "rem"); \
+    } \
+    break;
+
+              MAKE_INT_BRANCH (int8);
+              MAKE_INT_BRANCH (int16);
+              MAKE_INT_BRANCH (int32);
+              MAKE_INT_BRANCH (int64);
+              MAKE_INT_BRANCH (uint8);
+              MAKE_INT_BRANCH (uint16);
+              MAKE_INT_BRANCH (uint32);
+              MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
-                default:
-                  panic_impossible ();
-                }
-            }
-          else
-            error ("rem: cannot combine %s and %d",
-                   args(0).class_name ().c_str (),
-                   args(1).class_name ().c_str ());
-        }
-      else if (args(0).is_single_type () || args(1).is_single_type ())
-        {
-          if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-            retval = xrem (args(0).float_value (), args(1).float_value ());
-          else
-            {
-              FloatNDArray a0 = args(0).float_array_value ();
-              FloatNDArray a1 = args(1).float_array_value ();
-              retval = binmap<float> (a0, a1, xrem<float>, "rem");
+
+            default:
+              panic_impossible ();
             }
         }
       else
+        error ("rem: cannot combine %s and %d",
+               args(0).class_name ().c_str (),
+               args(1).class_name ().c_str ());
+    }
+  else if (args(0).is_single_type () || args(1).is_single_type ())
+    {
+      if (args(0).is_scalar_type () && args(1).is_scalar_type ())
+        retval = xrem (args(0).float_value (), args(1).float_value ());
+      else
         {
-          if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-            retval = xrem (args(0).scalar_value (), args(1).scalar_value ());
-          else if (args(0).is_sparse_type () || args(1).is_sparse_type ())
-            {
-              SparseMatrix m0 = args(0).sparse_matrix_value ();
-              SparseMatrix m1 = args(1).sparse_matrix_value ();
-              retval = binmap<double> (m0, m1, xrem<double>, "rem");
-            }
-          else
-            {
-              NDArray a0 = args(0).array_value ();
-              NDArray a1 = args(1).array_value ();
-              retval = binmap<double> (a0, a1, xrem<double>, "rem");
-            }
+          FloatNDArray a0 = args(0).float_array_value ();
+          FloatNDArray a1 = args(1).float_array_value ();
+          retval = binmap<float> (a0, a1, xrem<float>, "rem");
         }
     }
   else
-    print_usage ();
+    {
+      if (args(0).is_scalar_type () && args(1).is_scalar_type ())
+        retval = xrem (args(0).scalar_value (), args(1).scalar_value ());
+      else if (args(0).is_sparse_type () || args(1).is_sparse_type ())
+        {
+          SparseMatrix m0 = args(0).sparse_matrix_value ();
+          SparseMatrix m1 = args(1).sparse_matrix_value ();
+          retval = binmap<double> (m0, m1, xrem<double>, "rem");
+        }
+      else
+        {
+          NDArray a0 = args(0).array_value ();
+          NDArray a1 = args(1).array_value ();
+          retval = binmap<double> (a0, a1, xrem<double>, "rem");
+        }
+    }
 
   return retval;
 }
@@ -689,20 +700,22 @@
 
 %!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 ([0, 1, 2], [0, 0, 1]), [NaN, NaN, 0]);
 %!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]))
+%!assert (rem (uint8 ([0, 1, 2]), [0, 0, 1]), uint8 ([0, 0, 0]));
 
 ## Test sparse implementations
 %!shared xs
 %! xs = sparse (0:3);
 %!test
 %! y = rem (11, xs);
-%! assert (nnz (y), 3);
+%! assert (isnan (y(1)));
 %! assert (y, sparse (rem (11, 0:3)));
 %!test
 %! y = rem (0, xs);
-%! assert (nnz (y), 0);
-%! assert (y, sparse (zeros (1,4)));
+%! assert (nnz (y), 1);
+%! assert (y, sparse ([NaN 0 0 0]));
 %!test
 %! y = rem (xs, 2);
 %! assert (nnz (y), 2);
@@ -717,8 +730,15 @@
 %! assert (y, sparse (rem (11, 0:3)));
 %!test
 %! y = rem (sparse ([0 0 0 0]), xs);
-%! assert (nnz (y), 0);
-%! assert (y, sparse (zeros (1,4)));
+%! assert (nnz (y), 1);
+%! assert (y, sparse ([NaN 0 0 0]));
+
+## Bug #45587
+%!assert (signbit (rem (-0, 1)))
+%!assert (! signbit (rem (0, 1)))
+
+## bug #42627
+%!assert (rem (0.94, 0.01), 0.0)
 
 %!error rem (uint (8), int8 (5))
 %!error rem (uint8 ([1, 2]), uint8 ([3, 4, 5]))
@@ -726,9 +746,6 @@
 %!error rem (1, 2, 3)
 %!error rem ([1, 2], [3, 4, 5])
 %!error rem (i, 1)
-
-# bug 42627
-%!assert (rem (0.94, 0.01), 0.0);
 */
 
 DEFUN (mod, args, ,
@@ -745,96 +762,111 @@
 @noindent\n\
 and is written such that the correct modulus is returned for integer types.\n\
 This function handles negative values correctly.  That is,\n\
-@code{mod (-1, 3)} is 2, not -1, as @code{rem (-1, 3)} returns.\n\
-@code{mod (@var{x}, 0)} returns @var{x}.\n\
+@w{@code{mod (-1, 3)}} is 2, not -1, as @w{@code{rem (-1, 3)}} returns.\n\
 \n\
 An error results if the dimensions of the arguments do not agree, or if\n\
 either of the arguments is complex.\n\
+\n\
+Programming Notes: Floating point numbers within a few eps of an integer will\n\
+be rounded to an integer before computation for compatibility with\n\
+@sc{matlab}.\n\
+\n\
+By convention,\n\
+\n\
+@example\n\
+@group\n\
+mod (@var{x}, 0) = @var{x}\n\
+mod (@var{x}, @var{y})      returns a value with the signbit from @var{y}\n\
+@end group\n\
+@end example\n\
+\n\
+For the opposite conventions see the @code{rem} function.  In general,\n\
+@code{mod} is a better choice than @code{rem} when any of the inputs are\n\
+negative numbers or when the values are periodic.\n\
 @seealso{rem}\n\
 @end deftypefn")
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 2)
+  if (args.length () != 2)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    gripe_wrong_type_arg ("mod", args(0));
+  else if (! args(1).is_numeric_type ())
+    gripe_wrong_type_arg ("mod", args(1));
+  else if (args(0).is_complex_type () || args(1).is_complex_type ())
+    error ("mod: not defined for complex numbers");
+  else if (args(0).is_integer_type () || args(1).is_integer_type ())
     {
-      if (! args(0).is_numeric_type ())
-        gripe_wrong_type_arg ("mod", args(0));
-      else if (! args(1).is_numeric_type ())
-        gripe_wrong_type_arg ("mod", args(1));
-      else if (args(0).is_complex_type () || args(1).is_complex_type ())
-        error ("mod: not defined for complex numbers");
-      else if (args(0).is_integer_type () || args(1).is_integer_type ())
+      builtin_type_t btyp0 = args(0).builtin_type ();
+      builtin_type_t btyp1 = args(1).builtin_type ();
+      if (btyp0 == btyp_double || btyp0 == btyp_float)
+        btyp0 = btyp1;
+      if (btyp1 == btyp_double || btyp1 == btyp_float)
+        btyp1 = btyp0;
+
+      if (btyp0 == btyp1)
         {
-          builtin_type_t btyp0 = args(0).builtin_type ();
-          builtin_type_t btyp1 = args(1).builtin_type ();
-          if (btyp0 == btyp_double || btyp0 == btyp_float)
-            btyp0 = btyp1;
-          if (btyp1 == btyp_double || btyp1 == btyp_float)
-            btyp1 = btyp0;
-
-          if (btyp0 == btyp1)
+          switch (btyp0)
             {
-              switch (btyp0)
-                {
 #define MAKE_INT_BRANCH(X) \
-                case btyp_ ## X: \
-                    { \
-                    X##NDArray a0 = args(0).X##_array_value (); \
-                    X##NDArray a1 = args(1).X##_array_value (); \
-                    retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, mod, "mod"); \
-                    } \
-                  break;
-                MAKE_INT_BRANCH (int8);
-                MAKE_INT_BRANCH (int16);
-                MAKE_INT_BRANCH (int32);
-                MAKE_INT_BRANCH (int64);
-                MAKE_INT_BRANCH (uint8);
-                MAKE_INT_BRANCH (uint16);
-                MAKE_INT_BRANCH (uint32);
-                MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    { \
+      X##NDArray a0 = args(0).X##_array_value (); \
+      X##NDArray a1 = args(1).X##_array_value (); \
+      retval = binmap<octave_##X,octave_##X,octave_##X> (a0, a1, mod, "mod"); \
+    } \
+    break;
+
+              MAKE_INT_BRANCH (int8);
+              MAKE_INT_BRANCH (int16);
+              MAKE_INT_BRANCH (int32);
+              MAKE_INT_BRANCH (int64);
+              MAKE_INT_BRANCH (uint8);
+              MAKE_INT_BRANCH (uint16);
+              MAKE_INT_BRANCH (uint32);
+              MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
-                default:
-                  panic_impossible ();
-                }
-            }
-          else
-            error ("mod: cannot combine %s and %d",
-                   args(0).class_name ().c_str (),
-                   args(1).class_name ().c_str ());
-        }
-      else if (args(0).is_single_type () || args(1).is_single_type ())
-        {
-          if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-            retval = xmod (args(0).float_value (), args(1).float_value ());
-          else
-            {
-              FloatNDArray a0 = args(0).float_array_value ();
-              FloatNDArray a1 = args(1).float_array_value ();
-              retval = binmap<float> (a0, a1, xmod<float>, "mod");
+
+            default:
+              panic_impossible ();
             }
         }
       else
+        error ("mod: cannot combine %s and %d",
+               args(0).class_name ().c_str (),
+               args(1).class_name ().c_str ());
+    }
+  else if (args(0).is_single_type () || args(1).is_single_type ())
+    {
+      if (args(0).is_scalar_type () && args(1).is_scalar_type ())
+        retval = xmod (args(0).float_value (), args(1).float_value ());
+      else
         {
-          if (args(0).is_scalar_type () && args(1).is_scalar_type ())
-            retval = xmod (args(0).scalar_value (), args(1).scalar_value ());
-          else if (args(0).is_sparse_type () || args(1).is_sparse_type ())
-            {
-              SparseMatrix m0 = args(0).sparse_matrix_value ();
-              SparseMatrix m1 = args(1).sparse_matrix_value ();
-              retval = binmap<double> (m0, m1, xmod<double>, "mod");
-            }
-          else
-            {
-              NDArray a0 = args(0).array_value ();
-              NDArray a1 = args(1).array_value ();
-              retval = binmap<double> (a0, a1, xmod<double>, "mod");
-            }
+          FloatNDArray a0 = args(0).float_array_value ();
+          FloatNDArray a1 = args(1).float_array_value ();
+          retval = binmap<float> (a0, a1, xmod<float>, "mod");
         }
     }
   else
-    print_usage ();
+    {
+      if (args(0).is_scalar_type () && args(1).is_scalar_type ())
+        retval = xmod (args(0).scalar_value (), args(1).scalar_value ());
+      else if (args(0).is_sparse_type () || args(1).is_sparse_type ())
+        {
+          SparseMatrix m0 = args(0).sparse_matrix_value ();
+          SparseMatrix m1 = args(1).sparse_matrix_value ();
+          retval = binmap<double> (m0, m1, xmod<double>, "mod");
+        }
+      else
+        {
+          NDArray a0 = args(0).array_value ();
+          NDArray a1 = args(1).array_value ();
+          retval = binmap<double> (a0, a1, xmod<double>, "mod");
+        }
+    }
 
   return retval;
 }
@@ -881,8 +913,12 @@
 %!assert (mod (2.1, 0.1), 0)
 %!assert (mod (2.1, 0.2), 0.1, eps)
 
-# bug 42627
-%!assert (mod (0.94, 0.01), 0.0);
+## Bug #45587
+%!assert (signbit (mod (-0, 0)))
+%!assert (! signbit (mod (0, -0)))
+
+## Bug #42627
+%!assert (mod (0.94, 0.01), 0.0)
 */
 
 // FIXME: Need to convert reduction functions of this file for single precision
@@ -891,11 +927,8 @@
   (arg.is_ ## TYPE ## _type ()) \
     { \
       TYPE ## NDArray tmp = arg. TYPE ##_array_value (); \
-      \
-      if (! error_state) \
-        { \
-          retval = tmp.FCN (DIM); \
-        } \
+ \
+      retval = tmp.FCN (DIM); \
     }
 
 #define NATIVE_REDUCTION(FCN, BOOL_FCN) \
@@ -906,11 +939,11 @@
  \
   bool isnative = false; \
   bool isdouble = false; \
-  \
+ \
   if (nargin > 1 && args(nargin - 1).is_string ()) \
     { \
       std::string str = args(nargin - 1).string_value (); \
-      \
+ \
       if (str == "native") \
         isnative = true; \
       else if (str == "double") \
@@ -919,147 +952,131 @@
         error ("sum: unrecognized string argument"); \
       nargin --; \
     } \
-  \
-  if (nargin == 1 || nargin == 2) \
+ \
+  if (nargin < 1 || nargin > 2) \
+    print_usage (); \
+ \
+  octave_value arg = args(0); \
+ \
+  int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
+ \
+  if (dim >= -1) \
     { \
-      octave_value arg = args(0); \
+      if (arg.is_sparse_type ()) \
+        { \
+          if (arg.is_real_type ()) \
+            { \
+              SparseMatrix tmp = arg.sparse_matrix_value (); \
  \
-      int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
+              retval = tmp.FCN (dim); \
+            } \
+          else \
+            { \
+              SparseComplexMatrix tmp \
+                = arg.sparse_complex_matrix_value (); \
  \
-      if (! error_state) \
+              retval = tmp.FCN (dim); \
+            } \
+        } \
+      else \
         { \
-          if (dim >= -1) \
+          if (isnative) \
             { \
-              if (arg.is_sparse_type ()) \
+              if NATIVE_REDUCTION_1 (FCN, uint8, dim) \
+              else if NATIVE_REDUCTION_1 (FCN, uint16, dim) \
+              else if NATIVE_REDUCTION_1 (FCN, uint32, dim) \
+              else if NATIVE_REDUCTION_1 (FCN, uint64, dim) \
+              else if NATIVE_REDUCTION_1 (FCN, int8, dim) \
+              else if NATIVE_REDUCTION_1 (FCN, int16, dim) \
+              else if NATIVE_REDUCTION_1 (FCN, int32, dim) \
+              else if NATIVE_REDUCTION_1 (FCN, int64, dim) \
+              else if (arg.is_bool_type ()) \
                 { \
-                  if (arg.is_real_type ()) \
+                  boolNDArray tmp = arg.bool_array_value (); \
+ \
+                  retval = boolNDArray (tmp.BOOL_FCN (dim)); \
+                } \
+              else if (arg.is_char_matrix ()) \
+                { \
+                  error (#FCN, ": invalid char type"); \
+                } \
+              else if (!isdouble && arg.is_single_type ()) \
+                { \
+                  if (arg.is_complex_type ()) \
                     { \
-                      SparseMatrix tmp = arg.sparse_matrix_value (); \
-                      \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
+                      FloatComplexNDArray tmp = \
+                        arg.float_complex_array_value (); \
+ \
+                      retval = tmp.FCN (dim); \
                     } \
-                  else \
+                  else if (arg.is_real_type ()) \
                     { \
-                      SparseComplexMatrix tmp \
-                        = arg.sparse_complex_matrix_value (); \
-                      \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
+                      FloatNDArray tmp = arg.float_array_value (); \
+ \
+                      retval = tmp.FCN (dim); \
                     } \
                 } \
+              else if (arg.is_complex_type ()) \
+                { \
+                  ComplexNDArray tmp = arg.complex_array_value (); \
+ \
+                  retval = tmp.FCN (dim); \
+                } \
+              else if (arg.is_real_type ()) \
+                { \
+                  NDArray tmp = arg.array_value (); \
+ \
+                  retval = tmp.FCN (dim); \
+                } \
               else \
                 { \
-                  if (isnative) \
-                    { \
-                      if NATIVE_REDUCTION_1 (FCN, uint8, dim) \
-                      else if NATIVE_REDUCTION_1 (FCN, uint16, dim) \
-                      else if NATIVE_REDUCTION_1 (FCN, uint32, dim) \
-                      else if NATIVE_REDUCTION_1 (FCN, uint64, dim) \
-                      else if NATIVE_REDUCTION_1 (FCN, int8, dim) \
-                      else if NATIVE_REDUCTION_1 (FCN, int16, dim) \
-                      else if NATIVE_REDUCTION_1 (FCN, int32, dim) \
-                      else if NATIVE_REDUCTION_1 (FCN, int64, dim) \
-                      else if (arg.is_bool_type ()) \
-                        { \
-                          boolNDArray tmp = arg.bool_array_value (); \
-                          if (! error_state) \
-                            retval = boolNDArray (tmp.BOOL_FCN (dim)); \
-                        } \
-                      else if (arg.is_char_matrix ()) \
-                        { \
-                          error (#FCN, ": invalid char type"); \
-                        } \
-                      else if (!isdouble && arg.is_single_type ()) \
-                        { \
-                          if (arg.is_complex_type ()) \
-                            { \
-                              FloatComplexNDArray tmp = \
-                                arg.float_complex_array_value (); \
-                              \
-                              if (! error_state) \
-                                retval = tmp.FCN (dim); \
-                            } \
-                          else if (arg.is_real_type ()) \
-                            { \
-                              FloatNDArray tmp = arg.float_array_value (); \
-                              \
-                              if (! error_state) \
-                                retval = tmp.FCN (dim); \
-                            } \
-                        } \
-                      else if (arg.is_complex_type ()) \
-                        { \
-                          ComplexNDArray tmp = arg.complex_array_value (); \
-                          \
-                          if (! error_state) \
-                            retval = tmp.FCN (dim); \
-                        } \
-                      else if (arg.is_real_type ()) \
-                        { \
-                          NDArray tmp = arg.array_value (); \
-                          \
-                          if (! error_state) \
-                            retval = tmp.FCN (dim); \
-                        } \
-                      else \
-                        { \
-                          gripe_wrong_type_arg (#FCN, arg); \
-                          return retval; \
-                        } \
-                    } \
-                  else if (arg.is_bool_type ()) \
-                    { \
-                      boolNDArray tmp = arg.bool_array_value (); \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
-                  else if (!isdouble && arg.is_single_type ()) \
-                    { \
-                      if (arg.is_real_type ()) \
-                        { \
-                          FloatNDArray tmp = arg.float_array_value (); \
-                          \
-                          if (! error_state) \
-                            retval = tmp.FCN (dim); \
-                        } \
-                      else if (arg.is_complex_type ()) \
-                        { \
-                          FloatComplexNDArray tmp = \
-                            arg.float_complex_array_value (); \
-                          \
-                          if (! error_state) \
-                            retval = tmp.FCN (dim); \
-                        } \
-                    } \
-                  else if (arg.is_real_type ()) \
-                    { \
-                      NDArray tmp = arg.array_value (); \
-                      \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
-                  else if (arg.is_complex_type ()) \
-                    { \
-                      ComplexNDArray tmp = arg.complex_array_value (); \
-                      \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
-                  else \
-                    { \
-                      gripe_wrong_type_arg (#FCN, arg); \
-                      return retval; \
-                    } \
+                  gripe_wrong_type_arg (#FCN, arg); \
+                  return retval; \
                 } \
             } \
+          else if (arg.is_bool_type ()) \
+            { \
+              boolNDArray tmp = arg.bool_array_value (); \
+ \
+              retval = tmp.FCN (dim); \
+            } \
+          else if (!isdouble && arg.is_single_type ()) \
+            { \
+              if (arg.is_real_type ()) \
+                { \
+                  FloatNDArray tmp = arg.float_array_value (); \
+ \
+                  retval = tmp.FCN (dim); \
+                } \
+              else if (arg.is_complex_type ()) \
+                { \
+                  FloatComplexNDArray tmp = \
+                    arg.float_complex_array_value (); \
+ \
+                  retval = tmp.FCN (dim); \
+                } \
+            } \
+          else if (arg.is_real_type ()) \
+            { \
+              NDArray tmp = arg.array_value (); \
+ \
+              retval = tmp.FCN (dim); \
+            } \
+          else if (arg.is_complex_type ()) \
+            { \
+              ComplexNDArray tmp = arg.complex_array_value (); \
+ \
+              retval = tmp.FCN (dim); \
+            } \
           else \
-            error (#FCN ": invalid dimension argument = %d", dim + 1); \
+            { \
+              gripe_wrong_type_arg (#FCN, arg); \
+              return retval; \
+            } \
         } \
-      \
+      else \
+        error (#FCN ": invalid dimension argument = %d", dim + 1); \
     } \
-  else \
-    print_usage (); \
  \
   return retval
 
@@ -1069,77 +1086,66 @@
  \
   int nargin = args.length (); \
  \
-  if (nargin == 1 || nargin == 2) \
-    { \
-      octave_value arg = args(0); \
- \
-      int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
+  if (nargin < 1 || nargin > 2) \
+    print_usage (); \
  \
-      if (! error_state) \
-        { \
-          if (dim >= -1) \
-            { \
-              if (arg.is_real_type ()) \
-                { \
-                  if (arg.is_sparse_type ()) \
-                    { \
-                      SparseMatrix tmp = arg.sparse_matrix_value (); \
+  octave_value arg = args(0); \
  \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
-                  else if (arg.is_single_type ()) \
-                    { \
-                      FloatNDArray tmp = arg.float_array_value (); \
- \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
-                  else \
-                    { \
-                      NDArray tmp = arg.array_value (); \
+  int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
  \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
-                } \
-              else if (arg.is_complex_type ()) \
-                { \
-                  if (arg.is_sparse_type ()) \
-                    { \
-                      SparseComplexMatrix tmp = arg.sparse_complex_matrix_value (); \
+  if (dim >= -1) \
+    { \
+      if (arg.is_real_type ()) \
+        { \
+          if (arg.is_sparse_type ()) \
+            { \
+              SparseMatrix tmp = arg.sparse_matrix_value (); \
  \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
-                  else if (arg.is_single_type ()) \
-                    { \
-                      FloatComplexNDArray tmp \
-                        = arg.float_complex_array_value (); \
+              retval = tmp.FCN (dim); \
+            } \
+          else if (arg.is_single_type ()) \
+            { \
+              FloatNDArray tmp = arg.float_array_value (); \
  \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
-                  else \
-                    { \
-                      ComplexNDArray tmp = arg.complex_array_value (); \
- \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
-                } \
-              else \
-                { \
-                  gripe_wrong_type_arg (#FCN, arg); \
-                  return retval; \
-                } \
+              retval = tmp.FCN (dim); \
             } \
           else \
-            error (#FCN ": invalid dimension argument = %d", dim + 1); \
+            { \
+              NDArray tmp = arg.array_value (); \
+ \
+              retval = tmp.FCN (dim); \
+            } \
+        } \
+      else if (arg.is_complex_type ()) \
+        { \
+          if (arg.is_sparse_type ()) \
+            { \
+              SparseComplexMatrix tmp = arg.sparse_complex_matrix_value (); \
+ \
+              retval = tmp.FCN (dim); \
+            } \
+          else if (arg.is_single_type ()) \
+            { \
+              FloatComplexNDArray tmp \
+                = arg.float_complex_array_value (); \
+ \
+              retval = tmp.FCN (dim); \
+            } \
+          else \
+            { \
+              ComplexNDArray tmp = arg.complex_array_value (); \
+ \
+              retval = tmp.FCN (dim); \
+            } \
+        } \
+      else \
+        { \
+          gripe_wrong_type_arg (#FCN, arg); \
+          return retval; \
         } \
     } \
   else \
-    print_usage (); \
+    error (#FCN ": invalid dimension argument = %d", dim + 1); \
  \
   return retval
 
@@ -1212,93 +1218,87 @@
       nargin --;
     }
 
-  if (error_state)
-    return retval;
-
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  octave_value arg = args(0);
+
+  int dim = -1;
+  if (nargin == 2)
+    {
+      dim = args(1).int_value () - 1;
+      if (dim < 0)
+        error ("cumsum: invalid dimension argument = %d", dim + 1);
+    }
+
+  switch (arg.builtin_type ())
     {
-      octave_value arg = args(0);
-
-      int dim = -1;
-      if (nargin == 2)
-        {
-          dim = args(1).int_value () - 1;
-          if (dim < 0)
-            error ("cumsum: invalid dimension argument = %d", dim + 1);
-        }
-
-      if (! error_state)
-        {
-          switch (arg.builtin_type ())
-            {
-            case btyp_double:
-              if (arg.is_sparse_type ())
-                retval = arg.sparse_matrix_value ().cumsum (dim);
-              else
-                retval = arg.array_value ().cumsum (dim);
-              break;
-            case btyp_complex:
-              if (arg.is_sparse_type ())
-                retval = arg.sparse_complex_matrix_value ().cumsum (dim);
-              else
-                retval = arg.complex_array_value ().cumsum (dim);
-              break;
-            case btyp_float:
-              if (isdouble)
-                retval = arg.array_value ().cumsum (dim);
-              else
-                retval = arg.float_array_value ().cumsum (dim);
-              break;
-            case btyp_float_complex:
-              if (isdouble)
-                retval = arg.complex_array_value ().cumsum (dim);
-              else
-                retval = arg.float_complex_array_value ().cumsum (dim);
-              break;
+    case btyp_double:
+      if (arg.is_sparse_type ())
+        retval = arg.sparse_matrix_value ().cumsum (dim);
+      else
+        retval = arg.array_value ().cumsum (dim);
+      break;
+    case btyp_complex:
+      if (arg.is_sparse_type ())
+        retval = arg.sparse_complex_matrix_value ().cumsum (dim);
+      else
+        retval = arg.complex_array_value ().cumsum (dim);
+      break;
+    case btyp_float:
+      if (isdouble)
+        retval = arg.array_value ().cumsum (dim);
+      else
+        retval = arg.float_array_value ().cumsum (dim);
+      break;
+    case btyp_float_complex:
+      if (isdouble)
+        retval = arg.complex_array_value ().cumsum (dim);
+      else
+        retval = arg.float_complex_array_value ().cumsum (dim);
+      break;
 
 #define MAKE_INT_BRANCH(X) \
-            case btyp_ ## X: \
-              if (isnative) \
-                retval = arg.X ## _array_value ().cumsum (dim); \
-              else \
-                retval = arg.array_value ().cumsum (dim); \
-              break;
-            MAKE_INT_BRANCH (int8);
-            MAKE_INT_BRANCH (int16);
-            MAKE_INT_BRANCH (int32);
-            MAKE_INT_BRANCH (int64);
-            MAKE_INT_BRANCH (uint8);
-            MAKE_INT_BRANCH (uint16);
-            MAKE_INT_BRANCH (uint32);
-            MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    if (isnative) \
+      retval = arg.X ## _array_value ().cumsum (dim); \
+    else \
+      retval = arg.array_value ().cumsum (dim); \
+    break;
+
+      MAKE_INT_BRANCH (int8);
+      MAKE_INT_BRANCH (int16);
+      MAKE_INT_BRANCH (int32);
+      MAKE_INT_BRANCH (int64);
+      MAKE_INT_BRANCH (uint8);
+      MAKE_INT_BRANCH (uint16);
+      MAKE_INT_BRANCH (uint32);
+      MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
 
-            case btyp_bool:
-              if (arg.is_sparse_type ())
-                {
-                  SparseMatrix cs = arg.sparse_matrix_value ().cumsum (dim);
-                  if (isnative)
-                    retval = cs != 0.0;
-                  else
-                    retval = cs;
-                }
-              else
-                {
-                  NDArray cs = arg.bool_array_value ().cumsum (dim);
-                  if (isnative)
-                    retval = cs != 0.0;
-                  else
-                    retval = cs;
-                }
-              break;
-
-            default:
-              gripe_wrong_type_arg ("cumsum", arg);
-            }
+    case btyp_bool:
+      if (arg.is_sparse_type ())
+        {
+          SparseMatrix cs = arg.sparse_matrix_value ().cumsum (dim);
+          if (isnative)
+            retval = cs != 0.0;
+          else
+            retval = cs;
         }
+      else
+        {
+          NDArray cs = arg.bool_array_value ().cumsum (dim);
+          if (isnative)
+            retval = cs != 0.0;
+          else
+            retval = cs;
+        }
+      break;
+
+    default:
+      gripe_wrong_type_arg ("cumsum", arg);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1360,36 +1360,31 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 && args(0).is_defined ())
+  if (nargin < 1 || nargin > 3)
+    print_usage ();
+
+  if (nargin == 1)
     retval = args(0).diag ();
-  else if (nargin == 2 && args(0).is_defined () && args(1).is_defined ())
+  else if (nargin == 2)
     {
-      octave_idx_type k = args(1).int_value ();
-
-      if (error_state)
-        error ("diag: invalid argument K");
-      else
-        retval = args(0).diag (k);
+      octave_idx_type k = args(1).xint_value ("diag: invalid argument K");
+
+      retval = args(0).diag (k);
     }
-  else if (nargin == 3)
+  else
     {
       octave_value arg0 = args(0);
 
       if (arg0.ndims () == 2 && (arg0.rows () == 1 || arg0.columns () == 1))
         {
-          octave_idx_type m = args(1).int_value ();
-          octave_idx_type n = args(2).int_value ();
-
-          if (! error_state)
-            retval = arg0.diag (m, n);
-          else
-            error ("diag: invalid dimensions");
+          octave_idx_type m = args(1).xint_value ("diag: invalid dimensions");
+          octave_idx_type n = args(2).xint_value ("diag: invalid dimensions");
+
+          retval = arg0.diag (m, n);
         }
       else
         error ("diag: V must be a vector");
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1511,92 +1506,87 @@
       nargin --;
     }
 
-  if (error_state)
-    return retval;
-
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  octave_value arg = args(0);
+
+  int dim = -1;
+  if (nargin == 2)
+    {
+      dim = args(1).int_value () - 1;
+      if (dim < 0)
+        error ("prod: invalid dimension DIM = %d", dim + 1);
+    }
+
+  switch (arg.builtin_type ())
     {
-      octave_value arg = args(0);
-
-      int dim = -1;
-      if (nargin == 2)
-        {
-          dim = args(1).int_value () - 1;
-          if (dim < 0)
-            error ("prod: invalid dimension DIM = %d", dim + 1);
-        }
-
-      if (! error_state)
-        {
-          switch (arg.builtin_type ())
-            {
-            case btyp_double:
-              if (arg.is_sparse_type ())
-                retval = arg.sparse_matrix_value ().prod (dim);
-              else
-                retval = arg.array_value ().prod (dim);
-              break;
-            case btyp_complex:
-              if (arg.is_sparse_type ())
-                retval = arg.sparse_complex_matrix_value ().prod (dim);
-              else
-                retval = arg.complex_array_value ().prod (dim);
-              break;
-            case btyp_float:
-              if (isdouble)
-                retval = arg.float_array_value ().dprod (dim);
-              else
-                retval = arg.float_array_value ().prod (dim);
-              break;
-            case btyp_float_complex:
-              if (isdouble)
-                retval = arg.float_complex_array_value ().dprod (dim);
-              else
-                retval = arg.float_complex_array_value ().prod (dim);
-              break;
+    case btyp_double:
+      if (arg.is_sparse_type ())
+        retval = arg.sparse_matrix_value ().prod (dim);
+      else
+        retval = arg.array_value ().prod (dim);
+      break;
+    case btyp_complex:
+      if (arg.is_sparse_type ())
+        retval = arg.sparse_complex_matrix_value ().prod (dim);
+      else
+        retval = arg.complex_array_value ().prod (dim);
+      break;
+    case btyp_float:
+      if (isdouble)
+        retval = arg.float_array_value ().dprod (dim);
+      else
+        retval = arg.float_array_value ().prod (dim);
+      break;
+    case btyp_float_complex:
+      if (isdouble)
+        retval = arg.float_complex_array_value ().dprod (dim);
+      else
+        retval = arg.float_complex_array_value ().prod (dim);
+      break;
 
 #define MAKE_INT_BRANCH(X) \
-            case btyp_ ## X: \
-              if (isnative) \
-                retval = arg.X ## _array_value ().prod (dim); \
-              else \
-                retval = arg.array_value ().prod (dim); \
-              break;
-            MAKE_INT_BRANCH (int8);
-            MAKE_INT_BRANCH (int16);
-            MAKE_INT_BRANCH (int32);
-            MAKE_INT_BRANCH (int64);
-            MAKE_INT_BRANCH (uint8);
-            MAKE_INT_BRANCH (uint16);
-            MAKE_INT_BRANCH (uint32);
-            MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    if (isnative) \
+      retval = arg.X ## _array_value ().prod (dim); \
+    else \
+      retval = arg.array_value ().prod (dim); \
+    break;
+
+      MAKE_INT_BRANCH (int8);
+      MAKE_INT_BRANCH (int16);
+      MAKE_INT_BRANCH (int32);
+      MAKE_INT_BRANCH (int64);
+      MAKE_INT_BRANCH (uint8);
+      MAKE_INT_BRANCH (uint16);
+      MAKE_INT_BRANCH (uint32);
+      MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
 
-            // GAGME: Accursed Matlab compatibility...
-            case btyp_char:
-              retval = arg.array_value (true).prod (dim);
-              break;
-            case btyp_bool:
-              if (arg.is_sparse_type ())
-                {
-                  if (isnative)
-                    retval = arg.sparse_bool_matrix_value ().all (dim);
-                  else
-                    retval = arg.sparse_matrix_value ().prod (dim);
-                }
-              else if (isnative)
-                retval = arg.bool_array_value ().all (dim);
-              else
-                retval = NDArray (arg.bool_array_value ().all (dim));
-              break;
-
-            default:
-              gripe_wrong_type_arg ("prod", arg);
-            }
+          // GAGME: Accursed Matlab compatibility...
+    case btyp_char:
+      retval = arg.array_value (true).prod (dim);
+      break;
+
+    case btyp_bool:
+      if (arg.is_sparse_type ())
+        {
+          if (isnative)
+            retval = arg.sparse_bool_matrix_value ().all (dim);
+          else
+            retval = arg.sparse_matrix_value ().prod (dim);
         }
+      else if (isnative)
+        retval = arg.bool_array_value ().all (dim);
+      else
+        retval = NDArray (arg.bool_array_value ().all (dim));
+      break;
+
+    default:
+      gripe_wrong_type_arg ("prod", arg);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1701,7 +1691,7 @@
 
       result.clear (dv);
 
-      for (int j = 0; j < n_args && ! error_state; j++)
+      for (int j = 0; j < n_args; j++)
         {
           octave_quit ();
 
@@ -1712,15 +1702,14 @@
     {
       OCTAVE_LOCAL_BUFFER (Array<T>, array_list, n_args);
 
-      for (int j = 0; j < n_args && ! error_state; j++)
+      for (int j = 0; j < n_args; j++)
         {
           octave_quit ();
 
           array_list[j] = octave_value_extract<TYPE> (args(j));
         }
 
-      if (! error_state)
-        result = Array<T>::cat (dim, n_args, array_list);
+      result = Array<T>::cat (dim, n_args, array_list);
     }
 }
 
@@ -1733,15 +1722,14 @@
   int n_args = args.length ();
   OCTAVE_LOCAL_BUFFER (Sparse<T>, sparse_list, n_args);
 
-  for (int j = 0; j < n_args && ! error_state; j++)
+  for (int j = 0; j < n_args; j++)
     {
       octave_quit ();
 
       sparse_list[j] = octave_value_extract<TYPE> (args(j));
     }
 
-  if (! error_state)
-    result = Sparse<T>::cat (dim, n_args, sparse_list);
+  result = Sparse<T>::cat (dim, n_args, sparse_list);
 }
 
 // Dispatcher.
@@ -1765,15 +1753,14 @@
   int n_args = args.length ();
   OCTAVE_LOCAL_BUFFER (MAP, map_list, n_args);
 
-  for (int j = 0; j < n_args && ! error_state; j++)
+  for (int j = 0; j < n_args; j++)
     {
       octave_quit ();
 
       map_list[j] = octave_value_extract<MAP> (args(j));
     }
 
-  if (! error_state)
-    result = octave_map::cat (dim, n_args, map_list);
+  result = octave_map::cat (dim, n_args, map_list);
 }
 
 static octave_map
@@ -1804,10 +1791,19 @@
 
   if (fcn.is_defined ())
     {
-      octave_value_list result
-        = fcn.do_multi_index_op (1, octave_value_list (1, ov));
-
-      if (! error_state && result.length () > 0)
+      octave_value_list result;
+
+      try
+        {
+          result = fcn.do_multi_index_op (1, octave_value_list (1, ov));
+        }
+      catch (octave_execution_exception& e)
+        {
+          error (e, "conversion from %s to %s failed", dtype.c_str (),
+                 cname.c_str ());
+        }
+
+      if (result.length () > 0)
         retval = result(0);
       else
         error ("conversion from %s to %s failed", dtype.c_str (),
@@ -1822,10 +1818,19 @@
 
       if (fcn.is_defined ())
         {
-          octave_value_list result
-            = fcn.do_multi_index_op (1, octave_value_list (1, ov));
-
-          if (! error_state && result.length () > 0)
+          octave_value_list result;
+
+          try
+            {
+              result = fcn.do_multi_index_op (1, octave_value_list (1, ov));
+            }
+          catch (octave_execution_exception& e)
+            {
+              error (e, "%s constructor failed for %s argument", dtype.c_str (),
+                     cname.c_str ());
+            }
+
+          if (result.length () > 0)
             retval = result(0);
           else
             error ("%s constructor failed for %s argument", dtype.c_str (),
@@ -1851,24 +1856,24 @@
 
   if (fcn.is_defined ())
     {
-      // Have method for dominant type, so call it and let it handle
-      // conversions.
-
-      octave_value_list tmp2 = fcn.do_multi_index_op (1, ovl);
-
-      if (! error_state)
+      // Have method for dominant type.  Call it and let it handle conversions.
+
+      octave_value_list tmp2;
+
+      try
         {
-          if (tmp2.length () > 0)
-            retval = tmp2(0);
-          else
-            {
-              error ("%s/%s method did not return a value",
-                     dtype.c_str (), cattype.c_str ());
-              goto done;
-            }
+          tmp2 = fcn.do_multi_index_op (1, ovl);
+        }
+      catch (octave_execution_exception& e)
+        {
+          error (e, "%s/%s method failed", dtype.c_str (), cattype.c_str ());
         }
+
+      if (tmp2.length () > 0)
+        retval = tmp2(0);
       else
-        goto done;
+        error ("%s/%s method did not return a value", dtype.c_str (),
+               cattype.c_str ());
     }
   else
     {
@@ -1888,12 +1893,7 @@
           if (t1_type == dtype)
             tmp(j++) = elt;
           else if (elt.is_object () || ! elt.is_empty ())
-            {
-              tmp(j++) = attempt_type_conversion (elt, dtype);
-
-              if (error_state)
-                goto done;
-            }
+            tmp(j++) = attempt_type_conversion (elt, dtype);
         }
 
       tmp.resize (j);
@@ -1906,7 +1906,6 @@
       retval = octave_value (new octave_class (m, cname, parents));
     }
 
-done:
   return retval;
 }
 
@@ -1915,9 +1914,9 @@
 {
   octave_value retval;
 
-  // We may need to convert elements of the list to cells, so make a
-  // copy.  This should be efficient, it is done mostly by incrementing
-  // reference counts.
+  // We may need to convert elements of the list to cells, so make a copy.
+  // This should be efficient, it is done mostly by incrementing reference
+  // counts.
   octave_value_list args = xargs;
 
   int n_args = args.length ();
@@ -2051,7 +2050,7 @@
         retval = do_single_type_concat_map (args, dim);
       else
         {
-          dim_vector  dv = args(0).dims ();
+          dim_vector dv = args(0).dims ();
 
           // Default concatenation.
           bool (dim_vector::*concat_rule) (const dim_vector&, int)
@@ -2090,9 +2089,6 @@
           octave_value tmp = args(0);
           tmp = tmp.resize (dim_vector (0,0)).resize (dv);
 
-          if (error_state)
-            return retval;
-
           int dv_len = dv.length ();
           Array<octave_idx_type> ra_idx (dim_vector (dv_len, 1), 0);
 
@@ -2103,9 +2099,6 @@
               // the right type.
               tmp = do_cat_op (tmp, args(j), ra_idx);
 
-              if (error_state)
-                return retval;
-
               dim_vector dv_tmp = args(j).dims ();
 
               if (dim >= dv_len)
@@ -2115,8 +2108,7 @@
                   break;
                 }
               else
-                ra_idx (dim) += (dim < dv_tmp.length () ?
-                                 dv_tmp (dim) : 1);
+                ra_idx(dim) += (dim < dv_tmp.length () ? dv_tmp(dim) : 1);
             }
           retval = tmp;
         }
@@ -2411,17 +2403,12 @@
 
   if (args.length () > 0)
     {
-      int dim = args(0).int_value () - 1;
-
-      if (! error_state)
-        {
-          if (dim >= 0)
-            retval = do_cat (args.slice (1, args.length () - 1), dim, "cat");
-          else
-            error ("cat: DIM must be a valid dimension");
-        }
+      int dim = args(0).xint_value ("cat: DIM must be an integer") - 1;
+
+      if (dim >= 0)
+        retval = do_cat (args.slice (1, args.length () - 1), dim, "cat");
       else
-        error ("cat: DIM must be an integer");
+        error ("cat: DIM must be a valid dimension");
     }
   else
     print_usage ();
@@ -2584,15 +2571,14 @@
       // FIXME: maybe we should create an idx_vector object
       // here and pass that to permute?
 
-      int n = vec.length ();
+      int n = vec.numel ();
 
       for (int i = 0; i < n; i++)
         vec(i)--;
 
       octave_value ret = args(0).permute (vec, inv);
 
-      if (! error_state)
-        retval = ret;
+      retval = ret;
     }
   else
     print_usage ();
@@ -2664,14 +2650,10 @@
 @seealso{numel, size}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).length ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).length ());
 }
 
 DEFUN (ndims, args, ,
@@ -2691,14 +2673,10 @@
 @seealso{size}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).ndims ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).ndims ());
 }
 
 DEFUN (numel, args, ,
@@ -2745,7 +2723,7 @@
 @end deftypefn")
 {
   octave_value retval;
-  octave_idx_type nargin = args.length ();
+  int nargin = args.length ();
 
   if (nargin == 1)
     retval = args(0).numel ();
@@ -2827,24 +2805,19 @@
     }
   else if (nargin == 2 && nargout < 2)
     {
-      octave_idx_type nd = args(1).int_value (true);
-
-      if (error_state)
-        error ("size: DIM must be a scalar");
-      else
+      octave_idx_type nd = args(1).xint_value ("size: DIM must be an integer");
+
+      const dim_vector dv = args(0).dims ();
+
+      if (nd > 0)
         {
-          const dim_vector dv = args(0).dims ();
-
-          if (nd > 0)
-            {
-              if (nd <= dv.length ())
-                retval(0) = dv(nd-1);
-              else
-                retval(0) = 1;
-            }
+          if (nd <= dv.length ())
+            retval(0) = dv(nd-1);
           else
-            error ("size: requested dimension DIM (= %d) out of range", nd);
+            retval(0) = 1;
         }
+      else
+        error ("size: requested dimension DIM (= %d) out of range", nd);
     }
   else
     print_usage ();
@@ -2894,14 +2867,10 @@
 @seealso{nzmax, nonzeros, find}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).nnz ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).nnz ());
 }
 
 DEFUN (nzmax, args, ,
@@ -2915,14 +2884,10 @@
 @seealso{nnz, spalloc, sparse}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).nzmax ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).nzmax ());
 }
 
 DEFUN (rows, args, ,
@@ -2932,15 +2897,38 @@
 @seealso{columns, size, length, numel, isscalar, isvector, ismatrix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).rows ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
-}
+  return octave_value (args(0).rows ());
+}
+
+/*
+%!assert (rows (ones (2,5)), 2)
+%!assert (rows (ones (5,2)), 5)
+%!assert (rows (ones (5,4,3,2)), 5)
+%!assert (rows (ones (3,4,5,2)), 3)
+
+%!assert (rows (cell (2,5)), 2)
+%!assert (rows (cell (5,2)), 5)
+%!assert (rows (cell (5,4,3,2)), 5)
+%!assert (rows (cell (3,4,5,2)), 3)
+
+%!test
+%! x(2,5,3).a = 1;
+%! assert (rows (x), 2);
+%! y(5,4,3).b = 2;
+%! assert (rows (y), 5);
+
+%!assert (rows ("Hello World"), 1)
+
+%!assert (rows ([]), 0)
+%!assert (rows (zeros (2,0)), 2)
+
+## Test input validation
+%!error rows ()
+%!error rows (1,2)
+*/
 
 DEFUN (columns, args, ,
        "-*- texinfo -*-\n\
@@ -2949,14 +2937,10 @@
 @seealso{rows, size, length, numel, isscalar, isvector, ismatrix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).columns ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).columns ());
 }
 
 DEFUN (sum, args, ,
@@ -3019,107 +3003,105 @@
       nargin --;
     }
 
-  if (error_state)
-    return retval;
-
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  octave_value arg = args(0);
+
+  int dim = -1;
+  if (nargin == 2)
     {
-      octave_value arg = args(0);
-
-      int dim = -1;
-      if (nargin == 2)
-        {
-          dim = args(1).int_value () - 1;
-          if (dim < 0)
-            error ("sum: invalid dimension DIM = %d", dim + 1);
-        }
-
-      if (! error_state)
+      dim = args(1).int_value () - 1;
+      if (dim < 0)
+        error ("sum: invalid dimension DIM = %d", dim + 1);
+    }
+
+  switch (arg.builtin_type ())
+    {
+    case btyp_double:
+      if (arg.is_sparse_type ())
         {
-          switch (arg.builtin_type ())
-            {
-            case btyp_double:
-              if (arg.is_sparse_type ())
-                {
-                  if (isextra)
-                    warning ("sum: 'extra' not yet implemented for sparse matrices");
-                  retval = arg.sparse_matrix_value ().sum (dim);
-                }
-              else if (isextra)
-                retval = arg.array_value ().xsum (dim);
-              else
-                retval = arg.array_value ().sum (dim);
-              break;
-            case btyp_complex:
-              if (arg.is_sparse_type ())
-                {
-                  if (isextra)
-                    warning ("sum: 'extra' not yet implemented for sparse matrices");
-                  retval = arg.sparse_complex_matrix_value ().sum (dim);
-                }
-              else if (isextra)
-                retval = arg.complex_array_value ().xsum (dim);
-              else
-                retval = arg.complex_array_value ().sum (dim);
-              break;
-            case btyp_float:
-              if (isdouble || isextra)
-                retval = arg.float_array_value ().dsum (dim);
-              else
-                retval = arg.float_array_value ().sum (dim);
-              break;
-            case btyp_float_complex:
-              if (isdouble || isextra)
-                retval = arg.float_complex_array_value ().dsum (dim);
-              else
-                retval = arg.float_complex_array_value ().sum (dim);
-              break;
+          if (isextra)
+            warning ("sum: 'extra' not yet implemented for sparse matrices");
+          retval = arg.sparse_matrix_value ().sum (dim);
+        }
+      else if (isextra)
+        retval = arg.array_value ().xsum (dim);
+      else
+        retval = arg.array_value ().sum (dim);
+      break;
+
+    case btyp_complex:
+      if (arg.is_sparse_type ())
+        {
+          if (isextra)
+            warning ("sum: 'extra' not yet implemented for sparse matrices");
+          retval = arg.sparse_complex_matrix_value ().sum (dim);
+        }
+      else if (isextra)
+        retval = arg.complex_array_value ().xsum (dim);
+      else
+        retval = arg.complex_array_value ().sum (dim);
+      break;
+
+    case btyp_float:
+      if (isdouble || isextra)
+        retval = arg.float_array_value ().dsum (dim);
+      else
+        retval = arg.float_array_value ().sum (dim);
+      break;
+
+    case btyp_float_complex:
+      if (isdouble || isextra)
+        retval = arg.float_complex_array_value ().dsum (dim);
+      else
+        retval = arg.float_complex_array_value ().sum (dim);
+      break;
 
 #define MAKE_INT_BRANCH(X) \
-            case btyp_ ## X: \
-              if (isnative) \
-                retval = arg.X ## _array_value ().sum (dim); \
-              else \
-                retval = arg.X ## _array_value ().dsum (dim); \
-              break;
-            MAKE_INT_BRANCH (int8);
-            MAKE_INT_BRANCH (int16);
-            MAKE_INT_BRANCH (int32);
-            MAKE_INT_BRANCH (int64);
-            MAKE_INT_BRANCH (uint8);
-            MAKE_INT_BRANCH (uint16);
-            MAKE_INT_BRANCH (uint32);
-            MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    if (isnative) \
+      retval = arg.X ## _array_value ().sum (dim); \
+    else \
+      retval = arg.X ## _array_value ().dsum (dim); \
+    break;
+
+      MAKE_INT_BRANCH (int8);
+      MAKE_INT_BRANCH (int16);
+      MAKE_INT_BRANCH (int32);
+      MAKE_INT_BRANCH (int64);
+      MAKE_INT_BRANCH (uint8);
+      MAKE_INT_BRANCH (uint16);
+      MAKE_INT_BRANCH (uint32);
+      MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
 
-            // GAGME: Accursed Matlab compatibility...
-            case btyp_char:
-              if (isextra)
-                retval = arg.array_value (true).xsum (dim);
-              else
-                retval = arg.array_value (true).sum (dim);
-              break;
-            case btyp_bool:
-              if (arg.is_sparse_type ())
-                {
-                  if (isnative)
-                    retval = arg.sparse_bool_matrix_value ().any (dim);
-                  else
-                    retval = arg.sparse_bool_matrix_value ().sum (dim);
-                }
-              else if (isnative)
-                retval = arg.bool_array_value ().any (dim);
-              else
-                retval = arg.bool_array_value ().sum (dim);
-              break;
-
-            default:
-              gripe_wrong_type_arg ("sum", arg);
-            }
+      // GAGME: Accursed Matlab compatibility...
+    case btyp_char:
+      if (isextra)
+        retval = arg.array_value (true).xsum (dim);
+      else
+        retval = arg.array_value (true).sum (dim);
+      break;
+
+    case btyp_bool:
+      if (arg.is_sparse_type ())
+        {
+          if (isnative)
+            retval = arg.sparse_bool_matrix_value ().any (dim);
+          else
+            retval = arg.sparse_bool_matrix_value ().sum (dim);
         }
+      else if (isnative)
+        retval = arg.bool_array_value ().any (dim);
+      else
+        retval = arg.bool_array_value ().sum (dim);
+      break;
+
+    default:
+      gripe_wrong_type_arg ("sum", arg);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -3237,14 +3219,10 @@
 @seealso{isfloat, isinteger, ischar, isnumeric, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_bool_type ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_bool_type ());
 }
 
 DEFALIAS (isbool, islogical);
@@ -3273,14 +3251,10 @@
 @seealso{isfloat, ischar, islogical, isnumeric, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_integer_type ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_integer_type ());
 }
 
 DEFUN (iscomplex, args, ,
@@ -3290,14 +3264,10 @@
 @seealso{isreal, isnumeric, islogical, ischar, isfloat, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_complex_type ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_complex_type ());
 }
 
 DEFUN (isfloat, args, ,
@@ -3309,14 +3279,10 @@
 @seealso{isinteger, ischar, islogical, isnumeric, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_float_type ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_float_type ());
 }
 
 // FIXME: perhaps this should be implemented with an
@@ -3350,6 +3316,9 @@
 
   int nargin = args.length ();
 
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   if (nargin == 1)
     {
       octave_value arg = args(0);
@@ -3360,51 +3329,43 @@
         {
           if (arg.is_sparse_type ())
             {
-              SparseComplexMatrix val = arg.sparse_complex_matrix_value ();
-
-              if (! error_state)
-                retval = octave_value (new octave_sparse_complex_matrix (val));
+              SparseComplexMatrix val = arg.xsparse_complex_matrix_value ("complex: invalid conversion");
+
+              retval = octave_value (new octave_sparse_complex_matrix (val));
             }
           else if (arg.is_single_type ())
             {
               if (arg.numel () == 1)
                 {
-                  FloatComplex val = arg.float_complex_value ();
-
-                  if (! error_state)
-                    retval = octave_value (new octave_float_complex (val));
+                  FloatComplex val = arg.xfloat_complex_value ("complex: invalid conversion");
+
+                  retval = octave_value (new octave_float_complex (val));
                 }
               else
                 {
-                  FloatComplexNDArray val = arg.float_complex_array_value ();
-
-                  if (! error_state)
-                    retval = octave_value (new octave_float_complex_matrix (val));
+                  FloatComplexNDArray val = arg.xfloat_complex_array_value ("complex: invalid conversion");
+
+                  retval = octave_value (new octave_float_complex_matrix (val));
                 }
             }
           else
             {
               if (arg.numel () == 1)
                 {
-                  Complex val = arg.complex_value ();
-
-                  if (! error_state)
-                    retval = octave_value (new octave_complex (val));
+                  Complex val = arg.xcomplex_value ("complex: invalid conversion");
+
+                  retval = octave_value (new octave_complex (val));
                 }
               else
                 {
-                  ComplexNDArray val = arg.complex_array_value ();
-
-                  if (! error_state)
-                    retval = octave_value (new octave_complex_matrix (val));
+                  ComplexNDArray val = arg.xcomplex_array_value ("complex: invalid conversion");
+
+                  retval = octave_value (new octave_complex_matrix (val));
                 }
             }
-
-          if (error_state)
-            error ("complex: invalid conversion");
         }
     }
-  else if (nargin == 2)
+  else
     {
       octave_value re = args(0);
       octave_value im = args(1);
@@ -3414,66 +3375,63 @@
           const SparseMatrix re_val = re.sparse_matrix_value ();
           const SparseMatrix im_val = im.sparse_matrix_value ();
 
-          if (!error_state)
+          if (re.numel () == 1)
             {
-              if (re.numel () == 1)
+              SparseComplexMatrix result;
+              if (re_val.nnz () == 0)
+                result = Complex (0, 1) * SparseComplexMatrix (im_val);
+              else
                 {
-                  SparseComplexMatrix result;
-                  if (re_val.nnz () == 0)
-                    result = Complex (0, 1) * SparseComplexMatrix (im_val);
-                  else
+                  octave_idx_type nr = im_val.rows ();
+                  octave_idx_type nc = im_val.cols ();
+                  result = SparseComplexMatrix (nr, nc, re_val(0));
+
+                  for (octave_idx_type j = 0; j < nc; j++)
                     {
-                      octave_idx_type nr = im_val.rows ();
-                      octave_idx_type nc = im_val.cols ();
-                      result = SparseComplexMatrix (nr, nc, re_val(0));
-
-                      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) +=
-                              Complex (0, im_val.data (i));
-                        }
+                      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) +=
+                          Complex (0, im_val.data (i));
                     }
-                  retval = octave_value (new octave_sparse_complex_matrix (result));
                 }
-              else if (im.numel () == 1)
+              retval = octave_value (new octave_sparse_complex_matrix (result));
+            }
+          else if (im.numel () == 1)
+            {
+              SparseComplexMatrix result;
+              if (im_val.nnz () == 0)
+                result = SparseComplexMatrix (re_val);
+              else
+                {
+                  octave_idx_type nr = re_val.rows ();
+                  octave_idx_type nc = re_val.cols ();
+                  result = SparseComplexMatrix (nr, nc,
+                                                Complex (0, im_val(0)));
+
+                  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) +=
+                          re_val.data (i);
+                    }
+                }
+              retval = octave_value (new octave_sparse_complex_matrix (result));
+            }
+          else
+            {
+              if (re_val.dims () == im_val.dims ())
                 {
                   SparseComplexMatrix result;
-                  if (im_val.nnz () == 0)
-                    result = SparseComplexMatrix (re_val);
-                  else
-                    {
-                      octave_idx_type nr = re_val.rows ();
-                      octave_idx_type nc = re_val.cols ();
-                      result = SparseComplexMatrix (nr, nc,
-                                                    Complex (0, im_val(0)));
-
-                      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) +=
-                              re_val.data (i);
-                        }
-                    }
-                  retval = octave_value (new octave_sparse_complex_matrix (result));
+                  result = SparseComplexMatrix (re_val)
+                    + Complex (0, 1) * SparseComplexMatrix (im_val);
+                  retval = octave_value (
+                                         new octave_sparse_complex_matrix (result));
                 }
               else
-                {
-                  if (re_val.dims () == im_val.dims ())
-                    {
-                      SparseComplexMatrix result;
-                      result = SparseComplexMatrix (re_val)
-                               + Complex (0, 1) * SparseComplexMatrix (im_val);
-                      retval = octave_value (
-                                 new octave_sparse_complex_matrix (result));
-                    }
-                  else
-                    error ("complex: dimension mismatch");
-                }
+                error ("complex: dimension mismatch");
             }
         }
       else if (re.is_single_type () || im.is_single_type ())
@@ -3486,26 +3444,21 @@
                 {
                   float im_val = im.double_value ();
 
-                  if (! error_state)
-                    retval = octave_value (
-                               new octave_float_complex (FloatComplex (re_val,
-                                                                       im_val)));
+                  retval = octave_value (new octave_float_complex
+                                         (FloatComplex (re_val, im_val)));
                 }
               else
                 {
                   const FloatNDArray im_val = im.float_array_value ();
 
-                  if (! error_state)
-                    {
-                      FloatComplexNDArray result (im_val.dims (),
-                                                  FloatComplex ());
-
-                      for (octave_idx_type i = 0; i < im_val.numel (); i++)
-                        result.xelem (i) = FloatComplex (re_val, im_val(i));
-
-                      retval = octave_value (
-                                 new octave_float_complex_matrix (result));
-                    }
+                  FloatComplexNDArray result (im_val.dims (),
+                                              FloatComplex ());
+
+                  for (octave_idx_type i = 0; i < im_val.numel (); i++)
+                    result.xelem (i) = FloatComplex (re_val, im_val(i));
+
+                  retval = octave_value (new octave_float_complex_matrix
+                                         (result));
                 }
             }
           else
@@ -3516,39 +3469,33 @@
                 {
                   float im_val = im.float_value ();
 
-                  if (! error_state)
+                  FloatComplexNDArray result (re_val.dims (),
+                                              FloatComplex ());
+
+                  for (octave_idx_type i = 0; i < re_val.numel (); i++)
+                    result.xelem (i) = FloatComplex (re_val(i), im_val);
+
+                  retval = octave_value (new octave_float_complex_matrix
+                                         (result));
+                }
+              else
+                {
+                  const FloatNDArray im_val = im.float_array_value ();
+
+                  if (re_val.dims () == im_val.dims ())
                     {
                       FloatComplexNDArray result (re_val.dims (),
                                                   FloatComplex ());
 
                       for (octave_idx_type i = 0; i < re_val.numel (); i++)
-                        result.xelem (i) = FloatComplex (re_val(i), im_val);
-
-                      retval = octave_value (
-                                 new octave_float_complex_matrix (result));
+                        result.xelem (i) = FloatComplex (re_val(i),
+                                                         im_val(i));
+
+                      retval = octave_value (new octave_float_complex_matrix
+                                             (result));
                     }
-                }
-              else
-                {
-                  const FloatNDArray im_val = im.float_array_value ();
-
-                  if (! error_state)
-                    {
-                      if (re_val.dims () == im_val.dims ())
-                        {
-                          FloatComplexNDArray result (re_val.dims (),
-                                                      FloatComplex ());
-
-                          for (octave_idx_type i = 0; i < re_val.numel (); i++)
-                            result.xelem (i) = FloatComplex (re_val(i),
-                                                             im_val(i));
-
-                          retval = octave_value (
-                                     new octave_float_complex_matrix (result));
-                        }
-                      else
-                        error ("complex: dimension mismatch");
-                    }
+                  else
+                    error ("complex: dimension mismatch");
                 }
             }
         }
@@ -3560,23 +3507,19 @@
             {
               double im_val = im.double_value ();
 
-              if (! error_state)
-                retval = octave_value (new octave_complex (Complex (re_val,
-                                                                    im_val)));
+              retval = octave_value (new octave_complex
+                                     (Complex (re_val, im_val)));
             }
           else
             {
               const NDArray im_val = im.array_value ();
 
-              if (! error_state)
-                {
-                  ComplexNDArray result (im_val.dims (), Complex ());
-
-                  for (octave_idx_type i = 0; i < im_val.numel (); i++)
-                    result.xelem (i) = Complex (re_val, im_val(i));
-
-                  retval = octave_value (new octave_complex_matrix (result));
-                }
+              ComplexNDArray result (im_val.dims (), Complex ());
+
+              for (octave_idx_type i = 0; i < im_val.numel (); i++)
+                result.xelem (i) = Complex (re_val, im_val(i));
+
+              retval = octave_value (new octave_complex_matrix (result));
             }
         }
       else
@@ -3587,43 +3530,32 @@
             {
               double im_val = im.double_value ();
 
-              if (! error_state)
-                {
-                  ComplexNDArray result (re_val.dims (), Complex ());
-
-                  for (octave_idx_type i = 0; i < re_val.numel (); i++)
-                    result.xelem (i) = Complex (re_val(i), im_val);
-
-                  retval = octave_value (new octave_complex_matrix (result));
-                }
+              ComplexNDArray result (re_val.dims (), Complex ());
+
+              for (octave_idx_type i = 0; i < re_val.numel (); i++)
+                result.xelem (i) = Complex (re_val(i), im_val);
+
+              retval = octave_value (new octave_complex_matrix (result));
             }
           else
             {
               const NDArray im_val = im.array_value ();
 
-              if (! error_state)
+              if (re_val.dims () == im_val.dims ())
                 {
-                  if (re_val.dims () == im_val.dims ())
-                    {
-                      ComplexNDArray result (re_val.dims (), Complex ());
-
-                      for (octave_idx_type i = 0; i < re_val.numel (); i++)
-                        result.xelem (i) = Complex (re_val(i), im_val(i));
-
-                      retval = octave_value (
-                                 new octave_complex_matrix (result));
-                    }
-                  else
-                    error ("complex: dimension mismatch");
+                  ComplexNDArray result (re_val.dims (), Complex ());
+
+                  for (octave_idx_type i = 0; i < re_val.numel (); i++)
+                    result.xelem (i) = Complex (re_val(i), im_val(i));
+
+                  retval = octave_value (
+                                         new octave_complex_matrix (result));
                 }
+              else
+                error ("complex: dimension mismatch");
             }
         }
-
-      if (error_state)
-        error ("complex: invalid conversion");
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -3638,14 +3570,10 @@
 @seealso{iscomplex, isnumeric, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_real_type ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_real_type ());
 }
 
 DEFUN (isempty, args, ,
@@ -3656,14 +3584,10 @@
 @seealso{isnull, isa}\n\
 @end deftypefn")
 {
-  octave_value retval = false;
-
-  if (args.length () == 1)
-    retval = args(0).is_empty ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_empty ());
 }
 
 /*
@@ -3681,14 +3605,10 @@
 @seealso{isinteger, isfloat, isreal, iscomplex, islogical, ischar, iscell, isstruct, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_numeric_type ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_numeric_type ());
 }
 
 /*
@@ -3714,14 +3634,10 @@
 @seealso{isvector, ismatrix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).numel () == 1;
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).numel () == 1);
 }
 
 /*
@@ -3753,17 +3669,12 @@
 @seealso{isscalar, ismatrix, size, rows, columns, length}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      dim_vector sz = args(0).dims ();
-      retval = sz.length () == 2 && (sz(0) == 1 || sz(1) == 1);
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  dim_vector sz = args(0).dims ();
+
+  return octave_value (sz.length () == 2 && (sz(0) == 1 || sz(1) == 1));
 }
 
 /*
@@ -3793,17 +3704,12 @@
 @seealso{iscolumn, isscalar, isvector, ismatrix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      dim_vector sz = args(0).dims ();
-      retval = sz.length () == 2 && sz(0) == 1;
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  dim_vector sz = args(0).dims ();
+
+  return octave_value (sz.length () == 2 && sz(0) == 1);
 }
 
 /*
@@ -3843,17 +3749,12 @@
 @seealso{isrow, isscalar, isvector, ismatrix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      dim_vector sz = args(0).dims ();
-      retval = sz.length () == 2 && sz(1) == 1;
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  dim_vector sz = args(0).dims ();
+
+  return octave_value (sz.length () == 2 && sz(1) == 1);
 }
 
 /*
@@ -3892,17 +3793,12 @@
 @seealso{isscalar, isvector, iscell, isstruct, issparse, isa}\n\
 @end deftypefn")
 {
-  octave_value retval = false;
-
-  if (args.length () == 1)
-    {
-      dim_vector sz = args(0).dims ();
-      retval = (sz.length () == 2) && (sz(0) >= 0) && (sz(1) >= 0);
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  dim_vector sz = args(0).dims ();
+
+  return octave_value (sz.length () == 2 && sz(0) >= 0 && sz(1) >= 0);
 }
 
 /*
@@ -3940,17 +3836,12 @@
 @seealso{isscalar, isvector, ismatrix, size}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      dim_vector sz = args(0).dims ();
-      retval = sz.length () == 2 && sz(0) == sz(1);
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  dim_vector sz = args(0).dims ();
+
+  return octave_value (sz.length () == 2 && sz(0) == sz(1));
 }
 
 /*
@@ -3991,9 +3882,6 @@
       nargin--;
 
       dt = oct_data_conv::string_to_data_type (nm);
-
-      if (error_state)
-        return retval;
     }
 
   switch (nargin)
@@ -4010,90 +3898,77 @@
         dims.resize (nargin);
 
         for (int i = 0; i < nargin; i++)
-          {
-            dims(i) = args(i).is_empty () ? 0 : args(i).idx_type_value ();
-
-            if (error_state)
-              {
-                error ("%s: expecting scalar integer arguments", fcn);
-                break;
-              }
-          }
+          dims(i) = (args(i).is_empty ()
+                     ? 0 : args(i).xidx_type_value ("%s: dimension arguments must be scalar integers", fcn));
       }
       break;
     }
 
-  if (! error_state)
+  dims.chop_trailing_singletons ();
+
+  check_dimensions (dims, fcn);
+
+  // FIXME: perhaps this should be made extensible by
+  // using the class name to lookup a function to call to create
+  // the new value.
+
+  // Note that automatic narrowing will handle conversion from
+  // NDArray to scalar.
+
+  switch (dt)
     {
-      dims.chop_trailing_singletons ();
-
-      check_dimensions (dims, fcn);
-
-      // FIXME: perhaps this should be made extensible by
-      // using the class name to lookup a function to call to create
-      // the new value.
-
-      // Note that automatic narrowing will handle conversion from
-      // NDArray to scalar.
-
-      if (! error_state)
-        {
-          switch (dt)
-            {
-            case oct_data_conv::dt_int8:
-              retval = int8NDArray (dims, val);
-              break;
-
-            case oct_data_conv::dt_uint8:
-              retval = uint8NDArray (dims, val);
-              break;
-
-            case oct_data_conv::dt_int16:
-              retval = int16NDArray (dims, val);
-              break;
-
-            case oct_data_conv::dt_uint16:
-              retval = uint16NDArray (dims, val);
-              break;
-
-            case oct_data_conv::dt_int32:
-              retval = int32NDArray (dims, val);
-              break;
-
-            case oct_data_conv::dt_uint32:
-              retval = uint32NDArray (dims, val);
-              break;
-
-            case oct_data_conv::dt_int64:
-              retval = int64NDArray (dims, val);
-              break;
-
-            case oct_data_conv::dt_uint64:
-              retval = uint64NDArray (dims, val);
-              break;
-
-            case oct_data_conv::dt_single:
-              retval = FloatNDArray (dims, val);
-              break;
-
-            case oct_data_conv::dt_double:
-              {
-                if (val == 1 && dims.length () == 2 && dims (0) == 1)
-                  retval = Range (1.0, 0.0, dims (1)); // packed form
-                else
-                  retval = NDArray (dims, val);
-              }
-              break;
-
-            case oct_data_conv::dt_logical:
-              retval = boolNDArray (dims, val);
-              break;
-
-            default:
-              error ("%s: invalid class name", fcn);
-              break;
-            }
-        }
+    case oct_data_conv::dt_int8:
+      retval = int8NDArray (dims, val);
+      break;
+
+    case oct_data_conv::dt_uint8:
+      retval = uint8NDArray (dims, val);
+      break;
+
+    case oct_data_conv::dt_int16:
+      retval = int16NDArray (dims, val);
+      break;
+
+    case oct_data_conv::dt_uint16:
+      retval = uint16NDArray (dims, val);
+      break;
+
+    case oct_data_conv::dt_int32:
+      retval = int32NDArray (dims, val);
+      break;
+
+    case oct_data_conv::dt_uint32:
+      retval = uint32NDArray (dims, val);
+      break;
+
+    case oct_data_conv::dt_int64:
+      retval = int64NDArray (dims, val);
+      break;
+
+    case oct_data_conv::dt_uint64:
+      retval = uint64NDArray (dims, val);
+      break;
+
+    case oct_data_conv::dt_single:
+      retval = FloatNDArray (dims, val);
+      break;
+
+    case oct_data_conv::dt_double:
+      {
+        if (val == 1 && dims.length () == 2 && dims(0) == 1)
+          retval = Range (1.0, 0.0, dims(1));  // packed form
+        else
+          retval = NDArray (dims, val);
+      }
+      break;
+
+    case oct_data_conv::dt_logical:
+      retval = boolNDArray (dims, val);
+      break;
+
+    default:
+      error ("%s: invalid class name", fcn);
+      break;
     }
 
   return retval;
@@ -4117,9 +3992,6 @@
       nargin--;
 
       dt = oct_data_conv::string_to_data_type (nm);
-
-      if (error_state)
-        return retval;
     }
 
   switch (nargin)
@@ -4136,45 +4008,32 @@
         dims.resize (nargin);
 
         for (int i = 0; i < nargin; i++)
-          {
-            dims(i) = args(i).is_empty () ? 0 : args(i).idx_type_value ();
-
-            if (error_state)
-              {
-                error ("%s: expecting scalar integer arguments", fcn);
-                break;
-              }
-          }
+          dims(i) = (args(i).is_empty ()
+                     ? 0 : args(i).xidx_type_value ("%s: dimension arguments must be scalar integers", fcn));
       }
       break;
     }
 
-  if (! error_state)
+  dims.chop_trailing_singletons ();
+
+  check_dimensions (dims, fcn);
+
+  // Note that automatic narrowing will handle conversion from
+  // NDArray to scalar.
+
+  switch (dt)
     {
-      dims.chop_trailing_singletons ();
-
-      check_dimensions (dims, fcn);
-
-      // Note that automatic narrowing will handle conversion from
-      // NDArray to scalar.
-
-      if (! error_state)
-        {
-          switch (dt)
-            {
-            case oct_data_conv::dt_single:
-              retval = FloatNDArray (dims, fval);
-              break;
-
-            case oct_data_conv::dt_double:
-              retval = NDArray (dims, val);
-              break;
-
-            default:
-              error ("%s: invalid class name", fcn);
-              break;
-            }
-        }
+    case oct_data_conv::dt_single:
+      retval = FloatNDArray (dims, fval);
+      break;
+
+    case oct_data_conv::dt_double:
+      retval = NDArray (dims, val);
+      break;
+
+    default:
+      error ("%s: invalid class name", fcn);
+      break;
     }
 
   return retval;
@@ -4197,9 +4056,6 @@
       nargin--;
 
       dt = oct_data_conv::string_to_data_type (nm);
-
-      if (error_state)
-        return retval;
     }
 
   switch (nargin)
@@ -4216,45 +4072,32 @@
         dims.resize (nargin);
 
         for (int i = 0; i < nargin; i++)
-          {
-            dims(i) = args(i).is_empty () ? 0 : args(i).idx_type_value ();
-
-            if (error_state)
-              {
-                error ("%s: expecting scalar integer arguments", fcn);
-                break;
-              }
-          }
+          dims(i) = (args(i).is_empty ()
+                     ? 0 : args(i).xidx_type_value ("%s: dimension arguments must be scalar integers", fcn));
       }
       break;
     }
 
-  if (! error_state)
+  dims.chop_trailing_singletons ();
+
+  check_dimensions (dims, fcn);
+
+  // Note that automatic narrowing will handle conversion from
+  // NDArray to scalar.
+
+  switch (dt)
     {
-      dims.chop_trailing_singletons ();
-
-      check_dimensions (dims, fcn);
-
-      // Note that automatic narrowing will handle conversion from
-      // NDArray to scalar.
-
-      if (! error_state)
-        {
-          switch (dt)
-            {
-            case oct_data_conv::dt_single:
-              retval = FloatNDArray (dims, static_cast<float> (val));
-              break;
-
-            case oct_data_conv::dt_double:
-              retval = NDArray (dims, val);
-              break;
-
-            default:
-              error ("%s: invalid class name", fcn);
-              break;
-            }
-        }
+    case oct_data_conv::dt_single:
+      retval = FloatNDArray (dims, static_cast<float> (val));
+      break;
+
+    case oct_data_conv::dt_double:
+      retval = NDArray (dims, val);
+      break;
+
+    default:
+      error ("%s: invalid class name", fcn);
+      break;
     }
 
   return retval;
@@ -4278,9 +4121,6 @@
       nargin--;
 
       dt = oct_data_conv::string_to_data_type (nm);
-
-      if (error_state)
-        return retval;
     }
 
   switch (nargin)
@@ -4297,46 +4137,33 @@
         dims.resize (nargin);
 
         for (int i = 0; i < nargin; i++)
-          {
-            dims(i) = args(i).is_empty () ? 0 : args(i).idx_type_value ();
-
-            if (error_state)
-              {
-                error ("%s: expecting scalar integer arguments", fcn);
-                break;
-              }
-          }
+          dims(i) = (args(i).is_empty ()
+                     ? 0 : args(i).xidx_type_value ("%s: dimension arguments must be scalar integers", fcn));
       }
       break;
     }
 
-  if (! error_state)
+  dims.chop_trailing_singletons ();
+
+  check_dimensions (dims, fcn);
+
+  // Note that automatic narrowing will handle conversion from
+  // NDArray to scalar.
+
+  switch (dt)
     {
-      dims.chop_trailing_singletons ();
-
-      check_dimensions (dims, fcn);
-
-      // Note that automatic narrowing will handle conversion from
-      // NDArray to scalar.
-
-      if (! error_state)
-        {
-          switch (dt)
-            {
-            case oct_data_conv::dt_single:
-              retval = FloatComplexNDArray (dims,
-                                            static_cast<FloatComplex> (val));
-              break;
-
-            case oct_data_conv::dt_double:
-              retval = ComplexNDArray (dims, val);
-              break;
-
-            default:
-              error ("%s: invalid class name", fcn);
-              break;
-            }
-        }
+    case oct_data_conv::dt_single:
+      retval = FloatComplexNDArray (dims,
+                                    static_cast<FloatComplex> (val));
+      break;
+
+    case oct_data_conv::dt_double:
+      retval = ComplexNDArray (dims, val);
+      break;
+
+    default:
+      error ("%s: invalid class name", fcn);
+      break;
     }
 
   return retval;
@@ -4365,31 +4192,20 @@
         dims.resize (nargin);
 
         for (int i = 0; i < nargin; i++)
-          {
-            dims(i) = args(i).is_empty () ? 0 : args(i).idx_type_value ();
-
-            if (error_state)
-              {
-                error ("%s: expecting scalar integer arguments", fcn);
-                break;
-              }
-          }
+          dims(i) = (args(i).is_empty ()
+                     ? 0 : args(i).xidx_type_value ("%s: dimension arguments must be scalar integers", fcn));
       }
       break;
     }
 
-  if (! error_state)
-    {
-      dims.chop_trailing_singletons ();
-
-      check_dimensions (dims, fcn);
-
-      // Note that automatic narrowing will handle conversion from
-      // NDArray to scalar.
-
-      if (! error_state)
-        retval = boolNDArray (dims, val);
-    }
+  dims.chop_trailing_singletons ();
+
+  check_dimensions (dims, fcn);
+
+  // Note that automatic narrowing will handle conversion from
+  // NDArray to scalar.
+
+  retval = boolNDArray (dims, val);
 
   return retval;
 }
@@ -4688,64 +4504,59 @@
 the number of rows and columns and any further arguments specify additional\n\
 matrix dimensions.  The optional argument @var{class} specifies the return\n\
 type and may be either @qcode{\"double\"} or @qcode{\"single\"}.\n\
-@seealso{realmax, realmin, intmax, bitmax}\n\
+@seealso{realmax, realmin, intmax, flintmax}\n\
 @end deftypefn")
 {
-  int nargin = args.length ();
   octave_value retval;
 
-  if (nargin == 1 && ! args(0).is_string ())
+  if (args.length () == 1 && ! args(0).is_string ())
     {
       if (args(0).is_single_type ())
         {
           Array<float> x = args(0).float_array_value ();
 
-          if (! error_state)
+          Array<float> epsval (x.dims ());
+
+          for (octave_idx_type i = 0; i < x.numel (); i++)
             {
-              Array<float> epsval (x.dims ());
-
-              for (octave_idx_type i = 0; i < x.numel (); i++)
+              float val = ::fabsf (x(i));
+              if (xisnan (val) || xisinf (val))
+                epsval(i) = lo_ieee_nan_value ();
+              else if (val < std::numeric_limits<float>::min ())
+                epsval(i) = powf (2.0, -149e0);
+              else
                 {
-                  float val = ::fabsf (x(i));
-                  if (xisnan (val) || xisinf (val))
-                    epsval(i) = lo_ieee_nan_value ();
-                  else if (val < std::numeric_limits<float>::min ())
-                    epsval(i) = powf (2.0, -149e0);
-                  else
-                    {
-                      int expon;
-                      gnulib::frexpf (val, &expon);
-                      epsval(i) = std::pow (2.0f,
-                                            static_cast<float> (expon - 24));
-                    }
+                  int expon;
+                  gnulib::frexpf (val, &expon);
+                  epsval(i) = std::pow (2.0f,
+                                        static_cast<float> (expon - 24));
                 }
-              retval = epsval;
             }
+
+          retval = epsval;
         }
       else
         {
           Array<double> x = args(0).array_value ();
 
-          if (! error_state)
+          Array<double> epsval (x.dims ());
+
+          for (octave_idx_type i = 0; i < x.numel (); i++)
             {
-              Array<double> epsval (x.dims ());
-
-              for (octave_idx_type i = 0; i < x.numel (); i++)
+              double val = ::fabs (x(i));
+              if (xisnan (val) || xisinf (val))
+                epsval(i) = lo_ieee_nan_value ();
+              else if (val < std::numeric_limits<double>::min ())
+                epsval(i) = pow (2.0, -1074e0);
+              else
                 {
-                  double val = ::fabs (x(i));
-                  if (xisnan (val) || xisinf (val))
-                    epsval(i) = lo_ieee_nan_value ();
-                  else if (val < std::numeric_limits<double>::min ())
-                    epsval(i) = pow (2.0, -1074e0);
-                  else
-                    {
-                      int expon;
-                      gnulib::frexp (val, &expon);
-                      epsval(i) = std::pow (2.0,
-                                            static_cast<double> (expon - 53));
-                    }
-                  retval = epsval;
+                  int expon;
+                  gnulib::frexp (val, &expon);
+                  epsval(i) = std::pow (2.0,
+                                        static_cast<double> (expon - 53));
                 }
+
+              retval = epsval;
             }
         }
     }
@@ -4861,7 +4672,7 @@
 \n\
 The optional argument @var{class} specifies the return type and may be\n\
 either @qcode{\"double\"} or @qcode{\"single\"}.\n\
-@seealso{realmin, intmax, bitmax, eps}\n\
+@seealso{realmin, intmax, flintmax, eps}\n\
 @end deftypefn")
 {
   return fill_matrix (args, std::numeric_limits<double>::max (),
@@ -5080,58 +4891,55 @@
   // the class name to lookup a function to call to create the new
   // value.
 
-  if (! error_state)
+  switch (dt)
     {
-      switch (dt)
-        {
-        case oct_data_conv::dt_int8:
-          retval = identity_matrix<int8NDArray> (nr, nc);
-          break;
-
-        case oct_data_conv::dt_uint8:
-          retval = identity_matrix<uint8NDArray> (nr, nc);
-          break;
-
-        case oct_data_conv::dt_int16:
-          retval = identity_matrix<int16NDArray> (nr, nc);
-          break;
-
-        case oct_data_conv::dt_uint16:
-          retval = identity_matrix<uint16NDArray> (nr, nc);
-          break;
-
-        case oct_data_conv::dt_int32:
-          retval = identity_matrix<int32NDArray> (nr, nc);
-          break;
-
-        case oct_data_conv::dt_uint32:
-          retval = identity_matrix<uint32NDArray> (nr, nc);
-          break;
-
-        case oct_data_conv::dt_int64:
-          retval = identity_matrix<int64NDArray> (nr, nc);
-          break;
-
-        case oct_data_conv::dt_uint64:
-          retval = identity_matrix<uint64NDArray> (nr, nc);
-          break;
-
-        case oct_data_conv::dt_single:
-          retval = FloatDiagMatrix (nr, nc, 1.0f);
-          break;
-
-        case oct_data_conv::dt_double:
-          retval = DiagMatrix (nr, nc, 1.0);
-          break;
-
-        case oct_data_conv::dt_logical:
-          retval = identity_matrix<boolNDArray> (nr, nc);
-          break;
-
-        default:
-          error ("eye: invalid class name");
-          break;
-        }
+    case oct_data_conv::dt_int8:
+      retval = identity_matrix<int8NDArray> (nr, nc);
+      break;
+
+    case oct_data_conv::dt_uint8:
+      retval = identity_matrix<uint8NDArray> (nr, nc);
+      break;
+
+    case oct_data_conv::dt_int16:
+      retval = identity_matrix<int16NDArray> (nr, nc);
+      break;
+
+    case oct_data_conv::dt_uint16:
+      retval = identity_matrix<uint16NDArray> (nr, nc);
+      break;
+
+    case oct_data_conv::dt_int32:
+      retval = identity_matrix<int32NDArray> (nr, nc);
+      break;
+
+    case oct_data_conv::dt_uint32:
+      retval = identity_matrix<uint32NDArray> (nr, nc);
+      break;
+
+    case oct_data_conv::dt_int64:
+      retval = identity_matrix<int64NDArray> (nr, nc);
+      break;
+
+    case oct_data_conv::dt_uint64:
+      retval = identity_matrix<uint64NDArray> (nr, nc);
+      break;
+
+    case oct_data_conv::dt_single:
+      retval = FloatDiagMatrix (nr, nc, 1.0f);
+      break;
+
+    case oct_data_conv::dt_double:
+      retval = DiagMatrix (nr, nc, 1.0);
+      break;
+
+    case oct_data_conv::dt_logical:
+      retval = identity_matrix<boolNDArray> (nr, nc);
+      break;
+
+    default:
+      error ("eye: invalid class name");
+      break;
     }
 
   return retval;
@@ -5203,40 +5011,26 @@
       nargin--;
 
       dt = oct_data_conv::string_to_data_type (nm);
-
-      if (error_state)
-        return retval;
     }
 
-  switch (nargin)
+  if (nargin > 2)
+    print_usage ();
+
+  if (nargin == 0)
+    retval = identity_matrix (1, 1, dt);
+  else if (nargin == 1)
     {
-    case 0:
-      retval = identity_matrix (1, 1, dt);
-      break;
-
-    case 1:
-      {
-        octave_idx_type nr, nc;
-        get_dimensions (args(0), "eye", nr, nc);
-
-        if (! error_state)
-          retval = identity_matrix (nr, nc, dt);
-      }
-      break;
-
-    case 2:
-      {
-        octave_idx_type nr, nc;
-        get_dimensions (args(0), args(1), "eye", nr, nc);
-
-        if (! error_state)
-          retval = identity_matrix (nr, nc, dt);
-      }
-      break;
-
-    default:
-      print_usage ();
-      break;
+      octave_idx_type nr, nc;
+      get_dimensions (args(0), "eye", nr, nc);
+
+      retval = identity_matrix (nr, nc, dt);
+    }
+  else
+    {
+      octave_idx_type nr, nc;
+      get_dimensions (args(0), args(1), "eye", nr, nc);
+
+      retval = identity_matrix (nr, nc, dt);
     }
 
   return retval;
@@ -5276,7 +5070,7 @@
       else
         {
           CVT lv = octave_value_extract<CVT> (limit);
-          CVT bv (lv.length (), bs);
+          CVT bv (lv.numel (), bs);
           retval = linspace (bv, lv, n);
         }
     }
@@ -5286,7 +5080,7 @@
       if (limit.is_scalar_type ())
         {
           T ls = octave_value_extract<T> (limit);
-          CVT lv (bv.length (), ls);
+          CVT lv (bv.numel (), ls);
           retval = linspace (bv, lv, n);
         }
       else
@@ -5311,9 +5105,11 @@
 than @var{limit}, the elements are stored in decreasing order.  If the\n\
 number of points is not specified, a value of 100 is used.\n\
 \n\
-The @code{linspace} function always returns a row vector if both @var{base}\n\
-and @var{limit} are scalars.  If one, or both, of them are column vectors,\n\
-@code{linspace} returns a matrix.\n\
+The @code{linspace} function returns a row vector when both @var{base}\n\
+and @var{limit} are scalars.  If one, or both, inputs are vectors, then\n\
+@code{linspace} transforms them to column vectors and returns a matrix where\n\
+each row is an independent sequence between\n\
+@w{@code{@var{base}(@var{row_n}), @var{limit}(@var{row_n})}}.\n\
 \n\
 For compatibility with @sc{matlab}, return the second argument (@var{limit})\n\
 if fewer than two values are requested.\n\
@@ -5327,10 +5123,7 @@
   octave_idx_type npoints = 100;
 
   if (nargin != 2 && nargin != 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   if (nargin == 3)
     {
@@ -5341,33 +5134,38 @@
 
       if (arg_3.is_numeric_type () && arg_3.is_empty ())
         npoints = 1;
+      else if (! arg_3.is_scalar_type ())
+        error ("linspace: N must be a scalar");
       else
+        // Even if third arg is not an integer, it must be cast to int
         npoints = arg_3.idx_type_value ();
     }
 
-  if (! error_state)
+  octave_value arg_1 = args(0);
+  octave_value arg_2 = args(1);
+
+  dim_vector sz1 = arg_1.dims ();
+  bool isvector1 = sz1.length () == 2 && (sz1(0) == 1 || sz1(1) == 1);
+  dim_vector sz2 = arg_2.dims ();
+  bool isvector2 = sz2.length () == 2 && (sz2(0) == 1 || sz2(1) == 1);
+
+  if (! isvector1 || ! isvector2)
+    error ("linspace: A, B must be scalars or vectors");
+  else if (arg_1.is_single_type () || arg_2.is_single_type ())
     {
-      octave_value arg_1 = args(0);
-      octave_value arg_2 = args(1);
-
-      if (arg_1.is_single_type () || arg_2.is_single_type ())
-        {
-          if (arg_1.is_complex_type () || arg_2.is_complex_type ())
-            retval = do_linspace<FloatComplexMatrix> (arg_1, arg_2, npoints);
-          else
-            retval = do_linspace<FloatMatrix> (arg_1, arg_2, npoints);
-
-        }
+      if (arg_1.is_complex_type () || arg_2.is_complex_type ())
+        retval = do_linspace<FloatComplexMatrix> (arg_1, arg_2, npoints);
       else
-        {
-          if (arg_1.is_complex_type () || arg_2.is_complex_type ())
-            retval = do_linspace<ComplexMatrix> (arg_1, arg_2, npoints);
-          else
-            retval = do_linspace<Matrix> (arg_1, arg_2, npoints);
-        }
+        retval = do_linspace<FloatMatrix> (arg_1, arg_2, npoints);
+
     }
   else
-    error ("linspace: N must be an integer");
+    {
+      if (arg_1.is_complex_type () || arg_2.is_complex_type ())
+        retval = do_linspace<ComplexMatrix> (arg_1, arg_2, npoints);
+      else
+        retval = do_linspace<Matrix> (arg_1, arg_2, npoints);
+    }
 
   return retval;
 }
@@ -5382,16 +5180,52 @@
 %! 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))
-
+## Test complex values
+%!test
+%! exp = [1+0i, 2-1.25i, 3-2.5i, 4-3.75i, 5-5i];
+%! obs = linspace (1, 5-5i, 5);
+%! assert (obs, exp);
+
+## Test support for vectors in BASE and LIMIT
+%!assert (linspace ([1 2 3], [7 8 9]),
+%!        [linspace(1, 7); linspace(2, 8); linspace(3, 9)])
+%!assert (linspace ([1 2 3]', [7 8 9]'),
+%!        [linspace(1, 7); linspace(2, 8); linspace(3, 9)])
+%!assert (linspace ([1 2 3], 9),
+%!        [linspace(1, 9); linspace(2, 9); linspace(3, 9)])
+%!assert (linspace ([1 2 3]', 9),
+%!        [linspace(1, 9); linspace(2, 9); linspace(3, 9)])
+%!assert (linspace (1, [7 8 9]),
+%!        [linspace(1, 7); linspace(1, 8); linspace(1, 9)])
+%!assert (linspace (1, [7 8 9]'),
+%!        [linspace(1, 7); linspace(1, 8); linspace(1, 9)])
+
+## Test class of output
+%!assert (class (linspace (1, 2)), "double")
+%!assert (class (linspace (single (1), 2)), "single")
+%!assert (class (linspace (1, single (2))), "single")
+
+## Test obscure Matlab compatibility options
 %!assert (linspace (0, 1, []), 1)
+%!assert (linspace (10, 20, 2), [10 20])
+%!assert (linspace (10, 20, 1), [20])
+%!assert (linspace (10, 20, 0), zeros (1, 0))
+%!assert (linspace (10, 20, -1), zeros (1, 0))
+%!assert (numel (linspace (0, 1, 2+eps)), 2)
+%!assert (numel (linspace (0, 1, 2-eps)), 1)
+%!assert (linspace (10, 20, 2.1), [10 20])
+%!assert (linspace (10, 20, 2.9), [10 20])
 
 %!error linspace ()
 %!error linspace (1, 2, 3, 4)
+%!error <N must be a scalar> linspace (1, 2, [3, 4])
+%!error <must be scalars or vectors> linspace (ones (2,2), 2, 3)
+%!error <must be scalars or vectors> linspace (2, ones (2,2), 3)
+%!error <must be scalars or vectors> linspace (1, [], 3)
 */
 
-// FIXME: should accept dimensions as separate args for N-d
-// arrays as well as 1-d and 2-d arrays.
+// FIXME: should accept dimensions as separate args for N-D
+// arrays as well as 1-D and 2-D arrays.
 
 DEFUN (resize, args, ,
        "-*- texinfo -*-\n\
@@ -5441,12 +5275,16 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
 
+  if (nargin < 2)
+    print_usage ();
+
   if (nargin == 2)
     {
       Array<double> vec = args(1).vector_value ();
-      int ndim = vec.length ();
+      int ndim = vec.numel ();
       if (ndim == 1)
         {
           octave_idx_type m = static_cast<octave_idx_type> (vec(0));
@@ -5463,21 +5301,17 @@
           retval = retval.resize (dv, true);
         }
     }
-  else if (nargin > 2)
+  else
     {
       dim_vector dv;
       dv.resize (nargin - 1);
       for (octave_idx_type i = 1; i < nargin; i++)
         dv(i-1) = static_cast<octave_idx_type> (args(i).scalar_value ());
-      if (!error_state)
-        {
-          retval = args(0);
-          retval = retval.resize (dv, true);
-        }
-
+
+      retval = args(0);
+      retval = retval.resize (dv, true);
     }
-  else
-    print_usage ();
+
   return retval;
 }
 
@@ -5521,21 +5355,24 @@
 
   int nargin = args.length ();
 
+  if (nargin < 2)
+    print_usage ();
+
   dim_vector new_dims;
 
   if (nargin == 2)
     {
       Array<octave_idx_type> new_size = args(1).octave_idx_type_vector_value ();
 
-      if (new_size.length () < 2)
+      if (new_size.numel () < 2)
         {
           error ("reshape: SIZE must have 2 or more dimensions");
           return retval;
         }
 
-      new_dims = dim_vector::alloc (new_size.length ());
-
-      for (octave_idx_type i = 0; i < new_size.length (); i++)
+      new_dims = dim_vector::alloc (new_size.numel ());
+
+      for (octave_idx_type i = 0; i < new_size.numel (); i++)
         {
           if (new_size(i) < 0)
             {
@@ -5546,7 +5383,7 @@
             new_dims(i) = new_size(i);
         }
     }
-  else if (nargin > 2)
+  else
     {
       new_dims = dim_vector::alloc (nargin-1);
       int empty_dim = -1;
@@ -5570,9 +5407,7 @@
             {
               new_dims(i-1) = args(i).idx_type_value ();
 
-              if (error_state)
-                break;
-              else if (new_dims(i-1) < 0)
+              if (new_dims(i-1) < 0)
                 {
                   error ("reshape: SIZE must be non-negative");
                   break;
@@ -5580,7 +5415,7 @@
             }
         }
 
-      if (! error_state && (empty_dim > 0))
+      if (empty_dim > 0)
         {
           octave_idx_type nel = new_dims.numel ();
 
@@ -5599,14 +5434,8 @@
             }
         }
     }
-  else
-    {
-      print_usage ();
-      return retval;
-    }
-
-  if (! error_state)
-    retval = args(0).reshape (new_dims);
+
+  retval = args(0).reshape (new_dims);
 
   return retval;
 }
@@ -5658,7 +5487,7 @@
   if (nargin < 1 || nargin > 2)
     print_usage () ;
 
-  if (! error_state && nargin == 2)
+  if (nargin == 2)
     {
       dim = args(1).idx_type_value ();
 
@@ -5666,24 +5495,21 @@
         error ("vec: DIM must be greater than zero");
     }
 
-  if (! error_state)
+  octave_value colon (octave_value::magic_colon_t);
+  octave_value arg = args(0);
+  retval = arg.single_subsref ("(", colon);
+
+
+  if (dim > 1)
     {
-      octave_value colon (octave_value::magic_colon_t);
-      octave_value arg = args(0);
-      retval = arg.single_subsref ("(", colon);
-
-
-      if (! error_state && dim > 1)
-        {
-          dim_vector new_dims = dim_vector::alloc (dim);
-
-          for (int i = 0; i < dim-1; i++)
-            new_dims(i) = 1;
-
-          new_dims(dim-1) = retval.numel ();
-
-          retval = retval.reshape (new_dims);
-        }
+      dim_vector new_dims = dim_vector::alloc (dim);
+
+      for (int i = 0; i < dim-1; i++)
+        new_dims(i) = 1;
+
+      new_dims(dim-1) = retval.numel ();
+
+      retval = retval.reshape (new_dims);
     }
 
   return retval;
@@ -5714,14 +5540,10 @@
 @seealso{reshape}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).squeeze ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).squeeze ());
 }
 
 DEFUN (full, args, ,
@@ -5732,14 +5554,10 @@
 @seealso{sparse, issparse}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).full_value ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).full_value ());
 }
 
 // Compute various norms of the vector X.
@@ -5808,84 +5626,80 @@
 
   int nargin = args.length ();
 
-  if (nargin >= 1 && nargin <= 3)
+  if (nargin < 1 && nargin > 3)
+    print_usage ();
+
+  octave_value x_arg = args(0);
+
+  if (x_arg.ndims () == 2)
     {
-      octave_value x_arg = args(0);
-
-      if (x_arg.ndims () == 2)
+      enum { sfmatrix, sfcols, sfrows, sffrob, sfinf } strflag = sfmatrix;
+      if (nargin > 1 && args(nargin-1).is_string ())
         {
-          enum { sfmatrix, sfcols, sfrows, sffrob, sfinf } strflag = sfmatrix;
-          if (nargin > 1 && args(nargin-1).is_string ())
+          std::string str = args(nargin-1).string_value ();
+          if (str == "cols" || str == "columns")
+            strflag = sfcols;
+          else if (str == "rows")
+            strflag = sfrows;
+          else if (str == "fro")
+            strflag = sffrob;
+          else if (str == "inf")
+            strflag = sfinf;
+          else
+            error ("norm: unrecognized option: %s", str.c_str ());
+          // we've handled the last parameter, so act as if it was removed
+          nargin --;
+        }
+
+      octave_value p_arg = (nargin > 1) ? args(1) : octave_value (2);
+
+      if (p_arg.is_empty ())
+        p_arg = octave_value (2);
+      else if (p_arg.is_string ())
+        {
+          std::string str = p_arg.string_value ();
+          if ((strflag == sfcols || strflag == sfrows))
             {
-              std::string str = args(nargin-1).string_value ();
-              if (str == "cols" || str == "columns")
-                strflag = sfcols;
-              else if (str == "rows")
-                strflag = sfrows;
+              if (str == "cols" || str == "columns" || str == "rows")
+                error ("norm: invalid combination of options");
               else if (str == "fro")
-                strflag = sffrob;
+                p_arg = octave_value (2);
               else if (str == "inf")
-                strflag = sfinf;
+                p_arg = octave_Inf;
               else
                 error ("norm: unrecognized option: %s", str.c_str ());
-              // we've handled the last parameter, so act as if it was removed
-              nargin --;
             }
-
-          if (! error_state)
-            {
-              octave_value p_arg = (nargin > 1) ? args(1) : octave_value (2);
-
-              if (p_arg.is_empty ())
-                p_arg = octave_value (2);
-              else if (p_arg.is_string ())
-                {
-                  std::string str = p_arg.string_value ();
-                  if ((strflag == sfcols || strflag == sfrows))
-                    {
-                      if (str == "cols" || str == "columns" || str == "rows")
-                        error ("norm: invalid combination of options");
-                      else if (str == "fro")
-                        p_arg = octave_value (2);
-                      else if (str == "inf")
-                        p_arg = octave_Inf;
-                      else
-                        error ("norm: unrecognized option: %s", str.c_str ());
-                    }
-                  else
-                    error ("norm: invalid combination of options");
-                }
-              else if (! p_arg.is_scalar_type ())
-                gripe_wrong_type_arg ("norm", p_arg, true);
-
-              if (! error_state)
-                {
-                  switch (strflag)
-                    {
-                    case sfmatrix:
-                      retval(0) = xnorm (x_arg, p_arg);
-                      break;
-                    case sfcols:
-                      retval(0) = xcolnorms (x_arg, p_arg);
-                      break;
-                    case sfrows:
-                      retval(0) = xrownorms (x_arg, p_arg);
-                      break;
-                    case sffrob:
-                      retval(0) = xfrobnorm (x_arg);
-                      break;
-                    case sfinf:
-                      retval(0) = xnorm (x_arg, octave_Inf);
-                      break;
-                    }
-                }
-            }
+          else
+            error ("norm: invalid combination of options");
         }
-      else
-        error ("norm: only valid for 2-D objects");
+      else if (! p_arg.is_scalar_type ())
+        gripe_wrong_type_arg ("norm", p_arg, true);
+
+      switch (strflag)
+        {
+        case sfmatrix:
+          retval(0) = xnorm (x_arg, p_arg);
+          break;
+
+        case sfcols:
+          retval(0) = xcolnorms (x_arg, p_arg);
+          break;
+
+        case sfrows:
+          retval(0) = xrownorms (x_arg, p_arg);
+          break;
+
+        case sffrob:
+          retval(0) = xfrobnorm (x_arg);
+          break;
+
+        case sfinf:
+          retval(0) = xnorm (x_arg, octave_Inf);
+          break;
+        }
     }
   else
-    print_usage ();
+    error ("norm: only valid for 2-D objects");
 
   return retval;
 }
@@ -5964,13 +5778,10 @@
 unary_op_defun_body (octave_value::unary_op op,
                      const octave_value_list& args)
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = do_unary_op (op, args(0));
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return do_unary_op (op, args(0));
 }
 
 DEFUN (not, args, ,
@@ -6073,14 +5884,10 @@
 binary_op_defun_body (octave_value::binary_op op,
                       const octave_value_list& args)
 {
-  octave_value retval;
-
-  if (args.length () == 2)
-    retval = do_binary_op (op, args(0), args(1));
-  else
+  if (args.length () != 2)
     print_usage ();
 
-  return retval;
+  return do_binary_op (op, args(0), args(1));
 }
 
 static octave_value
@@ -6089,24 +5896,22 @@
                             const octave_value_list& args)
 {
   octave_value retval;
+
   int nargin = args.length ();
 
-  switch (nargin)
+  if (nargin == 0)
+    print_usage ();
+
+  if (nargin == 1)
+    retval = args(0);
+  else if (nargin == 2)
+    retval = do_binary_op (op, args(0), args(1));
+  else
     {
-    case 0:
-      print_usage ();
-      break;
-    case 1:
-      retval = args(0);
-      break;
-    case 2:
       retval = do_binary_op (op, args(0), args(1));
-      break;
-    default:
-      retval = do_binary_op (op, args(0), args(1));
+
       for (int i = 2; i < nargin; i++)
         retval.assign (aop, args(i));
-      break;
     }
 
   return retval;
@@ -6384,25 +6189,14 @@
 or @w{@code{base : increment : limit}}.\n\
 @end deftypefn")
 {
-  octave_value retval;
   int nargin = args.length ();
 
-  switch (nargin)
-    {
-    case 2:
-      retval = do_colon_op (args(0), args(1));
-      break;
-
-    case 3:
-      retval = do_colon_op (args(0), args(1), args (2));
-      break;
-
-    default:
-      print_usage ();
-      break;
-    }
-
-  return retval;
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  return (nargin == 2)
+    ? do_colon_op (args(0), args(1))
+    : do_colon_op (args(0), args(1), args (2));
 }
 
 static double tic_toc_timestamp = -1.0;
@@ -6455,9 +6249,7 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 0)
+  if (args.length () != 0)
     warning ("tic: ignoring extra arguments");
 
   octave_time now;
@@ -6494,44 +6286,34 @@
 
   if (nargin > 1)
     print_usage ();
+
+  if (nargin == 1)
+    {
+      octave_uint64 id = args(0).xuint64_scalar_value ("toc: invalid ID");
+
+      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?
+    }
+
+  if (start_time < 0)
+    error ("toc called before timer set");
   else
     {
-      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";
-            }
-        }
+      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;
@@ -6564,11 +6346,10 @@
 @end deftypefn")
 {
   octave_value_list retval;
-  int nargin = args.length ();
   double usr = 0.0;
   double sys = 0.0;
 
-  if (nargin != 0)
+  if (args.length () != 0)
     warning ("tic: ignoring extra arguments");
 
 #if defined (HAVE_GETRUSAGE)
@@ -6692,10 +6473,7 @@
   sortmode smode = ASCENDING;
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   bool return_idx = nargout > 1;
 
@@ -6712,10 +6490,7 @@
           else if (mode == "descend")
             smode = DESCENDING;
           else
-            {
-              error ("sort: MODE must be either \"ascend\" or \"descend\"");
-              return retval;
-            }
+            error ("sort: MODE must be either \"ascend\" or \"descend\"");
         }
       else
         dim = args(1).nint_value () - 1;
@@ -6724,26 +6499,16 @@
   if (nargin > 2)
     {
       if (args(1).is_string ())
-        {
-          print_usage ();
-          return retval;
-        }
-
-      if (! args(2).is_string ())
-        {
-          error ("sort: MODE must be a string");
-          return retval;
-        }
-      std::string mode = args(2).string_value ();
+        error ("sort: DIM must be a valid dimension");
+
+      std::string mode = args(2).xstring_value ("sort: MODE must be a string");
+
       if (mode == "ascend")
         smode = ASCENDING;
       else if (mode == "descend")
         smode = DESCENDING;
       else
-        {
-          error ("sort: MODE must be either \"ascend\" or \"descend\"");
-          return retval;
-        }
+        error ("sort: MODE must be either \"ascend\" or \"descend\"");
     }
 
   const dim_vector dv = arg.dims ();
@@ -6755,10 +6520,7 @@
   else
     {
       if (dim < 0)
-        {
-          error ("sort: DIM must be a valid dimension");
-          return retval;
-        }
+        error ("sort: DIM must be a valid dimension");
     }
 
   if (return_idx)
@@ -6968,11 +6730,11 @@
   int nargin = args.length ();
   sortmode smode = ASCENDING;
 
-  if (nargin < 1 || nargin > 2 || (nargin == 2 && ! args(1).is_string ()))
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  if (nargin == 2 && ! args(1).is_string ())
+    error ("__sort_rows_idx__: second argument must be a string");
 
   if (nargin > 1)
     {
@@ -7005,27 +6767,23 @@
 }
 
 static sortmode
-get_sort_mode_option (const octave_value& arg, const char *argn)
+get_sort_mode_option (const octave_value& arg)
 {
   // FIXME: we initialize to UNSORTED here to avoid a GCC warning
   // about possibly using sortmode uninitialized.
   // FIXME: shouldn't these modes be scoped inside a class?
   sortmode smode = UNSORTED;
 
-  if (arg.is_string ())
-    {
-      std::string mode = arg.string_value ();
-      if (mode == "ascending")
-        smode = ASCENDING;
-      else if (mode == "descending")
-        smode = DESCENDING;
-      else if (mode == "either")
-        smode = UNSORTED;
-      else
-        error ("issorted: MODE must be \"ascending\", \"descending\", or \"either\"");
-    }
+  std::string mode = arg.xstring_value ("issorted: MODE must be a string");
+
+  if (mode == "ascending")
+    smode = ASCENDING;
+  else if (mode == "descending")
+    smode = DESCENDING;
+  else if (mode == "either")
+    smode = UNSORTED;
   else
-    error ("issorted: expecting %s argument to be a string", argn);
+    error ("issorted: MODE must be \"ascending\", \"descending\", or \"either\"");
 
   return smode;
 }
@@ -7055,10 +6813,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   bool by_rows = false;
 
@@ -7069,21 +6824,13 @@
       octave_value mode_arg;
 
       if (nargin == 3)
-        smode = get_sort_mode_option (args(2), "third");
-
-      if (args(1).is_string ())
-        {
-          std::string tmp = args(1).string_value ();
-          if (tmp == "rows")
-            by_rows = true;
-          else
-            smode = get_sort_mode_option (args(1), "second");
-        }
+        smode = get_sort_mode_option (args(2));
+
+      std::string tmp = args(1).xstring_value ("issorted: second argument must be a string");
+      if (tmp == "rows")
+        by_rows = true;
       else
-        error ("issorted: second argument must be a string");
-
-      if (error_state)
-        return retval;
+        smode = get_sort_mode_option (args(1));
     }
 
   octave_value arg = args(0);
@@ -7114,32 +6861,44 @@
 %! 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 (um, "rows"))
 %!assert (issorted (sv))
-%!assert (!issorted (uv))
+%!assert (! issorted (uv))
 %!assert (issorted (sv'))
-%!assert (!issorted (uv'))
+%!assert (! issorted (uv'))
 %!assert (issorted (sm, "rows", "ascending"))
-%!assert (!issorted (um, "rows", "ascending"))
+%!assert (! issorted (um, "rows", "ascending"))
 %!assert (issorted (sv, "ascending"))
-%!assert (!issorted (uv, "ascending"))
+%!assert (! issorted (uv, "ascending"))
 %!assert (issorted (sv', "ascending"))
-%!assert (!issorted (uv', "ascending"))
-%!assert (!issorted (sm, "rows", "descending"))
+%!assert (! issorted (uv', "ascending"))
+%!assert (! issorted (sm, "rows", "descending"))
 %!assert (issorted (flipud (sm), "rows", "descending"))
-%!assert (!issorted (sv, "descending"))
+%!assert (! issorted (sv, "descending"))
 %!assert (issorted (fliplr (sv), "descending"))
-%!assert (!issorted (sv', "descending"))
+%!assert (! issorted (sv', "descending"))
 %!assert (issorted (fliplr (sv)', "descending"))
-%!assert (!issorted (um, "rows", "either"))
-%!assert (!issorted (uv, "either"))
+%!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"))
+
+%!error <needs a vector> issorted ([])
+
+## Test input validation
+%!error issorted () 
+%!error issorted (1,2,3,4) 
+%!error <second argument must be a string> issorted (1, 2)
+%!error <second argument must be a string> issorted (1, {"rows"})
+%!error <sparse matrices not yet supported> issorted (sparse ([1 2 3]), "rows")
+%!error <A must be a 2-dimensional object> issorted (rand (2,2,2), "rows")
+%!error <needs a vector> issorted (ones (2,2))
 */
 
 DEFUN (nth_element, args, ,
@@ -7167,27 +6926,28 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  octave_value argx = args(0);
+
+  int dim = -1;
+  if (nargin == 3)
     {
-      octave_value argx = args(0);
-
-      int dim = -1;
-      if (nargin == 3)
-        {
-          dim = args(2).int_value (true) - 1;
-          if (dim < 0)
-            error ("nth_element: DIM must be a valid dimension");
-        }
+      dim = args(2).int_value (true) - 1;
       if (dim < 0)
-        dim = argx.dims ().first_non_singleton ();
-
+        error ("nth_element: DIM must be a valid dimension");
+    }
+  if (dim < 0)
+    dim = argx.dims ().first_non_singleton ();
+
+  try
+    {
       idx_vector n = args(1).index_vector ();
 
-      if (error_state)
-        return retval;
-
       switch (argx.builtin_type ())
         {
         case btyp_double:
@@ -7203,18 +6963,18 @@
           retval = argx.float_complex_array_value ().nth_element (n, dim);
           break;
 #define MAKE_INT_BRANCH(X) \
-        case btyp_ ## X: \
-          retval = argx.X ## _array_value ().nth_element (n, dim); \
-          break;
-
-        MAKE_INT_BRANCH (int8);
-        MAKE_INT_BRANCH (int16);
-        MAKE_INT_BRANCH (int32);
-        MAKE_INT_BRANCH (int64);
-        MAKE_INT_BRANCH (uint8);
-        MAKE_INT_BRANCH (uint16);
-        MAKE_INT_BRANCH (uint32);
-        MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    retval = argx.X ## _array_value ().nth_element (n, dim); \
+    break;
+
+          MAKE_INT_BRANCH (int8);
+          MAKE_INT_BRANCH (int16);
+          MAKE_INT_BRANCH (int32);
+          MAKE_INT_BRANCH (int64);
+          MAKE_INT_BRANCH (uint8);
+          MAKE_INT_BRANCH (uint16);
+          MAKE_INT_BRANCH (uint32);
+          MAKE_INT_BRANCH (uint64);
 #undef MAKE_INT_BRANCH
         default:
           if (argx.is_cellstr ())
@@ -7223,8 +6983,11 @@
             gripe_wrong_type_arg ("nth_element", argx);
         }
     }
-  else
-    print_usage ();
+  catch (const index_exception& e)
+    {
+      index_error ("nth_element: invalid N value %s. %s",
+                   e.idx (), e.details ());
+    }
 
   return retval;
 }
@@ -7259,48 +7022,57 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
-  if (nargin >= 2 && nargin <= 3 && args(0).is_numeric_type ())
+
+  if (nargin < 2 && nargin > 3)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    error ("__accumarray_sum__: first argument must be numeric");
+
+  try
     {
       idx_vector idx = args(0).index_vector ();
       octave_idx_type n = -1;
       if (nargin == 3)
         n = args(2).idx_type_value (true);
 
-      if (! error_state)
+      octave_value vals = args(1);
+
+      if (vals.is_range ())
+        {
+          Range r = vals.range_value ();
+          if (r.inc () == 0)
+            vals = r.base ();
+        }
+
+      if (vals.is_single_type ())
         {
-          octave_value vals = args(1);
-          if (vals.is_range ())
-            {
-              Range r = vals.range_value ();
-              if (r.inc () == 0)
-                vals = r.base ();
-            }
-
-          if (vals.is_single_type ())
-            {
-              if (vals.is_complex_type ())
-                retval = do_accumarray_sum (idx,
-                                            vals.float_complex_array_value (),
-                                            n);
-              else
-                retval = do_accumarray_sum (idx, vals.float_array_value (), n);
-            }
-          else if (vals.is_numeric_type () || vals.is_bool_type ())
-            {
-              if (vals.is_complex_type ())
-                retval = do_accumarray_sum (idx,
-                                            vals.complex_array_value (),
-                                            n);
-              else
-                retval = do_accumarray_sum (idx, vals.array_value (), n);
-            }
+          if (vals.is_complex_type ())
+            retval = do_accumarray_sum (idx,
+                                        vals.float_complex_array_value (),
+                                        n);
           else
-            gripe_wrong_type_arg ("accumarray", vals);
+            retval = do_accumarray_sum (idx, vals.float_array_value (), n);
         }
+      else if (vals.is_numeric_type () || vals.is_bool_type ())
+        {
+          if (vals.is_complex_type ())
+            retval = do_accumarray_sum (idx,
+                                        vals.complex_array_value (),
+                                        n);
+          else
+            retval = do_accumarray_sum (idx, vals.array_value (), n);
+        }
+      else
+        gripe_wrong_type_arg ("accumarray", vals);
     }
-  else
-    print_usage ();
+  catch (const index_exception& e)
+    {
+      index_error ("__accumarray_sum__: invalid IDX %s. %s",
+                   e.idx (), e.details ());
+    }
 
   return retval;
 }
@@ -7339,66 +7111,80 @@
                           bool ismin)
 {
   octave_value retval;
+
   int nargin = args.length ();
-  if (nargin >= 3 && nargin <= 4 && args(0).is_numeric_type ())
+
+  if (nargin < 3 && nargin > 4)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    error ("accumarray: first argument must be numeric");
+
+  try
     {
       idx_vector idx = args(0).index_vector ();
       octave_idx_type n = -1;
       if (nargin == 4)
         n = args(3).idx_type_value (true);
 
-      if (! error_state)
+      octave_value vals = args(1);
+      octave_value zero = args(2);
+
+      switch (vals.builtin_type ())
         {
-          octave_value vals = args(1);
-          octave_value zero = args(2);
-
-          switch (vals.builtin_type ())
-            {
-            case btyp_double:
-              retval = do_accumarray_minmax (idx, vals.array_value (), n, ismin,
-                                             zero.double_value ());
-              break;
-            case btyp_float:
-              retval = do_accumarray_minmax (idx, vals.float_array_value (), n,
-                                             ismin, zero.float_value ());
-              break;
-            case btyp_complex:
-              retval = do_accumarray_minmax (idx, vals.complex_array_value (),
-                                             n, ismin, zero.complex_value ());
-              break;
-            case btyp_float_complex:
-              retval = do_accumarray_minmax (idx,
-                                             vals.float_complex_array_value (),
-                                             n, ismin,
-                                             zero.float_complex_value ());
-              break;
+        case btyp_double:
+          retval = do_accumarray_minmax (idx, vals.array_value (), n, ismin,
+                                         zero.double_value ());
+          break;
+
+        case btyp_float:
+          retval = do_accumarray_minmax (idx, vals.float_array_value (), n,
+                                         ismin, zero.float_value ());
+          break;
+
+        case btyp_complex:
+          retval = do_accumarray_minmax (idx, vals.complex_array_value (),
+                                         n, ismin, zero.complex_value ());
+          break;
+
+        case btyp_float_complex:
+          retval = do_accumarray_minmax (idx,
+                                         vals.float_complex_array_value (),
+                                         n, ismin,
+                                         zero.float_complex_value ());
+          break;
+
 #define MAKE_INT_BRANCH(X) \
-            case btyp_ ## X: \
-              retval = do_accumarray_minmax (idx, vals.X ## _array_value (), \
-                                             n, ismin, \
-                                             zero.X ## _scalar_value ()); \
-              break;
-
-            MAKE_INT_BRANCH (int8);
-            MAKE_INT_BRANCH (int16);
-            MAKE_INT_BRANCH (int32);
-            MAKE_INT_BRANCH (int64);
-            MAKE_INT_BRANCH (uint8);
-            MAKE_INT_BRANCH (uint16);
-            MAKE_INT_BRANCH (uint32);
-            MAKE_INT_BRANCH (uint64);
+  case btyp_ ## X: \
+    retval = do_accumarray_minmax (idx, vals.X ## _array_value (), \
+                                   n, ismin, zero.X ## _scalar_value ()); \
+            break;
+
+          MAKE_INT_BRANCH (int8);
+          MAKE_INT_BRANCH (int16);
+          MAKE_INT_BRANCH (int32);
+          MAKE_INT_BRANCH (int64);
+          MAKE_INT_BRANCH (uint8);
+          MAKE_INT_BRANCH (uint16);
+          MAKE_INT_BRANCH (uint32);
+          MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
-            case btyp_bool:
-              retval = do_accumarray_minmax (idx, vals.array_value (), n, ismin,
-                                             zero.bool_value ());
-              break;
-            default:
-              gripe_wrong_type_arg ("accumarray", vals);
-            }
+
+        case btyp_bool:
+          retval = do_accumarray_minmax (idx, vals.array_value (), n, ismin,
+                                         zero.bool_value ());
+          break;
+
+        default:
+          gripe_wrong_type_arg ("accumarray", vals);
         }
     }
-  else
-    print_usage ();
+  catch (const index_exception& e)
+    {
+      index_error ("do_accumarray_minmax_fun: invalid index %s. %s",
+                   e.idx (), e.details ());
+    }
 
   return retval;
 }
@@ -7459,8 +7245,16 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
-  if (nargin >= 2 && nargin <= 4 && args(0).is_numeric_type ())
+
+  if (nargin < 2 && nargin > 4)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    error ("__accumdim_sum__: first argument must be numeric");
+
+  try
     {
       idx_vector idx = args(0).index_vector ();
       int dim = -1;
@@ -7471,34 +7265,34 @@
       if (nargin == 4)
         n = args(3).idx_type_value (true);
 
-      if (! error_state)
+      octave_value vals = args(1);
+
+      if (vals.is_single_type ())
+        {
+          if (vals.is_complex_type ())
+            retval = do_accumdim_sum (idx,
+                                      vals.float_complex_array_value (),
+                                      dim, n);
+          else
+            retval = do_accumdim_sum (idx, vals.float_array_value (),
+                                      dim, n);
+        }
+      else if (vals.is_numeric_type () || vals.is_bool_type ())
         {
-          octave_value vals = args(1);
-
-          if (vals.is_single_type ())
-            {
-              if (vals.is_complex_type ())
-                retval = do_accumdim_sum (idx,
-                                          vals.float_complex_array_value (),
-                                          dim, n);
-              else
-                retval = do_accumdim_sum (idx, vals.float_array_value (),
-                                          dim, n);
-            }
-          else if (vals.is_numeric_type () || vals.is_bool_type ())
-            {
-              if (vals.is_complex_type ())
-                retval = do_accumdim_sum (idx, vals.complex_array_value (),
-                                          dim, n);
-              else
-                retval = do_accumdim_sum (idx, vals.array_value (), dim, n);
-            }
+          if (vals.is_complex_type ())
+            retval = do_accumdim_sum (idx, vals.complex_array_value (),
+                                      dim, n);
           else
-            gripe_wrong_type_arg ("accumdim", vals);
+            retval = do_accumdim_sum (idx, vals.array_value (), dim, n);
         }
+      else
+        gripe_wrong_type_arg ("accumdim", vals);
     }
-  else
-    print_usage ();
+  catch (const index_exception& e)
+    {
+      index_error ("__accumdim_sum__: invalid IDX %s. %s",
+                   e.idx (), e.details ());
+    }
 
   return retval;
 }
@@ -7599,74 +7393,76 @@
 @seealso{logical, diff}\n\
 @end deftypefn")
 {
-  int nargin = args.length ();
   octave_value retval;
 
-  if (nargin == 3 && (args(0).is_bool_type () || args(0).is_numeric_type ()))
+  if (args.length () != 3)
+    print_usage ();
+
+  if (! (args(0).is_bool_type () || args(0).is_numeric_type ()))
+    error ("merge: first argument must be logical or numeric");
+
+  octave_value mask_val = args(0);
+
+  if (mask_val.is_scalar_type ())
+    retval = mask_val.is_true () ? args(1) : args(2);
+  else
     {
-      octave_value mask_val = args(0);
-
-      if (mask_val.is_scalar_type ())
-        retval = mask_val.is_true () ? args(1) : args(2);
-      else
+      boolNDArray mask = mask_val.bool_array_value ();
+
+      octave_value tval = args(1);
+      octave_value fval = args(2);
+
+      if (tval.is_double_type () && fval.is_double_type ())
+        {
+          if (tval.is_complex_type () || fval.is_complex_type ())
+            retval = do_merge (mask,
+                               tval.complex_array_value (),
+                               fval.complex_array_value ());
+          else
+            retval = do_merge (mask,
+                               tval.array_value (),
+                               fval.array_value ());
+        }
+      else if (tval.is_single_type () && fval.is_single_type ())
         {
-          boolNDArray mask = mask_val.bool_array_value ();
-          octave_value tval = args(1);
-          octave_value fval = args(2);
-          if (tval.is_double_type () && fval.is_double_type ())
-            {
-              if (tval.is_complex_type () || fval.is_complex_type ())
-                retval = do_merge (mask,
-                                   tval.complex_array_value (),
-                                   fval.complex_array_value ());
-              else
-                retval = do_merge (mask,
-                                   tval.array_value (),
-                                   fval.array_value ());
-            }
-          else if (tval.is_single_type () && fval.is_single_type ())
-            {
-              if (tval.is_complex_type () || fval.is_complex_type ())
-                retval = do_merge (mask,
-                                   tval.float_complex_array_value (),
-                                   fval.float_complex_array_value ());
-              else
-                retval = do_merge (mask,
-                                   tval.float_array_value (),
-                                   fval.float_array_value ());
-            }
-          else if (tval.is_string () && fval.is_string ())
-            {
-              bool sq_string = tval.is_sq_string () || fval.is_sq_string ();
-              retval = octave_value (do_merge (mask,
-                                               tval.char_array_value (),
-                                               fval.char_array_value ()),
-                                     sq_string ? '\'' : '"');
-            }
-          else if (tval.is_cell () && fval.is_cell ())
-            {
-              retval = do_merge (mask,
-                                 tval.cell_value (),
-                                 fval.cell_value ());
-            }
-
-          MAKE_INT_BRANCH (int8)
-          MAKE_INT_BRANCH (int16)
-          MAKE_INT_BRANCH (int32)
-          MAKE_INT_BRANCH (int64)
-          MAKE_INT_BRANCH (uint8)
-          MAKE_INT_BRANCH (uint16)
-          MAKE_INT_BRANCH (uint32)
-          MAKE_INT_BRANCH (uint64)
-
+          if (tval.is_complex_type () || fval.is_complex_type ())
+            retval = do_merge (mask,
+                               tval.float_complex_array_value (),
+                               fval.float_complex_array_value ());
           else
-            error ("merge: cannot merge %s with %s with array mask",
-                   tval.class_name ().c_str (),
-                   fval.class_name ().c_str ());
+            retval = do_merge (mask,
+                               tval.float_array_value (),
+                               fval.float_array_value ());
+        }
+      else if (tval.is_string () && fval.is_string ())
+        {
+          bool sq_string = tval.is_sq_string () || fval.is_sq_string ();
+          retval = octave_value (do_merge (mask,
+                                           tval.char_array_value (),
+                                           fval.char_array_value ()),
+                                 sq_string ? '\'' : '"');
         }
+      else if (tval.is_cell () && fval.is_cell ())
+        {
+          retval = do_merge (mask,
+                             tval.cell_value (),
+                             fval.cell_value ());
+        }
+
+        MAKE_INT_BRANCH (int8)
+        MAKE_INT_BRANCH (int16)
+        MAKE_INT_BRANCH (int32)
+        MAKE_INT_BRANCH (int64)
+        MAKE_INT_BRANCH (uint8)
+        MAKE_INT_BRANCH (uint16)
+        MAKE_INT_BRANCH (uint32)
+        MAKE_INT_BRANCH (uint64)
+
+      else
+        error ("merge: cannot merge %s with %s with array mask",
+               tval.class_name ().c_str (),
+               fval.class_name ().c_str ());
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -7831,41 +7627,39 @@
 @seealso{sort, merge}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
   int nargin = args.length ();
-  octave_value retval;
 
   if (nargin < 1 || nargin > 3)
     print_usage ();
-  else if (! (args(0).is_numeric_type () || args(0).is_bool_type ()))
+
+  if (! (args(0).is_numeric_type () || args(0).is_bool_type ()))
     error ("diff: X must be numeric or logical");
 
-  if (! error_state)
+  int dim = -1;
+  octave_idx_type order = 1;
+  if (nargin > 1)
     {
-      int dim = -1;
-      octave_idx_type order = 1;
-      if (nargin > 1)
-        {
-          if (args(1).is_scalar_type ())
-            order = args(1).idx_type_value (true, false);
-          else if (! args(1).is_zero_by_zero ())
-            error ("order K must be a scalar or []");
-          if (! error_state && order < 0)
-            error ("order K must be non-negative");
-        }
-
-      if (nargin > 2)
-        {
-          dim = args(2).int_value (true, false);
-          if (! error_state && (dim < 1 || dim > args(0).ndims ()))
-            error ("DIM must be a valid dimension");
-          else
-            dim -= 1;
-        }
-
-      if (! error_state)
-        retval = do_diff (args(0), order, dim);
+      if (args(1).is_scalar_type ())
+        order = args(1).idx_type_value (true, false);
+      else if (! args(1).is_zero_by_zero ())
+        error ("diff: order K must be a scalar or []");
+      if (order < 0)
+        error ("diff: order K must be non-negative");
     }
 
+  if (nargin > 2)
+    {
+      dim = args(2).int_value (true, false);
+      if (dim < 1 || dim > args(0).ndims ())
+        error ("diff: DIM must be a valid dimension");
+      else
+        dim -= 1;
+    }
+
+  retval = do_diff (args(0), order, dim);
+
   return retval;
 }
 
@@ -7949,9 +7743,8 @@
       octave_value x = args(0);
 
       const Matrix rm = args(1).matrix_value ();
-      if (error_state)
-        return retval;
-      else if (rm.rows () != 2 || rm.ndims () != 2)
+
+      if (rm.rows () != 2 || rm.ndims () != 2)
         {
           error ("repelems: R must be a matrix with two rows");
           return retval;
@@ -8020,9 +7813,8 @@
 @end deftypefn")
 {
   octave_value_list retval;
-  int nargin = args.length ();
-
-  if (nargin != 1)
+
+  if (args.length () != 1)
     print_usage ();
   else
     {
@@ -8033,21 +7825,20 @@
         error ("base64_encode: encoding complex or sparse data is not supported");
       else if (args(0).is_integer_type ())
         {
-#define MAKE_INT_BRANCH(X)                                              \
-          if (args(0).is_ ## X ## _type ())                             \
-            {                                                           \
-              const X##NDArray in = args(0).  X## _array_value ();      \
-              size_t inlen =                                            \
-                in.numel () * sizeof (X## _t) / sizeof (char);          \
-              const char* inc =                                         \
-                reinterpret_cast<const char*> (in.data ());             \
-              char* out;                                                \
-              if (! error_state                                         \
-                  && octave_base64_encode (inc, inlen, &out))           \
-                {                                                       \
-                  retval(0) = octave_value (out);                       \
-                  ::free (out);                                         \
-                }                                                       \
+#define MAKE_INT_BRANCH(X) \
+          if (args(0).is_ ## X ## _type ()) \
+            { \
+              const X##NDArray in = args(0).  X## _array_value (); \
+              size_t inlen = \
+                in.numel () * sizeof (X## _t) / sizeof (char); \
+              const char* inc = \
+                reinterpret_cast<const char*> (in.data ()); \
+              char* out; \
+              if (octave_base64_encode (inc, inlen, &out)) \
+                { \
+                  retval(0) = octave_value (out); \
+                  ::free (out); \
+                } \
             }
 
           MAKE_INT_BRANCH(int8)
@@ -8071,8 +7862,7 @@
           const char*  inc;
           inc = reinterpret_cast<const char*> (in.data ());
           char* out;
-          if (! error_state
-              && octave_base64_encode (inc, inlen, &out))
+          if (octave_base64_encode (inc, inlen, &out))
             {
               retval(0) = octave_value (out);
               ::free (out);
@@ -8086,8 +7876,7 @@
           const char*  inc;
           inc = reinterpret_cast<const char*> (in.data ());
           char* out;
-          if (! error_state
-              && octave_base64_encode (inc, inlen, &out))
+          if (octave_base64_encode (inc, inlen, &out))
             {
               retval(0) = octave_value (out);
               ::free (out);
@@ -8139,25 +7928,19 @@
           const Array<octave_idx_type> size =
             args(1).octave_idx_type_vector_value ();
 
-          if (! error_state)
-            {
-              dims = dim_vector::alloc (size.length ());
-              for (octave_idx_type i = 0; i < size.length (); i++)
-                dims(i) = size(i);
-            }
+          dims = dim_vector::alloc (size.numel ());
+          for (octave_idx_type i = 0; i < size.numel (); i++)
+            dims(i) = size(i);
         }
 
       const std::string str = args(0).string_value ();
 
-      if (! error_state)
-        {
-          Array<double> res = octave_base64_decode (str);
-
-          if (nargin > 1)
-            res = res.reshape (dims);
-
-          retval = res;
-        }
+      Array<double> res = octave_base64_decode (str);
+
+      if (nargin > 1)
+        res = res.reshape (dims);
+
+      retval = res;
     }
 
   return retval;
--- a/libinterp/corefcn/data.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/data.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_data_h)
+#if ! defined (octave_data_h)
 #define octave_data_h 1
 
 #include <string>
--- a/libinterp/corefcn/debug.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/debug.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -196,7 +196,6 @@
 parse_dbfunction_params (const char *who, const octave_value_list& args,
                          std::string& symbol_name, bp_table::intmap& lines)
 {
-  int nargin = args.length ();
   int idx = 0;
   int list_idx = 0;
   symbol_name = std::string ();
@@ -210,15 +209,11 @@
       // string could be function name or line number
       int isint = atoi (args(0).string_value ().c_str ());
 
-      if (error_state)
-        return;
-
       if (isint == 0)
         {
           // It was a function name
           symbol_name = args(0).string_value ();
-          if (error_state)
-            return;
+
           idx = 1;
         }
       else
@@ -230,9 +225,7 @@
               idx = 0;
             }
           else
-            {
-              error ("%s: no function specified", who);
-            }
+            error ("%s: no function specified", who);
         }
     }
   else if (args(0).is_map ())
@@ -240,18 +233,16 @@
       // This is a problem because parse_dbfunction_params()
       // can only pass out a single function.
       error ("%s: struct input not implemented", who);
-      return;
     }
   else
     error ("%s: invalid parameter specified", who);
 
-  for (int i = idx; i < nargin; i++)
+  for (int i = idx; i < args.length (); i++)
     {
       if (args(i).is_string ())
         {
           int line = atoi (args(i).string_value ().c_str ());
-          if (error_state)
-            break;
+
           lines[list_idx++] = line;
         }
       else if (args(i).is_map ())
@@ -260,19 +251,12 @@
         {
           const NDArray arg = args(i).array_value ();
 
-          if (error_state)
-            break;
-
-          for (octave_idx_type j = 0; j < arg.nelem (); j++)
+          for (octave_idx_type j = 0; j < arg.numel (); j++)
             {
               int line = static_cast<int> (arg.elem (j));
-              if (error_state)
-                break;
+
               lines[list_idx++] = line;
             }
-
-          if (error_state)
-            break;
         }
     }
 }
@@ -291,10 +275,7 @@
     }
 
   if (! instance)
-    {
-      ::error ("unable to create breakpoint table!");
-      retval = false;
-    }
+    error ("unable to create breakpoint table!");
 
   return retval;
 }
@@ -649,8 +630,7 @@
   if (lines.size () == 0)
     lines[0] = 1;
 
-  if (! error_state)
-    retval = bp_table::add_breakpoint (symbol_name, lines);
+  retval = bp_table::add_breakpoint (symbol_name, lines);
 
   return intmap_to_ov (retval);
 }
@@ -696,17 +676,12 @@
   std::string symbol_name = "";
   bp_table::intmap lines;
 
-  int nargin = args.length ();
-
   parse_dbfunction_params ("dbclear", args, symbol_name, lines);
 
-  if (nargin == 1 && symbol_name == "all")
+  if (args.length () == 1 && symbol_name == "all")
     bp_table::remove_all_breakpoints ();
   else
-    {
-      if (! error_state)
-        bp_table::remove_breakpoint (symbol_name, lines);
-    }
+    bp_table::remove_breakpoint (symbol_name, lines);
 
   return retval;
 }
@@ -752,10 +727,7 @@
   std::string symbol_name;
 
   if (nargin != 0 && nargin != 1)
-    {
-      error ("dbstatus: only zero or one arguments accepted\n");
-      return octave_value ();
-    }
+    error ("dbstatus: only zero or one arguments accepted\n");
 
   if (nargin == 1)
     {
@@ -942,137 +914,124 @@
   octave_value retval;
   octave_user_code *dbg_fcn;
 
-  int nargin = args.length ();
   string_vector argv = args.make_argv ("dbtype");
 
-  if (! error_state)
+  switch (args.length ())
     {
-      switch (nargin)
-        {
-        case 0: // dbtype
-          dbg_fcn = get_user_code ();
+    case 0: // dbtype
+      dbg_fcn = get_user_code ();
+
+      if (dbg_fcn)
+        do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
+                   0, std::numeric_limits<int>::max ());
+      else
+        error ("dbtype: must be inside a user function to give no arguments to dbtype\n");
+
+      break;
+
+    case 1: // (dbtype start:end) || (dbtype func) || (dbtype lineno)
+      {
+        std::string arg = argv[1];
+
+        size_t ind = arg.find (':');
+
+        if (ind != std::string::npos)  // (dbtype start:end)
+          {
+            dbg_fcn = get_user_code ();
+
+            if (dbg_fcn)
+              {
+                std::string start_str = arg.substr (0, ind);
+                std::string end_str = arg.substr (ind + 1);
 
-          if (dbg_fcn)
-            do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
-                       0, std::numeric_limits<int>::max ());
-          else
-            error ("dbtype: must be inside a user function to give no arguments to dbtype\n");
+                int start, end;
+                start = atoi (start_str.c_str ());
+                if (end_str == "end")
+                  end = std::numeric_limits<int>::max ();
+                else
+                  end = atoi (end_str.c_str ());
 
-          break;
+                if (std::min (start, end) <= 0)
+                  error ("dbtype: start and end lines must be >= 1\n");
 
-        case 1: // (dbtype start:end) || (dbtype func) || (dbtype lineno)
+                if (start <= end)
+                  do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
+                             start, end);
+                else
+                  error ("dbtype: start line must be less than end line\n");
+              }
+          }
+        else  // (dbtype func) || (dbtype lineno)
           {
-            std::string arg = argv[1];
+            int line = atoi (arg.c_str ());
 
-            size_t ind = arg.find (':');
+            if (line == 0)  // (dbtype func)
+              {
+                dbg_fcn = get_user_code (arg);
 
-            if (ind != std::string::npos)  // (dbtype start:end)
+                if (dbg_fcn)
+                  do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
+                             0, std::numeric_limits<int>::max ());
+                else
+                  error ("dbtype: function <%s> not found\n", arg.c_str ());
+              }
+            else  // (dbtype lineno)
               {
+                if (line <= 0)
+                  error ("dbtype: start and end lines must be >= 1\n");
+
                 dbg_fcn = get_user_code ();
 
                 if (dbg_fcn)
-                  {
-                    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 = std::numeric_limits<int>::max ();
-                    else
-                      end = atoi (end_str.c_str ());
-
-                    if (std::min (start, end) <= 0)
-                      {
-                        error ("dbtype: start and end lines must be >= 1\n");
-                        break;
-                      }
-
-                    if (start <= end)
-                      do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
-                                 start, end);
-                    else
-                      error ("dbtype: start line must be less than end line\n");
-                  }
-              }
-            else  // (dbtype func) || (dbtype lineno)
-              {
-                int line = atoi (arg.c_str ());
-
-                if (line == 0)  // (dbtype func)
-                  {
-                    dbg_fcn = get_user_code (arg);
-
-                    if (dbg_fcn)
-                      do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
-                                 0, std::numeric_limits<int>::max ());
-                    else
-                      error ("dbtype: function <%s> not found\n", arg.c_str ());
-                  }
-                else  // (dbtype lineno)
-                  {
-                    if (line <= 0)
-                      {
-                        error ("dbtype: start and end lines must be >= 1\n");
-                        break;
-                      }
-
-                    dbg_fcn = get_user_code ();
-
-                    if (dbg_fcn)
-                      do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
-                                 line, line);
-                  }
+                  do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
+                             line, line);
               }
           }
-          break;
-
-        case 2: // (dbtype func start:end) || (dbtype func start)
-          dbg_fcn = get_user_code (argv[1]);
+      }
+      break;
 
-          if (dbg_fcn)
-            {
-              std::string arg = argv[2];
-              int start, end;
-              size_t ind = arg.find (':');
-
-              if (ind != std::string::npos)
-                {
-                  std::string start_str = arg.substr (0, ind);
-                  std::string end_str = arg.substr (ind + 1);
+    case 2: // (dbtype func start:end) || (dbtype func start)
+      dbg_fcn = get_user_code (argv[1]);
 
-                  start = atoi (start_str.c_str ());
-                  if (end_str == "end")
-                    end = std::numeric_limits<int>::max ();
-                  else
-                    end = atoi (end_str.c_str ());
-                }
-              else
-                {
-                  start = atoi (arg.c_str ());
-                  end = start;
-                }
+      if (dbg_fcn)
+        {
+          std::string arg = argv[2];
+          int start, end;
+          size_t ind = arg.find (':');
 
-              if (std::min (start, end) <= 0)
-                {
-                  error ("dbtype: start and end lines must be >= 1\n");
-                  break;
-                }
+          if (ind != std::string::npos)
+            {
+              std::string start_str = arg.substr (0, ind);
+              std::string end_str = arg.substr (ind + 1);
 
-              if (start <= end)
-                do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
-                           start, end);
+              start = atoi (start_str.c_str ());
+              if (end_str == "end")
+                end = std::numeric_limits<int>::max ();
               else
-                error ("dbtype: start line must be less than end line\n");
+                end = atoi (end_str.c_str ());
             }
           else
-            error ("dbtype: function <%s> not found\n", argv[1].c_str ());
+            {
+              start = atoi (arg.c_str ());
+              end = start;
+            }
 
-          break;
+          if (std::min (start, end) <= 0)
+            error ("dbtype: start and end lines must be >= 1\n");
 
-        default:
-          error ("dbtype: expecting zero, one, or two arguments\n");
+          if (start <= end)
+            do_dbtype (octave_stdout, dbg_fcn->fcn_file_name (),
+                       start, end);
+          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:
+      error ("dbtype: expecting zero, one, or two arguments\n");
     }
 
   return retval;
@@ -1164,15 +1123,18 @@
 
   size_t nskip = 0;
 
-  octave_idx_type len = args.length ();
+  int nargin = args.length ();
 
   // dbstack accepts up to 2 arguments.
 
-  if (len == 1 || len == 2)
+  if (nargin > 2)
+    print_usage ();
+
+  if (nargin == 1 || nargin == 2)
     {
       int n = 0;
 
-      for (octave_idx_type i = 0; i < len && ! error_state; i++)
+      for (octave_idx_type i = 0; i < nargin; i++)
         {
           octave_value arg = args(i);
 
@@ -1190,73 +1152,68 @@
           else
             n = arg.int_value ();
 
-          if (! error_state && n <= 0)
+          if (n <= 0)
             error ("dbstack: N must be a non-negative integer");
         }
 
       if (n > 0)
         nskip = n;
     }
-  else if (len)
-    print_usage ();
 
-  if (! error_state)
+  if (nargout == 0)
     {
-      if (nargout == 0)
+      octave_map stk = octave_call_stack::backtrace (nskip, curr_frame);
+      octave_idx_type nframes_to_display = stk.numel ();
+
+      if (nframes_to_display > 0)
         {
-          octave_map stk = octave_call_stack::backtrace (nskip, curr_frame);
-          octave_idx_type nframes_to_display = stk.numel ();
+          octave_preserve_stream_state stream_state (os);
 
-          if (nframes_to_display > 0)
-            {
-              octave_preserve_stream_state stream_state (os);
+          os << "stopped in:\n\n";
 
-              os << "stopped in:\n\n";
+          Cell names = stk.contents ("name");
+          Cell files = stk.contents ("file");
+          Cell lines = stk.contents ("line");
 
-              Cell names = stk.contents ("name");
-              Cell files = stk.contents ("file");
-              Cell lines = stk.contents ("line");
+          bool show_top_level = true;
 
-              bool show_top_level = true;
-
-              size_t max_name_len = 0;
+          size_t max_name_len = 0;
 
-              for (octave_idx_type i = 0; i < nframes_to_display; i++)
-                {
-                  std::string name = names(i).string_value ();
+          for (octave_idx_type i = 0; i < nframes_to_display; i++)
+            {
+              std::string name = names(i).string_value ();
+
+              max_name_len = std::max (name.length (), max_name_len);
+            }
 
-                  max_name_len = std::max (name.length (), max_name_len);
-                }
+          for (octave_idx_type i = 0; i < nframes_to_display; i++)
+            {
+              std::string name = names(i).string_value ();
+              std::string file = files(i).string_value ();
+              int line = lines(i).int_value ();
 
-              for (octave_idx_type i = 0; i < nframes_to_display; i++)
-                {
-                  std::string name = names(i).string_value ();
-                  std::string file = files(i).string_value ();
-                  int line = lines(i).int_value ();
-
-                  if (show_top_level && i == curr_frame)
-                    show_top_level = false;
+              if (show_top_level && i == curr_frame)
+                show_top_level = false;
 
-                  os << (i == curr_frame ? "  --> " : "      ")
-                     << std::setw (max_name_len) << name
-                     << " at line " << line
-                     << " [" << file << "]"
-                     << std::endl;
-                }
-
-              if (show_top_level)
-                os << "  --> top level" << std::endl;
+              os << (i == curr_frame ? "  --> " : "      ")
+                 << std::setw (max_name_len) << name
+                 << " at line " << line
+                 << " [" << file << "]"
+                 << std::endl;
             }
+
+          if (show_top_level)
+            os << "  --> top level" << std::endl;
         }
-      else
-        {
-          octave_map stk = octave_call_stack::backtrace (nskip,
-                                                         curr_frame,
-                                                         false);
+    }
+  else
+    {
+      octave_map stk = octave_call_stack::backtrace (nskip,
+                                                     curr_frame,
+                                                     false);
 
-          retval(1) = curr_frame < 0 ? 1 : curr_frame + 1;
-          retval(0) = stk;
-        }
+      retval(1) = curr_frame < 0 ? 1 : curr_frame + 1;
+      retval(0) = stk;
     }
 
   return retval;
@@ -1284,7 +1241,7 @@
 With optional argument @var{n}, omit the @var{n} innermost stack frames.\n\
 \n\
 Although accepted, the argument @var{-completenames} is silently ignored.\n\
-Octave always returns absolute file names.\n\
+Octave always returns absolute filenames.\n\
 \n\
 The arguments @var{n} and @var{-completenames} can be both specified in any\n\
 order.\n\
@@ -1339,14 +1296,11 @@
         n = args(0).int_value ();
     }
 
-  if (! error_state)
-    {
-      if (who == "dbup")
-        n = -n;
+  if (who == "dbup")
+    n = -n;
 
-      if (! octave_call_stack::goto_frame_relative (n, true))
-        error ("%s: invalid stack frame", who.c_str ());
-    }
+  if (! octave_call_stack::goto_frame_relative (n, true))
+    error ("%s: invalid stack frame", who.c_str ());
 }
 
 DEFUN (dbup, args, ,
@@ -1412,40 +1366,36 @@
 
       if (nargin > 1)
         print_usage ();
-      else if (nargin == 1)
+
+      if (nargin == 1)
         {
-          if (args(0).is_string ())
+          std::string arg = args(0).xstring_value ("dbstep: input argument must be a string");
+
+          if (arg == "in")
             {
-              std::string arg = args(0).string_value ();
+              Vdebugging = false;
 
-              if (arg == "in")
-                {
-                  Vdebugging = false;
+              tree_evaluator::dbstep_flag = -1;
+            }
+          else if (arg == "out")
+            {
+              Vdebugging = false;
 
-                  tree_evaluator::dbstep_flag = -1;
-                }
-              else if (arg == "out")
+              tree_evaluator::dbstep_flag = -2;
+            }
+          else
+            {
+              int n = atoi (arg.c_str ());
+
+              if (n > 0)
                 {
                   Vdebugging = false;
 
-                  tree_evaluator::dbstep_flag = -2;
+                  tree_evaluator::dbstep_flag = n;
                 }
               else
-                {
-                  int n = atoi (arg.c_str ());
-
-                  if (n > 0)
-                    {
-                      Vdebugging = false;
-
-                      tree_evaluator::dbstep_flag = n;
-                    }
-                  else
-                    error ("dbstep: invalid argument");
-                }
+                error ("dbstep: invalid argument");
             }
-          else
-            error ("dbstep: input argument must be a string");
         }
       else
         {
@@ -1471,14 +1421,12 @@
 {
   if (Vdebugging)
     {
-      if (args.length () == 0)
-        {
-          Vdebugging = false;
+      if (args.length () != 0)
+        print_usage ();
 
-          tree_evaluator::reset_debug_state ();
-        }
-      else
-        print_usage ();
+      Vdebugging = false;
+
+      tree_evaluator::reset_debug_state ();
     }
   else
     error ("dbcont: can only be called in debug mode");
@@ -1496,16 +1444,14 @@
 {
   if (Vdebugging)
     {
-      if (args.length () == 0)
-        {
-          Vdebugging = false;
+      if (args.length () != 0)
+        print_usage ();
 
-          tree_evaluator::reset_debug_state ();
+      Vdebugging = false;
 
-          octave_throw_interrupt_exception ();
-        }
-      else
-        print_usage ();
+      tree_evaluator::reset_debug_state ();
+
+      octave_throw_interrupt_exception ();
     }
   else
     error ("dbquit: can only be called in debug mode");
@@ -1520,14 +1466,10 @@
 @seealso{dbwhere, dbstack, dbstatus}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 0)
-    retval = Vdebugging;
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (Vdebugging);
 }
 
 DEFUN (__db_next_breakpoint_quiet__, args, ,
@@ -1543,25 +1485,15 @@
 
   int nargin = args.length ();
 
-  if (nargin == 0 || nargin == 1)
-    {
-      bool state = true;
+  if (nargin > 1)
+    print_usage ();
 
-      if (nargin == 1)
-        {
-          state = args(0).bool_value ();
+  bool state = true;
 
-          if (error_state)
-            {
-              gripe_wrong_type_arg ("db_next_breakpoint", args(0), true);
-              return retval;
-            }
-        }
+  if (nargin == 1)
+    state = args(0).bool_value ();
 
-      tree_evaluator::quiet_breakpoint_flag = state;
-    }
-  else
-    print_usage ();
+  tree_evaluator::quiet_breakpoint_flag = state;
 
   return retval;
 }
--- a/libinterp/corefcn/debug.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/debug.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_debug_h)
+#if ! defined (octave_debug_h)
 #define octave_debug_h 1
 
 #include <map>
--- a/libinterp/corefcn/defaults.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/defaults.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -584,14 +584,10 @@
 @seealso{EXEC_PATH, IMAGE_PATH}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 0)
-    retval = Voctave_home;
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (Voctave_home);
 }
 
 /*
@@ -606,16 +602,10 @@
 @seealso{ver, version}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 0)
-    retval = OCTAVE_VERSION;
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (OCTAVE_VERSION);
 }
 
 /*
--- a/libinterp/corefcn/defaults.in.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/defaults.in.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_defaults_h)
+#if ! defined (octave_defaults_h)
 #define octave_defaults_h 1
 
 #include <string>
--- a/libinterp/corefcn/defun-dld.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/defun-dld.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_defun_dld_h)
+#if ! defined (octave_defun_dld_h)
 #define octave_defun_dld_h 1
 
 #if defined (octave_defun_h)
--- a/libinterp/corefcn/defun-int.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/defun-int.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_defun_int_h)
+#if ! defined (octave_defun_int_h)
 #define octave_defun_int_h 1
 
 #include <string>
@@ -103,21 +103,14 @@
   octave_function * \
   gname (const octave_shlib& shl, bool relative) \
   { \
-    octave_function *retval = 0; \
- \
     check_version (OCTAVE_API_VERSION, name); \
  \
-    if (! error_state) \
-      { \
-        octave_dld_function *fcn = octave_dld_function::create (fname, shl, name, doc); \
+    octave_dld_function *fcn = octave_dld_function::create (fname, shl, name, doc); \
  \
-        if (relative) \
-          fcn->mark_relative (); \
+    if (relative) \
+      fcn->mark_relative (); \
  \
-        retval = fcn; \
-      } \
- \
-    return retval; \
+    return fcn; \
   }
 
 // MAKE_BUILTINS is defined to extract function names and related
--- a/libinterp/corefcn/defun.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/defun.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_defun_h)
+#if ! defined (octave_defun_h)
 #define octave_defun_h 1
 
 #if defined (octave_defun_dld_h)
--- a/libinterp/corefcn/det.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/det.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -66,13 +66,8 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 1)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 1)
+    print_usage ();
 
   octave_value arg = args(0);
 
@@ -151,15 +146,14 @@
           // Always compute rcond, so we can detect numerically
           // singular matrices.
           FloatMatrix m = arg.float_matrix_value ();
-          if (! error_state)
-            {
-              MAYBE_CAST (rep, octave_float_matrix);
-              MatrixType mtype = rep ? rep -> matrix_type () : MatrixType ();
-              FloatDET det = m.determinant (mtype, info, rcond);
-              retval(1) = rcond;
-              retval(0) = info == -1 ? 0.0f : det.value ();
-              if (rep) rep->matrix_type (mtype);
-            }
+
+          MAYBE_CAST (rep, octave_float_matrix);
+          MatrixType mtype = rep ? rep -> matrix_type () : MatrixType ();
+          FloatDET det = m.determinant (mtype, info, rcond);
+          retval(1) = rcond;
+          retval(0) = info == -1 ? 0.0f : det.value ();
+          if (rep)
+            rep->matrix_type (mtype);
         }
       else if (arg.is_complex_type ())
         {
@@ -168,15 +162,14 @@
           // Always compute rcond, so we can detect numerically
           // singular matrices.
           FloatComplexMatrix m = arg.float_complex_matrix_value ();
-          if (! error_state)
-            {
-              MAYBE_CAST (rep, octave_float_complex_matrix);
-              MatrixType mtype = rep ? rep -> matrix_type () : MatrixType ();
-              FloatComplexDET det = m.determinant (mtype, info, rcond);
-              retval(1) = rcond;
-              retval(0) = info == -1 ? FloatComplex (0.0) : det.value ();
-              if (rep) rep->matrix_type (mtype);
-            }
+
+          MAYBE_CAST (rep, octave_float_complex_matrix);
+          MatrixType mtype = rep ? rep -> matrix_type () : MatrixType ();
+          FloatComplexDET det = m.determinant (mtype, info, rcond);
+          retval(1) = rcond;
+          retval(0) = info == -1 ? FloatComplex (0.0) : det.value ();
+          if (rep)
+            rep->matrix_type (mtype);
         }
     }
   else
@@ -190,26 +183,23 @@
           if (arg.is_sparse_type ())
             {
               SparseMatrix m = arg.sparse_matrix_value ();
-              if (! error_state)
-                {
-                  DET det = m.determinant (info, rcond);
-                  retval(1) = rcond;
-                  retval(0) = info == -1 ? 0.0 : det.value ();
-                }
+
+              DET det = m.determinant (info, rcond);
+              retval(1) = rcond;
+              retval(0) = info == -1 ? 0.0 : det.value ();
             }
           else
             {
               Matrix m = arg.matrix_value ();
-              if (! error_state)
-                {
-                  MAYBE_CAST (rep, octave_matrix);
-                  MatrixType mtype = rep ? rep -> matrix_type ()
-                                         : MatrixType ();
-                  DET det = m.determinant (mtype, info, rcond);
-                  retval(1) = rcond;
-                  retval(0) = info == -1 ? 0.0 : det.value ();
-                  if (rep) rep->matrix_type (mtype);
-                }
+
+              MAYBE_CAST (rep, octave_matrix);
+              MatrixType mtype = rep ? rep -> matrix_type ()
+                : MatrixType ();
+              DET det = m.determinant (mtype, info, rcond);
+              retval(1) = rcond;
+              retval(0) = info == -1 ? 0.0 : det.value ();
+              if (rep)
+                rep->matrix_type (mtype);
             }
         }
       else if (arg.is_complex_type ())
@@ -221,26 +211,23 @@
           if (arg.is_sparse_type ())
             {
               SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
-              if (! error_state)
-                {
-                  ComplexDET det = m.determinant (info, rcond);
-                  retval(1) = rcond;
-                  retval(0) = info == -1 ? Complex (0.0) : det.value ();
-                }
+
+              ComplexDET det = m.determinant (info, rcond);
+              retval(1) = rcond;
+              retval(0) = info == -1 ? Complex (0.0) : det.value ();
             }
           else
             {
               ComplexMatrix m = arg.complex_matrix_value ();
-              if (! error_state)
-                {
-                  MAYBE_CAST (rep, octave_complex_matrix);
-                  MatrixType mtype = rep ? rep -> matrix_type ()
-                                         : MatrixType ();
-                  ComplexDET det = m.determinant (mtype, info, rcond);
-                  retval(1) = rcond;
-                  retval(0) = info == -1 ? Complex (0.0) : det.value ();
-                  if (rep) rep->matrix_type (mtype);
-                }
+
+              MAYBE_CAST (rep, octave_complex_matrix);
+              MatrixType mtype = rep ? rep -> matrix_type ()
+                : MatrixType ();
+              ComplexDET det = m.determinant (mtype, info, rcond);
+              retval(1) = rcond;
+              retval(0) = info == -1 ? Complex (0.0) : det.value ();
+              if (rep)
+                rep->matrix_type (mtype);
             }
         }
       else
--- a/libinterp/corefcn/dirfns.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/dirfns.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -122,23 +122,21 @@
 @seealso{pwd, mkdir, rmdir, dir, ls}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
-  int argc = args.length () + 1;
+  int nargin = args.length ();
+ 
+  if (nargin > 1)
+    print_usage ();
 
-  string_vector argv = args.make_argv ("cd");
-
-  if (error_state)
-    return retval;
+  octave_value_list retval;
 
   if (nargout > 0)
     retval = octave_value (octave_env::get_current_directory ());
 
-  if (argc > 1)
+  if (nargin == 1)
     {
-      std::string dirname = argv[1];
+      std::string dirname = args(0).xstring_value ("cd: DIR must be a string");
 
-      if (dirname.length () > 0)
+      if (! dirname.empty ())
         octave_change_to_directory (dirname);
     }
   else
@@ -181,34 +179,25 @@
 {
   octave_value_list retval;
 
+  if (args.length () != 1)
+    print_usage ();
+
   retval(2) = std::string ();
   retval(1) = -1.0;
   retval(0) = Cell ();
 
-  if (args.length () == 1)
-    {
-      std::string dirname = args(0).string_value ();
+  std::string dirname = args(0).xstring_value ("readdir: DIR must be a string");
 
-      if (error_state)
-        gripe_wrong_type_arg ("readdir", args(0));
-      else
-        {
-          dir_entry dir (dirname);
+  dir_entry dir (dirname);
 
-          if (dir)
-            {
-              string_vector dirlist = dir.read ();
-              retval(1) = 0.0;
-              retval(0) = Cell (dirlist.sort ());
-            }
-          else
-            {
-              retval(2) = dir.error ();
-            }
-        }
+  if (dir)
+    {
+      string_vector dirlist = dir.read ();
+      retval(1) = 0.0;
+      retval(0) = Cell (dirlist.sort ());
     }
   else
-    print_usage ();
+    retval(2) = dir.error ();
 
   return retval;
 }
@@ -238,70 +227,54 @@
 {
   octave_value_list retval;
 
+  int nargin = args.length ();
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   retval(2) = std::string ();
   retval(1) = std::string ();
   retval(0) = false;
 
-  int nargin = args.length ();
-
   std::string dirname;
 
   if (nargin == 2)
     {
-      std::string parent = args(0).string_value ();
-      std::string dir = args(1).string_value ();
+      std::string parent = args(0).xstring_value ("mkdir: PARENT must be a string");
+      std::string dir = args(1).xstring_value ("mkdir: DIR must be a string");
 
-      if (error_state)
-        {
-          gripe_wrong_type_arg ("mkdir", args(0));
-          return retval;
-        }
-      else
-        dirname = file_ops::concat (parent, dir);
+      dirname = file_ops::concat (parent, dir);
     }
   else if (nargin == 1)
-    {
-      dirname = args(0).string_value ();
+    dirname = args(0).xstring_value ("mkdir: DIR must be a string");
+
+  std::string msg;
 
-      if (error_state)
-        {
-          gripe_wrong_type_arg ("mkdir", args(0));
-          return retval;
-        }
-    }
+  dirname = file_ops::tilde_expand (dirname);
 
-  if (nargin == 1 || nargin == 2)
+  file_stat fs (dirname);
+
+  if (fs && fs.is_dir ())
     {
-      std::string msg;
-
-      dirname = file_ops::tilde_expand (dirname);
-
-      file_stat fs (dirname);
+      // For compatibility with Matlab, we return true when the
+      // directory already exists.
 
-      if (fs && fs.is_dir ())
+      retval(2) = "mkdir";
+      retval(1) = "directory exists";
+      retval(0) = true;
+    }
+  else
+    {
+      int status = octave_mkdir (dirname, 0777, msg);
+
+      if (status < 0)
         {
-          // For compatibility with Matlab, we return true when the
-          // directory already exists.
-
           retval(2) = "mkdir";
-          retval(1) = "directory exists";
-          retval(0) = true;
+          retval(1) = msg;
         }
       else
-        {
-          int status = octave_mkdir (dirname, 0777, msg);
-
-          if (status < 0)
-            {
-              retval(2) = "mkdir";
-              retval(1) = msg;
-            }
-          else
-            retval(0) = true;
-        }
+        retval(0) = true;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -326,59 +299,52 @@
 {
   octave_value_list retval;
 
+  int nargin = args.length ();
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   retval(2) = std::string ();
   retval(1) = std::string ();
   retval(0) = false;
 
-  int nargin = args.length ();
+  std::string dirname = args(0).xstring_value ("rmdir: DIR must be a string");
 
-  if (nargin == 1 || nargin == 2)
+  std::string fulldir = file_ops::tilde_expand (dirname);
+  int status = -1;
+  std::string msg;
+
+  if (nargin == 2)
     {
-      std::string dirname = args(0).string_value ();
-
-      if (error_state)
-        gripe_wrong_type_arg ("rmdir", args(0));
-      else
+      if (args(1).string_value () == "s")
         {
-          std::string fulldir = file_ops::tilde_expand (dirname);
-          int status = -1;
-          std::string msg;
-
-          if (nargin == 2)
-            {
-              if (args(1).string_value () == "s")
-                {
-                  bool doit = true;
+          bool doit = true;
 
-                  if (interactive && ! forced_interactive
-                      && Vconfirm_recursive_rmdir)
-                    {
-                      std::string prompt
-                        = "remove entire contents of " + fulldir + "? ";
-
-                      doit = octave_yes_or_no (prompt);
-                    }
+          if (interactive && ! forced_interactive
+              && Vconfirm_recursive_rmdir)
+            {
+              std::string prompt
+                = "remove entire contents of " + fulldir + "? ";
 
-                  if (doit)
-                    status = octave_recursive_rmdir (fulldir, msg);
-                }
-              else
-                error ("rmdir: expecting second argument to be \"s\"");
+              doit = octave_yes_or_no (prompt);
             }
-          else
-            status = octave_rmdir (fulldir, msg);
 
-          if (status < 0)
-            {
-              retval(2) = "rmdir";
-              retval(1) = msg;
-            }
-          else
-            retval(0) = true;
+          if (doit)
+            status = octave_recursive_rmdir (fulldir, msg);
         }
+      else
+        error ("rmdir: second argument must be \"s\" for recursive removal");
     }
   else
-    print_usage ();
+    status = octave_rmdir (fulldir, msg);
+
+  if (status < 0)
+    {
+      retval(2) = "rmdir";
+      retval(1) = msg;
+    }
+  else
+    retval(0) = true;
 
   return retval;
 }
@@ -397,35 +363,23 @@
 {
   octave_value_list retval;
 
+  if (args.length () != 2)
+    print_usage ();
+
   retval(1) = std::string ();
   retval(0) = -1.0;
 
-  if (args.length () == 2)
-    {
-      std::string from = args(0).string_value ();
+  std::string from = args(0).xstring_value ("link: OLD must be a string");
+  std::string to = args(1).xstring_value ("link: NEW must be a string");
 
-      if (error_state)
-        gripe_wrong_type_arg ("link", args(0));
-      else
-        {
-          std::string to = args(1).string_value ();
+  std::string msg;
 
-          if (error_state)
-            gripe_wrong_type_arg ("link", args(1));
-          else
-            {
-              std::string msg;
-
-              int status = octave_link (from, to, msg);
+  int status = octave_link (from, to, msg);
 
-              if (status < 0)
-                retval(1) = msg;
-              retval(0) = status;
-            }
-        }
-    }
-  else
-    print_usage ();
+  if (status < 0)
+    retval(1) = msg;
+
+  retval(0) = status;
 
   return retval;
 }
@@ -444,35 +398,23 @@
 {
   octave_value_list retval;
 
+  if (args.length () != 2)
+    print_usage ();
+
   retval(1) = std::string ();
   retval(0) = -1.0;
 
-  if (args.length () == 2)
-    {
-      std::string from = args(0).string_value ();
+  std::string from = args(0).xstring_value ("symlink: OLD must be a string");
+  std::string to = args(1).xstring_value ("symlink: NEW must be a string");
 
-      if (error_state)
-        gripe_wrong_type_arg ("symlink", args(0));
-      else
-        {
-          std::string to = args(1).string_value ();
+  std::string msg;
 
-          if (error_state)
-            gripe_wrong_type_arg ("symlink", args(1));
-          else
-            {
-              std::string msg;
-
-              int status = octave_symlink (from, to, msg);
+  int status = octave_symlink (from, to, msg);
 
-              if (status < 0)
-                retval(1) = msg;
-              retval(0) = status;
-            }
-        }
-    }
-  else
-    print_usage ();
+  if (status < 0)
+    retval(1) = msg;
+
+  retval(0) = status;
 
   return retval;
 }
@@ -492,31 +434,25 @@
 {
   octave_value_list retval;
 
+  if (args.length () != 1)
+    print_usage ();
+
   retval(2) = std::string ();
   retval(1) = -1.0;
   retval(0) = std::string ();
 
-  if (args.length () == 1)
-    {
-      std::string symlink = args(0).string_value ();
+  std::string symlink = args(0).xstring_value ("readlink: SYMLINK must be a string");
 
-      if (error_state)
-        gripe_wrong_type_arg ("readlink", args(0));
-      else
-        {
-          std::string result;
-          std::string msg;
+  std::string result;
+  std::string msg;
 
-          int status = octave_readlink (symlink, result, msg);
+  int status = octave_readlink (symlink, result, msg);
 
-          if (status < 0)
-            retval(2) = msg;
-          retval(1) = status;
-          retval(0) = result;
-        }
-    }
-  else
-    print_usage ();
+  if (status < 0)
+    retval(2) = msg;
+
+  retval(1) = status;
+  retval(0) = result;
 
   return retval;
 }
@@ -535,35 +471,23 @@
 {
   octave_value_list retval;
 
+  if (args.length () != 2)
+    print_usage ();
+
   retval(1) = std::string ();
   retval(0) = -1.0;
 
-  if (args.length () == 2)
-    {
-      std::string from = args(0).string_value ();
+  std::string from = args(0).xstring_value ("rename: OLD must be a string");
+  std::string to = args(1).xstring_value ("rename: NEW must be a string");
 
-      if (error_state)
-        gripe_wrong_type_arg ("rename", args(0));
-      else
-        {
-          std::string to = args(1).string_value ();
+  std::string msg;
 
-          if (error_state)
-            gripe_wrong_type_arg ("rename", args(1));
-          else
-            {
-              std::string msg;
-
-              int status = octave_rename (from, to, msg);
+  int status = octave_rename (from, to, msg);
 
-              if (status < 0)
-                retval(1) = msg;
-              retval(0) = status;
-            }
-        }
-    }
-  else
-    print_usage ();
+  if (status < 0)
+    retval(1) = msg;
+
+  retval(0) = status;
 
   return retval;
 }
@@ -572,7 +496,7 @@
        "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} glob (@var{pattern})\n\
 Given an array of pattern strings (as a char array or a cell array) in\n\
-@var{pattern}, return a cell array of file names that match any of\n\
+@var{pattern}, return a cell array of filenames that match any of\n\
 them, or an empty cell array if no patterns match.\n\
 \n\
 The pattern strings are interpreted as filename globbing patterns (as they\n\
@@ -592,7 +516,7 @@
 @end table\n\
 \n\
 Tilde expansion is performed on each of the patterns before looking for\n\
-matching file names.  For example:\n\
+matching filenames.  For example:\n\
 \n\
 @example\n\
 ls\n\
@@ -619,25 +543,14 @@
 @seealso{ls, dir, readdir, what}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      string_vector pat = args(0).all_strings ();
-
-      if (error_state)
-        gripe_wrong_type_arg ("glob", args(0));
-      else
-        {
-          glob_match pattern (file_ops::tilde_expand (pat));
-
-          retval = Cell (pattern.glob ());
-        }
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  string_vector pat = args(0).xall_strings ("glob: PATTERN must be a string");
+
+  glob_match pattern (file_ops::tilde_expand (pat));
+
+  return octave_value (Cell (pattern.glob ()));
 }
 
 /*
@@ -691,24 +604,15 @@
 {
   octave_value retval;
 
-  if (args.length () == 2)
-    {
-      string_vector pat = args(0).all_strings ();
-      string_vector str = args(1).all_strings ();
-
-      if (error_state)
-        gripe_wrong_type_arg ("fnmatch", args(0));
-      else
-        {
-          glob_match pattern (file_ops::tilde_expand (pat));
-
-          retval = pattern.match (str);
-        }
-    }
-  else
+  if (args.length () != 2)
     print_usage ();
 
-  return retval;
+  string_vector pat = args(0).all_strings ();
+  string_vector str = args(1).all_strings ();
+
+  glob_match pattern (file_ops::tilde_expand (pat));
+
+  return octave_value (pattern.match (str));
 }
 
 DEFUN (filesep, args, ,
@@ -726,24 +630,20 @@
 {
   octave_value retval;
 
-  if (args.length () == 0)
-    retval = file_ops::dir_sep_str ();
-  else if (args.length () == 1)
-    {
-      std::string s = args(0).string_value ();
+  int nargin = args.length ();
+  if (nargin > 1)
+    print_usage ();
 
-      if (! error_state)
-        {
-          if (s == "all")
-            retval = file_ops::dir_sep_chars ();
-          else
-            gripe_wrong_type_arg ("filesep", args(0));
-        }
+  if (nargin == 0)
+    retval = file_ops::dir_sep_str ();
+  else
+    {
+      std::string s = args(0).xstring_value ("filesep: argument must be a string");
+      if (s == "all")
+        retval = file_ops::dir_sep_chars ();
       else
-        gripe_wrong_type_arg ("filesep", args(0));
+        error ("filesep: argument must be \"all\"");
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -760,35 +660,31 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargout > 0 || nargin == 0)
     retval = dir_path::path_sep_str ();
 
   if (nargin == 1)
     {
-      std::string sval = args(0).string_value ();
+      std::string sval = args(0).xstring_value ("pathsep: argument must be a single character");
 
-      if (! error_state)
+      switch (sval.length ())
         {
-          switch (sval.length ())
-            {
-            case 1:
-              dir_path::path_sep_char (sval[0]);
-              break;
+        case 1:
+          dir_path::path_sep_char (sval[0]);
+          break;
 
-            case 0:
-              dir_path::path_sep_char ('\0');
-              break;
+        case 0:
+          dir_path::path_sep_char ('\0');
+          break;
 
-            default:
-              error ("pathsep: argument must be a single character");
-              break;
-            }
+        default:
+          error ("pathsep: argument must be a single character");
+          break;
         }
-      else
-        error ("pathsep: argument must be a single character");
     }
-  else if (nargin > 1)
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/corefcn/dirfns.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/dirfns.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_dirfns_h)
+#if ! defined (octave_dirfns_h)
 #define octave_dirfns_h 1
 
 #include <ctime>
--- a/libinterp/corefcn/display.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/display.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -64,7 +64,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create display_info object!");
+      error ("unable to create display_info object!");
 
       retval = false;
     }
--- a/libinterp/corefcn/display.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/display.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_display_h)
+#if ! defined (octave_display_h)
 #define octave_display_h 1
 
 #include <string>
--- a/libinterp/corefcn/dlmread.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/dlmread.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -180,7 +180,7 @@
 lowest alphabetical index @qcode{'A'} refers to the first column.  The\n\
 lowest row index is 1.\n\
 \n\
-@var{file} should be a file name or file id given by @code{fopen}.  In the\n\
+@var{file} should be a filename or file id given by @code{fopen}.  In the\n\
 latter case, the file is read until end of file is reached.\n\
 \n\
 The @qcode{\"emptyvalue\"} option may be used to specify the value used to\n\
@@ -198,23 +198,19 @@
       && args(nargin-2).string_value () == "emptyvalue")
     {
       empty_value = args(nargin-1).double_value ();
-      if (error_state)
-        return retval;
+
       nargin -= 2;
     }
 
   if (nargin < 1 || nargin > 4)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   std::istream *input = 0;
   std::ifstream input_file;
 
   if (args(0).is_string ())
     {
-      // File name.
+      // Filename.
       std::string fname (args(0).string_value ());
 
       std::string tname = file_ops::tilde_expand (fname);
@@ -222,33 +218,21 @@
       input_file.open (tname.c_str (), std::ios::in);
 
       if (! input_file)
-        {
-          error ("dlmread: unable to open file '%s'", fname.c_str ());
-          return retval;
-        }
-      else
-        input = &input_file;
+        error ("dlmread: unable to open file '%s'", fname.c_str ());
+
+      input = &input_file;
     }
   else if (args(0).is_scalar_type ())
     {
       octave_stream is = octave_stream_list::lookup (args(0), "dlmread");
 
-      if (error_state)
-        return retval;
-
       input = is.input_stream ();
 
       if (! input)
-        {
-          error ("dlmread: stream FILE not open for input");
-          return retval;
-        }
+        error ("dlmread: stream FILE not open for input");
     }
   else
-    {
-      error ("dlmread: FILE argument must be a string or file id");
-      return retval;
-    }
+    error ("dlmread: FILE argument must be a string or file id");
 
   // Set default separator.
   std::string sep;
@@ -258,9 +242,6 @@
         sep = do_string_escapes (args(1).string_value ());
       else
         sep = args(1).string_value ();
-
-      if (error_state)
-        return retval;
     }
 
   // Take a subset if a range was given.
@@ -279,181 +260,92 @@
         {
           r0 = args(2).idx_type_value ();
           c0 = args(3).idx_type_value ();
-
-          if (error_state)
-            return retval;
         }
 
       if (r0 < 0 || c0 < 0)
         error ("dlmread: left & top must be positive");
     }
 
-  if (!error_state)
-    {
-      octave_idx_type i = 0;
-      octave_idx_type j = 0;
-      octave_idx_type r = 1;
-      octave_idx_type c = 1;
-      octave_idx_type rmax = 0;
-      octave_idx_type cmax = 0;
+  octave_idx_type i = 0;
+  octave_idx_type j = 0;
+  octave_idx_type r = 1;
+  octave_idx_type c = 1;
+  octave_idx_type rmax = 0;
+  octave_idx_type cmax = 0;
 
-      Matrix rdata;
-      ComplexMatrix cdata;
+  Matrix rdata;
+  ComplexMatrix cdata;
+
+  bool iscmplx = false;
+  bool sepflag = false;
+
+  std::string line;
 
-      bool iscmplx = false;
-      bool sepflag = false;
+  // Skip the r0 leading lines as these might be a header.
+  for (octave_idx_type m = 0; m < r0; m++)
+    getline (*input, line);
+  r1 -= r0;
 
-      std::string line;
+  std::istringstream tmp_stream;
 
-      // Skip the r0 leading lines as these might be a header.
-      for (octave_idx_type m = 0; m < r0; m++)
-        getline (*input, line);
-      r1 -= r0;
+  // Read in the data one field at a time, growing the data matrix
+  // as needed.
+  while (getline (*input, line))
+    {
+      // Skip blank lines for compatibility.
+      if (line.find_first_not_of (" \t") == std::string::npos)
+        continue;
 
-      std::istringstream tmp_stream;
-
-      // Read in the data one field at a time, growing the data matrix
-      // as needed.
-      while (getline (*input, line))
+      // To be compatible with matlab, blank separator should
+      // correspond to whitespace as delimter.
+      if (!sep.length ())
         {
-          // Skip blank lines for compatibility.
-          if (line.find_first_not_of (" \t") == std::string::npos)
-            continue;
+          size_t n = line.find_first_of (",:; \t",
+                                         line.find_first_of ("0123456789"));
+          if (n == std::string::npos)
+            {
+              sep = " \t";
+              sepflag = true;
+            }
+          else
+            {
+              char ch = line.at (n);
 
-          // To be compatible with matlab, blank separator should
-          // correspond to whitespace as delimter.
-          if (!sep.length ())
-            {
-              size_t n = line.find_first_of (",:; \t",
-                                             line.find_first_of ("0123456789"));
-              if (n == std::string::npos)
+              switch (line.at (n))
                 {
-                  sep = " \t";
+                case ' ':
+                case '\t':
                   sepflag = true;
-                }
-              else
-                {
-                  char ch = line.at (n);
+                  sep = " \t";
+                  break;
 
-                  switch (line.at (n))
-                    {
-                    case ' ':
-                    case '\t':
-                      sepflag = true;
-                      sep = " \t";
-                      break;
-
-                    default:
-                      sep = ch;
-                      break;
-                    }
+                default:
+                  sep = ch;
+                  break;
                 }
             }
-
-          if (cmax == 0)
-            {
-              // Try to estimate the number of columns.  Skip leading
-              // whitespace.
-              size_t pos1 = line.find_first_not_of (" \t");
-              do
-                {
-                  size_t pos2 = line.find_first_of (sep, pos1);
-
-                  if (sepflag && pos2 != std::string::npos)
-                    // Treat consecutive separators as one.
-                    {
-                      pos2 = line.find_first_not_of (sep, pos2);
-                      if (pos2 != std::string::npos)
-                        pos2 -= 1;
-                      else
-                        pos2 = line.length () - 1;
-                    }
+        }
 
-                  cmax++;
-
-                  if (pos2 != std::string::npos)
-                    pos1 = pos2 + 1;
-                  else
-                    pos1 = std::string::npos;
-
-                }
-              while (pos1 != std::string::npos);
-
-              if (iscmplx)
-                cdata.resize (rmax, cmax);
-              else
-                rdata.resize (rmax, cmax);
-            }
-
-          r = (r > i + 1 ? r : i + 1);
-          j = 0;
-          // Skip leading whitespace.
+      if (cmax == 0)
+        {
+          // Try to estimate the number of columns.  Skip leading
+          // whitespace.
           size_t pos1 = line.find_first_not_of (" \t");
           do
             {
-              octave_quit ();
-
               size_t pos2 = line.find_first_of (sep, pos1);
-              std::string str = line.substr (pos1, pos2 - pos1);
 
               if (sepflag && pos2 != std::string::npos)
                 // Treat consecutive separators as one.
-                pos2 = line.find_first_not_of (sep, pos2) - 1;
-
-              c = (c > j + 1 ? c : j + 1);
-              if (r > rmax || c > cmax)
                 {
-                  // Use resize_and_fill for the case of not-equal
-                  // length rows.
-                  rmax = 2*r;
-                  cmax = c;
-                  if (iscmplx)
-                    cdata.resize (rmax, cmax);
+                  pos2 = line.find_first_not_of (sep, pos2);
+                  if (pos2 != std::string::npos)
+                    pos2 -= 1;
                   else
-                    rdata.resize (rmax, cmax);
+                    pos2 = line.length () - 1;
                 }
 
-              tmp_stream.str (str);
-              tmp_stream.clear ();
-
-              double x = octave_read_double (tmp_stream);
-              if (tmp_stream)
-                {
-                  if (tmp_stream.eof ())
-                    {
-                      if (iscmplx)
-                        cdata(i,j++) = x;
-                      else
-                        rdata(i,j++) = x;
-                    }
-                  else if (std::toupper (tmp_stream.peek ()) == 'I')
-                    {
-                      // This is to allow pure imaginary numbers.
-                      if (iscmplx)
-                        cdata(i,j++) = x;
-                      else
-                        rdata(i,j++) = x;
-                    }
-                  else
-                    {
-                      double y = octave_read_double (tmp_stream);
-
-                      if (!iscmplx && y != 0.)
-                        {
-                          iscmplx = true;
-                          cdata = ComplexMatrix (rdata);
-                        }
-
-                      if (iscmplx)
-                        cdata(i,j++) = Complex (x, y);
-                      else
-                        rdata(i,j++) = x;
-                    }
-                }
-              else if (iscmplx)
-                cdata(i,j++) = empty_value;
-              else
-                rdata(i,j++) = empty_value;
+              cmax++;
 
               if (pos2 != std::string::npos)
                 pos1 = pos2 + 1;
@@ -463,32 +355,115 @@
             }
           while (pos1 != std::string::npos);
 
-          if (i == r1)
-            break;
-
-          i++;
+          if (iscmplx)
+            cdata.resize (rmax, cmax);
+          else
+            rdata.resize (rmax, cmax);
         }
 
-      if (r1 >= r)
-        r1 = r - 1;
-      if (c1 >= c)
-        c1 = c - 1;
-
-      // Now take the subset of the matrix if there are any values.
-      if (i > 0 || j > 0)
+      r = (r > i + 1 ? r : i + 1);
+      j = 0;
+      // Skip leading whitespace.
+      size_t pos1 = line.find_first_not_of (" \t");
+      do
         {
-          if (iscmplx)
-            cdata = cdata.extract (0, c0, r1, c1);
-          else
-            rdata = rdata.extract (0, c0, r1, c1);
-        }
+          octave_quit ();
+
+          size_t pos2 = line.find_first_of (sep, pos1);
+          std::string str = line.substr (pos1, pos2 - pos1);
+
+          if (sepflag && pos2 != std::string::npos)
+            // Treat consecutive separators as one.
+            pos2 = line.find_first_not_of (sep, pos2) - 1;
+
+          c = (c > j + 1 ? c : j + 1);
+          if (r > rmax || c > cmax)
+            {
+              // Use resize_and_fill for the case of not-equal
+              // length rows.
+              rmax = 2*r;
+              cmax = c;
+              if (iscmplx)
+                cdata.resize (rmax, cmax);
+              else
+                rdata.resize (rmax, cmax);
+            }
+
+          tmp_stream.str (str);
+          tmp_stream.clear ();
+
+          double x = octave_read_double (tmp_stream);
+          if (tmp_stream)
+            {
+              if (tmp_stream.eof ())
+                {
+                  if (iscmplx)
+                    cdata(i,j++) = x;
+                  else
+                    rdata(i,j++) = x;
+                }
+              else if (std::toupper (tmp_stream.peek ()) == 'I')
+                {
+                  // This is to allow pure imaginary numbers.
+                  if (iscmplx)
+                    cdata(i,j++) = x;
+                  else
+                    rdata(i,j++) = x;
+                }
+              else
+                {
+                  double y = octave_read_double (tmp_stream);
 
+                  if (!iscmplx && y != 0.)
+                    {
+                      iscmplx = true;
+                      cdata = ComplexMatrix (rdata);
+                    }
+
+                  if (iscmplx)
+                    cdata(i,j++) = Complex (x, y);
+                  else
+                    rdata(i,j++) = x;
+                }
+            }
+          else if (iscmplx)
+            cdata(i,j++) = empty_value;
+          else
+            rdata(i,j++) = empty_value;
+
+          if (pos2 != std::string::npos)
+            pos1 = pos2 + 1;
+          else
+            pos1 = std::string::npos;
+
+        }
+      while (pos1 != std::string::npos);
+
+      if (i == r1)
+        break;
+
+      i++;
+    }
+
+  if (r1 >= r)
+    r1 = r - 1;
+  if (c1 >= c)
+    c1 = c - 1;
+
+  // Now take the subset of the matrix if there are any values.
+  if (i > 0 || j > 0)
+    {
       if (iscmplx)
-        retval(0) = cdata;
+        cdata = cdata.extract (0, c0, r1, c1);
       else
-        retval(0) = rdata;
+        rdata = rdata.extract (0, c0, r1, c1);
     }
 
+  if (iscmplx)
+    retval(0) = cdata;
+  else
+    retval(0) = rdata;
+
   return retval;
 }
 
--- a/libinterp/corefcn/dot.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/dot.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -126,10 +126,7 @@
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value argx = args(0);
   octave_value argy = args(1);
@@ -147,7 +144,7 @@
           argx = argx.reshape (dimx);
           dimy = dimy.redim (1);
           argy = argy.reshape (dimy);
-          match = ! error_state && (dimx == dimy);
+          match = dimx == dimy;
         }
 
       if (match)
@@ -158,9 +155,7 @@
           else
             dim = args(2).int_value (true) - 1;
 
-          if (error_state)
-            ;
-          else if (dim < 0)
+          if (dim < 0)
             error ("dot: DIM must be a valid dimension");
           else
             {
@@ -173,11 +168,11 @@
                       FloatComplexNDArray x = argx.float_complex_array_value ();
                       FloatComplexNDArray y = argy.float_complex_array_value ();
                       get_red_dims (dimx, dimy, dim, dimz, m, n, k);
-                      FloatComplexNDArray z(dimz);
-                      if (! error_state)
-                        F77_XFCN (cdotc3, CDOTC3, (m, n, k,
-                                                   x.data (), y.data (),
-                                                   z.fortran_vec ()));
+                      FloatComplexNDArray z (dimz);
+
+                      F77_XFCN (cdotc3, CDOTC3, (m, n, k,
+                                                 x.data (), y.data (),
+                                                 z.fortran_vec ()));
                       retval = z;
                     }
                   else
@@ -185,11 +180,11 @@
                       ComplexNDArray x = argx.complex_array_value ();
                       ComplexNDArray y = argy.complex_array_value ();
                       get_red_dims (dimx, dimy, dim, dimz, m, n, k);
-                      ComplexNDArray z(dimz);
-                      if (! error_state)
-                        F77_XFCN (zdotc3, ZDOTC3, (m, n, k,
-                                                   x.data (), y.data (),
-                                                   z.fortran_vec ()));
+                      ComplexNDArray z (dimz);
+
+                      F77_XFCN (zdotc3, ZDOTC3, (m, n, k,
+                                                 x.data (), y.data (),
+                                                 z.fortran_vec ()));
                       retval = z;
                     }
                 }
@@ -200,10 +195,10 @@
                       FloatNDArray x = argx.float_array_value ();
                       FloatNDArray y = argy.float_array_value ();
                       get_red_dims (dimx, dimy, dim, dimz, m, n, k);
-                      FloatNDArray z(dimz);
-                      if (! error_state)
-                        F77_XFCN (sdot3, SDOT3, (m, n, k, x.data (), y.data (),
-                                                 z.fortran_vec ()));
+                      FloatNDArray z (dimz);
+
+                      F77_XFCN (sdot3, SDOT3, (m, n, k, x.data (), y.data (),
+                                               z.fortran_vec ()));
                       retval = z;
                     }
                   else
@@ -211,10 +206,10 @@
                       NDArray x = argx.array_value ();
                       NDArray y = argy.array_value ();
                       get_red_dims (dimx, dimy, dim, dimz, m, n, k);
-                      NDArray z(dimz);
-                      if (! error_state)
-                        F77_XFCN (ddot3, DDOT3, (m, n, k, x.data (), y.data (),
-                                                 z.fortran_vec ()));
+                      NDArray z (dimz);
+
+                      F77_XFCN (ddot3, DDOT3, (m, n, k, x.data (), y.data (),
+                                               z.fortran_vec ()));
                       retval = z;
                     }
                 }
@@ -224,12 +219,10 @@
                   octave_value_list tmp;
                   tmp(1) = dim + 1;
                   tmp(0) = do_binary_op (octave_value::op_el_mul, argx, argy);
-                  if (! error_state)
-                    {
-                      tmp = feval ("sum", tmp, 1);
-                      if (! tmp.empty ())
-                        retval = tmp(0);
-                    }
+
+                  tmp = feval ("sum", tmp, 1);
+                  if (! tmp.empty ())
+                    retval = tmp(0);
                 }
             }
         }
@@ -301,13 +294,9 @@
 @end deftypefn")
 {
   octave_value retval;
-  int nargin = args.length ();
 
-  if (nargin != 2)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 2)
+    print_usage ();
 
   octave_value argx = args(0);
   octave_value argy = args(1);
@@ -340,22 +329,22 @@
                 {
                   FloatComplexNDArray x = argx.float_complex_array_value ();
                   FloatComplexNDArray y = argy.float_complex_array_value ();
-                  FloatComplexNDArray z(dimz);
-                  if (! error_state)
-                    F77_XFCN (cmatm3, CMATM3, (m, n, k, np,
-                                               x.data (), y.data (),
-                                               z.fortran_vec ()));
+                  FloatComplexNDArray z (dimz);
+
+                  F77_XFCN (cmatm3, CMATM3, (m, n, k, np,
+                                             x.data (), y.data (),
+                                             z.fortran_vec ()));
                   retval = z;
                 }
               else
                 {
                   ComplexNDArray x = argx.complex_array_value ();
                   ComplexNDArray y = argy.complex_array_value ();
-                  ComplexNDArray z(dimz);
-                  if (! error_state)
-                    F77_XFCN (zmatm3, ZMATM3, (m, n, k, np,
-                                               x.data (), y.data (),
-                                               z.fortran_vec ()));
+                  ComplexNDArray z (dimz);
+
+                  F77_XFCN (zmatm3, ZMATM3, (m, n, k, np,
+                                             x.data (), y.data (),
+                                             z.fortran_vec ()));
                   retval = z;
                 }
             }
@@ -365,22 +354,22 @@
                 {
                   FloatNDArray x = argx.float_array_value ();
                   FloatNDArray y = argy.float_array_value ();
-                  FloatNDArray z(dimz);
-                  if (! error_state)
-                    F77_XFCN (smatm3, SMATM3, (m, n, k, np,
-                                               x.data (), y.data (),
-                                               z.fortran_vec ()));
+                  FloatNDArray z (dimz);
+
+                  F77_XFCN (smatm3, SMATM3, (m, n, k, np,
+                                             x.data (), y.data (),
+                                             z.fortran_vec ()));
                   retval = z;
                 }
               else
                 {
                   NDArray x = argx.array_value ();
                   NDArray y = argy.array_value ();
-                  NDArray z(dimz);
-                  if (! error_state)
-                    F77_XFCN (dmatm3, DMATM3, (m, n, k, np,
-                                               x.data (), y.data (),
-                                               z.fortran_vec ()));
+                  NDArray z (dimz);
+
+                  F77_XFCN (dmatm3, DMATM3, (m, n, k, np,
+                                             x.data (), y.data (),
+                                             z.fortran_vec ()));
                   retval = z;
                 }
             }
--- a/libinterp/corefcn/dynamic-ld.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/dynamic-ld.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -159,11 +159,7 @@
     }
 
   if (! instance)
-    {
-      ::error ("unable to create shared library list object!");
-
-      retval = false;
-    }
+    error ("unable to create shared library list object!");
 
   return retval;
 }
@@ -215,11 +211,8 @@
     }
 
   if (! instance)
-    {
-      ::error ("unable to create dynamic loader object!");
+    error ("unable to create dynamic loader object!");
 
-      retval = false;
-    }
 
   return retval;
 }
@@ -269,40 +262,36 @@
     {
       oct_file.open (file_name);
 
-      if (! error_state && oct_file)
+      if (oct_file)
         octave_shlib_list::append (oct_file);
     }
 
-  if (! error_state)
+  if (oct_file)
     {
-      if (oct_file)
-        {
-          void *function = oct_file.search (fcn_name, name_mangler);
+      void *function = oct_file.search (fcn_name, name_mangler);
 
-          if (! function)
-            {
-              // FIXME: can we determine this C mangling scheme
-              // automatically at run time or configure time?
+      if (! function)
+        {
+          // FIXME: can we determine this C mangling scheme
+          // automatically at run time or configure time?
 
-              function = oct_file.search (fcn_name, name_uscore_mangler);
-            }
+          function = oct_file.search (fcn_name, name_uscore_mangler);
+        }
 
-          if (function)
-            {
-              octave_dld_fcn_getter f
-                = FCN_PTR_CAST (octave_dld_fcn_getter, function);
+      if (function)
+        {
+          octave_dld_fcn_getter f
+            = FCN_PTR_CAST (octave_dld_fcn_getter, function);
 
-              retval = f (oct_file, relative);
+          retval = f (oct_file, relative);
 
-              if (! retval)
-                ::error ("failed to install .oct file function '%s'",
-                         fcn_name.c_str ());
-            }
+          if (! retval)
+            error ("failed to install .oct file function '%s'",
+                   fcn_name.c_str ());
         }
-      else
-        ::error ("%s is not a valid shared library",
-                 file_name.c_str ());
     }
+  else
+    error ("%s is not a valid shared library", file_name.c_str ());
 
   return retval;
 }
@@ -329,47 +318,43 @@
     {
       mex_file.open (file_name);
 
-      if (! error_state && mex_file)
+      if (mex_file)
         octave_shlib_list::append (mex_file);
     }
 
-  if (! error_state)
+  if (mex_file)
     {
-      if (mex_file)
+      void *function = 0;
+
+      bool have_fmex = false;
+
+      function = mex_file.search (fcn_name, mex_mangler);
+
+      if (! function)
         {
-          void *function = 0;
+          // FIXME: can we determine this C mangling scheme
+          // automatically at run time or configure time?
 
-          bool have_fmex = false;
-
-          function = mex_file.search (fcn_name, mex_mangler);
+          function = mex_file.search (fcn_name, mex_uscore_mangler);
 
           if (! function)
             {
-              // FIXME: can we determine this C mangling scheme
-              // automatically at run time or configure time?
-
-              function = mex_file.search (fcn_name, mex_uscore_mangler);
+              function = mex_file.search (fcn_name, mex_f77_mangler);
 
-              if (! function)
-                {
-                  function = mex_file.search (fcn_name, mex_f77_mangler);
-
-                  if (function)
-                    have_fmex = true;
-                }
+              if (function)
+                have_fmex = true;
             }
+        }
 
-          if (function)
-            retval = new octave_mex_function (function, have_fmex,
-                                              mex_file, fcn_name);
-          else
-            ::error ("failed to install .mex file function '%s'",
-                     fcn_name.c_str ());
-        }
+      if (function)
+        retval = new octave_mex_function (function, have_fmex,
+                                          mex_file, fcn_name);
       else
-        ::error ("%s is not a valid shared library",
-                 file_name.c_str ());
+        error ("failed to install .mex file function '%s'",
+               fcn_name.c_str ());
     }
+  else
+    error ("%s is not a valid shared library", file_name.c_str ());
 
   return retval;
 }
--- a/libinterp/corefcn/dynamic-ld.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/dynamic-ld.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_dynamic_ld_h)
+#if ! defined (octave_dynamic_ld_h)
 #define octave_dynamic_ld_h 1
 
 #include <string>
--- a/libinterp/corefcn/eig.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/eig.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -55,10 +55,7 @@
   int nargin = args.length ();
 
   if (nargin > 2 || nargin == 0 || nargout > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg_a, arg_b;
 
@@ -127,19 +124,13 @@
             {
               ftmp_a = arg_a.float_matrix_value ();
 
-              if (error_state)
-                return retval;
-              else
-                result = FloatEIG (ftmp_a, nargout > 1);
+              result = FloatEIG (ftmp_a, nargout > 1);
             }
           else
             {
               fctmp_a = arg_a.float_complex_matrix_value ();
 
-              if (error_state)
-                return retval;
-              else
-                result = FloatEIG (fctmp_a, nargout > 1);
+              result = FloatEIG (fctmp_a, nargout > 1);
             }
         }
       else if (nargin == 2)
@@ -149,38 +140,29 @@
               ftmp_a = arg_a.float_matrix_value ();
               ftmp_b = arg_b.float_matrix_value ();
 
-              if (error_state)
-                return retval;
-              else
-                result = FloatEIG (ftmp_a, ftmp_b, nargout > 1);
+              result = FloatEIG (ftmp_a, ftmp_b, nargout > 1);
             }
           else
             {
               fctmp_a = arg_a.float_complex_matrix_value ();
               fctmp_b = arg_b.float_complex_matrix_value ();
 
-              if (error_state)
-                return retval;
-              else
-                result = FloatEIG (fctmp_a, fctmp_b, nargout > 1);
+              result = FloatEIG (fctmp_a, fctmp_b, nargout > 1);
             }
         }
 
-      if (! error_state)
+      if (nargout == 0 || nargout == 1)
+        {
+          retval(0) = result.eigenvalues ();
+        }
+      else
         {
-          if (nargout == 0 || nargout == 1)
-            {
-              retval(0) = result.eigenvalues ();
-            }
-          else
-            {
-              // Blame it on Matlab.
+          // Blame it on Matlab.
 
-              FloatComplexDiagMatrix d (result.eigenvalues ());
+          FloatComplexDiagMatrix d (result.eigenvalues ());
 
-              retval(1) = d;
-              retval(0) = result.eigenvectors ();
-            }
+          retval(1) = d;
+          retval(0) = result.eigenvectors ();
         }
     }
   else
@@ -193,19 +175,13 @@
             {
               tmp_a = arg_a.matrix_value ();
 
-              if (error_state)
-                return retval;
-              else
-                result = EIG (tmp_a, nargout > 1);
+              result = EIG (tmp_a, nargout > 1);
             }
           else
             {
               ctmp_a = arg_a.complex_matrix_value ();
 
-              if (error_state)
-                return retval;
-              else
-                result = EIG (ctmp_a, nargout > 1);
+              result = EIG (ctmp_a, nargout > 1);
             }
         }
       else if (nargin == 2)
@@ -215,38 +191,29 @@
               tmp_a = arg_a.matrix_value ();
               tmp_b = arg_b.matrix_value ();
 
-              if (error_state)
-                return retval;
-              else
-                result = EIG (tmp_a, tmp_b, nargout > 1);
+              result = EIG (tmp_a, tmp_b, nargout > 1);
             }
           else
             {
               ctmp_a = arg_a.complex_matrix_value ();
               ctmp_b = arg_b.complex_matrix_value ();
 
-              if (error_state)
-                return retval;
-              else
-                result = EIG (ctmp_a, ctmp_b, nargout > 1);
+              result = EIG (ctmp_a, ctmp_b, nargout > 1);
             }
         }
 
-      if (! error_state)
+      if (nargout == 0 || nargout == 1)
+        {
+          retval(0) = result.eigenvalues ();
+        }
+      else
         {
-          if (nargout == 0 || nargout == 1)
-            {
-              retval(0) = result.eigenvalues ();
-            }
-          else
-            {
-              // Blame it on Matlab.
+          // Blame it on Matlab.
 
-              ComplexDiagMatrix d (result.eigenvalues ());
+          ComplexDiagMatrix d (result.eigenvalues ());
 
-              retval(1) = d;
-              retval(0) = result.eigenvectors ();
-            }
+          retval(1) = d;
+          retval(0) = result.eigenvectors ();
         }
     }
 
@@ -324,6 +291,18 @@
 %! 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 = [1, 1+i; 1-i, 1];  B = [2, 0; 0, 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));
+
+%!test
+%! A = single ([1, 1+i; 1-i, 1]);  B = single ([2, 0; 0, 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")));
+
 %!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)
--- a/libinterp/corefcn/ellipj.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ellipj.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -28,12 +28,6 @@
 #include "error.h"
 #include "lo-specfun.h"
 
-static void
-gripe_ellipj_arg (const char *arg)
-{
-  error ("ellipj: expecting scalar or matrix as %s argument", arg);
-}
-
 DEFUN (ellipj, args, nargout,
        "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {[@var{sn}, @var{cn}, @var{dn}, @var{err}] =} ellipj (@var{u}, @var{m})\n\
@@ -79,36 +73,21 @@
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value u_arg = args(0);
   octave_value m_arg = args(1);
 
   if (m_arg.is_scalar_type ())
     {
-      double m = args(1).double_value ();
-
-      if (error_state)
-        {
-          gripe_ellipj_arg ("second");
-          return retval;
-        }
+      double m = args(1).xdouble_value ("ellipj: M must be a scalar or matrix");
 
       if (u_arg.is_scalar_type ())
         {
           if (u_arg.is_real_type ())
             {
               // u real, m scalar
-              double u = args(0).double_value ();
-
-              if (error_state)
-                {
-                  gripe_ellipj_arg ("first");
-                  return retval;
-                }
+              double u = args(0).xdouble_value ("ellipj: U must be a scalar or matrix");
 
               double sn, cn, dn;
               double err = 0;
@@ -124,13 +103,7 @@
           else
             {
               // u complex, m scalar
-              Complex u = u_arg.complex_value ();
-
-              if (error_state)
-                {
-                  gripe_ellipj_arg ("first");
-                  return retval;
-                }
+              Complex u = u_arg.xcomplex_value ("ellipj: U must be a scalar or matrix");
 
               Complex sn, cn, dn;
               double err = 0;
@@ -147,13 +120,7 @@
       else
         {
           // u is matrix, m is scalar
-          ComplexNDArray u = u_arg.complex_array_value ();
-
-          if (error_state)
-            {
-              gripe_ellipj_arg ("first");
-              return retval;
-            }
+          ComplexNDArray u = u_arg.xcomplex_array_value ("ellipj: U must be a scalar or matrix");
 
           dim_vector sz_u = u.dims ();
 
@@ -179,13 +146,7 @@
     }
   else
     {
-      NDArray m = args(1).array_value ();
-
-      if (error_state)
-        {
-          gripe_ellipj_arg ("second");
-          return retval;
-        }
+      NDArray m = args(1).xarray_value ("ellipj: M must be a scalar or matrix");
 
       dim_vector sz_m = m.dims ();
 
@@ -195,13 +156,7 @@
           if (u_arg.is_real_type ())
             {
               // u is real scalar, m is array
-              double u = u_arg.double_value ();
-
-              if (error_state)
-                {
-                  gripe_ellipj_arg ("first");
-                  return retval;
-                }
+              double u = u_arg.xdouble_value ("ellipj: U must be a scalar or matrix");
 
               NDArray sn (sz_m), cn (sz_m), dn (sz_m);
               NDArray err (sz_m);
@@ -225,13 +180,7 @@
           else
             {
               // u is complex scalar, m is array
-              Complex u = u_arg.complex_value ();
-
-              if (error_state)
-                {
-                  gripe_ellipj_arg ("first");
-                  return retval;
-                }
+              Complex u = u_arg.xcomplex_value ("ellipj: U must be a scalar or matrix");
 
               ComplexNDArray sn (sz_m), cn (sz_m), dn (sz_m);
               NDArray err (sz_m);
@@ -259,13 +208,7 @@
           if (u_arg.is_real_type ())
             {
               // u is real array, m is array
-              NDArray u = u_arg.array_value ();
-
-              if (error_state)
-                {
-                  gripe_ellipj_arg ("first");
-                  return retval;
-                }
+              NDArray u = u_arg.xarray_value ("ellipj: U must be a scalar or matrix");
 
               dim_vector sz_u = u.dims ();
 
@@ -322,13 +265,7 @@
           else
             {
               // u is complex array, m is array
-              ComplexNDArray u = u_arg.complex_array_value ();
-
-              if (error_state)
-                {
-                  gripe_ellipj_arg ("second");
-                  return retval;
-                }
+              ComplexNDArray u = u_arg.xcomplex_array_value ("ellipj: U must be a scalar or matrix");
 
               dim_vector sz_u = u.dims ();
 
@@ -931,18 +868,18 @@
 %!error ellipj ()
 %!error ellipj (1)
 %!error ellipj (1,2,3,4)
-%!warning <expecting 0 <= M <= 1> ellipj (1,2);
+%!warning <required value 0 <= M <= 1> ellipj (1,2);
 ## FIXME: errors commented out untill lasterr() truly returns the last error.
-%!#error <expecting scalar or matrix as second argument> ellipj (1, "1")
-%!#error <expecting scalar or matrix as first argument> ellipj ("1", 1)
-%!#error <expecting scalar or matrix as first argument> ellipj ({1}, 1)
-%!#error <expecting scalar or matrix as first argument> ellipj ({1, 2}, 1)
-%!#error <expecting scalar or matrix as second argument> ellipj (1, {1, 2})
-%!#error <expecting scalar or matrix as first argument> ellipj ("1", [1, 2])
-%!#error <expecting scalar or matrix as first argument> ellipj ({1}, [1, 2])
-%!#error <expecting scalar or matrix as first argument> ellipj ({1}, [1, 2])
-%!#error <expecting scalar or matrix as first argument> ellipj ("1,2", [1, 2])
-%!#error <expecting scalar or matrix as first argument> ellipj ({1, 2}, [1, 2])
+%!#error <M must be a scalar or matrix> ellipj (1, "1")
+%!#error <U must be a scalar or matrix> ellipj ("1", 1)
+%!#error <U must be a scalar or matrix> ellipj ({1}, 1)
+%!#error <U must be a scalar or matrix> ellipj ({1, 2}, 1)
+%!#error <M must be a scalar or matrix> ellipj (1, {1, 2})
+%!#error <U must be a scalar or matrix> ellipj ("1", [1, 2])
+%!#error <U must be a scalar or matrix> ellipj ({1}, [1, 2])
+%!#error <U must be a scalar or matrix> ellipj ({1}, [1, 2])
+%!#error <U must be a scalar or matrix> ellipj ("1,2", [1, 2])
+%!#error <U must be a scalar or matrix> ellipj ({1, 2}, [1, 2])
 %!error <Invalid size combination for U and M> ellipj ([1:4], [1:3])
 %!error <Invalid size combination for U and M> ellipj (complex (1:4,1:4), [1:3])
 
--- a/libinterp/corefcn/error.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/error.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -93,22 +93,11 @@
 //
 // Valid values:
 //
-//   -2: an error has occurred, but don't print any messages.
-//   -1: an error has occurred, we are printing a traceback
 //    0: no error
 //    1: an error has occurred
 //
 int error_state = 0;
 
-// Current warning state.
-//
-//  Valid values:
-//
-//    0: no warning
-//    1: a warning has occurred
-//
-int warning_state = 0;
-
 // Tell the error handler whether to print messages, or just store
 // them for later.  Used for handling errors in eval() and
 // the 'unwind_protect' statement.
@@ -123,8 +112,6 @@
 void
 reset_error_handler (void)
 {
-  error_state = 0;
-  warning_state = 0;
   buffer_error_messages = 0;
   discard_error_messages = false;
 }
@@ -146,6 +133,198 @@
   return octave_call_stack::empty_backtrace ();
 }
 
+static void
+verror (bool save_last_error, std::ostream& os,
+        const char *name, const char *id, const char *fmt, va_list args,
+        bool with_cfn = false)
+{
+  if (discard_error_messages)
+    return;
+
+  if (! buffer_error_messages)
+    flush_octave_stdout ();
+
+  // FIXME: we really want to capture the message before it has all the
+  //        formatting goop attached to it.  We probably also want just the
+  //        message, not the traceback information.
+
+  std::ostringstream output_buf;
+
+  octave_vformat (output_buf, fmt, args);
+
+  std::string base_msg = output_buf.str ();
+
+  bool to_beep_or_not_to_beep_p = Vbeep_on_error;
+
+  std::string msg_string;
+
+  if (to_beep_or_not_to_beep_p)
+    msg_string = "\a";
+
+  if (name)
+    msg_string += std::string (name) + ": ";
+
+  // If with_fcn is specified, we'll attempt to prefix the message with the name
+  // of the current executing function. But we'll do so only if:
+  // 1. the name is not empty (anonymous function)
+  // 2. it is not already there (including the following colon)
+  if (with_cfn)
+    {
+      octave_function *curfcn = octave_call_stack::current ();
+      if (curfcn)
+        {
+          std::string cfn = curfcn->name ();
+          if (! cfn.empty ())
+            {
+              cfn += ':';
+              if (cfn.length () > base_msg.length ()
+                  || base_msg.compare (0, cfn.length (), cfn) != 0)
+                {
+                  msg_string += cfn + ' ';
+                }
+            }
+        }
+    }
+
+  msg_string += base_msg + "\n";
+
+  if (save_last_error)
+    {
+      // This is the first error in a possible series.
+
+      Vlast_error_id = id;
+      Vlast_error_message = base_msg;
+
+      octave_user_code *fcn = octave_call_stack::caller_user_code ();
+
+      if (fcn)
+        {
+          octave_idx_type curr_frame = -1;
+
+          Vlast_error_stack = octave_call_stack::backtrace (0, curr_frame);
+        }
+      else
+        Vlast_error_stack = initialize_last_error_stack ();
+    }
+
+  if (! buffer_error_messages)
+    {
+      octave_diary << msg_string;
+      os << msg_string;
+    }
+}
+
+static void
+pr_where_2 (std::ostream& os, const char *fmt, va_list args)
+{
+  if (fmt)
+    {
+      if (*fmt)
+        {
+          size_t len = strlen (fmt);
+
+          if (len > 0)
+            {
+              if (fmt[len - 1] == '\n')
+                {
+                  if (len > 1)
+                    {
+                      std::string tmp_fmt (fmt, len - 1);
+                      verror (false, os, 0, "", tmp_fmt.c_str (), args);
+                    }
+                }
+              else
+                verror (false, os, 0, "", fmt, args);
+            }
+        }
+    }
+  else
+    panic ("pr_where_2: invalid format");
+}
+
+static void
+pr_where_1 (std::ostream& os, const char *fmt, ...)
+{
+  va_list args;
+  va_start (args, fmt);
+  pr_where_2 (os, fmt, args);
+  va_end (args);
+}
+
+static void
+pr_where (std::ostream& os, const char *who)
+{
+  std::list<octave_call_stack::stack_frame> frames
+    = octave_call_stack::backtrace_frames ();
+
+  size_t nframes = frames.size ();
+
+  if (nframes > 0)
+    pr_where_1 (os, "%s: called from\n", who);
+
+  // Print the error message only if it is different from the previous one;
+  // Makes the output more concise and readable.
+  frames.unique ();
+
+  for (std::list<octave_call_stack::stack_frame>::const_iterator p = frames.begin ();
+       p != frames.end (); p++)
+    {
+      const octave_call_stack::stack_frame& elt = *p;
+
+      std::string fcn_name = elt.fcn_name ();
+      int line = elt.line ();
+      int column = elt.column ();
+
+      pr_where_1 (os, "    %s at line %d column %d\n",
+                  fcn_name.c_str (), line, column);
+    }
+}
+
+static octave_execution_exception
+make_execution_exception (const char *who)
+{
+  std::ostringstream buf;
+
+  pr_where (buf, who);
+
+  octave_execution_exception retval;
+
+  retval.set_stack_trace (buf.str ());
+
+  return retval;
+}
+
+static void
+maybe_enter_debugger (octave_execution_exception& e,
+                      bool show_stack_trace = false)
+{
+  if ((interactive || forced_interactive)
+      && Vdebug_on_error && octave_call_stack::caller_user_code ())
+    {
+      unwind_protect frame;
+      frame.protect_var (Vdebug_on_error);
+      Vdebug_on_error = false;
+
+      tree_evaluator::debug_mode = true;
+
+      tree_evaluator::current_frame = octave_call_stack::current_frame ();
+
+      if (show_stack_trace)
+        {
+          std::string stack_trace = e.info ();
+
+          if (! stack_trace.empty ())
+            {
+              std::cerr << stack_trace;
+
+              e.set_stack_trace ();
+            }
+        }
+
+      do_keyboard (octave_value_list ());
+    }
+}
+
 // Warning messages are never buffered.
 
 static void
@@ -183,193 +362,6 @@
     }
 }
 
-static void
-verror (bool save_last_error, std::ostream& os,
-        const char *name, const char *id, const char *fmt, va_list args,
-        bool with_cfn = false)
-{
-  if (discard_error_messages)
-    return;
-
-  if (! buffer_error_messages)
-    flush_octave_stdout ();
-
-  // FIXME: we really want to capture the message before it has all the
-  //        formatting goop attached to it.  We probably also want just the
-  //        message, not the traceback information.
-
-  std::ostringstream output_buf;
-
-  octave_vformat (output_buf, fmt, args);
-
-  std::string base_msg = output_buf.str ();
-
-  bool to_beep_or_not_to_beep_p = Vbeep_on_error && ! error_state;
-
-  std::string msg_string;
-
-  if (to_beep_or_not_to_beep_p)
-    msg_string = "\a";
-
-  if (name)
-    msg_string += std::string (name) + ": ";
-
-  // If with_fcn is specified, we'll attempt to prefix the message with the name
-  // of the current executing function. But we'll do so only if:
-  // 1. the name is not empty (anonymous function)
-  // 2. it is not already there (including the following colon)
-  if (with_cfn)
-    {
-      octave_function *curfcn = octave_call_stack::current ();
-      if (curfcn)
-        {
-          std::string cfn = curfcn->name ();
-          if (! cfn.empty ())
-            {
-              cfn += ':';
-              if (cfn.length () > base_msg.length ()
-                  || base_msg.compare (0, cfn.length (), cfn) != 0)
-                {
-                  msg_string += cfn + ' ';
-                }
-            }
-        }
-    }
-
-  msg_string += base_msg + "\n";
-
-  if (! error_state && save_last_error)
-    {
-      // This is the first error in a possible series.
-
-      Vlast_error_id = id;
-      Vlast_error_message = base_msg;
-
-      octave_user_code *fcn = octave_call_stack::caller_user_code ();
-
-      if (fcn)
-        {
-          octave_idx_type curr_frame = -1;
-
-          Vlast_error_stack = octave_call_stack::backtrace (0, curr_frame);
-        }
-      else
-        Vlast_error_stack = initialize_last_error_stack ();
-    }
-
-  if (! buffer_error_messages)
-    {
-      octave_diary << msg_string;
-      os << msg_string;
-    }
-}
-
-static void
-pr_where_2 (const char *fmt, va_list args)
-{
-  if (fmt)
-    {
-      if (*fmt)
-        {
-          size_t len = strlen (fmt);
-
-          if (len > 0)
-            {
-              if (fmt[len - 1] == '\n')
-                {
-                  if (len > 1)
-                    {
-                      char *tmp_fmt = strsave (fmt);
-                      tmp_fmt[len - 1] = '\0';
-                      verror (false, std::cerr, 0, "", tmp_fmt, args);
-                      delete [] tmp_fmt;
-                    }
-                }
-              else
-                verror (false, std::cerr, 0, "", fmt, args);
-            }
-        }
-    }
-  else
-    panic ("pr_where_2: invalid format");
-}
-
-static void
-pr_where_1 (const char *fmt, ...)
-{
-  va_list args;
-  va_start (args, fmt);
-  pr_where_2 (fmt, args);
-  va_end (args);
-}
-
-static void
-pr_where (const char *who)
-{
-  std::list<octave_call_stack::stack_frame> frames
-    = octave_call_stack::backtrace_frames ();
-
-  size_t nframes = frames.size ();
-
-  if (nframes > 0)
-    pr_where_1 ("%s: called from\n", who);
-
-  for (std::list<octave_call_stack::stack_frame>::const_iterator p = frames.begin ();
-       p != frames.end (); p++)
-    {
-      const octave_call_stack::stack_frame& elt = *p;
-
-      std::string fcn_name = elt.fcn_name ();
-      int line = elt.line ();
-      int column = elt.column ();
-
-      pr_where_1 ("    %s at line %d column %d\n",
-                  fcn_name.c_str (), line, column);
-    }
-}
-
-// Note that we don't actually print any message if the error string
-// is just "" or "\n".  This allows error ("") and error ("\n") to
-// just set the error state.
-
-static void
-error_1 (std::ostream& os, const char *name, const char *id,
-         const char *fmt, va_list args, bool with_cfn = false)
-{
-  if (error_state != -2)
-    {
-      if (fmt && *fmt)
-        {
-          size_t len = strlen (fmt);
-
-          if (len > 0)
-            {
-              if (fmt[len - 1] == '\n')
-                {
-                  if (len > 1)
-                    {
-                      // Strip newline before issuing error
-                      std::string tmp_fmt (fmt, len - 1);
-                      verror (true, os, name, id, tmp_fmt.c_str (),
-                              args, with_cfn);
-                    }
-
-                  error_state = -2;
-                }
-              else
-                {
-                  verror (true, os, name, id, fmt, args, with_cfn);
-
-                  if (! error_state)
-                    error_state = 1;
-                }
-            }
-        }
-      else
-        panic ("error_1: invalid format");
-    }
-}
-
 void
 vmessage (const char *name, const char *fmt, va_list args)
 {
@@ -401,11 +393,30 @@
   va_end (args);
 }
 
-void
+static void
+usage_1 (octave_execution_exception& e, const char *id,
+         const char *fmt, va_list args) GCC_ATTR_NORETURN;
+
+static void
+usage_1 (octave_execution_exception& e, const char *id,
+         const char *fmt, va_list args)
+{
+  verror (true, std::cerr, "usage", id, fmt, args);
+
+  maybe_enter_debugger (e);
+
+  throw e;
+}
+
+static void
+usage_1 (const char *id, const char *fmt, va_list args) GCC_ATTR_NORETURN;
+
+static void
 usage_1 (const char *id, const char *fmt, va_list args)
 {
-  verror (true, std::cerr, "usage", id, fmt, args);
-  error_state = -1;
+  octave_execution_exception e = make_execution_exception ("usage");
+
+  usage_1 (e, id, fmt, args);
 }
 
 void
@@ -439,37 +450,75 @@
 }
 
 static void
-error_2 (const char *id, const char *fmt, va_list args, bool with_cfn = false)
-{
-  int init_state = error_state;
-
-  error_1 (std::cerr, "error", id, fmt, args, with_cfn);
+error_1 (octave_execution_exception& e, std::ostream& os,
+         const char *name, const char *id, const char *fmt,
+         va_list args, bool with_cfn = false) GCC_ATTR_NORETURN;
 
-  bool in_user_code = octave_call_stack::caller_user_code () != 0;
+static void
+error_1 (octave_execution_exception& e, std::ostream& os,
+         const char *name, const char *id, const char *fmt,
+         va_list args, bool with_cfn)
+{
+  bool show_stack_trace = false;
 
-  if (error_state != -2 && in_user_code && ! discard_error_messages)
-    pr_where ("error");
-
-  if (interactive && Vdebug_on_error && init_state == 0 && in_user_code)
+  if (fmt)
     {
-      unwind_protect frame;
-      frame.protect_var (Vdebug_on_error);
-      Vdebug_on_error = false;
+      if (*fmt)
+        {
+          size_t len = strlen (fmt);
 
-      error_state = 0;
+          if (len > 0)
+            {
+              if (fmt[len - 1] == '\n')
+                {
+                  if (len > 1)
+                    {
+                      std::string tmp_fmt (fmt, len - 1);
+                      verror (true, os, name, id, tmp_fmt.c_str (),
+                              args, with_cfn);
+                    }
+
+                  // If format ends with newline, suppress stack trace.
+                  e.set_stack_trace ();
+                }
+              else
+                {
+                  verror (true, os, name, id, fmt, args, with_cfn);
+
+                  bool in_user_code = octave_call_stack::caller_user_code () != 0;
 
-      tree_evaluator::debug_mode = true;
+                  if (in_user_code && ! discard_error_messages)
+                    show_stack_trace = true;
+                }
+            }
+        }
+    }
+  else
+    panic ("error_1: invalid format");
+
+  maybe_enter_debugger (e, show_stack_trace);
 
-      tree_evaluator::current_frame = octave_call_stack::current_frame ();
+  throw e;
+}
+
+static void
+error_1 (std::ostream& os, const char *name, const char *id,
+         const char *fmt, va_list args,
+         bool with_cfn = false) GCC_ATTR_NORETURN;
 
-      do_keyboard (octave_value_list ());
-    }
+static void
+error_1 (std::ostream& os, const char *name, const char *id,
+         const char *fmt, va_list args, bool with_cfn)
+{
+  octave_execution_exception e = make_execution_exception ("error");
+
+  error_1 (e, os, name, id, fmt, args, with_cfn);
 }
 
 void
 verror (const char *fmt, va_list args)
 {
-  error_2 ("", fmt, args);
+  error_1 (std::cerr, "error", "", fmt, args);
 }
 
 void
@@ -482,9 +531,24 @@
 }
 
 void
+verror (octave_execution_exception& e, const char *fmt, va_list args)
+{
+  error_1 (e, std::cerr, "error", "", fmt, args);
+}
+
+void
+error (octave_execution_exception& e, const char *fmt, ...)
+{
+  va_list args;
+  va_start (args, fmt);
+  verror (e, fmt, args);
+  va_end (args);
+}
+
+void
 verror_with_cfn (const char *fmt, va_list args)
 {
-  error_2 ("", fmt, args, true);
+  error_1 (std::cerr, "error", "", fmt, args, true);
 }
 
 void
@@ -499,7 +563,7 @@
 void
 verror_with_id (const char *id, const char *fmt, va_list args)
 {
-  error_2 (id, fmt, args);
+  error_1 (std::cerr, "error", id, fmt, args);
 }
 
 void
@@ -514,7 +578,7 @@
 void
 verror_with_id_cfn (const char *id, const char *fmt, va_list args)
 {
-  error_2 (id, fmt, args, true);
+  error_1 (std::cerr, "error", id, fmt, args, true);
 }
 
 void
@@ -628,7 +692,7 @@
     {
       // Handle this warning as an error.
 
-      error_2 (id, fmt, args);
+      error_1 (std::cerr, "error", id, fmt, args);
     }
   else if (warn_opt == 1)
     {
@@ -647,13 +711,10 @@
 
       bool in_user_code = octave_call_stack::caller_user_code () != 0;
 
-
       if (! fmt_suppresses_backtrace && in_user_code
-          && Vbacktrace_on_warning && ! warning_state
+          && Vbacktrace_on_warning
           && ! discard_warning_messages)
-        pr_where ("warning");
-
-      warning_state = 1;
+        pr_where (std::cerr, "warning");
 
       if ((interactive || forced_interactive)
           && Vdebug_on_warning && in_user_code)
@@ -779,9 +840,7 @@
 
   std::string tstr;
 
-  int nargin = args.length ();
-
-  if (nargin > 0)
+  if (args.length () > 0)
     {
       octave_value arg;
 
@@ -818,11 +877,9 @@
         {
           if (len > 1)
             {
-              char *tmp_msg = strsave (msg);
-              tmp_msg[len - 1] = '\0';
-              f (id, "%s\n", tmp_msg);
+              std::string tmp_msg (msg, len - 1);
+              f (id, "%s\n", tmp_msg.c_str ());
               retval = tmp_msg;
-              delete [] tmp_msg;
             }
         }
       else
@@ -848,129 +905,130 @@
 @end deftypefn")
 {
   octave_value retval;
-  int nargin = args.length ();
+
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin != 1)
-    print_usage ();
-  else
+  const octave_scalar_map err = args(0).scalar_map_value ();
+
+  if (err.contains ("message") && err.contains ("identifier"))
     {
-      const octave_scalar_map err = args(0).scalar_map_value ();
+      std::string msg = err.contents ("message").string_value ();
+      std::string id = err.contents ("identifier").string_value ();
+      int len = msg.length ();
 
-      if (! error_state)
+      std::string file;
+      std::string nm;
+      int l = -1;
+      int c = -1;
+
+      octave_map err_stack = initialize_last_error_stack ();
+
+      if (err.contains ("stack"))
         {
-          if (err.contains ("message") && err.contains ("identifier"))
+          err_stack = err.contents ("stack").map_value ();
+
+          if (err_stack.numel () > 0)
             {
-              std::string msg = err.contents ("message").string_value ();
-              std::string id = err.contents ("identifier").string_value ();
-              int len = msg.length ();
+              if (err_stack.contains ("file"))
+                file = err_stack.contents ("file")(0).string_value ();
+
+              if (err_stack.contains ("name"))
+                nm = err_stack.contents ("name")(0).string_value ();
+
+              if (err_stack.contains ("line"))
+                l = err_stack.contents ("line")(0).nint_value ();
+
+              if (err_stack.contains ("column"))
+                c = err_stack.contents ("column")(0).nint_value ();
+            }
+        }
 
-              std::string file;
-              std::string nm;
-              int l = -1;
-              int c = -1;
+      // Ugh.
+      std::string tmp_msg (msg);
+      if (tmp_msg[len-1] == '\n')
+        {
+          if (len > 1)
+            {
+              tmp_msg.erase (len - 1);
+              rethrow_error (id.c_str (), "%s\n", tmp_msg.c_str ());
+            }
+        }
+      else
+        rethrow_error (id.c_str (), "%s", tmp_msg.c_str ());
 
-              octave_map err_stack = initialize_last_error_stack ();
+      // FIXME: is this the right thing to do for Vlast_error_stack?
+      //        Should it be saved and restored with unwind_protect?
+
+      Vlast_error_stack = err_stack;
 
-              if (err.contains ("stack"))
+      if (err.contains ("stack"))
+        {
+          if (file.empty ())
+            {
+              if (nm.empty ())
                 {
-                  err_stack = err.contents ("stack").map_value ();
-
-                  if (err_stack.numel () > 0)
+                  if (l > 0)
                     {
-                      if (err_stack.contains ("file"))
-                        file = err_stack.contents ("file")(0).string_value ();
-
-                      if (err_stack.contains ("name"))
-                        nm = err_stack.contents ("name")(0).string_value ();
-
-                      if (err_stack.contains ("line"))
-                        l = err_stack.contents ("line")(0).nint_value ();
-
-                      if (err_stack.contains ("column"))
-                        c = err_stack.contents ("column")(0).nint_value ();
-                    }
-                }
-
-              // Ugh.
-              char *tmp_msg = strsave (msg.c_str ());
-              if (tmp_msg[len-1] == '\n')
-                {
-                  if (len > 1)
-                    {
-                      tmp_msg[len - 1] = '\0';
-                      rethrow_error (id.c_str (), "%s\n", tmp_msg);
+                      if (c > 0)
+                        pr_where_1 (std::cerr,
+                                    "error: near line %d, column %d",
+                                    l, c);
+                      else
+                        pr_where_1 (std::cerr, "error: near line %d", l);
                     }
                 }
               else
-                rethrow_error (id.c_str (), "%s", tmp_msg);
-              delete [] tmp_msg;
-
-              // FIXME: is this the right thing to do for Vlast_error_stack?
-              //        Should it be saved and restored with unwind_protect?
-
-              Vlast_error_stack = err_stack;
-
-              if (err.contains ("stack"))
                 {
-                  if (file.empty ())
+                  if (l > 0)
                     {
-                      if (nm.empty ())
-                        {
-                          if (l > 0)
-                            {
-                              if (c > 0)
-                                pr_where_1 ("error: near line %d, column %d",
-                                            l, c);
-                              else
-                                pr_where_1 ("error: near line %d", l);
-                            }
-                        }
+                      if (c > 0)
+                        pr_where_1 (std::cerr,
+                                    "error: called from '%s' near line %d, column %d",
+                                    nm.c_str (), l, c);
                       else
-                        {
-                          if (l > 0)
-                            {
-                              if (c > 0)
-                                pr_where_1 ("error: called from '%s' near line %d, column %d",
-                                            nm.c_str (), l, c);
-                              else
-                                pr_where_1 ("error: called from '%d' near line %d",
-                                            nm.c_str (), l);
-                            }
-                        }
-                    }
-                  else
-                    {
-                      if (nm.empty ())
-                        {
-                          if (l > 0)
-                            {
-                              if (c > 0)
-                                pr_where_1 ("error: in file %s near line %d, column %d",
-                                            file.c_str (), l, c);
-                              else
-                                pr_where_1 ("error: in file %s near line %d",
-                                            file.c_str (), l);
-                            }
-                        }
-                      else
-                        {
-                          if (l > 0)
-                            {
-                              if (c > 0)
-                                pr_where_1 ("error: called from '%s' in file %s near line %d, column %d",
-                                            nm.c_str (), file.c_str (), l, c);
-                              else
-                                pr_where_1 ("error: called from '%d' in file %s near line %d",
-                                            nm.c_str (), file.c_str (), l);
-                            }
-                        }
+                        pr_where_1 (std::cerr,
+                                    "error: called from '%d' near line %d",
+                                    nm.c_str (), l);
                     }
                 }
             }
           else
-            error ("rethrow: ERR structure must contain the fields 'message and 'identifier'");
+            {
+              if (nm.empty ())
+                {
+                  if (l > 0)
+                    {
+                      if (c > 0)
+                        pr_where_1 (std::cerr,
+                                    "error: in file %s near line %d, column %d",
+                                    file.c_str (), l, c);
+                      else
+                        pr_where_1 (std::cerr,
+                                    "error: in file %s near line %d",
+                                    file.c_str (), l);
+                    }
+                }
+              else
+                {
+                  if (l > 0)
+                    {
+                      if (c > 0)
+                        pr_where_1 (std::cerr,
+                                    "error: called from '%s' in file %s near line %d, column %d",
+                                    nm.c_str (), file.c_str (), l, c);
+                      else
+                        pr_where_1 (std::cerr,
+                                    "error: called from '%d' in file %s near line %d",
+                                    nm.c_str (), file.c_str (), l);
+                    }
+                }
+            }
         }
     }
+  else
+    error ("rethrow: ERR structure must contain the fields 'message and 'identifier'");
+
   return retval;
 }
 
@@ -994,31 +1052,28 @@
     {
       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] != ':')
         {
-          // 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)
             {
-              if (nargin > 1)
-                {
-                  id = arg1;
+              id = arg1;
 
-                  nargs.resize (nargin-1);
+              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";
+              for (int i = 1; i < nargin; i++)
+                nargs(i-1) = args(i);
             }
+          else
+            nargs(0) = "call to " + caller
+              + " with message identifier requires message";
         }
     }
 
@@ -1124,55 +1179,48 @@
 
   if (nargin == 0)
     print_usage ();
-  else
-    {
-      bool have_fmt = false;
 
-      if (nargin == 1 && args(0).is_map ())
-        {
-          // empty struct is not an error.  return and resume calling function.
-          if (args(0).is_empty ())
-            return retval;
+  bool have_fmt = false;
 
-          octave_value_list tmp;
-
-          octave_scalar_map m = args(0).scalar_map_value ();
+  if (nargin == 1 && args(0).is_map ())
+    {
+      // empty struct is not an error.  return and resume calling function.
+      if (args(0).is_empty ())
+        return retval;
 
-          // empty struct is not an error.  return and resume calling function.
-          if (m.nfields () == 0)
-            return retval;
-
-          if (m.contains ("message"))
-            {
-              octave_value c = m.getfield ("message");
+      octave_value_list tmp;
 
-              if (c.is_string ())
-                nargs(0) = c.string_value ();
-            }
+      octave_scalar_map m = args(0).scalar_map_value ();
 
-          if (m.contains ("identifier"))
-            {
-              octave_value c = m.getfield ("identifier");
+      // empty struct is not an error.  return and resume calling function.
+      if (m.nfields () == 0)
+        return retval;
 
-              if (c.is_string ())
-                id = c.string_value ();
-            }
+      if (m.contains ("message"))
+        {
+          octave_value c = m.getfield ("message");
 
-          // FIXME: also need to handle "stack" field in error 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);
-
-          if (error_state)
-            return retval;
+          if (c.is_string ())
+            nargs(0) = c.string_value ();
         }
 
-      handle_message (error_with_id, id.c_str (), "unspecified error",
-                      nargs, have_fmt);
+      if (m.contains ("identifier"))
+        {
+          octave_value c = m.getfield ("identifier");
+
+          if (c.is_string ())
+            id = c.string_value ();
+        }
+
+      // FIXME: also need to handle "stack" field in error 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, have_fmt);
 
   return retval;
 }
@@ -1192,6 +1240,8 @@
 
   octave_idx_type nel = ident.numel ();
 
+  assert (nel != 0);
+
   bool found = false;
 
   std::string val;
@@ -1219,13 +1269,14 @@
         }
     }
 
-  if (found)
-    {
-      retval.assign ("identifier", id);
-      retval.assign ("state", val);
-    }
-  else
-    error ("warning: unable to find default warning state!");
+  // The warning state "all" is always supposed to remain in the list,
+  // so we should always find a state, either explicitly or by using the
+  // state for "all".
+
+  assert (found);
+
+  retval.assign ("identifier", id);
+  retval.assign ("state", val);
 
   return retval;
 }
@@ -1418,8 +1469,7 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-  int argc = nargin + 1;
+  int argc = args.length () + 1;
 
   bool done = false;
 
@@ -1427,220 +1477,211 @@
     {
       string_vector argv = args.make_argv ("warning");
 
-      if (! error_state)
-        {
-          std::string arg1 = argv(1);
-          std::string arg2 = "all";
-
-          if (argc >= 3)
-            arg2 = argv(2);
+      std::string arg1 = argv(1);
+      std::string arg2 = "all";
 
-          if (arg1 == "on" || arg1 == "off" || arg1 == "error")
-            {
-              octave_map old_warning_options = warning_options;
+      if (argc >= 3)
+        arg2 = argv(2);
 
-              if (argc == 4 && argv(3) == "local"
-                  && ! symbol_table::at_top_level ())
-                {
-                  symbol_table::scope_id scope
-                    = octave_call_stack::current_scope ();
-
-                  symbol_table::context_id context
-                    = octave_call_stack::current_context ();
+      if (arg1 == "on" || arg1 == "off" || arg1 == "error")
+        {
+          octave_map old_warning_options = warning_options;
 
-                  octave_scalar_map val = warning_query (arg2);
-
-                  octave_value curr_state = val.contents ("state");
-
-                  // FIXME: this might be better with a dictionary object.
+          if (argc == 4 && argv(3) == "local"
+              && ! symbol_table::at_top_level ())
+            {
+              symbol_table::scope_id scope
+                = octave_call_stack::current_scope ();
 
-                  octave_value curr_warning_states
-                    = symbol_table::varval (".saved_warning_states.",
-                                            scope, context);
-
-                  octave_map m;
+              symbol_table::context_id context
+                = octave_call_stack::current_context ();
 
-                  if (curr_warning_states.is_defined ())
-                    m = curr_warning_states.map_value ();
-                  else
-                    {
-                      string_vector fields (2);
+              octave_scalar_map val = warning_query (arg2);
+
+              octave_value curr_state = val.contents ("state");
 
-                      fields(0) = "identifier";
-                      fields(1) = "state";
+              // FIXME: this might be better with a dictionary object.
 
-                      m = octave_map (dim_vector (0, 1), fields);
-                    }
+              octave_value curr_warning_states
+                = symbol_table::varval (".saved_warning_states.",
+                                        scope, context);
 
-                  if (error_state)
-                    panic_impossible ();
-
-                  Cell ids = m.contents ("identifier");
-                  Cell states = m.contents ("state");
+              octave_map m;
 
-                  octave_idx_type nel = states.numel ();
-                  bool found = false;
-                  octave_idx_type i;
-                  for (i = 0; i < nel; i++)
-                    {
-                      std::string id = ids(i).string_value ();
+              if (curr_warning_states.is_defined ())
+                m = curr_warning_states.map_value ();
+              else
+                {
+                  string_vector fields (2);
 
-                      if (error_state)
-                        panic_impossible ();
+                  fields(0) = "identifier";
+                  fields(1) = "state";
+
+                  m = octave_map (dim_vector (0, 1), fields);
+                }
 
-                      if (id == arg2)
-                        {
-                          states(i) = curr_state;
-                          found = true;
-                          break;
-                        }
-                    }
-
-                  if (! found)
-                    {
-                      m.resize (dim_vector (nel+1, 1));
+              Cell ids = m.contents ("identifier");
+              Cell states = m.contents ("state");
 
-                      ids.resize (dim_vector (nel+1, 1));
-                      states.resize (dim_vector (nel+1, 1));
-
-                      ids(nel) = arg2;
-                      states(nel) = curr_state;
-                    }
+              octave_idx_type nel = states.numel ();
+              bool found = false;
+              octave_idx_type i;
+              for (i = 0; i < nel; i++)
+                {
+                  std::string id = ids(i).string_value ();
 
-                  m.contents ("identifier") = ids;
-                  m.contents ("state") = states;
-
-                  symbol_table::assign
-                    (".saved_warning_states.", m, scope, context);
-
-                  // Now ignore the "local" argument and continue to
-                  // handle the current setting.
-                  argc--;
+                  if (id == arg2)
+                    {
+                      states(i) = curr_state;
+                      found = true;
+                      break;
+                    }
                 }
 
-              if (arg2 == "all")
+              if (! found)
                 {
-                  octave_map tmp;
+                  m.resize (dim_vector (nel+1, 1));
+
+                  ids.resize (dim_vector (nel+1, 1));
+                  states.resize (dim_vector (nel+1, 1));
 
-                  Cell id (1, 1);
-                  Cell st (1, 1);
+                  ids(nel) = arg2;
+                  states(nel) = curr_state;
+                }
 
-                  id(0) = arg2;
-                  st(0) = arg1;
+              m.contents ("identifier") = ids;
+              m.contents ("state") = states;
 
-                  // Since internal Octave functions are not
-                  // compatible, turning all warnings into errors
-                  // should leave the state of
-                  // Octave:language-extension alone.
+              symbol_table::assign
+                (".saved_warning_states.", m, scope, context);
+
+              // Now ignore the "local" argument and continue to
+              // handle the current setting.
+              argc--;
+            }
 
-                  if (arg1 == "error"
-                      && warning_options.contains ("identifier"))
-                    {
-                      octave_idx_type n = 1;
+          if (arg2 == "all")
+            {
+              octave_map tmp;
+
+              Cell id (1, 1);
+              Cell st (1, 1);
+
+              id(0) = arg2;
+              st(0) = arg1;
 
-                      Cell tid = warning_options.contents ("identifier");
-                      Cell tst = warning_options.contents ("state");
+              // Since internal Octave functions are not
+              // compatible, turning all warnings into errors
+              // should leave the state of
+              // Octave:language-extension alone.
 
-                      for (octave_idx_type i = 0; i < tid.numel (); i++)
-                        {
-                          octave_value vid = tid(i);
+              if (arg1 == "error"
+                  && warning_options.contains ("identifier"))
+                {
+                  octave_idx_type n = 1;
 
-                          if (vid.is_string ())
-                            {
-                              std::string key = vid.string_value ();
+                  Cell tid = warning_options.contents ("identifier");
+                  Cell tst = warning_options.contents ("state");
 
-                              if (key == "Octave:language-extension"
-                                  || key == "Octave:single-quote-string")
-                                {
-                                  id.resize (dim_vector (1, n+1));
-                                  st.resize (dim_vector (1, n+1));
+                  for (octave_idx_type i = 0; i < tid.numel (); i++)
+                    {
+                      octave_value vid = tid(i);
+
+                      if (vid.is_string ())
+                        {
+                          std::string key = vid.string_value ();
 
-                                  id(n) = tid(i);
-                                  st(n) = tst(i);
+                          if (key == "Octave:language-extension"
+                              || key == "Octave:single-quote-string")
+                            {
+                              id.resize (dim_vector (1, n+1));
+                              st.resize (dim_vector (1, n+1));
 
-                                  n++;
-                                }
+                              id(n) = tid(i);
+                              st(n) = tst(i);
+
+                              n++;
                             }
                         }
                     }
-
-                  tmp.assign ("identifier", id);
-                  tmp.assign ("state", st);
-
-                  warning_options = tmp;
-
-                  done = true;
-                }
-              else if (arg2 == "backtrace")
-                {
-                  if (arg1 != "error")
-                    {
-                      Vbacktrace_on_warning = (arg1 == "on");
-                      done = true;
-                    }
-                }
-              else if (arg2 == "debug")
-                {
-                  if (arg1 != "error")
-                    {
-                      Vdebug_on_warning = (arg1 == "on");
-                      done = true;
-                    }
-                }
-              else if (arg2 == "verbose")
-                {
-                  if (arg1 != "error")
-                    {
-                      Vverbose_warning = (arg1 == "on");
-                      done = true;
-                    }
-                }
-              else if (arg2 == "quiet")
-                {
-                  if (arg1 != "error")
-                    {
-                      Vquiet_warning = (arg1 == "on");
-                      done = true;
-                    }
-                }
-              else
-                {
-                  if (arg2 == "last")
-                    arg2 = Vlast_warning_id;
-
-                  set_warning_option (arg1, arg2);
-
-                  done = true;
                 }
 
-              if (done && nargout > 0)
-                retval = old_warning_options;
-            }
-          else if (arg1 == "query")
-            {
-              if (arg2 == "all")
-                retval = warning_options;
-              else if (arg2 == "backtrace" || arg2 == "debug"
-                       || arg2 == "verbose" || arg2 == "quiet")
-                {
-                  octave_scalar_map tmp;
-                  tmp.assign ("identifier", arg2);
-                  if (arg2 == "backtrace")
-                    tmp.assign ("state", Vbacktrace_on_warning ? "on" : "off");
-                  else if (arg2 == "debug")
-                    tmp.assign ("state", Vdebug_on_warning ? "on" : "off");
-                  else if (arg2 == "verbose")
-                    tmp.assign ("state", Vverbose_warning ? "on" : "off");
-                  else
-                    tmp.assign ("state", Vquiet_warning ? "on" : "off");
+              tmp.assign ("identifier", id);
+              tmp.assign ("state", st);
 
-                  retval = tmp;
-                }
-              else
-                retval = warning_query (arg2);
+              warning_options = tmp;
 
               done = true;
             }
+          else if (arg2 == "backtrace")
+            {
+              if (arg1 != "error")
+                {
+                  Vbacktrace_on_warning = (arg1 == "on");
+                  done = true;
+                }
+            }
+          else if (arg2 == "debug")
+            {
+              if (arg1 != "error")
+                {
+                  Vdebug_on_warning = (arg1 == "on");
+                  done = true;
+                }
+            }
+          else if (arg2 == "verbose")
+            {
+              if (arg1 != "error")
+                {
+                  Vverbose_warning = (arg1 == "on");
+                  done = true;
+                }
+            }
+          else if (arg2 == "quiet")
+            {
+              if (arg1 != "error")
+                {
+                  Vquiet_warning = (arg1 == "on");
+                  done = true;
+                }
+            }
+          else
+            {
+              if (arg2 == "last")
+                arg2 = Vlast_warning_id;
+
+              set_warning_option (arg1, arg2);
+
+              done = true;
+            }
+
+          if (done && nargout > 0)
+            retval = old_warning_options;
+        }
+      else if (arg1 == "query")
+        {
+          if (arg2 == "all")
+            retval = warning_options;
+          else if (arg2 == "backtrace" || arg2 == "debug"
+                   || arg2 == "verbose" || arg2 == "quiet")
+            {
+              octave_scalar_map tmp;
+              tmp.assign ("identifier", arg2);
+              if (arg2 == "backtrace")
+                tmp.assign ("state", Vbacktrace_on_warning ? "on" : "off");
+              else if (arg2 == "debug")
+                tmp.assign ("state", Vdebug_on_warning ? "on" : "off");
+              else if (arg2 == "verbose")
+                tmp.assign ("state", Vverbose_warning ? "on" : "off");
+              else
+                tmp.assign ("state", Vquiet_warning ? "on" : "off");
+
+              retval = tmp;
+            }
+          else
+            retval = warning_query (arg2);
+
+          done = true;
         }
     }
   else if (argc == 1)
@@ -1676,14 +1717,11 @@
                   std::string tst = state(i).string_value ();
                   std::string tid = ident(i).string_value ();
 
-                  if (error_state)
-                    return retval;
-
                   set_warning_option (tst, tid);
                 }
             }
           else
-            error ("warning: expecting structure with fields 'identifier' and 'state'");
+            error ("warning: STATE structure must have fields 'identifier' and 'state'");
 
           done = true;
 
@@ -1692,7 +1730,7 @@
         }
     }
 
-  if (! (error_state || done))
+  if (! done)
     {
       octave_value_list nargs = args;
 
@@ -1700,9 +1738,6 @@
 
       bool have_fmt = maybe_extract_message_id ("warning", args, nargs, id);
 
-      if (error_state)
-        return retval;
-
       std::string prev_msg = Vlast_warning_message;
 
       std::string curr_msg = handle_message (warning_with_id, id.c_str (),
@@ -1807,130 +1842,116 @@
 @seealso{lasterr, error, lastwarn}\n\
 @end deftypefn")
 {
-  octave_value retval;
   int nargin = args.length ();
 
-  unwind_protect frame;
+  if (nargin > 1)
+    print_usage ();
 
-  frame.protect_var (error_state);
-  error_state = 0;
+  octave_scalar_map err;
 
-  if (nargin < 2)
-    {
-      octave_scalar_map err;
+  err.assign ("message", Vlast_error_message);
+  err.assign ("identifier", Vlast_error_id);
 
-      err.assign ("message", Vlast_error_message);
-      err.assign ("identifier", Vlast_error_id);
+  err.assign ("stack", octave_value (Vlast_error_stack));
 
-      err.assign ("stack", octave_value (Vlast_error_stack));
-
-      if (nargin == 1)
+  if (nargin == 1)
+    {
+      if (args(0).is_string ())
         {
-          if (args(0).is_string ())
+          if (args(0).string_value () == "reset")
             {
-              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");
+              Vlast_error_stack = initialize_last_error_stack ();
             }
-          else if (args(0).is_map ())
+          else
+            error ("lasterror: unrecognized string argument");
+        }
+      else if (args(0).is_map ())
+        {
+          octave_scalar_map new_err = args(0).scalar_map_value ();
+          octave_scalar_map new_err_stack;
+          std::string new_error_message;
+          std::string new_error_id;
+          std::string new_error_file;
+          std::string new_error_name;
+          int new_error_line = -1;
+          int new_error_column = -1;
+
+          if (new_err.contains ("message"))
             {
-              octave_scalar_map new_err = args(0).scalar_map_value ();
-              octave_scalar_map new_err_stack;
-              std::string new_error_message;
-              std::string new_error_id;
-              std::string new_error_file;
-              std::string new_error_name;
-              int new_error_line = -1;
-              int new_error_column = -1;
+              const std::string tmp =
+                new_err.getfield ("message").string_value ();
+              new_error_message = tmp;
+            }
 
-              if (! error_state && new_err.contains ("message"))
+          if (new_err.contains ("identifier"))
+            {
+              const std::string tmp =
+                new_err.getfield ("identifier").string_value ();
+              new_error_id = tmp;
+            }
+
+          if (new_err.contains ("stack"))
+            {
+              new_err_stack =
+                new_err.getfield ("stack").scalar_map_value ();
+
+              if (new_err_stack.contains ("file"))
                 {
                   const std::string tmp =
-                    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_error_id = tmp;
+                    new_err_stack.getfield ("file").string_value ();
+                  new_error_file = tmp;
                 }
 
-              if (! error_state && new_err.contains ("stack"))
+              if (new_err_stack.contains ("name"))
                 {
-                  new_err_stack =
-                    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_error_file = tmp;
-                    }
+                  const std::string tmp =
+                    new_err_stack.getfield ("name").string_value ();
+                  new_error_name = tmp;
+                }
 
-                  if (! error_state && new_err_stack.contains ("name"))
-                    {
-                      const std::string tmp =
-                        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_error_line = tmp;
-                    }
-
-                  if (! error_state && new_err_stack.contains ("column"))
-                    {
-                      const int tmp =
-                        new_err_stack.getfield ("column").nint_value ();
-                      new_error_column = tmp;
-                    }
+              if (new_err_stack.contains ("line"))
+                {
+                  const int tmp =
+                    new_err_stack.getfield ("line").nint_value ();
+                  new_error_line = tmp;
                 }
 
-              if (! error_state)
+              if (new_err_stack.contains ("column"))
                 {
-                  Vlast_error_message = new_error_message;
-                  Vlast_error_id = new_error_id;
-
-                  if (new_err.contains ("stack"))
-                    {
-                      new_err_stack.setfield ("file", new_error_file);
-                      new_err_stack.setfield ("name", new_error_name);
-                      new_err_stack.setfield ("line", new_error_line);
-                      new_err_stack.setfield ("column", new_error_column);
-                      Vlast_error_stack = new_err_stack;
-                    }
-                  else
-                    {
-                      // No stack field.  Fill it in with backtrace info.
-                      octave_idx_type curr_frame = -1;
-
-                      Vlast_error_stack
-                        = octave_call_stack::backtrace (0, curr_frame);
-                    }
+                  const int tmp =
+                    new_err_stack.getfield ("column").nint_value ();
+                  new_error_column = tmp;
                 }
             }
-          else
-            error ("lasterror: argument must be a structure or a string");
-        }
+
+          Vlast_error_message = new_error_message;
+          Vlast_error_id = new_error_id;
 
-      if (! error_state)
-        retval = err;
+          if (new_err.contains ("stack"))
+            {
+              new_err_stack.setfield ("file", new_error_file);
+              new_err_stack.setfield ("name", new_error_name);
+              new_err_stack.setfield ("line", new_error_line);
+              new_err_stack.setfield ("column", new_error_column);
+              Vlast_error_stack = new_err_stack;
+            }
+          else
+            {
+              // No stack field.  Fill it in with backtrace info.
+              octave_idx_type curr_frame = -1;
+
+              Vlast_error_stack
+                = octave_call_stack::backtrace (0, curr_frame);
+            }
+        }
+      else
+        error ("lasterror: argument must be a structure or a string");
     }
-  else
-    print_usage ();
 
-  return retval;
+  return octave_value (err);
 }
 
 DEFUN (lasterr, args, nargout,
@@ -1949,43 +1970,31 @@
 @seealso{lasterror, error, lastwarn}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
-  unwind_protect frame;
-
-  frame.protect_var (error_state);
-  error_state = 0;
-
-  int argc = args.length () + 1;
-
-  if (argc < 4)
-    {
-      string_vector argv = args.make_argv ("lasterr");
+  int nargin = args.length ();
 
-      if (! error_state)
-        {
-          std::string prev_error_id = Vlast_error_id;
-          std::string prev_error_message = Vlast_error_message;
-
-          if (argc > 2)
-            Vlast_error_id = argv(2);
-
-          if (argc > 1)
-            Vlast_error_message = argv(1);
-
-          if (argc == 1 || nargout > 0)
-            {
-              retval(1) = prev_error_id;
-              retval(0) = prev_error_message;
-            }
-        }
-      else
-        error ("lasterr: all arguments must be strings");
-    }
-  else
+  if (nargin > 2)
     print_usage ();
 
-  return retval;
+  string_vector argv = args.make_argv ("lasterr");
+
+  std::string prev_error_id = Vlast_error_id;
+  std::string prev_error_message = Vlast_error_message;
+
+  if (nargin == 2)
+    {
+      Vlast_error_id = argv(2);
+      Vlast_error_message = argv(1);
+    }
+  else if (nargin == 1)
+    {
+      Vlast_error_id = "";
+      Vlast_error_message = argv(1);
+    }
+
+  if (nargin == 0 || nargout > 0)
+    return ovl (prev_error_message, prev_error_id);
+  else
+    return octave_value_list ();
 }
 
 DEFUN (lastwarn, args, nargout,
@@ -2004,39 +2013,31 @@
 @seealso{warning, lasterror, lasterr}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
-  int argc = args.length () + 1;
-
-  if (argc < 4)
-    {
-      string_vector argv = args.make_argv ("lastwarn");
-
-      if (! error_state)
-        {
-          std::string prev_warning_id = Vlast_warning_id;
-          std::string prev_warning_message = Vlast_warning_message;
+  int nargin = args.length ();
 
-          if (argc > 2)
-            Vlast_warning_id = argv(2);
-
-          if (argc > 1)
-            Vlast_warning_message = argv(1);
-
-          if (argc == 1 || nargout > 0)
-            {
-              warning_state = 0;
-              retval(1) = prev_warning_id;
-              retval(0) = prev_warning_message;
-            }
-        }
-      else
-        error ("lastwarn: all arguments must be strings");
-    }
-  else
+  if (nargin > 2)
     print_usage ();
 
-  return retval;
+  string_vector argv = args.make_argv ("lastwarn");
+
+  std::string prev_warning_id = Vlast_warning_id;
+  std::string prev_warning_message = Vlast_warning_message;
+
+  if (nargin == 2)
+    {
+      Vlast_warning_id = argv(2);
+      Vlast_warning_message = argv(1);
+    }
+  else if (nargin == 1)
+    {
+      Vlast_warning_id = "";
+      Vlast_warning_message = argv(1);
+    }
+
+  if (nargin == 0 || nargout > 0)
+    return ovl (prev_warning_message, prev_warning_id);
+  else
+    return octave_value_list ();
 }
 
 /* FIXME: Deprecated in 4.0 and scheduled for removal in 4.4 */
@@ -2160,7 +2161,6 @@
 void
 interpreter_try (unwind_protect& frame)
 {
-  frame.protect_var (error_state);
   frame.protect_var (buffer_error_messages);
   frame.protect_var (Vdebug_on_error);
   frame.protect_var (Vdebug_on_warning);
--- a/libinterp/corefcn/error.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/error.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_error_h)
+#if ! defined (octave_error_h)
 #define octave_error_h 1
 
 #include <cstdarg>
@@ -29,6 +29,7 @@
 class octave_map;
 class octave_value_list;
 class unwind_protect;
+class octave_execution_exception;
 
 #define panic_impossible() \
   panic ("impossible state reached in file '%s' at line %d", __FILE__, __LINE__)
@@ -42,20 +43,25 @@
 
 extern OCTINTERP_API void message (const char *name, const char *fmt, ...);
 
-extern OCTINTERP_API void vusage (const char *fmt, va_list args);
-extern OCTINTERP_API void usage (const char *fmt, ...);
+extern OCTINTERP_API void vusage (const char *fmt, va_list args) GCC_ATTR_NORETURN;
+extern OCTINTERP_API void usage (const char *fmt, ...) GCC_ATTR_NORETURN;
 
 extern OCTINTERP_API void vwarning (const char *fmt, va_list args);
 extern OCTINTERP_API void warning (const char *fmt, ...);
 
-extern OCTINTERP_API void verror (const char *fmt, va_list args);
-extern OCTINTERP_API void error (const char *fmt, ...);
+extern OCTINTERP_API void verror (const char *fmt, va_list args) GCC_ATTR_NORETURN;
+extern OCTINTERP_API void error (const char *fmt, ...) GCC_ATTR_NORETURN;
 
-extern OCTINTERP_API void verror_with_cfn (const char *fmt, va_list args);
-extern OCTINTERP_API void error_with_cfn (const char *fmt, ...);
+extern OCTINTERP_API void verror (octave_execution_exception&,
+                                  const char *fmt, va_list args) GCC_ATTR_NORETURN;
+extern OCTINTERP_API void error (octave_execution_exception&,
+                                 const char *fmt, ...) GCC_ATTR_NORETURN;
 
-extern OCTINTERP_API void vparse_error (const char *fmt, va_list args);
-extern OCTINTERP_API void parse_error (const char *fmt, ...);
+extern OCTINTERP_API void verror_with_cfn (const char *fmt, va_list args) GCC_ATTR_NORETURN;
+extern OCTINTERP_API void error_with_cfn (const char *fmt, ...) GCC_ATTR_NORETURN;
+
+extern OCTINTERP_API void vparse_error (const char *fmt, va_list args) GCC_ATTR_NORETURN;
+extern OCTINTERP_API void parse_error (const char *fmt, ...) GCC_ATTR_NORETURN;
 
 extern OCTINTERP_API void
 vmessage_with_id (const char *id, const char *name,
@@ -65,10 +71,10 @@
 message_with_id (const char *id, const char *name, const char *fmt, ...);
 
 extern OCTINTERP_API void
-vusage_with_id (const char *id, const char *fmt, va_list args);
+vusage_with_id (const char *id, const char *fmt, va_list args) GCC_ATTR_NORETURN;
 
 extern OCTINTERP_API void
-usage_with_id (const char *id, const char *fmt, ...);
+usage_with_id (const char *id, const char *fmt, ...) GCC_ATTR_NORETURN;
 
 extern OCTINTERP_API void
 vwarning_with_id (const char *id, const char *fmt, va_list args);
@@ -77,22 +83,22 @@
 warning_with_id (const char *id, const char *fmt, ...);
 
 extern OCTINTERP_API void
-verror_with_id (const char *id, const char *fmt, va_list args);
+verror_with_id (const char *id, const char *fmt, va_list args) GCC_ATTR_NORETURN;
 
 extern OCTINTERP_API void
-error_with_id (const char *id, const char *fmt, ...);
+error_with_id (const char *id, const char *fmt, ...) GCC_ATTR_NORETURN;
 
 extern OCTINTERP_API void
-verror_with_id_cfn (const char *id, const char *fmt, va_list args);
+verror_with_id_cfn (const char *id, const char *fmt, va_list args) GCC_ATTR_NORETURN;
 
 extern OCTINTERP_API void
-error_with_id_cfn (const char *id, const char *fmt, ...);
+error_with_id_cfn (const char *id, const char *fmt, ...) GCC_ATTR_NORETURN;
 
 extern OCTINTERP_API void
-vparse_error_with_id (const char *id, const char *fmt, va_list args);
+vparse_error_with_id (const char *id, const char *fmt, va_list args) GCC_ATTR_NORETURN;
 
 extern OCTINTERP_API void
-parse_error_with_id (const char *id, const char *fmt, ...);
+parse_error_with_id (const char *id, const char *fmt, ...) GCC_ATTR_NORETURN;
 
 extern OCTINTERP_API void panic (const char *fmt, ...) GCC_ATTR_NORETURN;
 
--- a/libinterp/corefcn/event-queue.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/event-queue.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_event_queue_h)
+#if ! defined (octave_event_queue_h)
 #define octave_event_queue_h 1
 
 #include <queue>
@@ -36,8 +36,8 @@
   event_queue (void) : fifo () { }
 
   // Destructor should not raise an exception, so all actions
-  // registered should be exception-safe (but setting error_state is
-  // allowed). If you're not sure, see event_queue_safe.
+  // registered should be exception-safe.  If you're not sure, see
+  // event_queue_safe.
 
   ~event_queue (void) { run (); }
 
--- a/libinterp/corefcn/fft.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/fft.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -47,10 +47,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
   dim_vector dims = arg.dims ();
@@ -74,9 +71,6 @@
         }
     }
 
-  if (error_state)
-    return retval;
-
   if (nargin > 2)
     {
       double dval = args(2).double_value ();
@@ -90,9 +84,6 @@
         dim = NINT (dval) - 1;
     }
 
-  if (error_state)
-    return retval;
-
   for (octave_idx_type i = 0; i < dims.length (); i++)
     if (dims(i) < 0)
       return retval;
@@ -112,9 +103,9 @@
     }
 
   if (n_points < 0)
-    n_points = dims (dim);
+    n_points = dims(dim);
   else
-    dims (dim) = n_points;
+    dims(dim) = n_points;
 
   if (dims.any_zero () || n_points == 0)
     {
@@ -130,21 +121,15 @@
         {
           FloatNDArray nda = arg.float_array_value ();
 
-          if (! error_state)
-            {
-              nda.resize (dims, 0.0);
-              retval = (type != 0 ? nda.ifourier (dim) : nda.fourier (dim));
-            }
+          nda.resize (dims, 0.0);
+          retval = (type != 0 ? nda.ifourier (dim) : nda.fourier (dim));
         }
       else
         {
           FloatComplexNDArray cnda = arg.float_complex_array_value ();
 
-          if (! error_state)
-            {
-              cnda.resize (dims, 0.0);
-              retval = (type != 0 ? cnda.ifourier (dim) : cnda.fourier (dim));
-            }
+          cnda.resize (dims, 0.0);
+          retval = (type != 0 ? cnda.ifourier (dim) : cnda.fourier (dim));
         }
     }
   else
@@ -153,26 +138,18 @@
         {
           NDArray nda = arg.array_value ();
 
-          if (! error_state)
-            {
-              nda.resize (dims, 0.0);
-              retval = (type != 0 ? nda.ifourier (dim) : nda.fourier (dim));
-            }
+          nda.resize (dims, 0.0);
+          retval = (type != 0 ? nda.ifourier (dim) : nda.fourier (dim));
         }
       else if (arg.is_complex_type ())
         {
           ComplexNDArray cnda = arg.complex_array_value ();
 
-          if (! error_state)
-            {
-              cnda.resize (dims, 0.0);
-              retval = (type != 0 ? cnda.ifourier (dim) : cnda.fourier (dim));
-            }
+          cnda.resize (dims, 0.0);
+          retval = (type != 0 ? cnda.ifourier (dim) : cnda.fourier (dim));
         }
       else
-        {
-          gripe_wrong_type_arg (fcn, arg);
-        }
+        gripe_wrong_type_arg (fcn, arg);
     }
 
   return retval;
--- a/libinterp/corefcn/fft2.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/fft2.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -49,10 +49,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
   dim_vector dims = arg.dims ();
@@ -71,9 +68,6 @@
         }
     }
 
-  if (error_state)
-    return retval;
-
   octave_idx_type n_cols = -1;
   if (nargin > 2)
     {
@@ -88,22 +82,19 @@
         }
     }
 
-  if (error_state)
-    return retval;
-
   for (int i = 0; i < dims.length (); i++)
     if (dims(i) < 0)
       return retval;
 
   if (n_rows < 0)
-    n_rows = dims (0);
+    n_rows = dims(0);
   else
-    dims (0) = n_rows;
+    dims(0) = n_rows;
 
   if (n_cols < 0)
-    n_cols = dims (1);
+    n_cols = dims(1);
   else
-    dims (1) = n_cols;
+    dims(1) = n_cols;
 
   if (dims.all_zero () || n_rows == 0 || n_cols == 0)
     {
@@ -119,21 +110,15 @@
         {
           FloatNDArray nda = arg.float_array_value ();
 
-          if (! error_state)
-            {
-              nda.resize (dims, 0.0);
-              retval = (type != 0 ? nda.ifourier2d () : nda.fourier2d ());
-            }
+          nda.resize (dims, 0.0);
+          retval = (type != 0 ? nda.ifourier2d () : nda.fourier2d ());
         }
       else
         {
           FloatComplexNDArray cnda = arg.float_complex_array_value ();
 
-          if (! error_state)
-            {
-              cnda.resize (dims, 0.0);
-              retval = (type != 0 ? cnda.ifourier2d () : cnda.fourier2d ());
-            }
+          cnda.resize (dims, 0.0);
+          retval = (type != 0 ? cnda.ifourier2d () : cnda.fourier2d ());
         }
     }
   else
@@ -142,26 +127,18 @@
         {
           NDArray nda = arg.array_value ();
 
-          if (! error_state)
-            {
-              nda.resize (dims, 0.0);
-              retval = (type != 0 ? nda.ifourier2d () : nda.fourier2d ());
-            }
+          nda.resize (dims, 0.0);
+          retval = (type != 0 ? nda.ifourier2d () : nda.fourier2d ());
         }
       else if (arg.is_complex_type ())
         {
           ComplexNDArray cnda = arg.complex_array_value ();
 
-          if (! error_state)
-            {
-              cnda.resize (dims, 0.0);
-              retval = (type != 0 ? cnda.ifourier2d () : cnda.fourier2d ());
-            }
+          cnda.resize (dims, 0.0);
+          retval = (type != 0 ? cnda.ifourier2d () : cnda.fourier2d ());
         }
       else
-        {
-          gripe_wrong_type_arg (fcn, arg);
-        }
+        gripe_wrong_type_arg (fcn, arg);
     }
 
   return retval;
--- a/libinterp/corefcn/fftn.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/fftn.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -48,10 +48,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
   dim_vector dims = arg.dims ();
@@ -62,11 +59,12 @@
 
   if (nargin > 1)
     {
-      Matrix val = args(1).matrix_value ();
+      Matrix val = args(1).xmatrix_value ("%s: SIZE must be a vector of length dim", fcn);
+
       if (val.rows () > val.columns ())
         val = val.transpose ();
 
-      if (error_state || val.columns () != dims.length () || val.rows () != 1)
+      if (val.columns () != dims.length () || val.rows () != 1)
         error ("%s: SIZE must be a vector of length dim", fcn);
       else
         {
@@ -85,9 +83,6 @@
         }
     }
 
-  if (error_state)
-    return retval;
-
   if (dims.all_zero ())
     {
       if (arg.is_single_type ())
@@ -102,21 +97,15 @@
         {
           FloatNDArray nda = arg.float_array_value ();
 
-          if (! error_state)
-            {
-              nda.resize (dims, 0.0);
-              retval = (type != 0 ? nda.ifourierNd () : nda.fourierNd ());
-            }
+          nda.resize (dims, 0.0);
+          retval = (type != 0 ? nda.ifourierNd () : nda.fourierNd ());
         }
       else
         {
           FloatComplexNDArray cnda = arg.float_complex_array_value ();
 
-          if (! error_state)
-            {
-              cnda.resize (dims, 0.0);
-              retval = (type != 0 ? cnda.ifourierNd () : cnda.fourierNd ());
-            }
+          cnda.resize (dims, 0.0);
+          retval = (type != 0 ? cnda.ifourierNd () : cnda.fourierNd ());
         }
     }
   else
@@ -125,26 +114,18 @@
         {
           NDArray nda = arg.array_value ();
 
-          if (! error_state)
-            {
-              nda.resize (dims, 0.0);
-              retval = (type != 0 ? nda.ifourierNd () : nda.fourierNd ());
-            }
+          nda.resize (dims, 0.0);
+          retval = (type != 0 ? nda.ifourierNd () : nda.fourierNd ());
         }
       else if (arg.is_complex_type ())
         {
           ComplexNDArray cnda = arg.complex_array_value ();
 
-          if (! error_state)
-            {
-              cnda.resize (dims, 0.0);
-              retval = (type != 0 ? cnda.ifourierNd () : cnda.fourierNd ());
-            }
+          cnda.resize (dims, 0.0);
+          retval = (type != 0 ? cnda.ifourierNd () : cnda.fourierNd ());
         }
       else
-        {
-          gripe_wrong_type_arg (fcn, arg);
-        }
+        gripe_wrong_type_arg (fcn, arg);
     }
 
   return retval;
--- a/libinterp/corefcn/file-io.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/file-io.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -182,17 +182,14 @@
 #endif
         }
 
-      if (! error_state)
-        {
-          // Use binary mode if 't' is not specified, but don't add
-          // 'b' if it is already present.
+      // Use binary mode if 't' is not specified, but don't add
+      // 'b' if it is already present.
 
-          size_t bpos = mode.find ('b');
-          size_t tpos = mode.find ('t');
+      size_t bpos = mode.find ('b');
+      size_t tpos = mode.find ('t');
 
-          if (bpos == std::string::npos && tpos == std::string::npos)
-            mode += 'b';
-        }
+      if (bpos == std::string::npos && tpos == std::string::npos)
+        mode += 'b';
     }
 }
 
@@ -201,37 +198,34 @@
 {
   std::ios::openmode retval = std::ios::in;
 
-  if (! error_state)
-    {
-      if (mode == "rt")
-        retval = std::ios::in;
-      else if (mode == "wt")
-        retval = std::ios::out | std::ios::trunc;
-      else if (mode == "at")
-        retval = std::ios::out | std::ios::app;
-      else if (mode == "r+t" || mode == "rt+")
-        retval = std::ios::in | std::ios::out;
-      else if (mode == "w+t" || mode == "wt+")
-        retval = std::ios::in | std::ios::out | std::ios::trunc;
-      else if (mode == "a+t" || mode == "at+")
-        retval = std::ios::in | std::ios::out | std::ios::app;
-      else if (mode == "rb" || mode == "r")
-        retval = std::ios::in | std::ios::binary;
-      else if (mode == "wb" || mode == "w")
-        retval = std::ios::out | std::ios::trunc | std::ios::binary;
-      else if (mode == "ab" || mode == "a")
-        retval = std::ios::out | std::ios::app | std::ios::binary;
-      else if (mode == "r+b" || mode == "rb+" || mode == "r+")
-        retval = std::ios::in | std::ios::out | std::ios::binary;
-      else if (mode == "w+b" || mode == "wb+" || mode == "w+")
-        retval = (std::ios::in | std::ios::out | std::ios::trunc
-                  | std::ios::binary);
-      else if (mode == "a+b" || mode == "ab+" || mode == "a+")
-        retval = (std::ios::in | std::ios::out | std::ios::app
-                  | std::ios::binary);
-      else
-        ::error ("invalid mode specified");
-    }
+  if (mode == "rt")
+    retval = std::ios::in;
+  else if (mode == "wt")
+    retval = std::ios::out | std::ios::trunc;
+  else if (mode == "at")
+    retval = std::ios::out | std::ios::app;
+  else if (mode == "r+t" || mode == "rt+")
+    retval = std::ios::in | std::ios::out;
+  else if (mode == "w+t" || mode == "wt+")
+    retval = std::ios::in | std::ios::out | std::ios::trunc;
+  else if (mode == "a+t" || mode == "at+")
+    retval = std::ios::in | std::ios::out | std::ios::app;
+  else if (mode == "rb" || mode == "r")
+    retval = std::ios::in | std::ios::binary;
+  else if (mode == "wb" || mode == "w")
+    retval = std::ios::out | std::ios::trunc | std::ios::binary;
+  else if (mode == "ab" || mode == "a")
+    retval = std::ios::out | std::ios::app | std::ios::binary;
+  else if (mode == "r+b" || mode == "rb+" || mode == "r+")
+    retval = std::ios::in | std::ios::out | std::ios::binary;
+  else if (mode == "w+b" || mode == "wb+" || mode == "w+")
+    retval = (std::ios::in | std::ios::out | std::ios::trunc
+              | std::ios::binary);
+  else if (mode == "a+b" || mode == "ab+" || mode == "a+")
+    retval = (std::ios::in | std::ios::out | std::ios::app
+              | std::ios::binary);
+  else
+    error ("invalid mode specified");
 
   return retval;
 }
@@ -245,24 +239,15 @@
 \n\
 If successful, @code{fclose} returns 0, otherwise, it returns -1.  The\n\
 second form of the @code{fclose} call closes all open files except\n\
-@code{stdout}, @code{stderr}, and @code{stdin}.\n\
-\n\
-Programming Note: When using @qcode{\"all\"} the file descriptors associated\n\
-with gnuplot will also be closed.  This will prevent further plotting with\n\
-gnuplot until Octave is closed and restarted.\n\
+@code{stdin}, @code{stdout}, @code{stderr}, and any FIDs associated\n\
+with gnuplot.\n\
 @seealso{fopen, fflush, freport}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    retval = octave_stream_list::remove (args(0), "fclose");
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_stream_list::remove (args(0), "fclose"));
 }
 
 DEFUN (fclear, args, ,
@@ -275,19 +260,14 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      int fid = octave_stream_list::get_file_number (args(0));
+  if (args.length () != 1)
+    print_usage ();
 
-      octave_stream os = octave_stream_list::lookup (fid, "fclear");
+  int fid = octave_stream_list::get_file_number (args(0));
 
-      if (! error_state)
-        os.clearerr ();
-    }
-  else
-    print_usage ();
+  octave_stream os = octave_stream_list::lookup (fid, "fclear");
+
+  os.clearerr ();
 
   return retval;
 }
@@ -309,30 +289,25 @@
 {
   octave_value retval = -1;
 
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin == 1)
-    {
-      // FIXME: any way to avoid special case for stdout?
-
-      int fid = octave_stream_list::get_file_number (args(0));
+  // FIXME: any way to avoid special case for stdout?
 
-      if (fid == 1)
-        {
-          flush_octave_stdout ();
+  int fid = octave_stream_list::get_file_number (args(0));
 
-          retval = 0;
-        }
-      else
-        {
-          octave_stream os = octave_stream_list::lookup (fid, "fflush");
+  if (fid == 1)
+    {
+      flush_octave_stdout ();
 
-          if (! error_state)
-            retval = os.flush ();
-        }
+      retval = 0;
     }
   else
-    print_usage ();
+    {
+      octave_stream os = octave_stream_list::lookup (fid, "fflush");
+
+      retval = os.flush ();
+    }
 
   return retval;
 }
@@ -359,32 +334,27 @@
 
   octave_value_list retval;
 
+  int nargin = args.length ();
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   retval(1) = 0;
   retval(0) = -1;
 
-  int nargin = args.length ();
-
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), who);
+  octave_stream os = octave_stream_list::lookup (args(0), who);
 
-      if (! error_state)
-        {
-          octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
+  octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
 
-          bool err = false;
+  bool err = false;
 
-          std::string tmp = os.getl (len_arg, err, who);
+  std::string tmp = os.getl (len_arg, err, who);
 
-          if (! (error_state || err))
-            {
-              retval(1) = tmp.length ();
-              retval(0) = tmp;
-            }
-        }
+  if (! err)
+    {
+      retval(1) = tmp.length ();
+      retval(0) = tmp;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -411,32 +381,27 @@
 
   octave_value_list retval;
 
+  int nargin = args.length ();
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   retval(1) = 0.0;
   retval(0) = -1.0;
 
-  int nargin = args.length ();
-
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), who);
+  octave_stream os = octave_stream_list::lookup (args(0), who);
 
-      if (! error_state)
-        {
-          octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
+  octave_value len_arg = (nargin == 2) ? args(1) : octave_value ();
 
-          bool err = false;
+  bool err = false;
 
-          std::string tmp = os.gets (len_arg, err, who);
+  std::string tmp = os.gets (len_arg, err, who);
 
-          if (! (error_state || err))
-            {
-              retval(1) = tmp.length ();
-              retval(0) = tmp;
-            }
-        }
+  if (! err)
+    {
+      retval(1) = tmp.length ();
+      retval(0) = tmp;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -466,24 +431,19 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), who);
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-      if (! error_state)
-        {
-          octave_value count_arg = (nargin == 2) ? args(1) : octave_value ();
+  octave_stream os = octave_stream_list::lookup (args(0), who);
+
+  octave_value count_arg = (nargin == 2) ? args(1) : octave_value ();
 
-          bool err = false;
-
-          off_t tmp = os.skipl (count_arg, err, who);
+  bool err = false;
 
-          if (! (error_state || err))
-            retval = tmp;
-        }
-    }
-  else
-    print_usage ();
+  off_t tmp = os.skipl (count_arg, err, who);
+
+  if (! err)
+    retval = tmp;
 
   return retval;
 }
@@ -503,51 +463,45 @@
 
   std::ios::openmode md = fopen_mode_to_ios_mode (mode);
 
-  if (! error_state)
-    {
-      oct_mach_info::float_format flt_fmt =
-        oct_mach_info::string_to_float_format (arch);
+  oct_mach_info::float_format flt_fmt =
+    oct_mach_info::string_to_float_format (arch);
 
-      if (! error_state)
-        {
-          std::string fname = file_ops::tilde_expand (name);
+  std::string fname = file_ops::tilde_expand (name);
 
-          file_stat fs (fname);
+  file_stat fs (fname);
 
-          if (! (md & std::ios::out))
-            fname = find_data_file_in_load_path ("fopen", fname);
+  if (! (md & std::ios::out))
+    fname = find_data_file_in_load_path ("fopen", fname);
 
-          if (! fs.is_dir ())
-            {
+  if (! fs.is_dir ())
+    {
 #if defined (HAVE_ZLIB)
-              if (use_zlib)
-                {
-                  FILE *fptr = gnulib::fopen (fname.c_str (), mode.c_str ());
+      if (use_zlib)
+        {
+          FILE *fptr = gnulib::fopen (fname.c_str (), mode.c_str ());
 
-                  int fd = fileno (fptr);
+          int fd = fileno (fptr);
 
-                  gzFile gzf = ::gzdopen (fd, mode.c_str ());
+          gzFile gzf = ::gzdopen (fd, mode.c_str ());
 
-                  if (fptr)
-                    retval = octave_zstdiostream::create (fname, gzf, fd,
-                                                          md, flt_fmt);
-                  else
-                    retval.error (gnulib::strerror (errno));
-                }
-              else
+          if (fptr)
+            retval = octave_zstdiostream::create (fname, gzf, fd,
+                                                  md, flt_fmt);
+          else
+            retval.error (gnulib::strerror (errno));
+        }
+      else
 #endif
-                {
-                  FILE *fptr = gnulib::fopen (fname.c_str (), mode.c_str ());
-
-                  retval = octave_stdiostream::create (fname, fptr, md,
-                                                       flt_fmt);
+        {
+          FILE *fptr = gnulib::fopen (fname.c_str (), mode.c_str ());
 
-                  if (! fptr)
-                    retval.error (gnulib::strerror (errno));
-                }
+          retval = octave_stdiostream::create (fname, fptr, md,
+                                               flt_fmt);
 
-            }
+          if (! fptr)
+            retval.error (gnulib::strerror (errno));
         }
+
     }
 
   return retval;
@@ -561,28 +515,11 @@
 
   fid = -1;
 
-  if (tc_name.is_string ())
-    {
-      std::string name = tc_name.string_value ();
-
-      if (tc_mode.is_string ())
-        {
-          std::string mode = tc_mode.string_value ();
+  std::string name = tc_name.xstring_value ("%s: filename must be a string", fcn);
+  std::string mode = tc_mode.xstring_value ("%s: file mode must be a string", fcn);
+  std::string arch = tc_arch.xstring_value ("%s: architecture type must be a string", fcn);
 
-          if (tc_arch.is_string ())
-            {
-              std::string arch = tc_arch.string_value ();
-
-              retval = do_stream_open (name, mode, arch, fid);
-            }
-          else
-            ::error ("%s: architecture type must be a string", fcn);
-        }
-      else
-        ::error ("%s: file mode must be a string", fcn);
-    }
-  else
-    ::error ("%s: file name must be a string", fcn);
+  retval = do_stream_open (name, mode, arch, fid);
 
   return retval;
 }
@@ -710,12 +647,9 @@
         {
           string_vector tmp = octave_stream_list::get_info (args(0));
 
-          if (! error_state)
-            {
-              retval(2) = tmp(2);
-              retval(1) = tmp(1);
-              retval(0) = tmp(0);
-            }
+          retval(2) = tmp(2);
+          retval(1) = tmp(1);
+          retval(0) = tmp(0);
 
           return retval;
         }
@@ -733,7 +667,7 @@
 
       octave_stream os = do_stream_open (args(0), mode, arch, "fopen", fid);
 
-      if (os && ! error_state)
+      if (os)
         {
           retval(1) = "";
           retval(0) = octave_stream_list::insert (os);
@@ -777,9 +711,7 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
-
-  if (nargin > 0)
+  if (args.length () > 0)
     warning ("freport: ignoring extra arguments");
 
   octave_stdout << octave_stream_list::list_open_files ();
@@ -801,19 +733,14 @@
 {
   octave_value retval;
 
+  if (args.length () != 1)
+    print_usage ();
+
   int result = -1;
 
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), "frewind");
+  octave_stream os = octave_stream_list::lookup (args(0), "frewind");
 
-      if (! error_state)
-        result = os.rewind ();
-    }
-  else
-    print_usage ();
+  result = os.rewind ();
 
   if (nargout > 0)
     retval = result;
@@ -844,20 +771,15 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), "fseek");
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  octave_stream os = octave_stream_list::lookup (args(0), "fseek");
 
-      if (! error_state)
-        {
-          octave_value origin_arg = (nargin == 3)
-                                    ? args(2) : octave_value (-1.0);
+  octave_value origin_arg = (nargin == 3)
+    ? args(2) : octave_value (-1.0);
 
-          retval = os.seek (args(1), origin_arg);
-        }
-    }
-  else
-    print_usage ();
+  retval = os.seek (args(1), origin_arg);
 
   return retval;
 }
@@ -872,17 +794,12 @@
 {
   octave_value retval = -1;
 
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), "ftell");
+  if (args.length () != 1)
+    print_usage ();
 
-      if (! error_state)
-        retval = os.tell ();
-    }
-  else
-    print_usage ();
+  octave_stream os = octave_stream_list::lookup (args(0), "ftell");
+
+  retval = os.tell ();
 
   return retval;
 }
@@ -914,43 +831,38 @@
 
   int nargin = args.length ();
 
-  if (nargin > 1 || (nargin > 0 && args(0).is_string ()))
+  if (! (nargin > 1 || (nargin > 0 && args(0).is_string ())))
+    print_usage ();
+
+  octave_stream os;
+  int fmt_n = 0;
+
+  if (args(0).is_string ())
     {
-      octave_stream os;
-      int fmt_n = 0;
+      os = octave_stream_list::lookup (1, who);
+    }
+  else
+    {
+      fmt_n = 1;
+      os = octave_stream_list::lookup (args(0), who);
+    }
 
-      if (args(0).is_string ())
+  if (args(fmt_n).is_string ())
+    {
+      octave_value_list tmp_args;
+
+      if (nargin > 1 + fmt_n)
         {
-          os = octave_stream_list::lookup (1, who);
-        }
-      else
-        {
-          fmt_n = 1;
-          os = octave_stream_list::lookup (args(0), who);
+          tmp_args.resize (nargin-fmt_n-1, octave_value ());
+
+          for (int i = fmt_n + 1; i < nargin; i++)
+            tmp_args(i-fmt_n-1) = args(i);
         }
 
-      if (! error_state)
-        {
-          if (args(fmt_n).is_string ())
-            {
-              octave_value_list tmp_args;
-
-              if (nargin > 1 + fmt_n)
-                {
-                  tmp_args.resize (nargin-fmt_n-1, octave_value ());
-
-                  for (int i = fmt_n + 1; i < nargin; i++)
-                    tmp_args(i-fmt_n-1) = args(i);
-                }
-
-              result = os.printf (args(fmt_n), tmp_args, who);
-            }
-          else
-            ::error ("%s: format TEMPLATE must be a string", who.c_str ());
-        }
+      result = os.printf (args(fmt_n), tmp_args, who);
     }
   else
-    print_usage ();
+    error ("%s: format TEMPLATE must be a string", who.c_str ());
 
   if (nargout > 0)
     retval = result;
@@ -984,27 +896,25 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
+  if (nargin == 0)
+    print_usage ();
+
+  if (args(0).is_string ())
     {
-      if (args(0).is_string ())
-        {
-          octave_value_list tmp_args;
+      octave_value_list tmp_args;
 
-          if (nargin > 1)
-            {
-              tmp_args.resize (nargin-1, octave_value ());
+      if (nargin > 1)
+        {
+          tmp_args.resize (nargin-1, octave_value ());
 
-              for (int i = 1; i < nargin; i++)
-                tmp_args(i-1) = args(i);
-            }
+          for (int i = 1; i < nargin; i++)
+            tmp_args(i-1) = args(i);
+        }
 
-          result = stdout_stream.printf (args(0), tmp_args, who);
-        }
-      else
-        ::error ("%s: format TEMPLATE must be a string", who.c_str ());
+      result = stdout_stream.printf (args(0), tmp_args, who);
     }
   else
-    print_usage ();
+    error ("%s: format TEMPLATE must be a string", who.c_str ());
 
   if (nargout > 0)
     retval = result;
@@ -1028,21 +938,12 @@
 {
   static std::string who = "fputs";
 
-  octave_value retval = -1;
-
-  int nargin = args.length ();
-
-  if (nargin == 2)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), who);
-
-      if (! error_state)
-        retval = os.puts (args(1), who);
-    }
-  else
+  if (args.length () != 2)
     print_usage ();
 
-  return retval;
+  octave_stream os = octave_stream_list::lookup (args(0), who);
+
+  return octave_value (os.puts (args(1), who));
 }
 
 DEFUN (puts, args, ,
@@ -1060,14 +961,10 @@
 {
   static std::string who = "puts";
 
-  octave_value retval = -1;
-
-  if (args.length () == 1)
-    retval = stdout_stream.puts (args(0), who);
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (stdout_stream.puts (args(0), who));
 }
 
 DEFUN (sprintf, args, ,
@@ -1092,50 +989,48 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
-    {
-      retval(2) = -1.0;
-      retval(1) = "unknown error";
-      retval(0) = "";
+  if (nargin == 0)
+    print_usage ();
 
-      octave_ostrstream *ostr = new octave_ostrstream ();
+  retval(2) = -1.0;
+  retval(1) = "unknown error";
+  retval(0) = "";
 
-      octave_stream os (ostr);
+  octave_ostrstream *ostr = new octave_ostrstream ();
+
+  octave_stream os (ostr);
 
-      if (os.is_valid ())
-        {
-          octave_value fmt_arg = args(0);
-
-          if (fmt_arg.is_string ())
-            {
-              octave_value_list tmp_args;
+  if (os.is_valid ())
+    {
+      octave_value fmt_arg = args(0);
 
-              if (nargin > 1)
-                {
-                  tmp_args.resize (nargin-1, octave_value ());
+      if (fmt_arg.is_string ())
+        {
+          octave_value_list tmp_args;
 
-                  for (int i = 1; i < nargin; i++)
-                    tmp_args(i-1) = args(i);
-                }
+          if (nargin > 1)
+            {
+              tmp_args.resize (nargin-1, octave_value ());
 
-              retval(2) = os.printf (fmt_arg, tmp_args, who);
-              retval(1) = os.error ();
+              for (int i = 1; i < nargin; i++)
+                tmp_args(i-1) = args(i);
+            }
 
-              std::string result = ostr->str ();
-              char type = fmt_arg.is_sq_string () ? '\'' : '"';
+          retval(2) = os.printf (fmt_arg, tmp_args, who);
+          retval(1) = os.error ();
 
-              retval(0) = (result.empty ()
-                           ? octave_value (charMatrix (1, 0), type)
-                           : octave_value (result, type));
-            }
-          else
-            ::error ("%s: format TEMPLATE must be a string", who.c_str ());
+          std::string result = ostr->str ();
+          char type = fmt_arg.is_sq_string () ? '\'' : '"';
+
+          retval(0) = (result.empty ()
+                       ? octave_value (charMatrix (1, 0), type)
+                       : octave_value (result, type));
         }
       else
-        ::error ("%s: unable to create output buffer", who.c_str ());
+        error ("%s: format TEMPLATE must be a string", who.c_str ());
     }
   else
-    print_usage ();
+    error ("%s: unable to create output buffer", who.c_str ());
 
   return retval;
 }
@@ -1196,17 +1091,17 @@
 
   int nargin = args.length ();
 
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
   if (nargin == 3 && args(2).is_string ())
     {
       octave_stream os = octave_stream_list::lookup (args(0), who);
 
-      if (! error_state)
-        {
-          if (args(1).is_string ())
-            retval = os.oscanf (args(1), who);
-          else
-            ::error ("%s: format TEMPLATE must be a string", who.c_str ());
-        }
+      if (args(1).is_string ())
+        retval = os.oscanf (args(1), who);
+      else
+        error ("%s: format TEMPLATE must be a string", who.c_str ());
     }
   else
     {
@@ -1214,39 +1109,25 @@
       retval(1) = 0.0;
       retval(0) = Matrix ();
 
-      if (nargin == 2 || nargin == 3)
-        {
-          octave_stream os = octave_stream_list::lookup (args(0), who);
+      octave_stream os = octave_stream_list::lookup (args(0), who);
 
-          if (! error_state)
-            {
-              if (args(1).is_string ())
-                {
-                  octave_idx_type count = 0;
-
-                  Array<double> size = (nargin == 3)
-                                       ? args(2).vector_value ()
-                                       : Array<double> (dim_vector (1, 1),
-                                                        lo_ieee_inf_value ());
+      if (args(1).is_string ())
+        {
+          octave_idx_type count = 0;
 
-                  if (! error_state)
-                    {
-                      octave_value tmp = os.scanf (args(1), size, count, who);
+          Array<double> size = (nargin == 3)
+            ? args(2).vector_value ()
+            : Array<double> (dim_vector (1, 1),
+                             lo_ieee_inf_value ());
 
-                      if (! error_state)
-                        {
-                          retval(2) = os.error ();
-                          retval(1) = count;
-                          retval(0) = tmp;
-                        }
-                    }
-                }
-              else
-                ::error ("%s: format must be a string", who.c_str ());
-            }
+          octave_value tmp = os.scanf (args(1), size, count, who);
+
+          retval(2) = os.error ();
+          retval(1) = count;
+          retval(0) = tmp;
         }
       else
-        print_usage ();
+        error ("%s: format must be a string", who.c_str ());
     }
 
   return retval;
@@ -1264,7 +1145,7 @@
       retval = tmp.string_value ();
     }
   else
-    ::error ("sscanf: argument STRING must be a string");
+    error ("sscanf: argument STRING must be a string");
 
   return retval;
 }
@@ -1288,81 +1169,66 @@
 
   int nargin = args.length ();
 
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
   if (nargin == 3 && args(2).is_string ())
     {
       std::string data = get_sscanf_data (args(0));
 
-      if (! error_state)
-        {
-          octave_stream os = octave_istrstream::create (data);
+      octave_stream os = octave_istrstream::create (data);
 
-          if (os.is_valid ())
-            {
-              if (args(1).is_string ())
-                retval = os.oscanf (args(1), who);
-              else
-                ::error ("%s: format TEMPLATE must be a string", who.c_str ());
-            }
+      if (os.is_valid ())
+        {
+          if (args(1).is_string ())
+            retval = os.oscanf (args(1), who);
           else
-            ::error ("%s: unable to create temporary input buffer",
-                     who.c_str ());
+            error ("%s: format TEMPLATE must be a string", who.c_str ());
         }
       else
-        ::error ("%s: argument STRING must be a string", who.c_str ());
+        error ("%s: unable to create temporary input buffer", who.c_str ());
     }
   else
     {
-      if (nargin == 2 || nargin == 3)
+      retval(3) = -1.0;
+      retval(2) = "unknown error";
+      retval(1) = 0.0;
+      retval(0) = Matrix ();
+
+      std::string data = get_sscanf_data (args(0));
+
+      octave_stream os = octave_istrstream::create (data);
+
+      if (os.is_valid ())
         {
-          retval(3) = -1.0;
-          retval(2) = "unknown error";
-          retval(1) = 0.0;
-          retval(0) = Matrix ();
-
-          std::string data = get_sscanf_data (args(0));
-
-          if (! error_state)
+          if (args(1).is_string ())
             {
-              octave_stream os = octave_istrstream::create (data);
-
-              if (os.is_valid ())
-                {
-                  if (args(1).is_string ())
-                    {
-                      octave_idx_type count = 0;
-
-                      Array<double> size = (nargin == 3)
-                                           ? args(2).vector_value ()
-                                           : Array<double> (dim_vector (1, 1),
-                                                            lo_ieee_inf_value ());
+              octave_idx_type count = 0;
 
-                      octave_value tmp = os.scanf (args(1), size, count, who);
+              Array<double> size = (nargin == 3)
+                ? args(2).vector_value ()
+                : Array<double> (dim_vector (1, 1),
+                                 lo_ieee_inf_value ());
 
-                      if (! error_state)
-                        {
-                          // FIXME: is this the right thing to do?
-                          // Extract error message first, because getting
-                          // position will clear it.
-                          std::string errmsg = os.error ();
+              octave_value tmp = os.scanf (args(1), size, count, who);
 
-                          retval(3)
-                            = (os.eof () ? data.length () : os.tell ()) + 1;
-                          retval(2) = errmsg;
-                          retval(1) = count;
-                          retval(0) = tmp;
-                        }
-                    }
-                  else
-                    ::error ("%s: format TEMPLATE must be a string",
-                             who.c_str ());
-                }
-              else
-                ::error ("%s: unable to create temporary input buffer",
-                         who.c_str  ());
+              // FIXME: is this the right thing to do?
+              // Extract error message first, because getting
+              // position will clear it.
+              std::string errmsg = os.error ();
+
+              retval(3) = (os.eof () ? data.length () : os.tell ()) + 1;
+              retval(2) = errmsg;
+              retval(1) = count;
+              retval(0) = tmp;
             }
+          else
+            error ("%s: format TEMPLATE must be a string",
+                   who.c_str ());
         }
       else
-        print_usage ();
+        error ("%s: unable to create temporary input buffer",
+               who.c_str  ());
     }
 
   return retval;
@@ -1394,58 +1260,44 @@
           const octave_value& prec_arg, const octave_value& skip_arg,
           const octave_value& arch_arg, octave_idx_type& count)
 {
-  octave_value retval;
-
   count = -1;
 
-  Array<double> size = size_arg.vector_value ();
+  Array<double> size = size_arg.xvector_value ("fread: invalid SIZE specified");
+
+  std::string prec = prec_arg.xstring_value ("fread: PRECISION must be a string");
 
-  if (! error_state)
-    {
-      if (prec_arg.is_string ())
-        {
-          std::string prec = prec_arg.string_value ();
+  int block_size = 1;
+  oct_data_conv::data_type input_type;
+  oct_data_conv::data_type output_type;
 
-          int block_size = 1;
-          oct_data_conv::data_type input_type;
-          oct_data_conv::data_type output_type;
-
-          oct_data_conv::string_to_data_type (prec, block_size,
-                                              input_type, output_type);
-
-          if (! error_state)
-            {
-              int skip = skip_arg.int_value (true);
+  try
+    {
+      oct_data_conv::string_to_data_type (prec, block_size,
+                                          input_type, output_type);
+    }
+  catch (octave_execution_exception& e)
+    {
+      error (e, "fread: invalid PRECISION specified");
+    }
 
-              if (! error_state)
-                {
-                  if (arch_arg.is_string ())
-                    {
-                      std::string arch = arch_arg.string_value ();
-
-                      oct_mach_info::float_format flt_fmt
-                        = oct_mach_info::string_to_float_format (arch);
+  int skip = 0;
 
-                      if (! error_state)
-                        retval = os.read (size, block_size, input_type,
-                                          output_type, skip, flt_fmt, count);
-                    }
-                  else
-                    ::error ("fread: ARCH architecture type must be a string");
-                }
-              else
-                ::error ("fread: SKIP must be an integer");
-            }
-          else
-            ::error ("fread: invalid PRECISION specified");
-        }
-      else
-        ::error ("fread: PRECISION must be a string");
+  try
+    {
+      skip = skip_arg.int_value (true);
+    }
+  catch (octave_execution_exception& e)
+    {
+      error (e, "fread: SKIP must be an integer");
     }
-  else
-    ::error ("fread: invalid SIZE specified");
+
+  std::string arch = arch_arg.xstring_value ("fread: ARCH architecture type must be a string");
 
-  return retval;
+  oct_mach_info::float_format flt_fmt
+    = oct_mach_info::string_to_float_format (arch);
+
+  return os.read (size, block_size, input_type, output_type, skip,
+                  flt_fmt, count);
 }
 
 DEFUN (fread, args, ,
@@ -1623,49 +1475,44 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0 && nargin < 6)
-    {
-      retval(1) = -1.0;
-      retval(0) = Matrix ();
+  if (nargin < 1 || nargin > 5)
+    print_usage ();
 
-      octave_stream os = octave_stream_list::lookup (args(0), "fread");
+  retval(1) = -1.0;
+  retval(0) = Matrix ();
+
+  octave_stream os = octave_stream_list::lookup (args(0), "fread");
 
-      if (! error_state)
-        {
-          octave_value size = lo_ieee_inf_value ();
-          octave_value prec = "uchar";
-          octave_value skip = 0;
-          octave_value arch = "unknown";
+  octave_value size = lo_ieee_inf_value ();
+  octave_value prec = "uchar";
+  octave_value skip = 0;
+  octave_value arch = "unknown";
 
-          int idx = 1;
+  int idx = 1;
 
-          if (nargin > idx && ! args(idx).is_string ())
-            size = args(idx++);
-
-          if (nargin > idx)
-            prec = args(idx++);
+  if (nargin > idx && ! args(idx).is_string ())
+    size = args(idx++);
 
-          if (nargin > idx)
-            skip = args(idx++);
+  if (nargin > idx)
+    prec = args(idx++);
 
-          if (nargin > idx)
-            arch = args(idx++);
-          else if (skip.is_string ())
-            {
-              arch = skip;
-              skip = 0;
-            }
+  if (nargin > idx)
+    skip = args(idx++);
 
-          octave_idx_type count = -1;
-
-          octave_value tmp = do_fread (os, size, prec, skip, arch, count);
+  if (nargin > idx)
+    arch = args(idx++);
+  else if (skip.is_string ())
+    {
+      arch = skip;
+      skip = 0;
+    }
 
-          retval(1) = count;
-          retval(0) = tmp;
-        }
-    }
-  else
-    print_usage ();
+  octave_idx_type count = -1;
+
+  octave_value tmp = do_fread (os, size, prec, skip, arch, count);
+
+  retval(1) = count;
+  retval(0) = tmp;
 
   return retval;
 }
@@ -1675,47 +1522,37 @@
            const octave_value& prec_arg, const octave_value& skip_arg,
            const octave_value& arch_arg)
 {
-  int retval = -1;
+  std::string prec = prec_arg.xstring_value ("fwrite: PRECISION must be a string");
 
-  if (prec_arg.is_string ())
+  int block_size = 1;
+  oct_data_conv::data_type output_type;
+
+  try
     {
-      std::string prec = prec_arg.string_value ();
-
-      int block_size = 1;
-      oct_data_conv::data_type output_type;
-
       oct_data_conv::string_to_data_type (prec, block_size, output_type);
-
-      if (! error_state)
-        {
-          int skip = skip_arg.int_value (true);
+    }
+  catch (octave_execution_exception& e)
+    {
+      error (e, "fwrite: invalid PRECISION specified");
+    }
 
-          if (! error_state)
-            {
-              if (arch_arg.is_string ())
-                {
-                  std::string arch = arch_arg.string_value ();
+  int skip = 0;
 
-                  oct_mach_info::float_format flt_fmt
-                    = oct_mach_info::string_to_float_format (arch);
+  try
+    {
+      skip = skip_arg.int_value (true);
+    }
+  catch (octave_execution_exception& e)
+    {
+      error (e, "fwrite: SKIP must be an integer");
+    }
 
-                  if (! error_state)
-                    retval = os.write (data, block_size, output_type,
-                                       skip, flt_fmt);
-                }
-              else
-                ::error ("fwrite: ARCH architecture type must be a string");
-            }
-          else
-            ::error ("fwrite: SKIP must be an integer");
-        }
-      else
-        ::error ("fwrite: invalid PRECISION specified");
-    }
-  else
-    ::error ("fwrite: PRECISION must be a string");
+  std::string arch = arch_arg.xstring_value ("fwrite: ARCH architecture type must be a string");
 
-  return retval;
+  oct_mach_info::float_format flt_fmt
+    = oct_mach_info::string_to_float_format (arch);
+
+  return os.write (data, block_size, output_type, skip, flt_fmt);
 }
 
 DEFUN (fwrite, args, ,
@@ -1740,47 +1577,36 @@
 @seealso{fread, fputs, fprintf, fopen}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   int nargin = args.length ();
 
-  if (nargin > 1 && nargin < 6)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), "fwrite");
-
-      if (! error_state)
-        {
-          octave_value prec = "uchar";
-          octave_value skip = 0;
-          octave_value arch = "unknown";
-
-          int idx = 1;
-
-          octave_value data = args(idx++);
-
-          if (nargin > idx)
-            prec = args(idx++);
-
-          if (nargin > idx)
-            skip = args(idx++);
-
-          if (nargin > idx)
-            arch = args(idx++);
-          else if (skip.is_string ())
-            {
-              arch = skip;
-              skip = 0;
-            }
-
-          double status = do_fwrite (os, data, prec, skip, arch);
-
-          retval = status;
-        }
-    }
-  else
+  if (nargin < 2 || nargin > 5)
     print_usage ();
 
-  return retval;
+  octave_stream os = octave_stream_list::lookup (args(0), "fwrite");
+
+  octave_value prec = "uchar";
+  octave_value skip = 0;
+  octave_value arch = "unknown";
+
+  int idx = 1;
+
+  octave_value data = args(idx++);
+
+  if (nargin > idx)
+    prec = args(idx++);
+
+  if (nargin > idx)
+    skip = args(idx++);
+
+  if (nargin > idx)
+    arch = args(idx++);
+  else if (skip.is_string ())
+    {
+      arch = skip;
+      skip = 0;
+    }
+
+  return octave_value (do_fwrite (os, data, prec, skip, arch));
 }
 
 DEFUNX ("feof", Ffeof, args, ,
@@ -1795,21 +1621,12 @@
 @seealso{fread, frewind, fseek, fclear, fopen}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), "feof");
-
-      if (! error_state)
-        retval = os.eof () ? 1.0 : 0.0;
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  octave_stream os = octave_stream_list::lookup (args(0), "feof");
+
+  return octave_value (os.eof () ? 1.0 : 0.0);
 }
 
 DEFUNX ("ferror", Fferror, args, ,
@@ -1837,34 +1654,26 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_stream os = octave_stream_list::lookup (args(0), "ferror");
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-      if (! error_state)
-        {
-          bool clear = false;
+  octave_stream os = octave_stream_list::lookup (args(0), "ferror");
 
-          if (nargin == 2)
-            {
-              std::string opt = args(1).string_value ();
+  bool clear = false;
 
-              if (! error_state)
-                clear = (opt == "clear");
-              else
-                return retval;
-            }
+  if (nargin == 2)
+    {
+      std::string opt = args(1).string_value ();
 
-          int error_number = 0;
+      clear = (opt == "clear");
+    }
 
-          std::string error_message = os.error (clear, error_number);
+  int error_number = 0;
 
-          retval(1) = error_number;
-          retval(0) = error_message;
-        }
-    }
-  else
-    print_usage ();
+  std::string error_message = os.error (clear, error_number);
+
+  retval(1) = error_number;
+  retval(0) = error_message;
 
   return retval;
 }
@@ -1909,41 +1718,26 @@
 {
   octave_value retval = -1;
 
-  int nargin = args.length ();
-
-  if (nargin == 2)
-    {
-      if (args(0).is_string ())
-        {
-          std::string name = args(0).string_value ();
+  if (args.length () != 2)
+    print_usage ();
 
-          if (args(1).is_string ())
-            {
-              std::string mode = args(1).string_value ();
-
-              if (mode == "r")
-                {
-                  octave_stream ips = octave_iprocstream::create (name);
+  std::string name = args(0).xstring_value ("popen: COMMAND must be a string");
+  std::string mode = args(1).xstring_value ("popen: MODE must be a string");
 
-                  retval = octave_stream_list::insert (ips);
-                }
-              else if (mode == "w")
-                {
-                  octave_stream ops = octave_oprocstream::create (name);
+  if (mode == "r")
+    {
+      octave_stream ips = octave_iprocstream::create (name);
 
-                  retval = octave_stream_list::insert (ops);
-                }
-              else
-                ::error ("popen: invalid MODE specified");
-            }
-          else
-            ::error ("popen: MODE must be a string");
-        }
-      else
-        ::error ("popen: COMMAND must be a string");
+      retval = octave_stream_list::insert (ips);
+    }
+  else if (mode == "w")
+    {
+      octave_stream ops = octave_oprocstream::create (name);
+
+      retval = octave_stream_list::insert (ops);
     }
   else
-    print_usage ();
+    error ("popen: invalid MODE specified");
 
   return retval;
 }
@@ -1957,16 +1751,10 @@
 @seealso{fclose, popen}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    retval = octave_stream_list::remove (args(0), "pclose");
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_stream_list::remove (args(0), "pclose"));
 }
 
 DEFUN (tempname, args, ,
@@ -1974,7 +1762,7 @@
 @deftypefn  {Built-in Function} {@var{fname} =} tempname ()\n\
 @deftypefnx {Built-in Function} {@var{fname} =} tempname (@var{dir})\n\
 @deftypefnx {Built-in Function} {@var{fname} =} tempname (@var{dir}, @var{prefix})\n\
-Return a unique temporary file name as a string.\n\
+Return a unique temporary filename as a string.\n\
 \n\
 If @var{prefix} is omitted, a value of @qcode{\"oct-\"} is used.\n\
 \n\
@@ -1991,34 +1779,22 @@
 {
   octave_value retval;
 
-  int len = args.length ();
-
-  if (len < 3)
-    {
-      std::string dir;
-      if (len > 0)
-        {
-          if (args(0).is_string ())
-            dir = args(0).string_value ();
-          else
-            ::error ("DIR must be a string");
-        }
+  int nargin = args.length ();
 
-      std::string pfx ("oct-");
-      if (len > 1)
-        {
-          if (args(1).is_string ())
-            pfx = args(1).string_value ();
-          else
-            ::error ("PREFIX must be a string");
-        }
-
-      retval = octave_tempnam (dir, pfx);
-    }
-  else
+  if (nargin > 2)
     print_usage ();
 
-  return retval;
+  std::string dir;
+
+  if (nargin > 0)
+    dir = args(0).xstring_value ("tempname: DIR must be a string");
+
+  std::string pfx ("oct-");
+
+  if (nargin > 1)
+    pfx = args(1).xstring_value ("tempname: PREFIX must be a string");
+
+  return octave_value (octave_tempnam (dir, pfx));
 }
 
 /*
@@ -2086,37 +1862,33 @@
 {
   octave_value_list retval;
 
+  if (args.length () != 0)
+    print_usage ();
+
   retval(1) = std::string ();
   retval(0) = -1;
 
-  int nargin = args.length ();
-
-  if (nargin == 0)
-    {
-      FILE *fid = gnulib::tmpfile ();
+  FILE *fid = gnulib::tmpfile ();
 
-      if (fid)
-        {
-          std::string nm;
+  if (fid)
+    {
+      std::string nm;
 
-          std::ios::openmode md = fopen_mode_to_ios_mode ("w+b");
+      std::ios::openmode md = fopen_mode_to_ios_mode ("w+b");
 
-          octave_stream s = octave_stdiostream::create (nm, fid, md);
-
-          if (s)
-            retval(0) = octave_stream_list::insert (s);
-          else
-            error ("tmpfile: failed to create octave_stdiostream object");
+      octave_stream s = octave_stdiostream::create (nm, fid, md);
 
-        }
+      if (s)
+        retval(0) = octave_stream_list::insert (s);
       else
-        {
-          retval(1) = gnulib::strerror (errno);
-          retval(0) = -1;
-        }
+        error ("tmpfile: failed to create octave_stdiostream object");
+
     }
   else
-    print_usage ();
+    {
+      retval(1) = gnulib::strerror (errno);
+      retval(0) = -1;
+    }
 
   return retval;
 }
@@ -2146,69 +1918,64 @@
 {
   octave_value_list retval;
 
+  int nargin = args.length ();
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   retval(2) = std::string ();
   retval(1) = std::string ();
   retval(0) = -1;
 
-  int nargin = args.length ();
+  std::string tmpl8 = args(0).xstring_value ("mkstemp: TEMPLATE argument must be a string");
 
-  if (nargin == 1 || nargin == 2)
+  OCTAVE_LOCAL_BUFFER (char, tmp, tmpl8.size () + 1);
+  strcpy (tmp, tmpl8.c_str ());
+
+  int fd = gnulib::mkostemp (tmp, O_BINARY);
+
+  if (fd < 0)
     {
-      if (args(0).is_string ())
-        {
-          std::string tmpl8 = args(0).string_value ();
+      retval(2) = gnulib::strerror (errno);
+      retval(0) = fd;
+    }
+  else
+    {
+      const char *fopen_mode = "w+b";
 
-          OCTAVE_LOCAL_BUFFER (char, tmp, tmpl8.size () + 1);
-          strcpy (tmp, tmpl8.c_str ());
+      FILE *fid = fdopen (fd, fopen_mode);
 
-          int fd = gnulib::mkostemp (tmp, O_BINARY);
+      if (fid)
+        {
+          std::string nm = tmp;
+
+          std::ios::openmode md = fopen_mode_to_ios_mode (fopen_mode);
 
-          if (fd < 0)
+          octave_stream s = octave_stdiostream::create (nm, fid, md);
+
+          if (s)
             {
-              retval(2) = gnulib::strerror (errno);
-              retval(0) = fd;
+              retval(1) = nm;
+              retval(0) = octave_stream_list::insert (s);
+
+              if (nargin == 2 && args(1).is_true ())
+                mark_for_deletion (nm);
             }
           else
-            {
-              const char *fopen_mode = "w+b";
-
-              FILE *fid = fdopen (fd, fopen_mode);
-
-              if (fid)
-                {
-                  std::string nm = tmp;
-
-                  std::ios::openmode md = fopen_mode_to_ios_mode (fopen_mode);
-
-                  octave_stream s = octave_stdiostream::create (nm, fid, md);
-
-                  if (s)
-                    {
-                      retval(1) = nm;
-                      retval(0) = octave_stream_list::insert (s);
-
-                      if (nargin == 2 && args(1).is_true ())
-                        mark_for_deletion (nm);
-                    }
-                  else
-                    error ("mkstemp: failed to create octave_stdiostream object");
-                }
-              else
-                {
-                  retval(2) = gnulib::strerror (errno);
-                  retval(0) = -1;
-                }
-            }
+            error ("mkstemp: failed to create octave_stdiostream object");
         }
       else
-        error ("mkstemp: TEMPLATE argument must be a string");
+        {
+          retval(2) = gnulib::strerror (errno);
+          retval(0) = -1;
+        }
     }
-  else
-    print_usage ();
 
   return retval;
 }
 
+// FIXME: This routine also exists verbatim in syscalls.cc.
+//        Maybe change to be a general utility routine.
 static int
 convert (int x, int ibase, int obase)
 {
@@ -2217,7 +1984,7 @@
   int tmp = x % obase;
 
   if (tmp > ibase - 1)
-    ::error ("umask: invalid digit");
+    error ("umask: invalid digit");
   else
     {
       retval = tmp;
@@ -2227,7 +1994,7 @@
           tmp = x % obase;
           if (tmp > ibase - 1)
             {
-              ::error ("umask: invalid digit");
+              error ("umask: invalid digit");
               break;
             }
           retval += mult * tmp;
@@ -2260,33 +2027,22 @@
 
   int status = 0;
 
-  if (args.length () == 1)
-    {
-      int mask = args(0).int_value (true);
+  if (args.length () != 1)
+    print_usage ();
+
+  int mask = args(0).xint_value ("umask: MASK must be an integer");
 
-      if (! error_state)
-        {
-          if (mask < 0)
-            {
-              status = -1;
-              ::error ("umask: MASK must be a positive integer value");
-            }
-          else
-            {
-              int oct_mask = convert (mask, 8, 10);
-
-              if (! error_state)
-                status = convert (octave_umask (oct_mask), 10, 8);
-            }
-        }
-      else
-        {
-          status = -1;
-          ::error ("umask: MASK must be an integer");
-        }
+  if (mask < 0)
+    {
+      status = -1;
+      error ("umask: MASK must be a positive integer value");
     }
   else
-    print_usage ();
+    {
+      int oct_mask = convert (mask, 8, 10);
+
+      status = convert (octave_umask (oct_mask), 10, 8);
+    }
 
   if (status >= 0)
     retval(0) = status;
@@ -2297,16 +2053,10 @@
 static octave_value
 const_value (const char *, const octave_value_list& args, int val)
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 0)
-    retval = val;
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (val);
 }
 
 DEFUNX ("P_tmpdir", FP_tmpdir, args, ,
@@ -2322,16 +2072,10 @@
 @seealso{tempdir, tempname, mkstemp, tmpfile}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 0)
-    retval = get_P_tmpdir ();
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (get_P_tmpdir ());
 }
 
 // NOTE: the values of SEEK_SET, SEEK_CUR, and SEEK_END have to be
@@ -2387,16 +2131,10 @@
 const_value (const char *, const octave_value_list& args,
              const octave_value& val)
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 0)
-    retval = val;
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (val);
 }
 
 DEFUNX ("stdin", Fstdin, args, ,
--- a/libinterp/corefcn/file-io.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/file-io.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 // Written by John C. Campbell <jcc@bevo.che.wisc.edu>
 
-#if !defined (octave_file_io_h)
+#if ! defined (octave_file_io_h)
 #define octave_file_io_h 1
 
 extern OCTINTERP_API void initialize_file_io (void);
--- a/libinterp/corefcn/filter.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/filter.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -38,7 +38,7 @@
 #include "error.h"
 #include "oct-obj.h"
 
-#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
+#if ! defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
 extern MArray<double>
 filter (MArray<double>&, MArray<double>&, MArray<double>&, int dim);
 
@@ -60,8 +60,8 @@
 {
   MArray<T> y;
 
-  octave_idx_type a_len  = a.length ();
-  octave_idx_type b_len  = b.length ();
+  octave_idx_type a_len  = a.numel ();
+  octave_idx_type b_len  = b.numel ();
 
   octave_idx_type ab_len = a_len > b_len ? a_len : b_len;
 
@@ -76,17 +76,11 @@
   T norm = a (0);
 
   if (norm == static_cast<T> (0.0))
-    {
-      error ("filter: the first element of A must be nonzero");
-      return y;
-    }
+    error ("filter: the first element of A must be nonzero");
 
   dim_vector x_dims = x.dims ();
   if (dim < 0 || dim > x_dims.length ())
-    {
-      error ("filter: DIM must be a valid dimension");
-      return y;
-    }
+    error ("filter: DIM must be a valid dimension");
 
   octave_idx_type x_len = x_dims(dim);
 
@@ -94,32 +88,20 @@
   octave_idx_type si_len = si_dims(0);
 
   if (si_len != ab_len - 1)
-    {
-      error ("filter: first dimension of SI must be of length max (length (a), length (b)) - 1");
-      return y;
-    }
+    error ("filter: first dimension of SI must be of length max (length (a), length (b)) - 1");
 
   if (si_dims.length () != x_dims.length ())
-    {
-      error ("filter: dimensionality of SI and X must agree");
-      return y;
-    }
+    error ("filter: dimensionality of SI and X must agree");
 
   for (octave_idx_type i = 1; i < dim; i++)
     {
       if (si_dims(i) != x_dims(i-1))
-        {
-          error ("filter: dimensionality of SI and X must agree");
-          return y;
-        }
+        error ("filter: dimensionality of SI and X must agree");
     }
   for (octave_idx_type i = dim+1; i < x_dims.length (); i++)
     {
       if (si_dims(i) != x_dims(i))
-        {
-          error ("filter: dimensionality of SI and X must agree");
-          return y;
-        }
+        error ("filter: dimensionality of SI and X must agree");
     }
 
   if (x_len == 0)
@@ -127,8 +109,8 @@
 
   if (norm != static_cast<T> (1.0))
     {
-      a = a / norm;
-      b = b / norm;
+      a /= norm;
+      b /= norm;
     }
 
   if (a_len <= 1 && si_len <= 0)
@@ -235,7 +217,7 @@
   return y;
 }
 
-#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
+#if ! defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
 extern MArray<double>
 filter (MArray<double>&, MArray<double>&, MArray<double>&,
         MArray<double>&, int dim);
@@ -270,13 +252,10 @@
         dim = 0;
     }
   else if (dim < 0 || dim > x_dims.length ())
-    {
-      error ("filter: DIM must be a valid dimension");
-      return MArray<T> ();
-    }
+    error ("filter: DIM must be a valid dimension");
 
-  octave_idx_type a_len = a.length ();
-  octave_idx_type b_len = b.length ();
+  octave_idx_type a_len = a.numel ();
+  octave_idx_type b_len = b.numel ();
 
   octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
   dim_vector si_dims = x.dims ();
@@ -394,15 +373,13 @@
 {
   octave_value_list retval;
 
-  int nargin  = args.length ();
+  int nargin = args.length ();
 
   if (nargin < 3 || nargin > 5)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
-  const char *errmsg = "filter: arguments a and b must be vectors";
+  const char *a_b_errmsg = "filter: A and B must be vectors";
+  const char *x_si_errmsg = "filter: X and SI must be arrays";
 
   int dim;
   dim_vector x_dims = args(2).dims ();
@@ -411,10 +388,7 @@
     {
       dim = args(4).nint_value () - 1;
       if (dim < 0 || dim >= x_dims.length ())
-        {
-          error ("filter: DIM must be a valid dimension");
-          return retval;
-        }
+        error ("filter: DIM must be a valid dimension");
     }
   else
     {
@@ -440,198 +414,157 @@
     {
       if (isfloat)
         {
-          FloatComplexColumnVector b (args(0).float_complex_vector_value ());
-          FloatComplexColumnVector a (args(1).float_complex_vector_value ());
-
-          FloatComplexNDArray x (args(2).float_complex_array_value ());
-
-          if (! error_state)
-            {
-              FloatComplexNDArray si;
+          FloatComplexColumnVector b = args(0).xfloat_complex_vector_value (a_b_errmsg);
+          FloatComplexColumnVector a = args(1).xfloat_complex_vector_value (a_b_errmsg);
+          FloatComplexNDArray x = args(2).xfloat_complex_array_value (x_si_errmsg);
 
-              if (nargin == 3 || args(3).is_empty ())
-                {
-                  octave_idx_type a_len = a.length ();
-                  octave_idx_type b_len = b.length ();
-
-                  octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
-
-                  dim_vector si_dims = x.dims ();
-                  for (int i = dim; i > 0; i--)
-                    si_dims(i) = si_dims(i-1);
-                  si_dims(0) = si_len;
+          FloatComplexNDArray si;
 
-                  si.resize (si_dims, 0.0);
-                }
-              else
-                {
-                  si = args(3).float_complex_array_value ();
+          if (nargin == 3 || args(3).is_empty ())
+            {
+              octave_idx_type a_len = a.numel ();
+              octave_idx_type b_len = b.numel ();
 
-                  if (si.is_vector () && x.is_vector ())
-                    si = si.reshape (dim_vector (si.numel (), 1));
-                }
+              octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
 
-              if (! error_state)
-                {
-                  FloatComplexNDArray y (filter (b, a, x, si, dim));
+              dim_vector si_dims = x.dims ();
+              for (int i = dim; i > 0; i--)
+                si_dims(i) = si_dims(i-1);
+              si_dims(0) = si_len;
 
-                  if (nargout == 2)
-                    retval(1) = si;
-
-                  retval(0) = y;
-                }
-              else
-                error (errmsg);
+              si.resize (si_dims, 0.0);
             }
           else
-            error (errmsg);
+            {
+              si = args(3).xfloat_complex_array_value (x_si_errmsg);
+
+              if (si.is_vector () && x.is_vector ())
+                si = si.reshape (dim_vector (si.numel (), 1));
+            }
+
+          FloatComplexNDArray y (filter (b, a, x, si, dim));
+
+          if (nargout == 2)
+            retval(1) = si;
+
+          retval(0) = y;
         }
       else
         {
-          ComplexColumnVector b (args(0).complex_vector_value ());
-          ComplexColumnVector a (args(1).complex_vector_value ());
-
-          ComplexNDArray x (args(2).complex_array_value ());
-
-          if (! error_state)
-            {
-              ComplexNDArray si;
+          ComplexColumnVector b = args(0).xcomplex_vector_value (a_b_errmsg);
+          ComplexColumnVector a = args(1).xcomplex_vector_value (a_b_errmsg);
 
-              if (nargin == 3 || args(3).is_empty ())
-                {
-                  octave_idx_type a_len = a.length ();
-                  octave_idx_type b_len = b.length ();
+          ComplexNDArray x = args(2).xcomplex_array_value (x_si_errmsg);
 
-                  octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
-
-                  dim_vector si_dims = x.dims ();
-                  for (int i = dim; i > 0; i--)
-                    si_dims(i) = si_dims(i-1);
-                  si_dims(0) = si_len;
+          ComplexNDArray si;
 
-                  si.resize (si_dims, 0.0);
-                }
-              else
-                {
-                  si = args(3).complex_array_value ();
+          if (nargin == 3 || args(3).is_empty ())
+            {
+              octave_idx_type a_len = a.numel ();
+              octave_idx_type b_len = b.numel ();
 
-                  if (si.is_vector () && x.is_vector ())
-                    si = si.reshape (dim_vector (si.numel (), 1));
-                }
+              octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
 
-              if (! error_state)
-                {
-                  ComplexNDArray y (filter (b, a, x, si, dim));
+              dim_vector si_dims = x.dims ();
+              for (int i = dim; i > 0; i--)
+                si_dims(i) = si_dims(i-1);
+              si_dims(0) = si_len;
 
-                  if (nargout == 2)
-                    retval(1) = si;
-
-                  retval(0) = y;
-                }
-              else
-                error (errmsg);
+              si.resize (si_dims, 0.0);
             }
           else
-            error (errmsg);
+            {
+              si = args(3).xcomplex_array_value (x_si_errmsg);
+
+              if (si.is_vector () && x.is_vector ())
+                si = si.reshape (dim_vector (si.numel (), 1));
+            }
+
+          ComplexNDArray y (filter (b, a, x, si, dim));
+
+          if (nargout == 2)
+            retval(1) = si;
+
+          retval(0) = y;
         }
     }
   else
     {
       if (isfloat)
         {
-          FloatColumnVector b (args(0).float_vector_value ());
-          FloatColumnVector a (args(1).float_vector_value ());
-
-          FloatNDArray x (args(2).float_array_value ());
-
-          if (! error_state)
-            {
-              FloatNDArray si;
+          FloatColumnVector b = args(0).xfloat_vector_value (a_b_errmsg);
+          FloatColumnVector a = args(1).xfloat_vector_value (a_b_errmsg);
 
-              if (nargin == 3 || args(3).is_empty ())
-                {
-                  octave_idx_type a_len = a.length ();
-                  octave_idx_type b_len = b.length ();
+          FloatNDArray x = args(2).xfloat_array_value (x_si_errmsg);
 
-                  octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
-
-                  dim_vector si_dims = x.dims ();
-                  for (int i = dim; i > 0; i--)
-                    si_dims(i) = si_dims(i-1);
-                  si_dims(0) = si_len;
+          FloatNDArray si;
 
-                  si.resize (si_dims, 0.0);
-                }
-              else
-                {
-                  si = args(3).float_array_value ();
+          if (nargin == 3 || args(3).is_empty ())
+            {
+              octave_idx_type a_len = a.numel ();
+              octave_idx_type b_len = b.numel ();
 
-                  if (si.is_vector () && x.is_vector ())
-                    si = si.reshape (dim_vector (si.numel (), 1));
-                }
+              octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
 
-              if (! error_state)
-                {
-                  FloatNDArray y (filter (b, a, x, si, dim));
+              dim_vector si_dims = x.dims ();
+              for (int i = dim; i > 0; i--)
+                si_dims(i) = si_dims(i-1);
+              si_dims(0) = si_len;
 
-                  if (nargout == 2)
-                    retval(1) = si;
-
-                  retval(0) = y;
-                }
-              else
-                error (errmsg);
+              si.resize (si_dims, 0.0);
             }
           else
-            error (errmsg);
+            {
+              si = args(3).xfloat_array_value (x_si_errmsg);
+
+              if (si.is_vector () && x.is_vector ())
+                si = si.reshape (dim_vector (si.numel (), 1));
+            }
+
+          FloatNDArray y (filter (b, a, x, si, dim));
+
+          if (nargout == 2)
+            retval(1) = si;
+
+          retval(0) = y;
         }
       else
         {
-          ColumnVector b (args(0).vector_value ());
-          ColumnVector a (args(1).vector_value ());
-
-          NDArray x (args(2).array_value ());
-
-          if (! error_state)
-            {
-              NDArray si;
+          ColumnVector b = args(0).xvector_value (a_b_errmsg);
+          ColumnVector a = args(1).xvector_value (a_b_errmsg);
 
-              if (nargin == 3 || args(3).is_empty ())
-                {
-                  octave_idx_type a_len = a.length ();
-                  octave_idx_type b_len = b.length ();
+          NDArray x = args(2).xarray_value (x_si_errmsg);
 
-                  octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
-
-                  dim_vector si_dims = x.dims ();
-                  for (int i = dim; i > 0; i--)
-                    si_dims(i) = si_dims(i-1);
-                  si_dims(0) = si_len;
+          NDArray si;
 
-                  si.resize (si_dims, 0.0);
-                }
-              else
-                {
-                  si = args(3).array_value ();
+          if (nargin == 3 || args(3).is_empty ())
+            {
+              octave_idx_type a_len = a.numel ();
+              octave_idx_type b_len = b.numel ();
 
-                  if (si.is_vector () && x.is_vector ())
-                    si = si.reshape (dim_vector (si.numel (), 1));
-                }
+              octave_idx_type si_len = (a_len > b_len ? a_len : b_len) - 1;
 
-              if (! error_state)
-                {
-                  NDArray y (filter (b, a, x, si, dim));
+              dim_vector si_dims = x.dims ();
+              for (int i = dim; i > 0; i--)
+                si_dims(i) = si_dims(i-1);
+              si_dims(0) = si_len;
 
-                  if (nargout == 2)
-                    retval(1) = si;
-
-                  retval(0) = y;
-                }
-              else
-                error (errmsg);
+              si.resize (si_dims, 0.0);
             }
           else
-            error (errmsg);
+            {
+              si = args(3).xarray_value (x_si_errmsg);
+
+              if (si.is_vector () && x.is_vector ())
+                si = si.reshape (dim_vector (si.numel (), 1));
+            }
+
+          NDArray y (filter (b, a, x, si, dim));
+
+          if (nargout == 2)
+            retval(1) = si;
+
+          retval(0) = y;
         }
     }
 
--- a/libinterp/corefcn/find.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/find.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -61,7 +61,7 @@
     case 2:
       {
         Array<octave_idx_type> jdx (idx.dims ());
-        octave_idx_type n = idx.length ();
+        octave_idx_type n = idx.numel ();
         octave_idx_type nr = nda.rows ();
         for (octave_idx_type i = 0; i < n; i++)
           {
@@ -388,22 +388,16 @@
   int nargin = args.length ();
 
   if (nargin > 3 || nargin < 1)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   // Setup the default options.
   octave_idx_type n_to_find = -1;
   if (nargin > 1)
     {
-      double val = args(1).scalar_value ();
+      double val = args(1).xscalar_value ("find: N must be an integer");
 
-      if (error_state || (val < 0 || (! xisinf (val) && val != xround (val))))
-        {
-          error ("find: N must be a non-negative integer");
-          return retval;
-        }
+      if (val < 0 || (! xisinf (val) && val != xround (val)))
+        error ("find: N must be a non-negative integer");
       else if (! xisinf (val))
         n_to_find = val;
     }
@@ -416,19 +410,13 @@
 
       std::string s_arg = args(2).string_value ();
 
-      if (! error_state)
-        {
-          if (s_arg == "first")
-            direction = 1;
-          else if (s_arg == "last")
-            direction = -1;
-        }
+      if (s_arg == "first")
+        direction = 1;
+      else if (s_arg == "last")
+        direction = -1;
 
       if (direction == 0)
-        {
-          error ("find: DIRECTION must be \"first\" or \"last\"");
-          return retval;
-        }
+        error ("find: DIRECTION must be \"first\" or \"last\"");
     }
 
   octave_value arg = args(0);
@@ -439,23 +427,24 @@
         {
           SparseBoolMatrix v = arg.sparse_bool_matrix_value ();
 
-          if (! error_state)
-            retval = find_nonzero_elem_idx (v, nargout,
-                                            n_to_find, direction);
+          retval = find_nonzero_elem_idx (v, nargout, n_to_find, direction);
         }
       else if (nargout <= 1 && n_to_find == -1 && direction == 1)
         {
           // This case is equivalent to extracting indices from a logical
           // matrix. Try to reuse the possibly cached index vector.
+
+          // No need to catch index_exception, since arg is bool.
+          // Out-of-range errors have already set pos, and will be
+          // caught later.
+
           retval(0) = arg.index_vector ().unmask ();
         }
       else
         {
           boolNDArray v = arg.bool_array_value ();
 
-          if (! error_state)
-            retval = find_nonzero_elem_idx (v, nargout,
-                                            n_to_find, direction);
+          retval = find_nonzero_elem_idx (v, nargout, n_to_find, direction);
         }
     }
   else if (arg.is_integer_type ())
@@ -464,10 +453,8 @@
       else if (arg.is_ ## INTT ## _type ()) \
         { \
           INTT ## NDArray v = arg.INTT ## _array_value (); \
-          \
-          if (! error_state) \
-            retval = find_nonzero_elem_idx (v, nargout, \
-                                            n_to_find, direction);\
+ \
+          retval = find_nonzero_elem_idx (v, nargout, n_to_find, direction); \
         }
 
       if (false)
@@ -489,17 +476,13 @@
         {
           SparseMatrix v = arg.sparse_matrix_value ();
 
-          if (! error_state)
-            retval = find_nonzero_elem_idx (v, nargout,
-                                            n_to_find, direction);
+          retval = find_nonzero_elem_idx (v, nargout, n_to_find, direction);
         }
       else if (arg.is_complex_type ())
         {
           SparseComplexMatrix v = arg.sparse_complex_matrix_value ();
 
-          if (! error_state)
-            retval = find_nonzero_elem_idx (v, nargout,
-                                            n_to_find, direction);
+          retval = find_nonzero_elem_idx (v, nargout, n_to_find, direction);
         }
       else
         gripe_wrong_type_arg ("find", arg);
@@ -508,15 +491,13 @@
     {
       PermMatrix P = arg.perm_matrix_value ();
 
-      if (! error_state)
-        retval = find_nonzero_elem_idx (P, nargout, n_to_find, direction);
+      retval = find_nonzero_elem_idx (P, nargout, n_to_find, direction);
     }
   else if (arg.is_string ())
     {
       charNDArray chnda = arg.char_array_value ();
 
-      if (! error_state)
-        retval = find_nonzero_elem_idx (chnda, nargout, n_to_find, direction);
+      retval = find_nonzero_elem_idx (chnda, nargout, n_to_find, direction);
     }
   else if (arg.is_single_type ())
     {
@@ -524,32 +505,26 @@
         {
           FloatNDArray nda = arg.float_array_value ();
 
-          if (! error_state)
-            retval = find_nonzero_elem_idx (nda, nargout, n_to_find,
-                                            direction);
+          retval = find_nonzero_elem_idx (nda, nargout, n_to_find, direction);
         }
       else if (arg.is_complex_type ())
         {
           FloatComplexNDArray cnda = arg.float_complex_array_value ();
 
-          if (! error_state)
-            retval = find_nonzero_elem_idx (cnda, nargout, n_to_find,
-                                            direction);
+          retval = find_nonzero_elem_idx (cnda, nargout, n_to_find, direction);
         }
     }
   else if (arg.is_real_type ())
     {
       NDArray nda = arg.array_value ();
 
-      if (! error_state)
-        retval = find_nonzero_elem_idx (nda, nargout, n_to_find, direction);
+      retval = find_nonzero_elem_idx (nda, nargout, n_to_find, direction);
     }
   else if (arg.is_complex_type ())
     {
       ComplexNDArray cnda = arg.complex_array_value ();
 
-      if (! error_state)
-        retval = find_nonzero_elem_idx (cnda, nargout, n_to_find, direction);
+      retval = find_nonzero_elem_idx (cnda, nargout, n_to_find, direction);
     }
   else
     gripe_wrong_type_arg ("find", arg);
--- a/libinterp/corefcn/gammainc.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/gammainc.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -83,129 +83,99 @@
 
   int nargin = args.length ();
 
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
   if (nargin == 3)
     {
-      if (args(2).is_string ())
-        {
-          std::string s = args(2).string_value ();
-          std::transform (s.begin (), s.end (), s.begin (), tolower);
-          if (s == "upper")
-            lower = false;
-          else if (s != "lower")
-            error ("gammainc: third argument must be \"lower\" or \"upper\"");
-        }
-      else
+      std::string s = args(2).xstring_value ("gammainc: third argument must be \"lower\" or \"upper\"");
+
+      std::transform (s.begin (), s.end (), s.begin (), tolower);
+
+      if (s == "upper")
+        lower = false;
+      else if (s != "lower")
         error ("gammainc: third argument must be \"lower\" or \"upper\"");
-
     }
 
-  if (!error_state && nargin >= 2  && nargin <= 3)
-    {
-      octave_value x_arg = args(0);
-      octave_value a_arg = args(1);
-
-      // FIXME: Can we make a template version of the duplicated code below
-      if (x_arg.is_single_type () || a_arg.is_single_type ())
-        {
-          if (x_arg.is_scalar_type ())
-            {
-              float x = x_arg.float_value ();
+  octave_value x_arg = args(0);
+  octave_value a_arg = args(1);
 
-              if (! error_state)
-                {
-                  if (a_arg.is_scalar_type ())
-                    {
-                      float a = a_arg.float_value ();
+  // FIXME: Can we make a template version of the duplicated code below
+  if (x_arg.is_single_type () || a_arg.is_single_type ())
+    {
+      if (x_arg.is_scalar_type ())
+        {
+          float x = x_arg.float_value ();
 
-                      if (! error_state)
-                        retval = lower ? gammainc (x, a)
-                                       : 1.0f - gammainc (x, a);
-                    }
-                  else
-                    {
-                      FloatNDArray a = a_arg.float_array_value ();
+          if (a_arg.is_scalar_type ())
+            {
+              float a = a_arg.float_value ();
 
-                      if (! error_state)
-                        retval = lower ? gammainc (x, a)
-                                       : 1.0f - gammainc (x, a);
-                    }
-                }
+              retval = lower ? gammainc (x, a) : 1.0f - gammainc (x, a);
             }
           else
             {
-              FloatNDArray x = x_arg.float_array_value ();
-
-              if (! error_state)
-                {
-                  if (a_arg.is_scalar_type ())
-                    {
-                      float a = a_arg.float_value ();
+              FloatNDArray a = a_arg.float_array_value ();
 
-                      if (! error_state)
-                        retval = lower ? gammainc (x, a)
-                                       : 1.0f - gammainc (x, a);
-                    }
-                  else
-                    {
-                      FloatNDArray a = a_arg.float_array_value ();
-
-                      if (! error_state)
-                        retval = lower ? gammainc (x, a)
-                                       : 1.0f - gammainc (x, a);
-                    }
-                }
+              retval = lower ? gammainc (x, a) : 1.0f - gammainc (x, a);
             }
         }
       else
         {
-          if (x_arg.is_scalar_type ())
-            {
-              double x = x_arg.double_value ();
-
-              if (! error_state)
-                {
-                  if (a_arg.is_scalar_type ())
-                    {
-                      double a = a_arg.double_value ();
+          FloatNDArray x = x_arg.float_array_value ();
 
-                      if (! error_state)
-                        retval = lower ? gammainc (x, a) : 1. - gammainc (x, a);
-                    }
-                  else
-                    {
-                      NDArray a = a_arg.array_value ();
+          if (a_arg.is_scalar_type ())
+            {
+              float a = a_arg.float_value ();
 
-                      if (! error_state)
-                        retval = lower ? gammainc (x, a) : 1. - gammainc (x, a);
-                    }
-                }
+              retval = lower ? gammainc (x, a) : 1.0f - gammainc (x, a);
             }
           else
             {
-              NDArray x = x_arg.array_value ();
-
-              if (! error_state)
-                {
-                  if (a_arg.is_scalar_type ())
-                    {
-                      double a = a_arg.double_value ();
+              FloatNDArray a = a_arg.float_array_value ();
 
-                      if (! error_state)
-                        retval = lower ? gammainc (x, a) : 1. - gammainc (x, a);
-                    }
-                  else
-                    {
-                      NDArray a = a_arg.array_value ();
-
-                      if (! error_state)
-                        retval = lower ? gammainc (x, a) : 1. - gammainc (x, a);
-                    }
-                }
+              retval = lower ? gammainc (x, a) : 1.0f - gammainc (x, a);
             }
         }
     }
   else
-    print_usage ();
+    {
+      if (x_arg.is_scalar_type ())
+        {
+          double x = x_arg.double_value ();
+
+          if (a_arg.is_scalar_type ())
+            {
+              double a = a_arg.double_value ();
+
+              retval = lower ? gammainc (x, a) : 1. - gammainc (x, a);
+            }
+          else
+            {
+              NDArray a = a_arg.array_value ();
+
+              retval = lower ? gammainc (x, a) : 1. - gammainc (x, a);
+            }
+        }
+      else
+        {
+          NDArray x = x_arg.array_value ();
+
+          if (a_arg.is_scalar_type ())
+            {
+              double a = a_arg.double_value ();
+
+              retval = lower ? gammainc (x, a) : 1. - gammainc (x, a);
+            }
+          else
+            {
+              NDArray a = a_arg.array_value ();
+
+              retval = lower ? gammainc (x, a) : 1. - gammainc (x, a);
+            }
+        }
+    }
 
   return retval;
 }
--- a/libinterp/corefcn/gcd.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/gcd.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -40,8 +40,7 @@
 simple_gcd (double a, double b)
 {
   if (! xisinteger (a) || ! xisinteger (b))
-    (*current_liboctave_error_handler)
-      ("gcd: all values must be integers");
+    error ("gcd: all values must be integers");
 
   double aa = fabs (a);
   double bb = fabs (b);
@@ -78,8 +77,7 @@
 {
   if (! xisinteger (a.real ()) || ! xisinteger (a.imag ())
       || ! xisinteger (b.real ()) || ! xisinteger (b.imag ()))
-    (*current_liboctave_error_handler)
-      ("gcd: all complex parts must be integers");
+    error ("gcd: all complex parts must be integers");
 
   std::complex<FP> aa = a;
   std::complex<FP> bb = b;
@@ -119,8 +117,7 @@
 extended_gcd (double a, double b, double& x, double& y)
 {
   if (! xisinteger (a) || ! xisinteger (b))
-    (*current_liboctave_error_handler)
-      ("gcd: all values must be integers");
+    error ("gcd: all values must be integers");
 
   double aa = fabs (a);
   double bb = fabs (b);
@@ -159,8 +156,7 @@
 {
   if (! xisinteger (a.real ()) || ! xisinteger (a.imag ())
       || ! xisinteger (b.real ()) || ! xisinteger (b.imag ()))
-    (*current_liboctave_error_handler)
-      ("gcd: all complex parts must be integers");
+    error ("gcd: all complex parts must be integers");
 
   std::complex<FP> aa = a;
   std::complex<FP> bb = b;
@@ -420,7 +416,7 @@
     }
 
   // For consistency.
-  if (! error_state && a.is_sparse_type () && b.is_sparse_type ())
+  if (a.is_sparse_type () && b.is_sparse_type ())
     {
       retval = retval.sparse_matrix_value ();
       x = x.sparse_matrix_value ();
@@ -480,41 +476,31 @@
 
   int nargin = args.length ();
 
-  if (nargin > 1)
-    {
-      if (nargout > 1)
-        {
-          retval.resize (nargin + 1);
-
-          retval(0) = do_extended_gcd (args(0), args(1), retval(1), retval(2));
+  if (nargin < 2)
+    print_usage ();
 
-          for (int j = 2; j < nargin; j++)
-            {
-              octave_value x;
-              retval(0) = do_extended_gcd (retval(0), args(j),
-                                           x, retval(j+1));
-              for (int i = 0; i < j; i++)
-                retval(i+1).assign (octave_value::op_el_mul_eq, x);
+  if (nargout > 1)
+    {
+      retval.resize (nargin + 1);
 
-              if (error_state)
-                break;
-            }
-        }
-      else
-        {
-          retval(0) = do_simple_gcd (args(0), args(1));
+      retval(0) = do_extended_gcd (args(0), args(1), retval(1), retval(2));
 
-          for (int j = 2; j < nargin; j++)
-            {
-              retval(0) = do_simple_gcd (retval(0), args(j));
-
-              if (error_state)
-                break;
-            }
+      for (int j = 2; j < nargin; j++)
+        {
+          octave_value x;
+          retval(0) = do_extended_gcd (retval(0), args(j),
+                                       x, retval(j+1));
+          for (int i = 0; i < j; i++)
+            retval(i+1).assign (octave_value::op_el_mul_eq, x);
         }
     }
   else
-    print_usage ();
+    {
+      retval(0) = do_simple_gcd (args(0), args(1));
+
+      for (int j = 2; j < nargin; j++)
+        retval(0) = do_simple_gcd (retval(0), args(j));
+    }
 
   return retval;
 }
--- a/libinterp/corefcn/getgrent.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/getgrent.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -73,20 +73,16 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = 0;
+  if (args.length () != 0)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string msg;
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  // octave_group::getgrent may set msg.
+  octave_value val = mk_gr_map (octave_group::getgrent (msg));
 
-      retval(1) = msg;
-      retval(0) = mk_gr_map (octave_group::getgrent (msg));
-    }
-  else
-    print_usage ();
+  retval(1) = msg;
+  retval(0) = val;
 
   return retval;
 }
@@ -103,32 +99,26 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = 0;
+  if (args.length () != 1)
+    print_usage ();
 
-  int nargin = args.length ();
+  double dval = args(0).double_value ();
 
-  if (nargin == 1)
+  if (D_NINT (dval) == dval)
     {
-      double dval = args(0).double_value ();
+      gid_t gid = static_cast<gid_t> (dval);
 
-      if (! error_state)
-        {
-          if (D_NINT (dval) == dval)
-            {
-              gid_t gid = static_cast<gid_t> (dval);
+      std::string msg;
 
-              std::string msg;
+      // octave_group::getgrgid may set msg.
+      octave_value val = mk_gr_map (octave_group::getgrgid (gid, msg));
 
-              retval(1) = msg;
-              retval(0) = mk_gr_map (octave_group::getgrgid (gid, msg));
-            }
-          else
-            error ("getgrgid: GID must be an integer");
-        }
+      retval(1) = msg;
+      retval(0) = val;
     }
+
   else
-    print_usage ();
+    error ("getgrgid: GID must be an integer");
 
   return retval;
 }
@@ -145,25 +135,18 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = 0;
+  if (args.length () != 1)
+    print_usage ();
 
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      std::string s = args(0).string_value ();
+  std::string s = args(0).string_value ();
 
-      if (! error_state)
-        {
-          std::string msg;
+  std::string msg;
 
-          retval(1) = msg;
-          retval(0) = mk_gr_map (octave_group::getgrnam (s.c_str (), msg));
-        }
-    }
-  else
-    print_usage ();
+  // octave_group::getgrnam may set msg.
+  octave_value val = mk_gr_map (octave_group::getgrnam (s.c_str (), msg));
+
+  retval(1) = msg;
+  retval(0) = val;
 
   return retval;
 }
@@ -177,20 +160,16 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = -1.0;
+  if (args.length () != 0)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string msg;
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  // octave_group::setgrent may set msg.
+  int status = octave_group::setgrent (msg);
 
-      retval(1) = msg;
-      retval(0) = static_cast<double> (octave_group::setgrent (msg));
-    }
-  else
-    print_usage ();
+  retval(1) = msg;
+  retval(0) = static_cast<double> (status);
 
   return retval;
 }
@@ -204,20 +183,16 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = -1.0;
+  if (args.length () != 0)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string msg;
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  // octave_group::endgrent may set msg.
+  int status = octave_group::endgrent (msg);
 
-      retval(1) = msg;
-      retval(0) = static_cast<double> (octave_group::endgrent (msg));
-    }
-  else
-    print_usage ();
+  retval(1) = msg;
+  retval(0) = static_cast<double> (status);
 
   return retval;
 }
--- a/libinterp/corefcn/getpwent.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/getpwent.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -77,20 +77,16 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = 0;
+  if (args.length () != 0)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string msg;
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  // octave_passwd::getpwent may set msg.
+  octave_value val = mk_pw_map (octave_passwd::getpwent (msg));
 
-      retval(1) = msg;
-      retval(0) = mk_pw_map (octave_passwd::getpwent (msg));
-    }
-  else
-    print_usage ();
+  retval(1) = msg;
+  retval(0) = val;
 
   return retval;
 }
@@ -107,32 +103,25 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = 0;
+  if (args.length () != 1)
+    print_usage ();
 
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      double dval = args(0).double_value ();
+  double dval = args(0).double_value ();
 
-      if (! error_state)
-        {
-          if (D_NINT (dval) == dval)
-            {
-              uid_t uid = static_cast<uid_t> (dval);
+  if (D_NINT (dval) == dval)
+    {
+      uid_t uid = static_cast<uid_t> (dval);
+
+      std::string msg;
 
-              std::string msg;
+      // octave_passwd::getpwuid may set msg.
+      octave_value val = mk_pw_map (octave_passwd::getpwuid (uid, msg));
 
-              retval(1) = msg;
-              retval(0) = mk_pw_map (octave_passwd::getpwuid (uid, msg));
-            }
-          else
-            error ("getpwuid: UID must be an integer");
-        }
+      retval(1) = msg;
+      retval(0) = val;
     }
   else
-    print_usage ();
+    error ("getpwuid: UID must be an integer");
 
   return retval;
 }
@@ -149,25 +138,18 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = 0.0;
+  if (args.length () != 1)
+    print_usage ();
 
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      std::string s = args(0).string_value ();
+  std::string s = args(0).string_value ();
 
-      if (! error_state)
-        {
-          std::string msg;
+  std::string msg;
 
-          retval(1) = msg;
-          retval(0) = mk_pw_map (octave_passwd::getpwnam (s, msg));
-        }
-    }
-  else
-    print_usage ();
+  // octave_passwd::getpwnam may set msg.
+  octave_value val = mk_pw_map (octave_passwd::getpwnam (s, msg));
+
+  retval(1) = msg;
+  retval(0) = val;
 
   return retval;
 }
@@ -181,20 +163,16 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = -1.0;
+  if (args.length () != 0)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string msg;
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  // octave_passwd::setpwent may set msg.
+  int status = octave_passwd::setpwent (msg);
 
-      retval(1) = msg;
-      retval(0) = static_cast<double> (octave_passwd::setpwent (msg));
-    }
-  else
-    print_usage ();
+  retval(1) = msg;
+  retval(0) = static_cast<double> (status);
 
   return retval;
 }
@@ -208,20 +186,16 @@
 {
   octave_value_list retval;
 
-  retval(1) = std::string ();
-  retval(0) = -1.0;
+  if (args.length () != 0)
+    print_usage ();
 
-  int nargin = args.length ();
+  std::string msg;
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  // octave_passwd::endpwent may set msg.
+  int status = octave_passwd::endpwent (msg);
 
-      retval(1) = msg;
-      retval(0) = static_cast<double> (octave_passwd::endpwent (msg));
-    }
-  else
-    print_usage ();
+  retval(1) = msg;
+  retval(0) = static_cast<double> (status);
 
   return retval;
 }
--- a/libinterp/corefcn/getrusage.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/getrusage.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -43,7 +43,7 @@
 #include "oct-obj.h"
 #include "utils.h"
 
-#if !defined (HZ)
+#if ! defined (HZ)
 #if defined (CLK_TCK)
 #define HZ CLK_TCK
 #elif defined (USG)
--- a/libinterp/corefcn/givens.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/givens.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -76,123 +76,92 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
+  if (args.length () != 2 || nargout > 2)
+    print_usage ();
 
-  if (nargin != 2 || nargout > 2)
+  if (args(0).is_single_type () || args(1).is_single_type ())
     {
-      print_usage ();
-      return retval;
-    }
-  else
-    {
-      if (args(0).is_single_type () || args(1).is_single_type ())
+      if (args(0).is_complex_type () || args(1).is_complex_type ())
         {
-          if (args(0).is_complex_type () || args(1).is_complex_type ())
-            {
-              FloatComplex cx = args(0).float_complex_value ();
-              FloatComplex cy = args(1).float_complex_value ();
-
-              if (! error_state)
-                {
-                  FloatComplexMatrix result = Givens (cx, cy);
+          FloatComplex cx = args(0).float_complex_value ();
+          FloatComplex cy = args(1).float_complex_value ();
 
-                  if (! error_state)
-                    {
-                      switch (nargout)
-                        {
-                        case 0:
-                        case 1:
-                          retval(0) = result;
-                          break;
+          FloatComplexMatrix result = Givens (cx, cy);
 
-                        case 2:
-                          retval(1) = result (0, 1);
-                          retval(0) = result (0, 0);
-                          break;
-                        }
-                    }
-                }
-            }
-          else
+          switch (nargout)
             {
-              float x = args(0).float_value ();
-              float y = args(1).float_value ();
-
-              if (! error_state)
-                {
-                  FloatMatrix result = Givens (x, y);
+            case 0:
+            case 1:
+              retval(0) = result;
+              break;
 
-                  if (! error_state)
-                    {
-                      switch (nargout)
-                        {
-                        case 0:
-                        case 1:
-                          retval(0) = result;
-                          break;
-
-                        case 2:
-                          retval(1) = result (0, 1);
-                          retval(0) = result (0, 0);
-                          break;
-                        }
-                    }
-                }
+            case 2:
+              retval(1) = result (0, 1);
+              retval(0) = result (0, 0);
+              break;
             }
         }
       else
         {
-          if (args(0).is_complex_type () || args(1).is_complex_type ())
-            {
-              Complex cx = args(0).complex_value ();
-              Complex cy = args(1).complex_value ();
+          float x = args(0).float_value ();
+          float y = args(1).float_value ();
 
-              if (! error_state)
-                {
-                  ComplexMatrix result = Givens (cx, cy);
+          FloatMatrix result = Givens (x, y);
 
-                  if (! error_state)
-                    {
-                      switch (nargout)
-                        {
-                        case 0:
-                        case 1:
-                          retval(0) = result;
-                          break;
+          switch (nargout)
+            {
+            case 0:
+            case 1:
+              retval(0) = result;
+              break;
 
-                        case 2:
-                          retval(1) = result (0, 1);
-                          retval(0) = result (0, 0);
-                          break;
-                        }
-                    }
-                }
+            case 2:
+              retval(1) = result (0, 1);
+              retval(0) = result (0, 0);
+              break;
             }
-          else
+        }
+    }
+  else
+    {
+      if (args(0).is_complex_type () || args(1).is_complex_type ())
+        {
+          Complex cx = args(0).complex_value ();
+          Complex cy = args(1).complex_value ();
+
+          ComplexMatrix result = Givens (cx, cy);
+
+          switch (nargout)
             {
-              double x = args(0).double_value ();
-              double y = args(1).double_value ();
-
-              if (! error_state)
-                {
-                  Matrix result = Givens (x, y);
+            case 0:
+            case 1:
+              retval(0) = result;
+              break;
 
-                  if (! error_state)
-                    {
-                      switch (nargout)
-                        {
-                        case 0:
-                        case 1:
-                          retval(0) = result;
-                          break;
+            case 2:
+              retval(1) = result (0, 1);
+              retval(0) = result (0, 0);
+              break;
+            }
+        }
+      else
+        {
+          double x = args(0).double_value ();
+          double y = args(1).double_value ();
 
-                        case 2:
-                          retval(1) = result (0, 1);
-                          retval(0) = result (0, 0);
-                          break;
-                        }
-                    }
-                }
+          Matrix result = Givens (x, y);
+
+          switch (nargout)
+            {
+            case 0:
+            case 1:
+              retval(0) = result;
+              break;
+
+            case 2:
+              retval(1) = result (0, 1);
+              retval(0) = result (0, 0);
+              break;
             }
         }
     }
--- a/libinterp/corefcn/gl-render.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/gl-render.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -223,7 +223,7 @@
       else
         {
           ok = false;
-          warning ("opengl_texture::create: invalid texture data type (expected double or uint8)");
+          warning ("opengl_texture::create: invalid texture data type (double or uint8 required)");
         }
 
       if (ok)
@@ -667,7 +667,7 @@
 
   // Clear background
 
-  if (c.length () >= 3)
+  if (c.numel () >= 3)
     {
       glClearColor (c(0), c(1), c(2), 1);
       glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -1475,6 +1475,7 @@
   draw_axes_boxes (props);
 
   set_font (props);
+  set_interpreter (props.get_ticklabelinterpreter ());
 
   draw_axes_x_grid (props);
   draw_axes_y_grid (props);
@@ -1517,7 +1518,7 @@
         clip[i] = (clip_code (x(i), y(i), z_mid) & clip_mask);
     }
 
-  if (! props.linestyle_is ("none"))
+  if (! props.linestyle_is ("none") && ! props.color_is ("none"))
     {
       set_color (props.get_color_rgb ());
       set_linestyle (props.get_linestyle (), false);
@@ -3229,7 +3230,19 @@
 {
 #if HAVE_FREETYPE
   text_renderer.text_to_pixels (txt, pixels, bbox,
-                                halign, valign, rotation, "none");
+                                halign, valign, rotation, interpreter);
+#endif
+}
+
+void
+opengl_renderer::text_to_strlist (const std::string& txt,
+                                  std::list<ft_render::ft_string>& lst,
+                                  Matrix& bbox,
+                                  int halign, int valign, double rotation)
+{
+#if HAVE_FREETYPE
+  text_renderer.text_to_strlist (txt, lst, bbox,
+                                 halign, valign, rotation, interpreter);
 #endif
 }
 
--- a/libinterp/corefcn/gl-render.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/gl-render.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_gl_render_h)
+#if ! defined (octave_gl_render_h)
 #define octave_gl_render_h 1
 
 #ifdef HAVE_WINDOWS_H
@@ -59,7 +59,7 @@
   opengl_renderer (void)
     : toolkit (), xform (), xmin (), xmax (), ymin (), ymax (),
     zmin (), zmax (), xZ1 (), xZ2 (), marker_id (), filled_marker_id (),
-    camera_pos (), camera_dir ()
+    camera_pos (), camera_dir (), interpreter ("none")
 #if HAVE_FREETYPE
     , text_renderer ()
 #endif
@@ -71,7 +71,7 @@
 
   virtual void draw (const Matrix& hlist, bool toplevel = false)
   {
-    int len = hlist.length ();
+    int len = hlist.numel ();
 
     for (int i = len-1; i >= 0; i--)
       {
@@ -108,6 +108,10 @@
                             double z1, double z2);
   virtual void set_clipping (bool on);
   virtual void set_font (const base_properties& props);
+  virtual void set_interpreter (const caseless_str interp)
+  {
+    interpreter = interp;
+  }
 
   virtual void init_marker (const std::string& m, double size, float width);
   virtual void end_marker (void);
@@ -120,6 +124,12 @@
                                int halign = 0, int valign = 0,
                                double rotation = 0.0);
 
+  virtual void text_to_strlist (const std::string& txt,
+                                std::list<ft_render::ft_string>& lst,
+                                Matrix& bbox,
+                                int halign = 0, int valign = 0,
+                                double rotation = 0.0);
+
   virtual Matrix render_text (const std::string& txt,
                               double x, double y, double z,
                               int halign, int valign, double rotation = 0.0);
@@ -207,6 +217,9 @@
   // camera information for primitive sorting
   ColumnVector camera_pos, camera_dir;
 
+  // interpreter to be used by text_to_pixels
+  caseless_str interpreter;
+
 #if HAVE_FREETYPE
   // FreeType render, used for text rendering
   ft_render text_renderer;
--- a/libinterp/corefcn/gl2ps-renderer.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/gl2ps-renderer.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -26,6 +26,7 @@
 
 #include "error.h"
 #include "gl2ps-renderer.h"
+#include "txt-eng-ft.h"
 
 #ifdef HAVE_GL2PS_H
 
@@ -66,10 +67,7 @@
       else if (term.find ("tex") != std::string::npos)
         gl2ps_term = GL2PS_TEX;
       else
-        {
-          error ("gl2ps-renderer::draw: Unknown terminal %s", term.c_str ());
-          return;
-        }
+        error ("gl2ps-renderer::draw: Unknown terminal %s", term.c_str ());
 
       GLint gl2ps_text = 0;
       if (term.find ("notxt") != std::string::npos)
@@ -130,28 +128,22 @@
             {
               old_print_cmd.clear ();
               error ("gl2ps-renderer::draw: gl2psBeginPage returned GL2PS_ERROR");
-              return;
             }
 
           old_print_cmd = print_cmd;
 
           opengl_renderer::draw (go);
 
-          // Without glFinish () there may primitives be missing in the
+          // Without glFinish () there may be primitives missing in the
           // gl2ps output.
           glFinish ();
 
           state = gl2psEndPage ();
 
-          if (state == GL2PS_NO_FEEDBACK)
-            {
-              warning ("gl2ps-renderer::draw: empty feedback buffer and/or nothing else to print");
-            }
-          else if (state == GL2PS_ERROR)
+          if (state == GL2PS_ERROR)
             {
               old_print_cmd.clear ();
               error ("gl2ps-renderer::draw: gl2psEndPage returned GL2PS_ERROR");
-              return;
             }
 
           // Don't check state for GL2PS_UNINITIALIZED (should never happen)
@@ -198,42 +190,194 @@
   return gl2psa;
 }
 
-Matrix
-glps_renderer::render_text (const std::string& txt,
-                            double x, double y, double z,
-                            int ha, int va, double rotation)
+void
+glps_renderer::fix_strlist_position (double x, double y, double z,
+                                     Matrix box, double rotation,
+                                     std::list<ft_render::ft_string>& lst)
 {
-  if (txt.empty ())
-    return Matrix (1, 4, 0.0);
-
-  glRasterPos3d (x, y, z);
+  for (std::list<ft_render::ft_string>::iterator p = lst.begin ();
+       p != lst.end (); p++)
+    {
+      // Get pixel coordinates
+      ColumnVector coord_pix = get_transform ().transform (x, y, z, false);
 
-  gl2psTextOpt (txt.c_str (), fontname.c_str (), fontsize,
-                alignment_to_mode (ha, va), rotation);
+      // Translate and rotate
+      double rot = rotation * 4.0 * atan (1.0) / 180;
+      coord_pix(0) += ((*p).get_x () + box(0))*cos (rot)
+                      - ((*p).get_y () + box(1))*sin (rot);
+      coord_pix(1) -= ((*p).get_y () + box(1))*cos (rot)
+                      + ((*p).get_x () + box(0))*sin (rot);;
 
-  // FIXME?
-  // We have no way of getting a bounding box from gl2ps, so we use FreeType.
-  Matrix bbox;
-  uint8NDArray pixels;
-  text_to_pixels (txt, pixels, bbox, 0, 0, rotation);
-
-  return bbox;
+      // Turn coordinates back into current gl coordinates
+      ColumnVector coord =
+        get_transform ().untransform (coord_pix(0), coord_pix(1),
+                                      coord_pix(2), false);
+      (*p).set_x (coord(0));
+      (*p).set_y (coord(1));
+      (*p).set_z (coord(2));
+    }
 }
 
-void
-glps_renderer::set_font (const base_properties& props)
+static std::string
+code_to_symbol (uint32_t code)
 {
-  opengl_renderer::set_font (props);
+  std::string retval;
 
-  fontsize = props.get ("fontsize_points").double_value ();
+  uint32_t idx = code - 945;
+  if (idx < 25)
+    {
+      std::string characters("abgdezhqiklmnxoprVstufcyw");
+      retval = characters[idx];
+      return retval;
+    }
 
-  caseless_str fn = props.get ("fontname").xtolower ().string_value ();
-  bool isbold =
-    (props.get ("fontweight").xtolower ().string_value () == "bold");
-  bool isitalic =
-    (props.get ("fontangle").xtolower ().string_value () == "italic");
+  idx = code - 913;
+  if (idx < 25)
+    {
+      std::string characters("ABGDEZHQIKLMNXOPRVSTUFCYW");
+      retval = characters[idx];
+    }
+  else if (code == 978)
+    retval = std::string ("U");
+  else if (code == 215)
+    retval = std::string ("\xb4");
+  else if (code == 177)
+    retval = std::string ("\xb1");
+  else if (code == 8501)
+    retval = std::string ("\xc0");
+  else if (code == 8465)
+    retval = std::string ("\xc1");
+  else if (code == 8242)
+    retval = std::string ("\xa2");
+  else if (code == 8736)
+    retval = std::string ("\xd0");
+  else if (code == 172)
+    retval = std::string ("\xd8");
+  else if (code == 9829)
+    retval = std::string ("\xa9");
+  else if (code == 8472)
+    retval = std::string ("\xc3");
+  else if (code == 8706)
+    retval = std::string ("\xb6");
+  else if (code == 8704)
+    retval = std::string ("\x22");
+  else if (code == 9827)
+    retval = std::string ("\xa7");
+  else if (code == 9824)
+    retval = std::string ("\xaa");
+  else if (code == 8476)
+    retval = std::string ("\xc2");
+  else if (code == 8734)
+    retval = std::string ("\xa5");
+  else if (code == 8730)
+    retval = std::string ("\xd6");
+  else if (code == 8707)
+  retval = std::string ("\x24");
+  else if (code == 9830)
+    retval = std::string ("\xa8");
+  else if (code == 8747)
+    retval = std::string ("\xf2");
+  else if (code == 8727)
+    retval = std::string ("\x2a");
+  else if (code == 8744)
+    retval = std::string ("\xda");
+  else if (code == 8855)
+    retval = std::string ("\xc4");
+  else if (code == 8901)
+    retval = std::string ("\xd7");
+  else if (code == 8728)
+    retval = std::string ("\xb0");
+  else if (code == 8745)
+    retval = std::string ("\xc7");
+  else if (code == 8743)
+    retval = std::string ("\xd9");
+  else if (code == 8856)
+    retval = std::string ("\xc6");
+  else if (code == 8729)
+    retval = std::string ("\xb7");
+  else if (code == 8746)
+    retval = std::string ("\xc8");
+  else if (code == 8853)
+    retval = std::string ("\xc5");
+  else if (code == 8804)
+    retval = std::string ("\xa3");
+  else if (code == 8712)
+    retval = std::string ("\xce");
+  else if (code == 8839)
+    retval = std::string ("\xca");
+  else if (code == 8801)
+    retval = std::string ("\xba");
+  else if (code == 8773)
+    retval = std::string ("\x40");
+  else if (code == 8834)
+    retval = std::string ("\xcc");
+  else if (code == 8805)
+    retval = std::string ("\xb3");
+  else if (code == 8715)
+    retval = std::string ("\x27");
+  else if (code == 8764)
+    retval = std::string ("\x7e");
+  else if (code == 8733)
+    retval = std::string ("\xb5");
+  else if (code == 8838)
+    retval = std::string ("\xcd");
+  else if (code == 8835)
+    retval = std::string ("\xc9");
+  else if (code == 8739)
+    retval = std::string ("\xbd");
+  else if (code == 8776)
+    retval = std::string ("\xbb");
+  else if (code == 8869)
+    retval = std::string ("\x5e");
+  else if (code == 8656)
+    retval = std::string ("\xdc");
+  else if (code == 8592)
+    retval = std::string ("\xac");
+  else if (code == 8658)
+    retval = std::string ("\xde");
+  else if (code == 8594)
+    retval = std::string ("\xae");
+  else if (code == 8596)
+    retval = std::string ("\xab");
+  else if (code == 8593)
+    retval = std::string ("\xad");
+  else if (code == 8595)
+    retval = std::string ("\xaf");
+  else if (code == 8970)
+    retval = std::string ("\xeb");
+  else if (code == 8971)
+    retval = std::string ("\xfb");
+  else if (code == 10216)
+    retval = std::string ("\xe1");
+  else if (code == 10217)
+    retval = std::string ("\xf1");
+  else if (code == 8968)
+    retval = std::string ("\xe9");
+  else if (code == 8969)
+    retval = std::string ("\xf9");
+  else if (code == 8800)
+    retval = std::string ("\xb9");
+  else if (code == 8230)
+    retval = std::string ("\xbc");
+  else if (code == 176)
+    retval = std::string ("\xb0");
+  else if (code == 8709)
+    retval = std::string ("\xc6");
+  else if (code == 169)
+    retval = std::string ("\xd3");
 
-  fontname = "";
+  if (retval.empty ())
+    warning ("print: unhandled symbol %d", code);
+
+  return retval;
+}
+
+
+static std::string
+select_font (caseless_str fn, bool isbold, bool isitalic)
+{
+  std::transform (fn.begin (), fn.end (), fn.begin (), ::tolower);
+  std::string fontname;
   if (fn == "times" || fn == "times-roman")
     {
       if (isitalic && isbold)
@@ -271,6 +415,135 @@
       else
         fontname = "Helvetica";
     }
+  return fontname;
+}
+
+static void
+escape_character (const std::string chr, std::string& str)
+{
+  std::size_t idx = str.find (chr);
+  while (idx != std::string::npos)
+    {
+      str.insert (idx, "\\");
+      idx = str.find (chr, idx + 2);
+    }
+}
+
+Matrix
+glps_renderer::render_text (const std::string& txt,
+                            double x, double y, double z,
+                            int ha, int va, double rotation)
+{
+  std::string saved_font = fontname;
+
+  if (txt.empty ())
+    return Matrix (1, 4, 0.0);
+
+  // We have no way to get a bounding box from gl2ps, so we parse the raw
+  // string using freetype
+  Matrix bbox;
+  std::string str = txt;
+  std::list<ft_render::ft_string> lst;
+
+  text_to_strlist (str, lst, bbox, ha, va, rotation);
+
+  // When using "tex" or when the string has only one line and no
+  // special characters, use gl2ps for alignment
+  if (lst.empty () || term.find ("tex") != std::string::npos
+      || (lst.size () == 1 && ! lst.front ().get_code ()))
+    {
+      std::string name = fontname;
+      int sz = fontsize;
+      if (! lst.empty () && term.find ("tex") == std::string::npos)
+        {
+          ft_render::ft_string s = lst.front ();
+          name = select_font (s.get_name (), s.get_weight () == "bold",
+                              s.get_angle () == "italic");
+          set_color (s.get_color ());
+          str = s.get_string ();
+          sz = s.get_size ();
+        }
+
+      glRasterPos3d (x, y, z);
+
+      // Escape parenthesis until gl2ps does it (see bug ##45301).
+      if (term.find ("svg") == std::string::npos
+          && term.find ("tex") == std::string::npos)
+        {
+          escape_character ("(", str);
+          escape_character (")", str);
+        }
+
+      gl2psTextOpt (str.c_str (), name.c_str (), sz,
+                    alignment_to_mode (ha, va), rotation);
+      return bbox;
+    }
+
+  // Translate and rotate coordinates in order to use bottom-left alignment
+  fix_strlist_position (x, y, z, bbox, rotation, lst);
+
+  for (std::list<ft_render::ft_string>::iterator p = lst.begin ();
+       p != lst.end (); p++)
+    {
+      fontname = select_font ((*p).get_name (),
+                              (*p).get_weight () == "bold",
+                              (*p).get_angle () == "italic");
+      if ((*p).get_code ())
+        {
+          // This is only one character represented by a uint32 (utf8) code.
+          // We replace it by the corresponding character in the
+          // "Symbol" font except for svg which has built-in utf8 support.
+          if (term.find ("svg") == std::string::npos)
+            {
+              fontname = "Symbol";
+              str = code_to_symbol ((*p).get_code ());
+            }
+          else
+            {
+              std::stringstream ss;
+              ss << (*p).get_code ();
+              str = "&#" + ss.str () + ";";
+            }
+        }
+      else
+        {
+          str = (*p).get_string ();
+          // Escape parenthesis until gl2ps does it (see bug ##45301).
+          if (term.find ("svg") == std::string::npos)
+            {
+              escape_character ("(", str);
+              escape_character (")", str);
+            }
+        }
+
+      set_color ((*p).get_color ());
+      glRasterPos3d ((*p).get_x (), (*p).get_y (), (*p).get_z ());
+      gl2psTextOpt (str.c_str (), fontname.c_str (), (*p).get_size (),
+                    GL2PS_TEXT_BL, rotation);
+    }
+
+  fontname = saved_font;
+  return bbox;
+}
+
+void
+glps_renderer::set_font (const base_properties& props)
+{
+  opengl_renderer::set_font (props);
+
+  // Set the interpreter so that text_to_pixels can parse strings properly
+  if (props.has_property ("interpreter"))
+    set_interpreter (props.get ("interpreter").string_value ());
+
+  fontsize = props.get ("fontsize_points").double_value ();
+
+  caseless_str fn = props.get ("fontname").xtolower ().string_value ();
+  bool isbold =
+    (props.get ("fontweight").xtolower ().string_value () == "bold");
+  bool isitalic =
+    (props.get ("fontangle").xtolower ().string_value () == "italic");
+
+  fontname = select_font (fn, isbold, isitalic);
 }
 
 template <typename T>
@@ -306,10 +579,15 @@
   if (props.get_string ().is_empty ())
     return;
 
+  // First set font properties: freetype will use them to compute
+  // coordinates and gl2ps will retrieve the color directly from the
+  // feedback buffer
   set_font (props);
   set_color (props.get_color_rgb ());
 
-  const Matrix pos = get_transform ().scale (props.get_data_position ());
+  std::string saved_font = fontname;
+
+  // Alignment
   int halign = 0;
   int valign = 0;
 
@@ -327,16 +605,12 @@
 
   // FIXME: handle margin and surrounding box
 
-  glRasterPos3d (pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0);
-
-  octave_value string_prop = props.get_string ();
+  Matrix bbox;
+  const Matrix pos = get_transform ().scale (props.get_data_position ());
+  std::string str = props.get_string ().all_strings ().join ("\n");
 
-  string_vector sv = string_prop.all_strings ();
-
-  std::string s = sv.join ("\n");
-
-  gl2psTextOpt (s.c_str (), fontname.c_str (), fontsize,
-                alignment_to_mode (halign, valign), props.get_rotation ());
+  render_text (str, pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0,
+               halign, valign, props.get_rotation ());
 }
 
 static void
--- a/libinterp/corefcn/gl2ps-renderer.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/gl2ps-renderer.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_gl2ps_renderer_h)
+#if ! defined (octave_gl2ps_renderer_h)
 #define octave_gl2ps_renderer_h 1
 
 #include "graphics.h"
@@ -36,7 +36,8 @@
 {
 public:
   glps_renderer (FILE *_fp, const std::string& _term)
-    : opengl_renderer () , fp (_fp), term (_term), fontsize (), fontname () { }
+    : opengl_renderer () , fp (_fp), term (_term), fontsize (),
+    fontname () { }
 
   ~glps_renderer (void) { }
 
@@ -50,6 +51,24 @@
 
   void set_font (const base_properties& props);
 
+  void draw_axes (const axes::properties& props)
+  {
+    // Initialize a sorting tree (viewport) in gl2ps for each axes
+    GLint vp[4];
+    glGetIntegerv (GL_VIEWPORT, vp);
+    gl2psBeginViewport (vp);
+
+    // Draw and  glFinish () or there may primitives missing in the
+    // gl2ps output.
+    opengl_renderer::draw_axes (props);
+    glFinish ();
+
+    // Finalize viewport
+    GLint state = gl2psEndViewport ();
+    if (state == GL2PS_NO_FEEDBACK)
+      warning ("gl2ps-renderer::draw: empty feedback buffer and/or nothing else to print");
+  }
+
   void draw_text (const text::properties& props);
   void draw_pixels (GLsizei w, GLsizei h, GLenum format,
                     GLenum type, const GLvoid *data);
@@ -84,6 +103,13 @@
   }
 
 private:
+  // Use xform to compute the coordinates of the ft_string list
+  // that have been parsed by freetype
+  void fix_strlist_position (double x, double y, double z,
+                             Matrix box, double rotation,
+                             std::list<ft_render::ft_string>& lst);
+
+private:
   int alignment_to_mode (int ha, int va) const;
   FILE *fp;
   caseless_str term;
--- a/libinterp/corefcn/graphics.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/graphics.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -134,50 +134,88 @@
 }
 
 static Matrix
-jet_colormap (void)
-{
+viridis_colormap (void)
+{
+  // The values below have been produced by viridis (64)(:)
+  // It would be nice to be able to feval the
+  // viridis function but since there is a static property object that includes
+  // a colormap_property object, we need to initialize this before main is
+  // even called, so calling an interpreted function is not possible.
+
+  const double cmapv[] = {
+    2.67004010000000e-01, 2.72651720952381e-01, 2.77106307619048e-01,
+    2.80356151428571e-01, 2.82390045238095e-01, 2.83204606666667e-01,
+    2.82809341428571e-01, 2.81230763333333e-01, 2.78516153333333e-01,
+    2.74735528571429e-01, 2.69981791904762e-01, 2.64368580952381e-01,
+    2.58026184285714e-01, 2.51098684761905e-01, 2.43732853333333e-01,
+    2.36073294285714e-01, 2.28263191428571e-01, 2.20424955714286e-01,
+    2.12666598571429e-01, 2.05079113809524e-01, 1.97721880952381e-01,
+    1.90631350000000e-01, 1.83819438571429e-01, 1.77272360952381e-01,
+    1.70957518571429e-01, 1.64832915714286e-01, 1.58845368095238e-01,
+    1.52951235714286e-01, 1.47131626666667e-01, 1.41402210952381e-01,
+    1.35832975714286e-01, 1.30582113809524e-01, 1.25898377619048e-01,
+    1.22163105714286e-01, 1.19872409523810e-01, 1.19626570000000e-01,
+    1.22045948571429e-01, 1.27667691904762e-01, 1.36834947142857e-01,
+    1.49643331428571e-01, 1.65967274285714e-01, 1.85538397142857e-01,
+    2.08030450000000e-01, 2.33127309523809e-01, 2.60531475238095e-01,
+    2.90000730000000e-01, 3.21329971428571e-01, 3.54355250000000e-01,
+    3.88930322857143e-01, 4.24933143333333e-01, 4.62246770476190e-01,
+    5.00753620000000e-01, 5.40336957142857e-01, 5.80861172380952e-01,
+    6.22170772857143e-01, 6.64087320476191e-01, 7.06403823333333e-01,
+    7.48885251428571e-01, 7.91273132857143e-01, 8.33302102380952e-01,
+    8.74717527142857e-01, 9.15296319047619e-01, 9.54839555238095e-01,
+    9.93247890000000e-01, 4.87433000000000e-03, 2.58456800000000e-02,
+    5.09139004761905e-02, 7.42014957142857e-02, 9.59536042857143e-02,
+    1.16893314761905e-01, 1.37350195714286e-01, 1.57479940000000e-01,
+    1.77347967619048e-01, 1.96969168571429e-01, 2.16330337619048e-01,
+    2.35404660952381e-01, 2.54161735714286e-01, 2.72573219047619e-01,
+    2.90619516666667e-01, 3.08291041428571e-01, 3.25586450952381e-01,
+    3.42517215238095e-01, 3.59102207142857e-01, 3.75366067142857e-01,
+    3.91340913333333e-01, 4.07061480000000e-01, 4.22563764285714e-01,
+    4.37885543809524e-01, 4.53062984285714e-01, 4.68129543809524e-01,
+    4.83117059523810e-01, 4.98052961428571e-01, 5.12959473333333e-01,
+    5.27854311428571e-01, 5.42750087142857e-01, 5.57652481904762e-01,
+    5.72563073333333e-01, 5.87476284285714e-01, 6.02382410952381e-01,
+    6.17265840000000e-01, 6.32106955714286e-01, 6.46881817142857e-01,
+    6.61562926190476e-01, 6.76119717142857e-01, 6.90518987142857e-01,
+    7.04725181904762e-01, 7.18700950000000e-01, 7.32406441904762e-01,
+    7.45802021904762e-01, 7.58846480000000e-01, 7.71497934761905e-01,
+    7.83714033809524e-01, 7.95453081428571e-01, 8.06673890000000e-01,
+    8.17337565714286e-01, 8.27409135714286e-01, 8.36858167619048e-01,
+    8.45663399523809e-01, 8.53815582857143e-01, 8.61321019047619e-01,
+    8.68206316666667e-01, 8.74522215714286e-01, 8.80346158571429e-01,
+    8.85780083333333e-01, 8.90945338571429e-01, 8.95973498571429e-01,
+    9.01005800000000e-01, 9.06156570000000e-01, 3.29415190000000e-01,
+    3.53367293333333e-01, 3.76236064761905e-01, 3.97901482857143e-01,
+    4.18250757142857e-01, 4.37178920000000e-01, 4.54595888571429e-01,
+    4.70433883333333e-01, 4.84653865714286e-01, 4.97250492857143e-01,
+    5.08254501428571e-01, 5.17731949047619e-01, 5.25780221428571e-01,
+    5.32522206190476e-01, 5.38097133333333e-01, 5.42651800000000e-01,
+    5.46335411904762e-01, 5.49287148571429e-01, 5.51635008571429e-01,
+    5.53493173333333e-01, 5.54953478571429e-01, 5.56089070000000e-01,
+    5.56952166666667e-01, 5.57576145714286e-01, 5.57974025714286e-01,
+    5.58142745238095e-01, 5.58058673809524e-01, 5.57684744285714e-01,
+    5.56973310000000e-01, 5.55864478571429e-01, 5.54288677142857e-01,
+    5.52175699047619e-01, 5.49445382857143e-01, 5.46023368571429e-01,
+    5.41830633809524e-01, 5.36795616666667e-01, 5.30847985714286e-01,
+    5.23924198571429e-01, 5.15966779523810e-01, 5.06924262857143e-01,
+    4.96751861428571e-01, 4.85412122857143e-01, 4.72873300000000e-01,
+    4.59105875238095e-01, 4.44095883333333e-01, 4.27825852857143e-01,
+    4.10292713809524e-01, 3.91487632857143e-01, 3.71420688571429e-01,
+    3.50098750000000e-01, 3.27544678571429e-01, 3.03798967142857e-01,
+    2.78916748571429e-01, 2.53000856190476e-01, 2.26223670000000e-01,
+    1.98879439523810e-01, 1.71494930000000e-01, 1.45037631428572e-01,
+    1.21291048571429e-01, 1.03326155238095e-01, 9.53507900000000e-02,
+    1.00469958095238e-01, 1.17876387142857e-01, 1.43936200000000e-01};
+
+  // It would be nice if Matrix had a ctor allowing to do the
+  // following without a copy
   Matrix cmap (64, 3, 0.0);
-
-  // Produce X in the same manner as linspace so that
-  // jet_colormap and jet.m produce *exactly* the same result.
-  double delta = 1.0 / 63.0;
-
-  for (octave_idx_type i = 0; i < 64; i++)
-    {
-      // This is the jet colormap.  It would be nice to be able
-      // to feval the jet function but since there is a static
-      // property object that includes a colormap_property
-      // object, we need to initialize this before main is even
-      // called, so calling an interpreted function is not
-      // possible.
-
-      double x = i*delta;
-
-      if (x >= 3.0/8.0 && x < 5.0/8.0)
-        cmap(i,0) = 4.0 * x - 3.0/2.0;
-      else if (x >= 5.0/8.0 && x < 7.0/8.0)
-        cmap(i,0) = 1.0;
-      else if (x >= 7.0/8.0)
-        cmap(i,0) = -4.0 * x + 9.0/2.0;
-
-      if (x >= 1.0/8.0 && x < 3.0/8.0)
-        cmap(i,1) = 4.0 * x - 1.0/2.0;
-      else if (x >= 3.0/8.0 && x < 5.0/8.0)
-        cmap(i,1) = 1.0;
-      else if (x >= 5.0/8.0 && x < 7.0/8.0)
-        cmap(i,1) = -4.0 * x + 7.0/2.0;
-
-      if (x < 1.0/8.0)
-        cmap(i,2) = 4.0 * x + 1.0/2.0;
-      else if (x >= 1.0/8.0 && x < 3.0/8.0)
-        cmap(i,2) = 1.0;
-      else if (x >= 3.0/8.0 && x < 5.0/8.0)
-        cmap(i,2) = -4.0 * x + 5.0/2.0;
-    }
-
+  std::copy (cmapv, cmapv + (64*3), cmap.fortran_vec ());
   return cmap;
 }
 
+
 static double
 default_screendepth (void)
 {
@@ -187,8 +225,10 @@
 static Matrix
 default_screensize (void)
 {
-  Matrix retval (1, 4, 1.0);
-
+  Matrix retval (1, 4);
+
+  retval(0) = 1.0;
+  retval(1) = 1.0;
   retval(2) = display_info::width ();
   retval(3) = display_info::height ();
 
@@ -231,7 +271,7 @@
 static Matrix
 default_lim (bool logscale = false)
 {
-  Matrix m (1, 2, 0);
+  Matrix m (1, 2);
 
   if (logscale)
     {
@@ -239,7 +279,10 @@
       m(1) = 1.0;
     }
   else
-    m(1) = 1;
+    {
+      m(0) = 0.0;
+      m(1) = 1.0;
+    }
 
   return m;
 }
@@ -258,7 +301,8 @@
 static Matrix
 default_image_cdata (void)
 {
-  Matrix m (64, 64, 0.0);
+  Matrix m (64, 64);
+
   int i = 0;
   for (int col = 0; col < 64; col++)
     for (int row = 0; row < 64; row++)
@@ -273,7 +317,8 @@
 static Matrix
 default_surface_xdata (void)
 {
-  Matrix m (3, 3, 0.0);
+  Matrix m (3, 3);
+
   for (int col = 0; col < 3; col++)
     for (int row = 0; row < 3; row++)
       m(row,col) = col+1;
@@ -284,7 +329,8 @@
 static Matrix
 default_surface_ydata (void)
 {
-  Matrix m (3, 3, 0.0);
+  Matrix m (3, 3);
+
   for (int row = 0; row < 3; row++)
     for (int col = 0; col < 3; col++)
       m(row,col) = row+1;
@@ -296,8 +342,10 @@
 default_surface_zdata (void)
 {
   Matrix m (3, 3, 0.0);
+
   for (int row = 0; row < 3; row++)
     m(row,row) = 1.0;
+
   return m;
 }
 
@@ -310,19 +358,24 @@
 static Matrix
 default_patch_faces (void)
 {
-  Matrix m (1, 3, 1.0);
+  Matrix m (1, 3);
+
+  m(0) = 1.0;
   m(1) = 2.0;
   m(2) = 3.0;
+
   return m;
 }
 
 static Matrix
 default_patch_vertices (void)
 {
-  Matrix m (3, 2, 0);
+  Matrix m (3, 2, 0.0);
+
   m(1) = 1.0;
   m(3) = 1.0;
   m(4) = 1.0;
+
   return m;
 }
 
@@ -330,7 +383,9 @@
 default_patch_xdata (void)
 {
   Matrix m (3, 1, 0.0);
+
   m(1) = 1.0;
+
   return m;
 }
 
@@ -338,94 +393,116 @@
 default_patch_ydata (void)
 {
   Matrix m (3, 1, 1.0);
+
   m(2) = 0.0;
+
   return m;
 }
 
 static Matrix
 default_axes_position (void)
 {
-  Matrix m (1, 4, 0.0);
+  Matrix m (1, 4);
+
   m(0) = 0.13;
   m(1) = 0.11;
   m(2) = 0.775;
   m(3) = 0.815;
+
   return m;
 }
 
 static Matrix
 default_axes_outerposition (void)
 {
-  Matrix m (1, 4, 0.0);
-  m(2) = m(3) = 1.0;
+  Matrix m (1, 4);
+
+  m(0) = 0.0;
+  m(1) = 0.0;
+  m(2) = 1.0;
+  m(3) = 1.0;
+
   return m;
 }
 
 static Matrix
 default_axes_view (void)
 {
-  Matrix m (1, 2, 0.0);
+  Matrix m (1, 2);
+
+  m(0) = 0.0;
   m(1) = 90.0;
+
   return m;
 }
 
 static Matrix
 default_axes_tick (void)
 {
-  Matrix m (1, 6, 0.0);
+  Matrix m (1, 6);
+
   m(0) = 0.0;
   m(1) = 0.2;
   m(2) = 0.4;
   m(3) = 0.6;
   m(4) = 0.8;
   m(5) = 1.0;
+
   return m;
 }
 
 static Matrix
 default_axes_ticklength (void)
 {
-  Matrix m (1, 2, 0.0);
+  Matrix m (1, 2);
+
   m(0) = 0.01;
   m(1) = 0.025;
+
   return m;
 }
 
 static Matrix
 default_figure_position (void)
 {
-  Matrix m (1, 4, 0.0);
+  Matrix m (1, 4);
+
   m(0) = 300;
   m(1) = 200;
   m(2) = 560;
   m(3) = 420;
+
   return m;
 }
 
 static Matrix
 default_figure_papersize (void)
 {
-  Matrix m (1, 2, 0.0);
+  Matrix m (1, 2);
+
   m(0) = 8.5;
   m(1) = 11.0;
+
   return m;
 }
 
 static Matrix
 default_figure_paperposition (void)
 {
-  Matrix m (1, 4, 0.0);
+  Matrix m (1, 4);
+
   m(0) = 0.25;
   m(1) = 2.50;
   m(2) = 8.00;
   m(3) = 6.00;
+
   return m;
 }
 
 static Matrix
 default_control_position (void)
 {
-  Matrix retval (1, 4, 0.0);
+  Matrix retval (1, 4);
 
   retval(0) = 0;
   retval(1) = 0;
@@ -438,7 +515,7 @@
 static Matrix
 default_control_sliderstep (void)
 {
-  Matrix retval (1, 2, 0.0);
+  Matrix retval (1, 2);
 
   retval(0) = 0.01;
   retval(1) = 0.1;
@@ -449,7 +526,7 @@
 static Matrix
 default_panel_position (void)
 {
-  Matrix retval (1, 4, 0.0);
+  Matrix retval (1, 4);
 
   retval(0) = 0;
   retval(1) = 0;
@@ -548,7 +625,7 @@
       double f = 0.0;
 
       // FIXME: this assumes the system font is Helvetica 10pt
-      //          (for which "x" requires 6x12 pixels at 74.951 pixels/inch)
+      //        (for which "x" requires 6x12 pixels at 74.951 pixels/inch)
       f = 12.0 * res / 74.951;
 
       if (f > 0)
@@ -825,8 +902,7 @@
     {
       Matrix _cmap = fig.get (caseless_str ("colormap")).matrix_value ();
 
-      if (! error_state)
-        cmap = _cmap;
+      cmap = _cmap;
     }
 
   if (is_scaled)
@@ -837,8 +913,7 @@
         {
           Matrix _clim = ax.get (caseless_str ("clim")).matrix_value ();
 
-          if (! error_state)
-            clim = _clim;
+          clim = _clim;
         }
     }
 
@@ -1047,7 +1122,6 @@
 {
   if (do_set (v))
     {
-
       // Notify graphics toolkit.
       if (id >= 0 && do_notify_toolkit)
         {
@@ -1057,7 +1131,7 @@
         }
 
       // run listeners
-      if (do_run && ! error_state)
+      if (do_run)
         run_listeners (POSTSET);
 
       return true;
@@ -1073,12 +1147,7 @@
   const octave_value_list& l = listeners[mode];
 
   for (int i = 0; i < l.length (); i++)
-    {
-      gh_manager::execute_listener (parent, l(i));
-
-      if (error_state)
-        break;
-    }
+    gh_manager::execute_listener (parent, l(i));
 }
 
 radio_values::radio_values (const std::string& opt_string)
@@ -1224,9 +1293,10 @@
             }
           else
             {
-              color_values col (s);
-              if (! error_state)
+              try
                 {
+                  color_values col (s);
+
                   if (current_type != color_t || col != color_val)
                     {
                       color_val = col;
@@ -1234,9 +1304,11 @@
                       return true;
                     }
                 }
-              else
-                error ("invalid value for color property \"%s\" (value = %s)",
-                       get_name ().c_str (), s.c_str ());
+              catch (octave_execution_exception& e)
+                {
+                  error (e, "invalid value for color property \"%s\" (value = %s)",
+                         get_name ().c_str (), s.c_str ());
+                }
             }
         }
       else
@@ -1250,14 +1322,12 @@
       if (m.numel () == 3)
         {
           color_values col (m(0), m(1), m(2));
-          if (! error_state)
-            {
-              if (current_type != color_t || col != color_val)
-                {
-                  color_val = col;
-                  current_type = color_t;
-                  return true;
-                }
+
+          if (current_type != color_t || col != color_val)
+            {
+              color_val = col;
+              current_type = color_t;
+              return true;
             }
         }
       else
@@ -1485,27 +1555,22 @@
         return false;
     }
 
-  double dv = v.double_value ();
-
-  if (! error_state)
-    {
-      graphics_handle gh = gh_manager::lookup (dv);
-
-      if (xisnan (gh.value ()) || gh.ok ())
-        {
-          if (current_val != gh)
-            {
-              current_val = gh;
-              return true;
-            }
-        }
-      else
-        error ("set: invalid graphics handle (= %g) for property \"%s\"",
-               dv, get_name ().c_str ());
-    }
-  else
-    error ("set: invalid graphics handle for property \"%s\"",
-           get_name ().c_str ());
+  double dv = v.xdouble_value ("set: invalid graphics handle for property \"%s\"",
+                              get_name ().c_str ());
+
+  graphics_handle gh = gh_manager::lookup (dv);
+
+  if (xisnan (gh.value ()) || gh.ok ())
+    {
+      if (current_val != gh)
+        {
+          current_val = gh;
+          return true;
+        }
+    }
+  else
+    error ("set: invalid graphics handle (= %g) for property \"%s\"",
+           dv, get_name ().c_str ());
 
   return false;
 }
@@ -1559,7 +1624,6 @@
 
       if (go.valid_object ())
         gh_manager::free (*p);
-
     }
 
   if (clear)
@@ -1569,30 +1633,28 @@
 bool
 callback_property::validate (const octave_value& v) const
 {
-  // case 1: function handle
-  // case 2: cell array with first element being a function handle
+  // case 1: empty matrix
+  // case 2: function handle
   // case 3: string corresponding to known function name
-  // case 4: evaluatable string
-  // case 5: empty matrix
-
-  if (v.is_function_handle ())
+  // case 4: string that can be eval()'ed
+  // case 5: cell array with first element being a function handle
+
+  if (v.is_empty ())
+    return true;
+  else if (v.is_function_handle ())
     return true;
   else if (v.is_string ())
     // complete validation will be done at execution-time
     return true;
-  else if (v.is_cell () && v.length () > 0
-           && (v.rows () == 1 || v.columns () == 1)
+  else if (v.is_cell () && (v.rows () == 1 || v.columns () == 1)
            && v.cell_value ()(0).is_function_handle ())
     return true;
-  else if (v.is_empty ())
-    return true;
 
   return false;
 }
 
-// If TRUE, we are executing any callback function, or the functions it
-// calls.  Used to determine handle visibility inside callback
-// functions.
+// If TRUE, we are executing any callback function, or the functions it calls.
+// Used to determine handle visibility inside callback functions.
 static bool executing_callback = false;
 
 void
@@ -1619,8 +1681,8 @@
     }
 }
 
-// Used to cache dummy graphics objects from which dynamic
-// properties can be cloned.
+// Used to cache dummy graphics objects from which dynamic properties can be
+// cloned.
 static std::map<caseless_str, graphics_object> dprop_obj_map;
 
 property
@@ -1631,54 +1693,44 @@
 
   if (type.compare ("string"))
     {
-      std::string val = (args.length () > 0 ? args(0).string_value () : "");
-
-      if (! error_state)
-        retval = property (new string_property (name, h, val));
+      std::string sv = (args.length () > 0 ? args(0).string_value () : "");
+
+      retval = property (new string_property (name, h, sv));
     }
   else if (type.compare ("any"))
     {
-      octave_value val = args.length () > 0 ? args(0)
-                                            : octave_value (Matrix ());
-
-      retval = property (new any_property (name, h, val));
+      octave_value ov = args.length () > 0 ? args(0)
+                                           : octave_value (Matrix ());
+
+      retval = property (new any_property (name, h, ov));
     }
   else if (type.compare ("radio"))
     {
-      if (args.length () > 0)
-        {
-          std::string vals = args(0).string_value ();
-
-          if (! error_state)
-            {
-              retval = property (new radio_property (name, h, vals));
-
-              if (args.length () > 1)
-                retval.set (args(1));
-            }
-          else
-            error ("addproperty: invalid argument for radio property, expected a string value");
-        }
+      if (args.length () < 1)
+        error ("addproperty: missing possible values for radio property");
       else
-        error ("addproperty: missing possible values for radio property");
+        {
+          std::string sv = args(0).xstring_value ("addproperty: argument for radio property must be a string");
+
+          retval = property (new radio_property (name, h, sv));
+
+          if (args.length () > 1)
+            retval.set (args(1));
+        }
     }
   else if (type.compare ("double"))
     {
-      double d = (args.length () > 0 ? args(0).double_value () : 0);
-
-      if (! error_state)
-        retval = property (new double_property (name, h, d));
+      double dv = (args.length () > 0 ? args(0).double_value () : 0.0);
+
+      retval = property (new double_property (name, h, dv));
     }
   else if (type.compare ("handle"))
     {
-      double hh = (args.length () > 0 ? args(0).double_value () : octave_NaN);
-
-      if (! error_state)
-        {
-          graphics_handle gh (hh);
-
-          retval = property (new handle_property (name, h, gh));
-        }
+      double hv = (args.length () > 0 ? args(0).double_value () : octave_NaN);
+
+      graphics_handle gh (hv);
+
+      retval = property (new handle_property (name, h, gh));
     }
   else if (type.compare ("boolean"))
     {
@@ -1694,7 +1746,6 @@
       if (args.length () > 0)
         {
           retval.set (args(0));
-
           // FIXME: additional argument could define constraints,
           //        but is this really useful?
         }
@@ -1707,18 +1758,12 @@
       if (args.length () > 1)
         rv = radio_values (args(1).string_value ());
 
-      if (! error_state)
-        {
-          retval = property (new color_property (name, h, cv, rv));
-
-          if (! error_state)
-            {
-              if (args.length () > 0 && ! args(0).is_empty ())
-                retval.set (args(0));
-              else
-                retval.set (rv.default_value ());
-            }
-        }
+      retval = property (new color_property (name, h, cv, rv));
+
+      if (args.length () > 0 && ! args(0).is_empty ())
+        retval.set (args(0));
+      else
+        retval.set (rv.default_value ());
     }
   else
     {
@@ -1750,16 +1795,13 @@
             {
               property prop = go.get_properties ().get_property (go_rest);
 
-              if (! error_state)
-                {
-                  retval = prop.clone ();
-
-                  retval.set_parent (h);
-                  retval.set_name (name);
-
-                  if (args.length () > 0)
-                    retval.set (args(0));
-                }
+              retval = prop.clone ();
+
+              retval.set_parent (h);
+              retval.set_name (name);
+
+              if (args.length () > 0)
+                retval.set (args(0));
             }
           else
             error ("addproperty: invalid object type (= %s)",
@@ -1824,60 +1866,57 @@
 void
 figure::properties::set___mouse_mode__ (const octave_value& val_arg)
 {
-  if (! error_state)
-    {
-      std::string direction = "in";
-
-      octave_value val = val_arg;
-
-      if (val.is_string ())
-        {
-          std::string modestr = val.string_value ();
-
-          if (modestr == "zoom in")
-            {
-              val = modestr = "zoom";
-              direction = "in";
-            }
-          else if (modestr == "zoom out")
-            {
-              val = modestr = "zoom";
-              direction = "out";
-            }
-
-          if (__mouse_mode__.set (val, true))
-            {
-              std::string mode = __mouse_mode__.current_value ();
-
-              octave_scalar_map pm = get___pan_mode__ ().scalar_map_value ();
-              pm.setfield ("Enable", mode == "pan" ? "on" : "off");
-              set___pan_mode__ (pm);
-
-              octave_scalar_map rm = get___rotate_mode__ ().scalar_map_value ();
-              rm.setfield ("Enable", mode == "rotate" ? "on" : "off");
-              set___rotate_mode__ (rm);
-
-              octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
-              zm.setfield ("Enable", mode == "zoom" ? "on" : "off");
+  std::string direction = "in";
+
+  octave_value val = val_arg;
+
+  if (val.is_string ())
+    {
+      std::string modestr = val.string_value ();
+
+      if (modestr == "zoom in")
+        {
+          val = modestr = "zoom";
+          direction = "in";
+        }
+      else if (modestr == "zoom out")
+        {
+          val = modestr = "zoom";
+          direction = "out";
+        }
+
+      if (__mouse_mode__.set (val, true))
+        {
+          std::string mode = __mouse_mode__.current_value ();
+
+          octave_scalar_map pm = get___pan_mode__ ().scalar_map_value ();
+          pm.setfield ("Enable", mode == "pan" ? "on" : "off");
+          set___pan_mode__ (pm);
+
+          octave_scalar_map rm = get___rotate_mode__ ().scalar_map_value ();
+          rm.setfield ("Enable", mode == "rotate" ? "on" : "off");
+          set___rotate_mode__ (rm);
+
+          octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
+          zm.setfield ("Enable", mode == "zoom" ? "on" : "off");
+          zm.setfield ("Direction", direction);
+          set___zoom_mode__ (zm);
+
+          mark_modified ();
+        }
+      else if (modestr == "zoom")
+        {
+          octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
+          std::string curr_direction
+            = zm.getfield ("Direction").string_value ();
+
+          if (direction != curr_direction)
+            {
               zm.setfield ("Direction", direction);
               set___zoom_mode__ (zm);
 
               mark_modified ();
             }
-          else if (modestr == "zoom")
-            {
-              octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
-              std::string curr_direction
-                = zm.getfield ("Direction").string_value ();
-
-              if (direction != curr_direction)
-                {
-                  zm.setfield ("Direction", direction);
-                  set___zoom_mode__ (zm);
-
-                  mark_modified ();
-                }
-            }
         }
     }
 }
@@ -1963,6 +2002,8 @@
           bool has_property = false;
           if (pfx == "axes")
             has_property = axes::properties::has_core_property (pname);
+          else if (pfx == "figure")
+            has_property = figure::properties::has_core_property (pname);
           else if (pfx == "line")
             has_property = line::properties::has_core_property (pname);
           else if (pfx == "text")
@@ -1971,8 +2012,6 @@
             has_property = image::properties::has_core_property (pname);
           else if (pfx == "patch")
             has_property = patch::properties::has_core_property (pname);
-          else if (pfx == "figure")
-            has_property = figure::properties::has_core_property (pname);
           else if (pfx == "surface")
             has_property = surface::properties::has_core_property (pname);
           else if (pfx == "hggroup")
@@ -1995,9 +2034,9 @@
               bool remove = false;
               if (val.is_string ())
                 {
-                  std::string tval = val.string_value ();
-
-                  remove = (tval.compare ("remove") == 0);
+                  std::string sval = val.string_value ();
+
+                  remove = (sval.compare ("remove") == 0);
                 }
 
               pval_map_type& pval_map = plist_map[pfx];
@@ -2017,7 +2056,7 @@
         }
     }
 
-  if (! error_state && offset == 0)
+  if (offset == 0)
     error ("invalid default property specification");
 }
 
@@ -2143,27 +2182,19 @@
 
   if (nargin == 0)
     error ("graphics_object::set: Nothing to set");
-  else if (nargin % 2 == 0)
+  else if (nargin % 2 != 0)
+    error ("set: invalid number of arguments");
+  else
     {
       for (int i = 0; i < nargin; i += 2)
         {
-          caseless_str name = args(i).string_value ();
-
-          if (! error_state)
-            {
-              octave_value val = args(i+1);
-
-              set_value_or_default (name, val);
-
-              if (error_state)
-                break;
-            }
-          else
-            error ("set: expecting argument %d to be a property name", i);
-        }
-    }
-  else
-    error ("set: invalid number of arguments");
+          caseless_str pname = args(i).xstring_value ("set: argument %d must be a property name", i);
+
+          octave_value val = args(i+1);
+
+          set_value_or_default (pname, val);
+        }
+    }
 }
 
 /*
@@ -2181,26 +2212,23 @@
 
 // Set properties given in two cell arrays containing names and values.
 void
-graphics_object::set (const Array<std::string>& names,
+graphics_object::set (const Array<std::string>& pnames,
                       const Cell& values, octave_idx_type row)
 {
-  if (names.numel () != values.columns ())
+  if (pnames.numel () != values.columns ())
     {
       error ("set: number of names must match number of value columns (%d != %d)",
-             names.numel (), values.columns ());
-    }
-
-  octave_idx_type k = names.columns ();
+             pnames.numel (), values.columns ());
+    }
+
+  octave_idx_type k = pnames.columns ();
 
   for (octave_idx_type column = 0; column < k; column++)
     {
-      caseless_str name = names(column);
+      caseless_str pname = pnames(column);
       octave_value val  = values(row, column);
 
-      set_value_or_default (name, val);
-
-      if (error_state)
-        break;
+      set_value_or_default (pname, val);
     }
 }
 
@@ -2256,14 +2284,13 @@
 {
   for (octave_idx_type p = 0; p < m.nfields (); p++)
     {
-      caseless_str name  = m.keys ()[p];
-
-      octave_value val = octave_value (m.contents (name).elem (m.numel () - 1));
-
-      set_value_or_default (name, val);
-
-      if (error_state)
-        break;
+      // FIXME: Would it be better to extract all the keys at once rather than
+      //        repeatedly call keys() inside a for loop?
+      caseless_str pname = m.keys ()[p];
+
+      octave_value val = octave_value (m.contents (pname).elem (m.numel () - 1));
+
+      set_value_or_default (pname, val);
     }
 }
 
@@ -2351,46 +2378,40 @@
 // Set a property to a value or to its (factory) default value.
 
 void
-graphics_object::set_value_or_default (const caseless_str& name,
+graphics_object::set_value_or_default (const caseless_str& pname,
                                        const octave_value& val)
 {
   if (val.is_string ())
     {
-      std::string tval = val.string_value ();
+      std::string sval = val.string_value ();
 
       octave_value default_val;
 
-      if (tval.compare ("default") == 0)
-        {
-          default_val = get_default (name);
-
-          if (error_state)
-            return;
-
-          rep->set (name, default_val);
-        }
-      else if (tval.compare ("factory") == 0)
-        {
-          default_val = get_factory_default (name);
-
-          if (error_state)
-            return;
-
-          rep->set (name, default_val);
+      if (sval.compare ("default") == 0)
+        {
+          default_val = get_default (pname);
+
+          rep->set (pname, default_val);
+        }
+      else if (sval.compare ("factory") == 0)
+        {
+          default_val = get_factory_default (pname);
+
+          rep->set (pname, default_val);
         }
       else
         {
           // Matlab specifically uses "\default" to escape string setting
-          if (tval.compare ("\\default") == 0)
-            rep->set (name, "default");
-          else if (tval.compare ("\\factory") == 0)
-            rep->set (name, "factory");
+          if (sval.compare ("\\default") == 0)
+            rep->set (pname, "default");
+          else if (sval.compare ("\\factory") == 0)
+            rep->set (pname, "factory");
           else
-            rep->set (name, val);
-        }
-    }
-  else
-    rep->set (name, val);
+            rep->set (pname, val);
+        }
+    }
+  else
+    rep->set (pname, val);
 }
 
 /*
@@ -2426,8 +2447,8 @@
 
   if (integer_figure_handle)
     {
-      // Figure handles are positive integers corresponding to the
-      // figure number.
+      // Figure handles are positive integers corresponding
+      // to the figure number.
 
       // We always want the lowest unused figure number.
 
@@ -2439,9 +2460,8 @@
   else
     {
       // Other graphics handles are negative integers plus some random
-      // fractional part.  To avoid running out of integers, we
-      // recycle the integer part but tack on a new random part each
-      // time.
+      // fractional part.  To avoid running out of integers, we recycle the
+      // integer part but tack on a new random part each time.
 
       free_list_iterator p = handle_free_list.begin ();
 
@@ -2485,8 +2505,8 @@
               // Notify graphics toolkit.
               p->second.finalize ();
 
-              // Note: this will be valid only for first explicitly
-              // deleted object.  All its children will then have an
+              // Note: this will be valid only for first explicitly deleted
+              // object.  All its children will then have an
               // unknown graphics toolkit.
 
               // Graphics handles for non-figure objects are negative
@@ -2543,11 +2563,11 @@
 gh_manager *gh_manager::instance = 0;
 
 static void
-xset (const graphics_handle& h, const caseless_str& name,
+xset (const graphics_handle& h, const caseless_str& pname,
       const octave_value& val)
 {
-  graphics_object obj = gh_manager::get_object (h);
-  obj.set (name, val);
+  graphics_object go = gh_manager::get_object (h);
+  go.set (pname, val);
 }
 
 static void
@@ -2555,53 +2575,48 @@
 {
   if (args.length () > 0)
     {
-      graphics_object obj = gh_manager::get_object (h);
-      obj.set (args);
+      graphics_object go = gh_manager::get_object (h);
+      go.set (args);
     }
 }
 
 static octave_value
-xget (const graphics_handle& h, const caseless_str& name)
-{
-  graphics_object obj = gh_manager::get_object (h);
-  return obj.get (name);
+xget (const graphics_handle& h, const caseless_str& pname)
+{
+  graphics_object go = gh_manager::get_object (h);
+  return go.get (pname);
 }
 
 static graphics_handle
 reparent (const octave_value& ov, const std::string& who,
-          const std::string& property, const graphics_handle& new_parent,
+          const std::string& pname, const graphics_handle& new_parent,
           bool adopt = true)
 {
   graphics_handle h = octave_NaN;
 
-  double val = ov.double_value ();
-
-  if (! error_state)
-    {
-      h = gh_manager::lookup (val);
-
-      if (h.ok ())
-        {
-          graphics_object obj = gh_manager::get_object (h);
-
-          graphics_handle parent_h = obj.get_parent ();
-
-          graphics_object parent_obj = gh_manager::get_object (parent_h);
-
-          parent_obj.remove_child (h);
-
-          if (adopt)
-            obj.set ("parent", new_parent.value ());
-          else
-            obj.reparent (new_parent);
-        }
+  double hv = ov.xdouble_value ("%s: %s must be a graphics handle",
+                               who.c_str (), pname.c_str ());
+
+  h = gh_manager::lookup (hv);
+
+  if (h.ok ())
+    {
+      graphics_object go = gh_manager::get_object (h);
+
+      graphics_handle parent_h = go.get_parent ();
+
+      graphics_object parent_go = gh_manager::get_object (parent_h);
+
+      parent_go.remove_child (h);
+
+      if (adopt)
+        go.set ("parent", new_parent.value ());
       else
-        error ("%s: invalid graphics handle (= %g) for %s",
-               who.c_str (), val, property.c_str ());
-    }
-  else
-    error ("%s: expecting %s to be a graphics handle",
-           who.c_str (), property.c_str ());
+        go.reparent (new_parent);
+    }
+  else
+    error ("%s: invalid graphics handle (= %g) for %s",
+           who.c_str (), hv, pname.c_str ());
 
   return h;
 }
@@ -2629,27 +2644,24 @@
 {
   if (h.ok ())
     {
-      graphics_object obj = gh_manager::get_object (h);
+      graphics_object go = gh_manager::get_object (h);
 
       // Don't do recursive deleting, due to callbacks
-      if (! obj.get_properties ().is_beingdeleted ())
-        {
-          graphics_handle parent_h = obj.get_parent ();
-
-          graphics_object parent_obj =
-            gh_manager::get_object (parent_h);
-
-          // NOTE: free the handle before removing it from its
-          //       parent's children, such that the object's
-          //       state is correct when the deletefcn callback
-          //       is executed
+      if (! go.get_properties ().is_beingdeleted ())
+        {
+          graphics_handle parent_h = go.get_parent ();
+
+          graphics_object parent_go = gh_manager::get_object (parent_h);
+
+          // NOTE: free the handle before removing it from its parent's
+          //       children, such that the object's state is correct when the
+          //       deletefcn callback is executed
 
           gh_manager::free (h);
 
-          // A callback function might have already deleted
-          // the parent
-          if (parent_obj.valid_object ())
-            parent_obj.remove_child (h);
+          // A callback function might have already deleted the parent
+          if (parent_go.valid_object ())
+            parent_go.remove_child (h);
 
           Vdrawnow_requested = true;
         }
@@ -2670,23 +2682,23 @@
 }
 
 static void
-close_figure (const graphics_handle& handle)
-{
-  octave_value closerequestfcn = xget (handle, "closerequestfcn");
-
-  OCTAVE_SAFE_CALL (gh_manager::execute_callback, (handle, closerequestfcn));
+close_figure (const graphics_handle& h)
+{
+  octave_value closerequestfcn = xget (h, "closerequestfcn");
+
+  OCTAVE_SAFE_CALL (gh_manager::execute_callback, (h, closerequestfcn));
 }
 
 static void
-force_close_figure (const graphics_handle& handle)
-{
-  // Remove the deletefcn and closerequestfcn callbacks and delete the
-  // object directly.
-
-  xset (handle, "deletefcn", Matrix ());
-  xset (handle, "closerequestfcn", Matrix ());
-
-  delete_graphics_object (handle);
+force_close_figure (const graphics_handle& h)
+{
+  // Remove the deletefcn and closerequestfcn callbacks
+  // and delete the object directly.
+
+  xset (h, "deletefcn", Matrix ());
+  xset (h, "closerequestfcn", Matrix ());
+
+  delete_graphics_object (h);
 }
 
 void
@@ -2733,10 +2745,10 @@
 }
 
 static void
-adopt (const graphics_handle& p, const graphics_handle& h)
-{
-  graphics_object parent_obj = gh_manager::get_object (p);
-  parent_obj.adopt (h);
+adopt (const graphics_handle& parent_h, const graphics_handle& h)
+{
+  graphics_object parent_go = gh_manager::get_object (parent_h);
+  parent_go.adopt (h);
 }
 
 static bool
@@ -2764,15 +2776,12 @@
     {
       const NDArray handles = val.array_value ();
 
-      if (! error_state)
-        {
-          boolNDArray result (handles.dims ());
-
-          for (octave_idx_type i = 0; i < handles.numel (); i++)
-            result.xelem (i) = is_handle (handles (i));
-
-          retval = result;
-        }
+      boolNDArray result (handles.dims ());
+
+      for (octave_idx_type i = 0; i < handles.numel (); i++)
+        result.xelem (i) = is_handle (handles(i));
+
+      retval = result;
     }
 
   return retval;
@@ -2781,16 +2790,16 @@
 static bool
 is_figure (double val)
 {
-  graphics_object obj = gh_manager::get_object (val);
-
-  return obj && obj.isa ("figure");
+  graphics_object go = gh_manager::get_object (val);
+
+  return go && go.isa ("figure");
 }
 
 static void
 xcreatefcn (const graphics_handle& h)
 {
-  graphics_object obj = gh_manager::get_object (h);
-  obj.get_properties ().execute_createfcn  ();
+  graphics_object go = gh_manager::get_object (h);
+  go.get_properties ().execute_createfcn  ();
 }
 
 static void
@@ -2829,15 +2838,15 @@
 }
 
 static void
-xreset_default_properties (graphics_handle gh,
+xreset_default_properties (graphics_handle h,
                            property_list::pval_map_type factory_pval)
 {
-  graphics_object obj = gh_manager::get_object (gh);
+  graphics_object go = gh_manager::get_object (h);
 
   // Replace factory defaults by user defined ones
-  std::string go_name = obj.get_properties ().graphics_object_name ();
+  std::string go_name = go.get_properties ().graphics_object_name ();
   property_list::pval_map_type pval;
-  obj.build_user_defaults_map (pval, go_name);
+  go.build_user_defaults_map (pval, go_name);
 
   for (property_list::pval_map_const_iterator p = pval.begin ();
        p != pval.end (); p++)
@@ -2845,7 +2854,6 @@
       factory_pval[p->first] = p->second;
     }
 
-
   // Reset defaults
   for (property_list::pval_map_const_iterator it = factory_pval.begin ();
        it != factory_pval.end (); it++)
@@ -2853,7 +2861,7 @@
       std::string pname = it->first;
 
       // Don't reset internal properties and handle_properties
-      if (! obj.has_readonly_property (pname)
+      if (! go.has_readonly_property (pname)
           && pname.find ("__") != 0 && pname.find ("current") != 0
           && pname != "uicontextmenu" && pname != "parent")
         {
@@ -2861,20 +2869,20 @@
           if (pname.find ("mode") == (pname.length () - 4))
             pval[pname] = it->second;
           else
-            obj.set (pname, it->second);
+            go.set (pname, it->second);
         }
     }
 
   // set *mode properties
   for (property_list::pval_map_const_iterator it = pval.begin ();
        it != pval.end (); it++)
-    obj.set (it->first, it->second);
+    go.set (it->first, it->second);
 }
 
 // ---------------------------------------------------------------------
 
 void
-base_properties::set_from_list (base_graphics_object& obj,
+base_properties::set_from_list (base_graphics_object& bgo,
                                 property_list& defaults)
 {
   std::string go_name = graphics_object_name ();
@@ -2891,12 +2899,13 @@
         {
           std::string pname = q->first;
 
-          obj.set (pname, q->second);
-
-          if (error_state)
-            {
-              error ("error setting default property %s", pname.c_str ());
-              break;
+          try
+            {
+              bgo.set (pname, q->second);
+            }
+          catch (octave_execution_exception& e)
+            {
+              error (e, "error setting default property %s", pname.c_str ());
             }
         }
     }
@@ -2919,17 +2928,17 @@
 */
 
 octave_value
-base_properties::get_dynamic (const caseless_str& name) const
+base_properties::get_dynamic (const caseless_str& pname) const
 {
   octave_value retval;
 
   std::map<caseless_str, property, cmp_caseless_str>::const_iterator it =
-    all_props.find (name);
+    all_props.find (pname);
 
   if (it != all_props.end ())
     retval = it->second.get ();
   else
-    error ("get: unknown property \"%s\"", name.c_str ());
+    error ("get: unknown property \"%s\"", pname.c_str ());
 
   return retval;
 }
@@ -2976,23 +2985,20 @@
   else
     error ("set: unknown property \"%s\"", pname.c_str ());
 
-  if (! error_state)
-    {
-      dynamic_properties.insert (pname);
-
-      mark_modified ();
-    }
+  dynamic_properties.insert (pname);
+
+  mark_modified ();
 }
 
 property
-base_properties::get_property_dynamic (const caseless_str& name)
+base_properties::get_property_dynamic (const caseless_str& pname)
 {
   std::map<caseless_str, property, cmp_caseless_str>::const_iterator it =
-    all_props.find (name);
+    all_props.find (pname);
 
   if (it == all_props.end ())
     {
-      error ("get_property: unknown property \"%s\"", name.c_str ());
+      error ("get_property: unknown property \"%s\"", pname.c_str ());
       return property ();
     }
   else
@@ -3002,50 +3008,43 @@
 void
 base_properties::set_parent (const octave_value& val)
 {
-  double hnp = val.double_value ();
+  double hp = val.xdouble_value ("set: parent must be a graphics handle");
 
   graphics_handle new_parent = octave_NaN;
 
-  if (! error_state)
-    {
-      if (hnp == __myhandle__)
-        error ("set: can not set object parent to be object itself");
+  if (hp == __myhandle__)
+    error ("set: can not set object parent to be object itself");
+  else
+    {
+      new_parent = gh_manager::lookup (hp);
+
+      if (new_parent.ok ())
+        {
+          // Remove child from current parent
+          graphics_object old_parent_go;
+          old_parent_go = gh_manager::get_object (get_parent ());
+
+          if (old_parent_go.get_handle () != hp)
+            old_parent_go.remove_child (__myhandle__);
+          else
+            return;  // Do nothing more
+
+          // Check new parent's parent is not this child to avoid recursion
+          graphics_object new_parent_go;
+          new_parent_go = gh_manager::get_object (new_parent);
+          if (new_parent_go.get_parent () == __myhandle__)
+            {
+              // new parent's parent gets child's original parent
+              new_parent_go.get_properties ().set_parent (get_parent ().as_octave_value ());
+            }
+
+          // Set parent property to new_parent and do adoption
+          parent = new_parent.as_octave_value ();
+          ::adopt (parent.handle_value (), __myhandle__);
+        }
       else
-        {
-          new_parent = gh_manager::lookup (hnp);
-
-          if (new_parent.ok ())
-            {
-              // Remove child from current parent
-              graphics_object old_parent_obj;
-              old_parent_obj = gh_manager::get_object (get_parent ());
-
-
-              if (old_parent_obj.get_handle () != hnp)
-                old_parent_obj.remove_child (__myhandle__);
-              else
-                // Do nothing more
-                return;
-
-              // Check new parent's parent is not this child to avoid recursion
-              graphics_object new_parent_obj;
-              new_parent_obj = gh_manager::get_object (new_parent);
-              if (new_parent_obj.get_parent () == __myhandle__)
-                {
-                  // new parent's parent gets child's original parent
-                  new_parent_obj.get_properties ().set_parent (get_parent ().as_octave_value ());
-                }
-
-              // Set parent property to new_parent and do adoption
-              parent = new_parent.as_octave_value ();
-              ::adopt (parent.handle_value (), __myhandle__);
-            }
-          else
-            error ("set: invalid graphics handle (= %g) for parent", hnp);
-        }
-    }
-  else
-    error ("set: expecting parent to be a graphics handle");
+        error ("set: invalid graphics handle (= %g) for parent", hp);
+    }
 }
 
 /*
@@ -3063,38 +3062,40 @@
 void
 base_properties::mark_modified (void)
 {
+  // Mark existing object as modified
   __modified__ = "on";
-  graphics_object parent_obj = gh_manager::get_object (get_parent ());
-  if (parent_obj)
-    parent_obj.mark_modified ();
+  // Attempt to mark parent object as modified if it exists
+  graphics_object parent_go = gh_manager::get_object (get_parent ());
+  if (parent_go)
+    parent_go.mark_modified ();
 }
 
 void
 base_properties::override_defaults (base_graphics_object& obj)
 {
-  graphics_object parent_obj = gh_manager::get_object (get_parent ());
-
-  if (parent_obj)
-    parent_obj.override_defaults (obj);
+  graphics_object parent_go = gh_manager::get_object (get_parent ());
+
+  if (parent_go)
+    parent_go.override_defaults (obj);
 }
 
 void
 base_properties::update_axis_limits (const std::string& axis_type) const
 {
-  graphics_object obj = gh_manager::get_object (__myhandle__);
-
-  if (obj)
-    obj.update_axis_limits (axis_type);
+  graphics_object go = gh_manager::get_object (__myhandle__);
+
+  if (go)
+    go.update_axis_limits (axis_type);
 }
 
 void
 base_properties::update_axis_limits (const std::string& axis_type,
                                      const graphics_handle& h) const
 {
-  graphics_object obj = gh_manager::get_object (__myhandle__);
-
-  if (obj)
-    obj.update_axis_limits (axis_type, h);
+  graphics_object go = gh_manager::get_object (__myhandle__);
+
+  if (go)
+    go.update_axis_limits (axis_type, h);
 }
 
 void
@@ -3103,11 +3104,11 @@
   if (uicontextmenu.get ().is_empty ())
     return;
 
-  graphics_object obj = gh_manager::get_object (uicontextmenu.get ());
-  if (obj && obj.isa ("uicontextmenu"))
+  graphics_object go = gh_manager::get_object (uicontextmenu.get ());
+  if (go && go.isa ("uicontextmenu"))
     {
       uicontextmenu::properties& props =
-        reinterpret_cast<uicontextmenu::properties&> (obj.get_properties ());
+        reinterpret_cast<uicontextmenu::properties&> (go.get_properties ());
       props.add_dependent_obj (__myhandle__);
     }
 }
@@ -3147,30 +3148,32 @@
 void
 base_properties::update_autopos (const std::string& elem_type)
 {
-  graphics_object parent_obj = gh_manager::get_object (get_parent ());
-
-  if (parent_obj.valid_object ())
-    parent_obj.get_properties ().update_autopos (elem_type);
-}
-
-void
-base_properties::add_listener (const caseless_str& nm, const octave_value& v,
+  graphics_object parent_go = gh_manager::get_object (get_parent ());
+
+  if (parent_go.valid_object ())
+    parent_go.get_properties ().update_autopos (elem_type);
+}
+
+void
+base_properties::add_listener (const caseless_str& pname,
+                               const octave_value& val,
                                listener_mode mode)
 {
-  property p = get_property (nm);
-
-  if (! error_state && p.ok ())
-    p.add_listener (v, mode);
-}
-
-void
-base_properties::delete_listener (const caseless_str& nm,
-                                  const octave_value& v, listener_mode mode)
-{
-  property p = get_property (nm);
-
-  if (! error_state && p.ok ())
-    p.delete_listener (v, mode);
+  property p = get_property (pname);
+
+  if (p.ok ())
+    p.add_listener (val, mode);
+}
+
+void
+base_properties::delete_listener (const caseless_str& pname,
+                                  const octave_value& val,
+                                  listener_mode mode)
+{
+  property p = get_property (pname);
+
+  if (p.ok ())
+    p.delete_listener (val, mode);
 }
 
 // ---------------------------------------------------------------------
@@ -3180,10 +3183,10 @@
 {
   if (valid_object ())
     {
-      graphics_object parent_obj = gh_manager::get_object (get_parent ());
-
-      if (parent_obj)
-        parent_obj.update_axis_limits (axis_type);
+      graphics_object parent_go = gh_manager::get_object (get_parent ());
+
+      if (parent_go)
+        parent_go.update_axis_limits (axis_type);
     }
   else
     error ("base_graphics_object::update_axis_limits: invalid graphics object");
@@ -3193,15 +3196,15 @@
 base_graphics_object::update_axis_limits (const std::string& axis_type,
                                           const graphics_handle& h)
 {
-  if (valid_object ())
-    {
-      graphics_object parent_obj = gh_manager::get_object (get_parent ());
-
-      if (parent_obj)
-        parent_obj.update_axis_limits (axis_type, h);
-    }
-  else
+  if (! valid_object ())
     error ("base_graphics_object::update_axis_limits: invalid graphics object");
+  else
+    {
+      graphics_object parent_go = gh_manager::get_object (get_parent ());
+
+      if (parent_go)
+        parent_go.update_axis_limits (axis_type, h);
+    }
 }
 
 void
@@ -3217,7 +3220,6 @@
 
       unwind_protect frame;
 
-      frame.protect_var (error_state);
       frame.protect_var (discard_error_messages);
       frame.protect_var (Vdebug_on_error);
       frame.protect_var (Vdebug_on_warning);
@@ -3226,10 +3228,17 @@
       Vdebug_on_error = false;
       Vdebug_on_warning = false;
 
-      property p = get_properties ().get_property (pa->first);
-
-      if (! error_state && p.ok ())
-        p.delete_listener ();
+      try
+        {
+          property p = get_properties ().get_property (pa->first);
+
+          if (p.ok ())
+            p.delete_listener ();
+        }
+      catch (const octave_execution_exception&)
+        {
+          recover_from_exception ();
+        }
     }
 }
 
@@ -3252,11 +3261,10 @@
         }
     }
 
-  graphics_object parent_obj = gh_manager::get_object (get_parent ());
-
-  if (parent_obj)
-    parent_obj.build_user_defaults_map (def, go_name);
-
+  graphics_object parent_go = gh_manager::get_object (get_parent ());
+
+  if (parent_go)
+    parent_go.build_user_defaults_map (def, go_name);
 }
 
 void
@@ -3277,15 +3285,16 @@
 {
   std::string retval;
 
-  if (valid_object ())
+  if (! valid_object ())
+    error ("base_graphics_object::values_as_string: invalid graphics object");
+  else
     {
       octave_map m = get ().map_value ();
-      graphics_object obj = gh_manager::get_object (get_handle ());
+      graphics_object go = gh_manager::get_object (get_handle ());
 
       for (octave_map::const_iterator pa = m.begin (); pa != m.end (); pa++)
         {
-          if (pa->first != "children"
-              && ! obj.has_readonly_property (pa->first))
+          if (pa->first != "children" && ! go.has_readonly_property (pa->first))
             {
               property p = get_properties ().get_property (pa->first);
 
@@ -3301,8 +3310,6 @@
       if (! retval.empty ())
         retval += "\n";
     }
-  else
-    error ("base_graphics_object::values_as_string: invalid graphics object");
 
   return retval;
 }
@@ -3312,11 +3319,13 @@
 {
   std::string retval;
 
-  if (valid_object ())
-    {
-      graphics_object obj = gh_manager::get_object (get_handle ());
-
-      if (prop != "children" && ! obj.has_readonly_property (prop))
+  if (! valid_object ())
+    error ("base_graphics_object::value_as_string: invalid graphics object");
+  else
+    {
+      graphics_object go = gh_manager::get_object (get_handle ());
+
+      if (prop != "children" && ! go.has_readonly_property (prop))
         {
           property p = get_properties ().get_property (prop);
 
@@ -3330,8 +3339,6 @@
       if (! retval.empty ())
         retval += "\n";
     }
-  else
-    error ("base_graphics_object::value_as_string: invalid graphics object");
 
   return retval;
 }
@@ -3341,16 +3348,18 @@
 {
   octave_scalar_map retval;
 
-  if (valid_object ())
+  if (! valid_object ())
+    error ("base_graphics_object::values_as_struct: invalid graphics object");
+  else
     {
       octave_scalar_map m = get ().scalar_map_value ();
-      graphics_object obj = gh_manager::get_object (get_handle ());
+      graphics_object go = gh_manager::get_object (get_handle ());
 
       for (octave_scalar_map::const_iterator pa = m.begin ();
            pa != m.end (); pa++)
         {
           if (pa->first != "children"
-              && ! obj.has_readonly_property (pa->first))
+              && ! go.has_readonly_property (pa->first))
             {
               property p = get_properties ().get_property (pa->first);
 
@@ -3364,8 +3373,6 @@
             }
         }
     }
-  else
-    error ("base_graphics_object::values_as_struct: invalid graphics object");
 
   return retval;
 }
@@ -3415,9 +3422,6 @@
 {
   graphics_handle val (v);
 
-  if (error_state)
-    return;
-
   if (xisnan (val.value ()))
     {
       if (! cbo_stack.empty ())
@@ -3445,9 +3449,6 @@
 {
   graphics_handle val (v);
 
-  if (error_state)
-    return;
-
   if (xisnan (val.value ()) || is_handle (val))
     {
       currentfigure = val;
@@ -3459,264 +3460,98 @@
     gripe_set_invalid ("currentfigure");
 }
 
-std::string
-root_figure::properties::get_diary (void) const
-{
-  bool is_diary_on = F__diarystate__ ()(0).bool_value ();
-  if (is_diary_on)
-    return std::string ("on");
-  else
-    return std::string ("off");
-}
-
-void
-root_figure::properties::set_diary (const octave_value& val)
-{
-  if (! error_state)
-    {
-      // Input checking and abrev. matching
-      diary.set (val, false);
-
-      if (! error_state)
-        {
-          Fdiary (ovl (diary.current_value ()));
-
-          diary.run_listeners ();
-        }
-    }
-}
-
-std::string
-root_figure::properties::get_diaryfile (void) const
-{
-  return F__diaryfile__ ()(0).string_value ();
-}
-
-void
-root_figure::properties::set_diaryfile (const octave_value& val)
-{
-  if (! error_state)
-    {
-      // Input checking and abrev. matching
-      diaryfile.set (val, false);
-
-      if (! error_state)
-        {
-          Fdiary (ovl (diaryfile.string_value ()));
-
-          diaryfile.run_listeners ();
-        }
-    }
-}
-
-std::string
-root_figure::properties::get_echo (void) const
-{
-  bool is_echo_on = F__echostate__ ()(0).bool_value ();
-  if (is_echo_on)
-    return std::string ("on");
-  else
-    return std::string ("off");
-}
-
-void
-root_figure::properties::set_echo (const octave_value& val)
-{
-  if (! error_state)
-    {
-      // Input checking and abrev. matching
-      echo.set (val, false);
-
-      if (! error_state)
-        {
-          Fecho (ovl (echo.current_value ()));
-
-          echo.run_listeners ();
-        }
-    }
-}
-
-std::string
-root_figure::properties::get_errormessage (void) const
-{
-  return Flasterr ()(0).string_value ();
-}
-
-std::string
-root_figure::properties::get_format (void) const
-{
-  return F__formatstring__ ()(0).string_value ();
-}
-
-void
-root_figure::properties::set_format (const octave_value& val)
-{
-  if (! error_state)
-    {
-      // Input checking and abrev. matching
-      format.set (val, false);
-
-      if (! error_state)
-        {
-          Fformat (ovl (format.current_value ()));
-
-          format.run_listeners ();
-        }
-    }
-}
-
-std::string
-root_figure::properties::get_formatspacing (void) const
-{
-  bool iscompact = F__compactformat__ ()(0).bool_value ();
-  if (iscompact)
-    return std::string ("compact");
-  else
-    return std::string ("loose");
-}
-
-void
-root_figure::properties::set_formatspacing (const octave_value& val)
-{
-  if (! error_state)
-    {
-      // Input checking and abrev. matching
-      formatspacing.set (val, false);
-
-      if (! error_state)
-        {
-          std::string strval = formatspacing.current_value ();
-
-          if (strval == "compact")
-            F__compactformat__ (ovl (true));
-          else
-            F__compactformat__ (ovl (false));
-
-          formatspacing.run_listeners ();
-        }
-    }
-}
-
-
-double
-root_figure::properties::get_recursionlimit (void) const
-{
-  return Fmax_recursion_depth ()(0).double_value ();
-}
-
-void
-root_figure::properties::set_recursionlimit (const octave_value& val)
-{
-  if (! error_state)
-    {
-      // Input checking and abrev. matching
-      recursionlimit.set (val, false);
-
-      if (! error_state)
-        {
-          double dval = recursionlimit.double_value ();
-
-          Fmax_recursion_depth (ovl (dval));
-
-          recursionlimit.run_listeners ();
-        }
-    }
-}
-
 void
 figure::properties::set_integerhandle (const octave_value& val)
 {
-  if (! error_state)
-    {
-      if (integerhandle.set (val, true))
-        {
-          bool int_fig_handle = integerhandle.is_on ();
-
-          graphics_object this_go = gh_manager::get_object (__myhandle__);
-
-          graphics_handle old_myhandle = __myhandle__;
-
-          __myhandle__ = gh_manager::get_handle (int_fig_handle);
-
-          gh_manager::renumber_figure (old_myhandle, __myhandle__);
-
-          graphics_object parent_go = gh_manager::get_object (get_parent ());
-
-          base_properties& props = parent_go.get_properties ();
-
-          props.renumber_child (old_myhandle, __myhandle__);
-
-          Matrix kids = get_children ();
-
-          for (octave_idx_type i = 0; i < kids.numel (); i++)
-            {
-              graphics_object kid = gh_manager::get_object (kids(i));
-
-              kid.get_properties ().renumber_parent (__myhandle__);
-            }
-
-          graphics_handle cf = gh_manager::current_figure ();
-
-          if (__myhandle__ == cf)
-            xset (0, "currentfigure", __myhandle__.value ());
-
-          this_go.update (integerhandle.get_id ());
-
-          mark_modified ();
-        }
-    }
-}
-
-// FIXME: This should update monitorpositions and pointerlocation, but
-// as these properties are yet used, and so it doesn't matter that they
-// aren't set yet.
+  if (integerhandle.set (val, true))
+    {
+      bool int_fig_handle = integerhandle.is_on ();
+
+      graphics_object this_go = gh_manager::get_object (__myhandle__);
+
+      graphics_handle old_myhandle = __myhandle__;
+
+      __myhandle__ = gh_manager::get_handle (int_fig_handle);
+
+      gh_manager::renumber_figure (old_myhandle, __myhandle__);
+
+      graphics_object parent_go = gh_manager::get_object (get_parent ());
+
+      base_properties& props = parent_go.get_properties ();
+
+      props.renumber_child (old_myhandle, __myhandle__);
+
+      Matrix kids = get_children ();
+
+      for (octave_idx_type i = 0; i < kids.numel (); i++)
+        {
+          graphics_object kid = gh_manager::get_object (kids(i));
+
+          kid.get_properties ().renumber_parent (__myhandle__);
+        }
+
+      graphics_handle cf = gh_manager::current_figure ();
+
+      if (__myhandle__ == cf)
+        xset (0, "currentfigure", __myhandle__.value ());
+
+      this_go.update (integerhandle.get_id ());
+
+      mark_modified ();
+    }
+}
+
+// FIXME: This should update monitorpositions and pointerlocation, but as these
+// properties aren't yet used, it doesn't matter that they aren't set either.
 void
 root_figure::properties::update_units (void)
 {
   caseless_str xunits = get_units ();
 
-  Matrix ss = default_screensize ();
+  Matrix scrn_sz = default_screensize ();
 
   double dpi = get_screenpixelsperinch ();
 
   if (xunits.compare ("inches"))
     {
-      ss(0) = 0;
-      ss(1) = 0;
-      ss(2) /= dpi;
-      ss(3) /= dpi;
+      scrn_sz(0) = 0;
+      scrn_sz(1) = 0;
+      scrn_sz(2) /= dpi;
+      scrn_sz(3) /= dpi;
     }
   else if (xunits.compare ("centimeters"))
     {
-      ss(0) = 0;
-      ss(1) = 0;
-      ss(2) *= 2.54 / dpi;
-      ss(3) *= 2.54 / dpi;
+      scrn_sz(0) = 0;
+      scrn_sz(1) = 0;
+      scrn_sz(2) *= 2.54 / dpi;
+      scrn_sz(3) *= 2.54 / dpi;
     }
   else if (xunits.compare ("normalized"))
     {
-      ss = Matrix (1, 4, 1.0);
-      ss(0) = 0;
-      ss(1) = 0;
+      scrn_sz = Matrix (1, 4, 1.0);
+      scrn_sz(0) = 0;
+      scrn_sz(1) = 0;
     }
   else if (xunits.compare ("points"))
     {
-      ss(0) = 0;
-      ss(1) = 0;
-      ss(2) *= 72 / dpi;
-      ss(3) *= 72 / dpi;
-    }
-
-  set_screensize (ss);
+      scrn_sz(0) = 0;
+      scrn_sz(1) = 0;
+      scrn_sz(2) *= 72 / dpi;
+      scrn_sz(3) *= 72 / dpi;
+    }
+
+  set_screensize (scrn_sz);
 }
 
 Matrix
 root_figure::properties::get_boundingbox (bool, const Matrix&) const
 {
   Matrix screen_size = screen_size_pixels ();
-  Matrix pos = Matrix (1, 4, 0);
+  Matrix pos = Matrix (1, 4, 0.0);
+
   pos(2) = screen_size(0);
   pos(3) = screen_size(1);
+
   return pos;
 }
 
@@ -3743,15 +3578,15 @@
 */
 
 void
-root_figure::properties::remove_child (const graphics_handle& gh)
-{
-  gh_manager::pop_figure (gh);
+root_figure::properties::remove_child (const graphics_handle& h)
+{
+  gh_manager::pop_figure (h);
 
   graphics_handle cf = gh_manager::current_figure ();
 
   xset (0, "currentfigure", cf.value ());
 
-  base_properties::remove_child (gh);
+  base_properties::remove_child (h);
 }
 
 property_list
@@ -3770,25 +3605,22 @@
 // ---------------------------------------------------------------------
 
 void
-figure::properties::set_currentaxes (const octave_value& v)
-{
-  graphics_handle val (v);
-
-  if (error_state)
-    return;
-
-  if (xisnan (val.value ()) || is_handle (val))
-    currentaxes = val;
+figure::properties::set_currentaxes (const octave_value& val)
+{
+  graphics_handle hax (val);
+
+  if (xisnan (hax.value ()) || is_handle (hax))
+    currentaxes = hax;
   else
     gripe_set_invalid ("currentaxes");
 }
 
 void
-figure::properties::remove_child (const graphics_handle& gh)
-{
-  base_properties::remove_child (gh);
-
-  if (gh == currentaxes.handle_value ())
+figure::properties::remove_child (const graphics_handle& h)
+{
+  base_properties::remove_child (h);
+
+  if (h == currentaxes.handle_value ())
     {
       graphics_handle new_currentaxes;
 
@@ -3846,15 +3678,12 @@
 void
 figure::properties::set_visible (const octave_value& val)
 {
-  std::string s = val.string_value ();
-
-  if (! error_state)
-    {
-      if (s == "on")
-        xset (0, "currentfigure", __myhandle__.value ());
-
-      visible = val;
-    }
+  std::string sval = val.string_value ();
+
+  if (sval == "on")
+    xset (0, "currentfigure", __myhandle__.value ());
+
+  visible = val;
 }
 
 Matrix
@@ -3896,7 +3725,7 @@
 figure::properties::map_from_boundingbox (double x, double y) const
 {
   Matrix bb = get_boundingbox (true);
-  Matrix pos (1, 2, 0);
+  Matrix pos (1, 2, 0.0);
 
   pos(0) = x;
   pos(1) = y;
@@ -3913,7 +3742,7 @@
 figure::properties::map_to_boundingbox (double x, double y) const
 {
   Matrix bb = get_boundingbox (true);
-  Matrix pos (1, 2, 0);
+  Matrix pos (1, 2, 0.0);
 
   pos(0) = x;
   pos(1) = y;
@@ -3930,99 +3759,81 @@
 figure::properties::set_position (const octave_value& v,
                                   bool do_notify_toolkit)
 {
-  if (! error_state)
-    {
-      Matrix old_bb, new_bb;
-      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)
-        {
-          if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
-            {
-              execute_resizefcn ();
-              update_boundingbox ();
-            }
-        }
-
-      if (modified)
-        {
-          position.run_listeners (POSTSET);
-          mark_modified ();
-        }
-
-      if (paperpositionmode.is ("auto"))
-        paperposition.set (get_auto_paperposition ());
-    }
+  Matrix old_bb, new_bb;
+  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)
+    {
+      if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3))
+        {
+          execute_resizefcn ();
+          update_boundingbox ();
+        }
+    }
+
+  if (modified)
+    {
+      position.run_listeners (POSTSET);
+      mark_modified ();
+    }
+
+  if (paperpositionmode.is ("auto"))
+    paperposition.set (get_auto_paperposition ());
 }
 
 void
 figure::properties::set_outerposition (const octave_value& v,
                                        bool do_notify_toolkit)
 {
-  if (! error_state)
-    {
-      if (outerposition.set (v, true, do_notify_toolkit))
-        {
+  if (outerposition.set (v, true, do_notify_toolkit))
+    mark_modified ();
+}
+
+void
+figure::properties::set_paperunits (const octave_value& val)
+{
+  caseless_str punits = val.string_value ();
+  caseless_str ptype = get_papertype ();
+
+  if (punits.compare ("normalized") && ptype.compare ("<custom>"))
+    error ("set: can't set paperunits to normalized when papertype is custom");
+  else
+    {
+      caseless_str old_paperunits = get_paperunits ();
+      if (paperunits.set (val, true))
+        {
+          update_paperunits (old_paperunits);
           mark_modified ();
         }
     }
 }
 
 void
-figure::properties::set_paperunits (const octave_value& v)
-{
-  if (! error_state)
-    {
-      caseless_str typ = get_papertype ();
-      caseless_str punits = v.string_value ();
-      if (! error_state)
-        {
-          if (punits.compare ("normalized") && typ.compare ("<custom>"))
-            error ("set: can't set the paperunits to normalized when the papertype is custom");
-          else
-            {
-              caseless_str old_paperunits = get_paperunits ();
-              if (paperunits.set (v, true))
-                {
-                  update_paperunits (old_paperunits);
-                  mark_modified ();
-                }
-            }
-        }
-    }
-}
-
-void
-figure::properties::set_papertype (const octave_value& v)
-{
-  if (! error_state)
-    {
-      caseless_str typ = v.string_value ();
-      caseless_str punits = get_paperunits ();
-      if (! error_state)
-        {
-          if (punits.compare ("normalized") && typ.compare ("<custom>"))
-            error ("set: can't set the paperunits to normalized when the papertype is custom");
-          else
-            {
-              if (papertype.set (v, true))
-                {
-                  update_papertype ();
-                  mark_modified ();
-                }
-            }
+figure::properties::set_papertype (const octave_value& val)
+{
+  caseless_str ptype = val.string_value ();
+  caseless_str punits = get_paperunits ();
+
+  if (punits.compare ("normalized") && ptype.compare ("<custom>"))
+    error ("set: can't set paperunits to normalized when papertype is custom");
+  else
+    {
+      if (papertype.set (val, true))
+        {
+          update_papertype ();
+          mark_modified ();
         }
     }
 }
 
 static Matrix
-papersize_from_type (const caseless_str punits, const caseless_str typ)
-{
-  Matrix ret (1, 2, 1.0);
+papersize_from_type (const caseless_str punits, const caseless_str ptype)
+{
+  Matrix retval (1, 2, 1.0);
 
   if (! punits.compare ("normalized"))
     {
@@ -4045,134 +3856,134 @@
           mm2units = 72.0 / 25.4;
         }
 
-      if (typ.compare ("usletter"))
-        {
-          ret (0) = 8.5 * in2units;
-          ret (1) = 11.0 * in2units;
-        }
-      else if (typ.compare ("uslegal"))
-        {
-          ret (0) = 8.5 * in2units;
-          ret (1) = 14.0 * in2units;
-        }
-      else if (typ.compare ("tabloid"))
-        {
-          ret (0) = 11.0 * in2units;
-          ret (1) = 17.0 * in2units;
-        }
-      else if (typ.compare ("a0"))
-        {
-          ret (0) = 841.0 * mm2units;
-          ret (1) = 1189.0 * mm2units;
-        }
-      else if (typ.compare ("a1"))
-        {
-          ret (0) = 594.0 * mm2units;
-          ret (1) = 841.0 * mm2units;
-        }
-      else if (typ.compare ("a2"))
-        {
-          ret (0) = 420.0 * mm2units;
-          ret (1) = 594.0 * mm2units;
-        }
-      else if (typ.compare ("a3"))
-        {
-          ret (0) = 297.0 * mm2units;
-          ret (1) = 420.0 * mm2units;
-        }
-      else if (typ.compare ("a4"))
-        {
-          ret (0) = 210.0 * mm2units;
-          ret (1) = 297.0 * mm2units;
-        }
-      else if (typ.compare ("a5"))
-        {
-          ret (0) = 148.0 * mm2units;
-          ret (1) = 210.0 * mm2units;
-        }
-      else if (typ.compare ("b0"))
-        {
-          ret (0) = 1029.0 * mm2units;
-          ret (1) = 1456.0 * mm2units;
-        }
-      else if (typ.compare ("b1"))
-        {
-          ret (0) = 728.0 * mm2units;
-          ret (1) = 1028.0 * mm2units;
-        }
-      else if (typ.compare ("b2"))
-        {
-          ret (0) = 514.0 * mm2units;
-          ret (1) = 728.0 * mm2units;
-        }
-      else if (typ.compare ("b3"))
-        {
-          ret (0) = 364.0 * mm2units;
-          ret (1) = 514.0 * mm2units;
-        }
-      else if (typ.compare ("b4"))
-        {
-          ret (0) = 257.0 * mm2units;
-          ret (1) = 364.0 * mm2units;
-        }
-      else if (typ.compare ("b5"))
-        {
-          ret (0) = 182.0 * mm2units;
-          ret (1) = 257.0 * mm2units;
-        }
-      else if (typ.compare ("arch-a"))
-        {
-          ret (0) = 9.0 * in2units;
-          ret (1) = 12.0 * in2units;
-        }
-      else if (typ.compare ("arch-b"))
-        {
-          ret (0) = 12.0 * in2units;
-          ret (1) = 18.0 * in2units;
-        }
-      else if (typ.compare ("arch-c"))
-        {
-          ret (0) = 18.0 * in2units;
-          ret (1) = 24.0 * in2units;
-        }
-      else if (typ.compare ("arch-d"))
-        {
-          ret (0) = 24.0 * in2units;
-          ret (1) = 36.0 * in2units;
-        }
-      else if (typ.compare ("arch-e"))
-        {
-          ret (0) = 36.0 * in2units;
-          ret (1) = 48.0 * in2units;
-        }
-      else if (typ.compare ("a"))
-        {
-          ret (0) = 8.5 * in2units;
-          ret (1) = 11.0 * in2units;
-        }
-      else if (typ.compare ("b"))
-        {
-          ret (0) = 11.0 * in2units;
-          ret (1) = 17.0 * in2units;
-        }
-      else if (typ.compare ("c"))
-        {
-          ret (0) = 17.0 * in2units;
-          ret (1) = 22.0 * in2units;
-        }
-      else if (typ.compare ("d"))
-        {
-          ret (0) = 22.0 * in2units;
-          ret (1) = 34.0 * in2units;
-        }
-      else if (typ.compare ("e"))
-        {
-          ret (0) = 34.0 * in2units;
-          ret (1) = 43.0 * in2units;
-        }
-    }
-
-  return ret;
+      if (ptype.compare ("usletter"))
+        {
+          retval(0) = 8.5 * in2units;
+          retval(1) = 11.0 * in2units;
+        }
+      else if (ptype.compare ("uslegal"))
+        {
+          retval(0) = 8.5 * in2units;
+          retval(1) = 14.0 * in2units;
+        }
+      else if (ptype.compare ("tabloid"))
+        {
+          retval(0) = 11.0 * in2units;
+          retval(1) = 17.0 * in2units;
+        }
+      else if (ptype.compare ("a0"))
+        {
+          retval(0) = 841.0 * mm2units;
+          retval(1) = 1189.0 * mm2units;
+        }
+      else if (ptype.compare ("a1"))
+        {
+          retval(0) = 594.0 * mm2units;
+          retval(1) = 841.0 * mm2units;
+        }
+      else if (ptype.compare ("a2"))
+        {
+          retval(0) = 420.0 * mm2units;
+          retval(1) = 594.0 * mm2units;
+        }
+      else if (ptype.compare ("a3"))
+        {
+          retval(0) = 297.0 * mm2units;
+          retval(1) = 420.0 * mm2units;
+        }
+      else if (ptype.compare ("a4"))
+        {
+          retval(0) = 210.0 * mm2units;
+          retval(1) = 297.0 * mm2units;
+        }
+      else if (ptype.compare ("a5"))
+        {
+          retval(0) = 148.0 * mm2units;
+          retval(1) = 210.0 * mm2units;
+        }
+      else if (ptype.compare ("b0"))
+        {
+          retval(0) = 1029.0 * mm2units;
+          retval(1) = 1456.0 * mm2units;
+        }
+      else if (ptype.compare ("b1"))
+        {
+          retval(0) = 728.0 * mm2units;
+          retval(1) = 1028.0 * mm2units;
+        }
+      else if (ptype.compare ("b2"))
+        {
+          retval(0) = 514.0 * mm2units;
+          retval(1) = 728.0 * mm2units;
+        }
+      else if (ptype.compare ("b3"))
+        {
+          retval(0) = 364.0 * mm2units;
+          retval(1) = 514.0 * mm2units;
+        }
+      else if (ptype.compare ("b4"))
+        {
+          retval(0) = 257.0 * mm2units;
+          retval(1) = 364.0 * mm2units;
+        }
+      else if (ptype.compare ("b5"))
+        {
+          retval(0) = 182.0 * mm2units;
+          retval(1) = 257.0 * mm2units;
+        }
+      else if (ptype.compare ("arch-a"))
+        {
+          retval(0) = 9.0 * in2units;
+          retval(1) = 12.0 * in2units;
+        }
+      else if (ptype.compare ("arch-b"))
+        {
+          retval(0) = 12.0 * in2units;
+          retval(1) = 18.0 * in2units;
+        }
+      else if (ptype.compare ("arch-c"))
+        {
+          retval(0) = 18.0 * in2units;
+          retval(1) = 24.0 * in2units;
+        }
+      else if (ptype.compare ("arch-d"))
+        {
+          retval(0) = 24.0 * in2units;
+          retval(1) = 36.0 * in2units;
+        }
+      else if (ptype.compare ("arch-e"))
+        {
+          retval(0) = 36.0 * in2units;
+          retval(1) = 48.0 * in2units;
+        }
+      else if (ptype.compare ("a"))
+        {
+          retval(0) = 8.5 * in2units;
+          retval(1) = 11.0 * in2units;
+        }
+      else if (ptype.compare ("b"))
+        {
+          retval(0) = 11.0 * in2units;
+          retval(1) = 17.0 * in2units;
+        }
+      else if (ptype.compare ("c"))
+        {
+          retval(0) = 17.0 * in2units;
+          retval(1) = 22.0 * in2units;
+        }
+      else if (ptype.compare ("d"))
+        {
+          retval(0) = 22.0 * in2units;
+          retval(1) = 34.0 * in2units;
+        }
+      else if (ptype.compare ("e"))
+        {
+          retval(0) = 34.0 * in2units;
+          retval(1) = 43.0 * in2units;
+        }
+    }
+
+  return retval;
 }
 
 
@@ -4304,9 +4115,9 @@
 
   std::string porient = get_paperorientation ();
   caseless_str punits = get_paperunits ();
-  caseless_str typ = get_papertype ();
-
-  if (typ.compare ("<custom>"))
+  caseless_str ptype = get_papertype ();
+
+  if (ptype.compare ("<custom>"))
     {
       if (old_paperunits.compare ("centimeters"))
         {
@@ -4332,7 +4143,7 @@
     }
   else
     {
-      sz = papersize_from_type (punits, typ);
+      sz = papersize_from_type (punits, ptype);
       if (porient == "landscape")
         std::swap (sz(0), sz(1));
     }
@@ -4356,7 +4167,7 @@
       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
+      // between update_papersize and update_papertype.
       papersize.set (octave_value (sz));
     }
 
@@ -4378,6 +4189,7 @@
     {
       paperorientation.set ("portrait");
     }
+
   std::string punits = get_paperunits ();
   if (punits == "centimeters")
     {
@@ -4391,93 +4203,93 @@
     }
   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>";
+      // FIXME: The papersizes info is also in papersize_from_type().
+      //        Both should be rewritten to avoid the duplication.
+      //        Don't Repeat Yourself (DRY) principle.
+      std::string ptype = "<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";
+        ptype = "usletter";
       else if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 14.0) < tol)
-        typ = "uslegal";
+        ptype = "uslegal";
       else if (std::abs (sz(0) - 11.0) + std::abs (sz(1) - 17.0) < tol)
-        typ = "tabloid";
+        ptype = "tabloid";
       else if (std::abs (sz(0) - 841.0 * mm2in)
                + std::abs (sz(1) - 1198.0 * mm2in) < tol)
-        typ = "a0";
+        ptype = "a0";
       else if (std::abs (sz(0) - 594.0 * mm2in)
                + std::abs (sz(1) - 841.0 * mm2in) < tol)
-        typ = "a1";
+        ptype = "a1";
       else if (std::abs (sz(0) - 420.0 * mm2in)
                + std::abs (sz(1) - 594.0 * mm2in) < tol)
-        typ = "a2";
+        ptype = "a2";
       else if (std::abs (sz(0) - 297.0 * mm2in)
                + std::abs (sz(1) - 420.0 * mm2in) < tol)
-        typ = "a3";
+        ptype = "a3";
       else if (std::abs (sz(0) - 210.0 * mm2in)
                + std::abs (sz(1) - 297.0 * mm2in) < tol)
-        typ = "a4";
+        ptype = "a4";
       else if (std::abs (sz(0) - 148.0 * mm2in)
                + std::abs (sz(1) - 210.0 * mm2in) < tol)
-        typ = "a5";
+        ptype = "a5";
       else if (std::abs (sz(0) - 1029.0 * mm2in)
                + std::abs (sz(1) - 1456.0 * mm2in) < tol)
-        typ = "b0";
+        ptype = "b0";
       else if (std::abs (sz(0) - 728.0 * mm2in)
                + std::abs (sz(1) - 1028.0 * mm2in) < tol)
-        typ = "b1";
+        ptype = "b1";
       else if (std::abs (sz(0) - 514.0 * mm2in)
                + std::abs (sz(1) - 728.0 * mm2in) < tol)
-        typ = "b2";
+        ptype = "b2";
       else if (std::abs (sz(0) - 364.0 * mm2in)
                + std::abs (sz(1) - 514.0 * mm2in) < tol)
-        typ = "b3";
+        ptype = "b3";
       else if (std::abs (sz(0) - 257.0 * mm2in)
                + std::abs (sz(1) - 364.0 * mm2in) < tol)
-        typ = "b4";
+        ptype = "b4";
       else if (std::abs (sz(0) - 182.0 * mm2in)
                + std::abs (sz(1) - 257.0 * mm2in) < tol)
-        typ = "b5";
+        ptype = "b5";
       else if (std::abs (sz(0) - 9.0)
                + std::abs (sz(1) - 12.0) < tol)
-        typ = "arch-a";
+        ptype = "arch-a";
       else if (std::abs (sz(0) - 12.0)
                + std::abs (sz(1) - 18.0) < tol)
-        typ = "arch-b";
+        ptype = "arch-b";
       else if (std::abs (sz(0) - 18.0)
                + std::abs (sz(1) - 24.0) < tol)
-        typ = "arch-c";
+        ptype = "arch-c";
       else if (std::abs (sz(0) - 24.0)
                + std::abs (sz(1) - 36.0) < tol)
-        typ = "arch-d";
+        ptype = "arch-d";
       else if (std::abs (sz(0) - 36.0)
                + std::abs (sz(1) - 48.0) < tol)
-        typ = "arch-e";
+        ptype = "arch-e";
       else if (std::abs (sz(0) - 8.5)
                + std::abs (sz(1) - 11.0) < tol)
-        typ = "a";
+        ptype = "a";
       else if (std::abs (sz(0) - 11.0)
                + std::abs (sz(1) - 17.0) < tol)
-        typ = "b";
+        ptype = "b";
       else if (std::abs (sz(0) - 17.0)
                + std::abs (sz(1) - 22.0) < tol)
-        typ = "c";
+        ptype = "c";
       else if (std::abs (sz(0) - 22.0)
                + std::abs (sz(1) - 34.0) < tol)
-        typ = "d";
+        ptype = "d";
       else if (std::abs (sz(0) - 34.0)
                + std::abs (sz(1) - 43.0) < tol)
-        typ = "e";
+        ptype = "e";
       // Call papertype.set rather than set_papertype to avoid loops between
       // update_papersize and update_papertype
-      papertype.set (typ);
+      papertype.set (ptype);
     }
   if (punits == "centimeters")
     {
@@ -4581,16 +4393,14 @@
 */
 
 void
-figure::properties::set_units (const octave_value& v)
-{
-  if (! error_state)
-    {
-      caseless_str old_units = get_units ();
-      if (units.set (v, true))
-        {
-          update_units (old_units);
-          mark_modified ();
-        }
+figure::properties::set_units (const octave_value& val)
+{
+  caseless_str old_units = get_units ();
+
+  if (units.set (val, true))
+    {
+      update_units (old_units);
+      mark_modified ();
     }
 }
 
@@ -4644,10 +4454,10 @@
 
   if (retval.is_undefined ())
     {
-      graphics_handle parent = get_parent ();
-      graphics_object parent_obj = gh_manager::get_object (parent);
-
-      retval = parent_obj.get_default (name);
+      graphics_handle parent_h = get_parent ();
+      graphics_object parent_go = gh_manager::get_object (parent_h);
+
+      retval = parent_go.get_default (name);
     }
 
   return retval;
@@ -4682,6 +4492,8 @@
   colororder.add_constraint (dim_vector (-1, 3));
   dataaspectratio.add_constraint (dim_vector (1, 3));
   plotboxaspectratio.add_constraint (dim_vector (1, 3));
+  // FIXME: Should these use dimension vectors?  Currently can set 'xlim' to
+  // any matrix size, but only first two elements are used.
   alim.add_constraint (2);
   clim.add_constraint (2);
   xlim.add_constraint (2);
@@ -4766,8 +4578,8 @@
 axes::properties::calc_tightbox (const Matrix& init_pos)
 {
   Matrix pos = init_pos;
-  graphics_object obj = gh_manager::get_object (get_parent ());
-  Matrix parent_bb = obj.get_properties ().get_boundingbox (true);
+  graphics_object go = gh_manager::get_object (get_parent ());
+  Matrix parent_bb = go.get_properties ().get_boundingbox (true);
   Matrix ext = get_extent (true, true);
   ext(1) = parent_bb(3) - ext(1) - ext(3);
   ext(0)++;
@@ -4789,6 +4601,7 @@
     }
   if (ext(1)+ext(3) > pos(1)+pos(3))
     pos(3) = ext(1)+ext(3)-pos(1);
+
   return pos;
 }
 
@@ -4904,18 +4717,15 @@
              who.c_str (), cname.c_str ());
     }
 
-  if (! error_state)
-    {
-      xset (val, "handlevisibility", "off");
-
-      gh_manager::free (hp.handle_value ());
-
-      base_properties::remove_child (hp.handle_value ());
-
-      hp = val;
-
-      adopt (hp.handle_value ());
-    }
+  xset (val, "handlevisibility", "off");
+
+  gh_manager::free (hp.handle_value ());
+
+  base_properties::remove_child (hp.handle_value ());
+
+  hp = val;
+
+  adopt (hp.handle_value ());
 }
 
 void
@@ -4975,7 +4785,7 @@
 }
 
 void
-axes::properties::set_defaults (base_graphics_object& obj,
+axes::properties::set_defaults (base_graphics_object& bgo,
                                 const std::string& mode)
 {
   box = "on";
@@ -4986,16 +4796,15 @@
 
   Matrix tlim (1, 2, 0.0);
   tlim(1) = 1;
+  alim = tlim;
   xlim = tlim;
   ylim = tlim;
   zlim = tlim;
 
-  Matrix cl (1, 2, 0);
+  Matrix cl (1, 2, 0.0);
   cl(1) = 1;
   clim = cl;
 
-  alim = tlim;
-
   xlimmode = "auto";
   ylimmode = "auto";
   zlimmode = "auto";
@@ -5024,7 +4833,7 @@
   yticklabelmode = "auto";
   zticklabelmode = "auto";
 
-  interpreter = "none";
+  ticklabelinterpreter = "tex";
 
   color = color_values ("white");
   xcolor = color_values ("black");
@@ -5169,7 +4978,7 @@
 
   update_transform ();
   sync_positions ();
-  override_defaults (obj);
+  override_defaults (bgo);
 }
 
 void
@@ -5234,8 +5043,10 @@
 xform_matrix (void)
 {
   Matrix m (4, 4, 0.0);
+
   for (int i = 0; i < 4; i++)
     m(i,i) = 1;
+
   return m;
 }
 
@@ -5243,7 +5054,9 @@
 xform_vector (void)
 {
   ColumnVector v (4, 0.0);
+
   v(3) = 1;
+
   return v;
 }
 
@@ -5251,7 +5064,11 @@
 xform_vector (double x, double y, double z)
 {
   ColumnVector v (4, 1.0);
-  v(0) = x; v(1) = y; v(2) = z;
+
+  v(0) = x;
+  v(1) = y;
+  v(2) = z;
+
   return v;
 }
 
@@ -5265,7 +5082,12 @@
 xform_scale (double x, double y, double z)
 {
   Matrix m (4, 4, 0.0);
-  m(0,0) = x; m(1,1) = y; m(2,2) = z; m(3,3) = 1;
+
+  m(0,0) = x;
+  m(1,1) = y;
+  m(2,2) = z;
+  m(3,3) = 1;
+
   return m;
 }
 
@@ -5273,7 +5095,12 @@
 xform_translate (double x, double y, double z)
 {
   Matrix m = xform_matrix ();
-  m(0,3) = x; m(1,3) = y; m(2,3) = z; m(3,3) = 1;
+
+  m(0,3) = x;
+  m(1,3) = y;
+  m(2,3) = z;
+  m(3,3) = 1;
+
   return m;
 }
 
@@ -5292,7 +5119,7 @@
 inline void
 xform (ColumnVector& v, const Matrix& m)
 {
-  v = m*v;
+  v = m * v;
 }
 
 inline void
@@ -5334,9 +5161,11 @@
 cross (const ColumnVector& v1, const ColumnVector& v2)
 {
   ColumnVector r = xform_vector ();
-  r(0) = v1(1)*v2(2)-v1(2)*v2(1);
-  r(1) = v1(2)*v2(0)-v1(0)*v2(2);
-  r(2) = v1(0)*v2(1)-v1(1)*v2(0);
+
+  r(0) = v1(1)*v2(2) - v1(2)*v2(1);
+  r(1) = v1(2)*v2(0) - v1(0)*v2(2);
+  r(2) = v1(0)*v2(1) - v1(1)*v2(0);
+
   return r;
 }
 
@@ -5355,7 +5184,9 @@
     1,1,1,1
   };
   Matrix m (4, 8);
+
   memcpy (m.fortran_vec (), data, sizeof (double)*32);
+
   return m;
 }
 
@@ -5363,7 +5194,9 @@
 cam2xform (const Array<double>& m)
 {
   ColumnVector retval (4, 1.0);
+
   memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof (double)*3);
+
   return retval;
 }
 
@@ -5403,9 +5236,9 @@
 
   if (cameratargetmode_is ("auto"))
     {
-      c_center(0) = (xlimits(0)+xlimits(1))/2;
-      c_center(1) = (ylimits(0)+ylimits(1))/2;
-      c_center(2) = (zlimits(0)+zlimits(1))/2;
+      c_center(0) = (xlimits(0) + xlimits(1)) / 2;
+      c_center(1) = (ylimits(0) + ylimits(1)) / 2;
+      c_center(2) = (zlimits(0) + zlimits(1)) / 2;
 
       cameratarget = xform2cam (c_center);
     }
@@ -5417,7 +5250,7 @@
       Matrix tview = get_view ().matrix_value ();
       double az = tview(0);
       double 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);
@@ -5486,7 +5319,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);
     }
 
@@ -5506,8 +5339,8 @@
   Matrix x_cube = x_view * unit_cube ();
   ColumnVector cmin = x_cube.row_min ();
   ColumnVector cmax = x_cube.row_max ();
-  double xM = cmax(0)-cmin(0);
-  double yM = cmax(1)-cmin(1);
+  double xM = cmax(0) - cmin(0);
+  double yM = cmax(1) - cmin(1);
 
   Matrix bb = get_boundingbox (true);
 
@@ -5584,9 +5417,8 @@
 
   x_render_inv = x_render.inverse ();
 
-  // Note: these matrices are a slight modified version of the regular
-  // matrices, more suited for OpenGL rendering (x_gl_mat1 => light
-  // => x_gl_mat2)
+  // Note: these matrices are a slight modified version of the regular matrices,
+  // more suited for OpenGL rendering (x_gl_mat1 => light => x_gl_mat2)
   x_gl_mat1 = x_view;
   scale (x_gl_mat1, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)),
          zd/(zlimits(1)-zlimits(0)));
@@ -5623,9 +5455,9 @@
 
   p1 = xform.transform (x_min, (y_min+y_max)/2, (z_min+z_max)/2, false);
   p2 = xform.transform (x_max, (y_min+y_max)/2, (z_min+z_max)/2, false);
-  dir(0) = xround (p2(0)-p1(0));
-  dir(1) = xround (p2(1)-p1(1));
-  dir(2) = (p2(2)-p1(2));
+  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)
     xstate = AXE_DEPTH_DIR;
   else if (dir(2) == 0)
@@ -5647,13 +5479,13 @@
     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));
-
-  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);
-  dir(0) = xround (p2(0)-p1(0));
-  dir(1) = xround (p2(1)-p1(1));
-  dir(2) = (p2(2)-p1(2));
+  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);
+  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)
     ystate = AXE_DEPTH_DIR;
   else if (dir(2) == 0)
@@ -5675,13 +5507,13 @@
     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));
-  dir(1) = xround (p2(1)-p1(1));
-  dir(2) = (p2(2)-p1(2));
+  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)
     zstate = AXE_DEPTH_DIR;
   else if (dir(2) == 0)
@@ -5703,7 +5535,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);
@@ -5769,8 +5601,8 @@
 
   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));
+  ticklen(0) *= std::max (bbox(2), bbox(3));
+  ticklen(1) *= std::max (bbox(2), bbox(3));
 
   xticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1));
   yticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1));
@@ -5841,13 +5673,13 @@
   if (updating_xlabel_position)
     return;
 
-  graphics_object obj = gh_manager::get_object (get_xlabel ());
-
-  if (! obj.valid_object ())
+  graphics_object go = gh_manager::get_object (get_xlabel ());
+
+  if (! go.valid_object ())
     return;
 
   text::properties& xlabel_props
-    = reinterpret_cast<text::properties&> (obj.get_properties ());
+    = reinterpret_cast<text::properties&> (go.get_properties ());
 
   bool is_empty = xlabel_props.get_string ().is_empty ();
 
@@ -5860,8 +5692,7 @@
       if (xlabel_props.horizontalalignmentmode_is ("auto"))
         {
           xlabel_props.set_horizontalalignment
-            (xstate > AXE_DEPTH_DIR
-             ? "center" : (xyzSym ? "left" : "right"));
+            (xstate > AXE_DEPTH_DIR ? "center" : (xyzSym ? "left" : "right"));
 
           xlabel_props.set_horizontalalignmentmode ("auto");
         }
@@ -5887,15 +5718,15 @@
 
       double wmax = ext(0);
       double hmax = ext(1);
-      double angle = 0;
+      double angle = 0.0;
       ColumnVector p =
-        graphics_xform::xform_vector ((xpTickN+xpTick)/2, ypTick, zpTick);
+        graphics_xform::xform_vector ((xpTickN + xpTick)/2, ypTick, zpTick);
 
       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);
 
@@ -5943,13 +5774,13 @@
   if (updating_ylabel_position)
     return;
 
-  graphics_object obj = gh_manager::get_object (get_ylabel ());
-
-  if (! obj.valid_object ())
+  graphics_object go = gh_manager::get_object (get_ylabel ());
+
+  if (! go.valid_object ())
     return;
 
   text::properties& ylabel_props
-    = reinterpret_cast<text::properties&> (obj.get_properties ());
+    = reinterpret_cast<text::properties&> (go.get_properties ());
 
   bool is_empty = ylabel_props.get_string ().is_empty ();
 
@@ -5962,8 +5793,7 @@
       if (ylabel_props.horizontalalignmentmode_is ("auto"))
         {
           ylabel_props.set_horizontalalignment
-            (ystate > AXE_DEPTH_DIR
-             ? "center" : (!xyzSym ? "left" : "right"));
+            (ystate > AXE_DEPTH_DIR ? "center" : (!xyzSym ? "left" : "right"));
 
           ylabel_props.set_horizontalalignmentmode ("auto");
         }
@@ -5998,15 +5828,15 @@
 
       double wmax = ext(0)+4;
       double hmax = ext(1);
-      double angle = 0;
+      double angle = 0.0;
       ColumnVector p =
-        graphics_xform::xform_vector (xpTick, (ypTickN+ypTick)/2, zpTick);
+        graphics_xform::xform_vector (xpTick, (ypTickN + ypTick)/2, zpTick);
 
       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);
 
@@ -6054,13 +5884,13 @@
   if (updating_zlabel_position)
     return;
 
-  graphics_object obj = gh_manager::get_object (get_zlabel ());
-
-  if (! obj.valid_object ())
+  graphics_object go = gh_manager::get_object (get_zlabel ());
+
+  if (! go.valid_object ())
     return;
 
   text::properties& zlabel_props
-    = reinterpret_cast<text::properties&> (obj.get_properties ());
+    = reinterpret_cast<text::properties&> (go.get_properties ());
 
   bool camAuto = cameraupvectormode_is ("auto");
   bool is_empty = zlabel_props.get_string ().is_empty ();
@@ -6101,26 +5931,26 @@
 
       double wmax = ext(0);
       double hmax = ext(1);
-      double angle = 0;
+      double angle = 0.0;
       ColumnVector p;
 
       if (xySym)
         {
           p = graphics_xform::xform_vector (xPlaneN, yPlane,
-                                            (zpTickN+zpTick)/2);
+                                            (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);
+                                            (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);
@@ -6178,13 +6008,13 @@
   if (updating_title_position)
     return;
 
-  graphics_object obj = gh_manager::get_object (get_title ());
-
-  if (! obj.valid_object ())
+  graphics_object go = gh_manager::get_object (get_title ());
+
+  if (! go.valid_object ())
     return;
 
   text::properties& title_props
-    = reinterpret_cast<text::properties&> (obj.get_properties ());
+    = reinterpret_cast<text::properties&> (go.get_properties ());
 
   unwind_protect frame;
   frame.protect_var (updating_title_position);
@@ -6198,9 +6028,9 @@
       Matrix bbox = get_extent (false);
 
       ColumnVector p =
-        graphics_xform::xform_vector (bbox(0)+bbox(2)/2,
-                                      bbox(1)-10,
-                                      (x_zlim(0)+x_zlim(1))/2);
+        graphics_xform::xform_vector (bbox(0) + bbox(2)/2,
+                                      bbox(1) - 10,
+                                      (x_zlim(0) + x_zlim(1))/2);
 
       if (x2Dtop)
         {
@@ -6239,15 +6069,15 @@
 normalized_aspectratios (Matrix& aspectratios, const Matrix& scalefactors,
                          double xlength, double ylength, double zlength)
 {
-  double xval = xlength/scalefactors(0);
-  double yval = ylength/scalefactors(1);
-  double zval = zlength/scalefactors(2);
+  double xval = xlength / scalefactors(0);
+  double yval = ylength / scalefactors(1);
+  double zval = zlength / scalefactors(2);
 
   double minval = xmin (xmin (xval, yval), zval);
 
-  aspectratios(0) = xval/minval;
-  aspectratios(1) = yval/minval;
-  aspectratios(2) = zval/minval;
+  aspectratios(0) = xval / minval;
+  aspectratios(1) = yval / minval;
+  aspectratios(2) = zval / minval;
 }
 
 static void
@@ -6265,11 +6095,11 @@
         {
           limits(0) = minval;
           limits(1) = maxval;
-          s = xmax(s, (maxval - minval) / (pbfactor * dafactor));
-        }
-    }
-  else
-    s = xmax(s, (limits(1) - limits(0)) / (pbfactor * dafactor));
+          s = xmax (s, (maxval - minval) / (pbfactor * dafactor));
+        }
+    }
+  else
+    s = xmax (s, (limits(1) - limits(0)) / (pbfactor * dafactor));
 }
 
 static std::set<double> updating_aspectratios;
@@ -6285,9 +6115,9 @@
   Matrix ylimits = get_ylim ().matrix_value ();
   Matrix zlimits = get_zlim ().matrix_value ();
 
-  double dx = (xlimits(1)-xlimits(0));
-  double dy = (ylimits(1)-ylimits(0));
-  double dz = (zlimits(1)-zlimits(0));
+  double dx = (xlimits(1) - xlimits(0));
+  double dy = (ylimits(1) - ylimits(0));
+  double dz = (zlimits(1) - zlimits(0));
 
   Matrix da = get_dataaspectratio ().matrix_value ();
   Matrix pba = get_plotboxaspectratio ().matrix_value ();
@@ -6340,15 +6170,14 @@
 
       if (modified_limits)
         {
-
           unwind_protect frame;
           frame.protect_var (updating_aspectratios);
 
           updating_aspectratios.insert (get___myhandle__ ().value ());
 
-          dx = pba(0) *da(0);
-          dy = pba(1) *da(1);
-          dz = pba(2) *da(2);
+          dx = pba(0) * da(0);
+          dy = pba(1) * da(1);
+          dz = pba(2) * da(2);
           if (xisinf (s))
             s = 1 / xmin (xmin (dx, dy), dz);
 
@@ -6410,13 +6239,13 @@
                         : get_outerposition ().matrix_value ();
   Matrix parent_size (parent_pix_size);
 
-  if (parent_size.numel () == 0)
-    {
-      graphics_object obj = gh_manager::get_object (get_parent ());
-
-      if (obj.valid_object ())
+  if (parent_size.is_empty ())
+    {
+      graphics_object go = gh_manager::get_object (get_parent ());
+
+      if (go.valid_object ())
         parent_size =
-          obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
+          go.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
       else
         parent_size = default_figure_position ();
     }
@@ -6436,10 +6265,8 @@
   graphics_xform xform = get_transform ();
 
   Matrix ext (1, 4, 0.0);
-  ext(0) = octave_Inf;
-  ext(1) = octave_Inf;
-  ext(2) = -octave_Inf;
-  ext(3) = -octave_Inf;
+  ext(0) = ext(1) = octave_Inf;
+  ext(2) = ext(3) = -octave_Inf;
   for (int i = 0; i <= 1; i++)
     for (int j = 0; j <= 1; j++)
       for (int k = 0; k <= 1; k++)
@@ -6457,19 +6284,19 @@
     {
       for (int i = 0; i < 4; i++)
         {
-          graphics_handle text_handle;
+          graphics_handle htext;
           if (i == 0)
-            text_handle = get_title ();
+            htext = get_title ();
           else if (i == 1)
-            text_handle = get_xlabel ();
+            htext = get_xlabel ();
           else if (i == 2)
-            text_handle = get_ylabel ();
+            htext = get_ylabel ();
           else if (i == 3)
-            text_handle = get_zlabel ();
+            htext = get_zlabel ();
 
           text::properties& text_props
             = reinterpret_cast<text::properties&>
-                (gh_manager::get_object (text_handle).get_properties ());
+                (gh_manager::get_object (htext).get_properties ());
 
           Matrix text_pos = text_props.get_data_position ();
           text_pos = xform.transform (text_pos(0), text_pos(1), text_pos(2));
@@ -6512,8 +6339,8 @@
         }
     }
 
-  ext(2) = ext(2)-ext(0);
-  ext(3) = ext(3)-ext(1);
+  ext(2) = ext(2) - ext(0);
+  ext(3) = ext(3) - ext(1);
 
   return ext;
 }
@@ -6525,7 +6352,7 @@
 
   if (val.is_cellstr ())
     {
-      // Always return a column vector for Matlab Compatibility
+      // Always return a column vector for Matlab compatibility
       if (val.columns () > 1)
         retval = val.reshape (dim_vector (val.numel (), 1));
     }
@@ -6570,57 +6397,48 @@
 }
 
 void
-axes::properties::set_xticklabel (const octave_value& v)
-{
-  if (!error_state)
-    {
-      if (xticklabel.set (convert_ticklabel_string (v), false))
-        {
-          set_xticklabelmode ("manual");
-          xticklabel.run_listeners (POSTSET);
-          mark_modified ();
-        }
-      else
-        set_xticklabelmode ("manual");
-
-      sync_positions ();
-    }
-}
-
-void
-axes::properties::set_yticklabel (const octave_value& v)
-{
-  if (!error_state)
-    {
-      if (yticklabel.set (convert_ticklabel_string (v), false))
-        {
-          set_yticklabelmode ("manual");
-          yticklabel.run_listeners (POSTSET);
-          mark_modified ();
-        }
-      else
-        set_yticklabelmode ("manual");
-
-      sync_positions ();
-    }
-}
-
-void
-axes::properties::set_zticklabel (const octave_value& v)
-{
-  if (!error_state)
-    {
-      if (zticklabel.set (convert_ticklabel_string (v), false))
-        {
-          set_zticklabelmode ("manual");
-          zticklabel.run_listeners (POSTSET);
-          mark_modified ();
-        }
-      else
-        set_zticklabelmode ("manual");
-
-      sync_positions ();
-    }
+axes::properties::set_xticklabel (const octave_value& val)
+{
+  if (xticklabel.set (convert_ticklabel_string (val), false))
+    {
+      set_xticklabelmode ("manual");
+      xticklabel.run_listeners (POSTSET);
+      mark_modified ();
+    }
+  else
+    set_xticklabelmode ("manual");
+
+  sync_positions ();
+}
+
+void
+axes::properties::set_yticklabel (const octave_value& val)
+{
+  if (yticklabel.set (convert_ticklabel_string (val), false))
+    {
+      set_yticklabelmode ("manual");
+      yticklabel.run_listeners (POSTSET);
+      mark_modified ();
+    }
+  else
+    set_yticklabelmode ("manual");
+
+  sync_positions ();
+}
+
+void
+axes::properties::set_zticklabel (const octave_value& val)
+{
+  if (zticklabel.set (convert_ticklabel_string (val), false))
+    {
+      set_zticklabelmode ("manual");
+      zticklabel.run_listeners (POSTSET);
+      mark_modified ();
+    }
+  else
+    set_zticklabelmode ("manual");
+
+  sync_positions ();
 }
 
 // Almost identical to convert_ticklabel_string but it only accepts
@@ -6665,34 +6483,29 @@
 }
 
 void
-axes::properties::set_linestyleorder (const octave_value& v)
-{
-  if (!error_state)
-    {
-      linestyleorder.set (convert_linestyleorder_string (v), false);
-    }
-}
-
-void
-axes::properties::set_units (const octave_value& v)
-{
-  if (! error_state)
-    {
-      caseless_str old_units = get_units ();
-      if (units.set (v, true))
-        {
-          update_units (old_units);
-          mark_modified ();
-        }
+axes::properties::set_linestyleorder (const octave_value& val)
+{
+  linestyleorder.set (convert_linestyleorder_string (val), false);
+}
+
+void
+axes::properties::set_units (const octave_value& val)
+{
+  caseless_str old_units = get_units ();
+
+  if (units.set (val, true))
+    {
+      update_units (old_units);
+      mark_modified ();
     }
 }
 
 void
 axes::properties::update_units (const caseless_str& old_units)
 {
-  graphics_object obj = gh_manager::get_object (get_parent ());
+  graphics_object parent_go = gh_manager::get_object (get_parent ());
   Matrix parent_bb
-    = obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
+    = parent_go.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,
@@ -6713,16 +6526,14 @@
 }
 
 void
-axes::properties::set_fontunits (const octave_value& v)
-{
-  if (! error_state)
-    {
-      caseless_str old_fontunits = get_fontunits ();
-      if (fontunits.set (v, true))
-        {
-          update_fontunits (old_fontunits);
-          mark_modified ();
-        }
+axes::properties::set_fontunits (const octave_value& val)
+{
+  caseless_str old_fontunits = get_fontunits ();
+
+  if (fontunits.set (val, true))
+    {
+      update_fontunits (old_fontunits);
+      mark_modified ();
     }
 }
 
@@ -6731,23 +6542,23 @@
 {
   caseless_str new_units = get_fontunits ();
   double parent_height = get_boundingbox (true).elem (3);
-  double fsz = get_fontsize ();
-
-  fsz = convert_font_size (fsz, old_units, new_units, parent_height);
-
-  set_fontsize (octave_value (fsz));
+  double fontsz = get_fontsize ();
+
+  fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
+
+  set_fontsize (octave_value (fontsz));
 }
 
 double
 axes::properties::get_fontsize_points (double box_pix_height) const
 {
-  double fs = get_fontsize ();
+  double fontsz = get_fontsize ();
   double parent_height = box_pix_height;
 
   if (fontunits_is ("normalized") && parent_height <= 0)
     parent_height = get_boundingbox (true).elem (3);
 
-  return convert_font_size (fs, get_fontunits (), "points", parent_height);
+  return convert_font_size (fontsz, get_fontunits (), "points", parent_height);
 }
 
 ColumnVector
@@ -6763,8 +6574,7 @@
 }
 
 ColumnVector
-graphics_xform::transform (double x, double y, double z,
-                           bool use_scale) const
+graphics_xform::transform (double x, double y, double z, bool use_scale) const
 {
   if (use_scale)
     {
@@ -6793,16 +6603,16 @@
 }
 
 octave_value
-axes::get_default (const caseless_str& name) const
-{
-  octave_value retval = default_properties.lookup (name);
+axes::get_default (const caseless_str& pname) const
+{
+  octave_value retval = default_properties.lookup (pname);
 
   if (retval.is_undefined ())
     {
-      graphics_handle parent = get_parent ();
-      graphics_object parent_obj = gh_manager::get_object (parent);
-
-      retval = parent_obj.get_default (name);
+      graphics_handle parent_h = get_parent ();
+      graphics_object parent_go = gh_manager::get_object (parent_h);
+
+      retval = parent_go.get_default (pname);
     }
 
   return retval;
@@ -6840,7 +6650,7 @@
     {
       Matrix m = data.matrix_value ();
 
-      if (! error_state && m.numel () == 4)
+      if (m.numel () == 4)
         {
           double val;
 
@@ -6863,8 +6673,8 @@
     }
 }
 
-// magform(x) Returns (a, b), where x = a * 10^b, abs (a) >= 1., and b is
-// integer.
+// magform(x) Returns (a, b),
+// where x = a * 10^b, abs (a) >= 1., and b is integer.
 
 static void
 magform (double x, double& a, int& b)
@@ -6890,15 +6700,15 @@
 {
   int ticint = 5;
 
-  // Reference: Lewart, C. R., "Algorithms SCALE1, SCALE2, and
-  // SCALE3 for Determination of Scales on Computer Generated
-  // Plots", Communications of the ACM, 10 (1973), 639-640.
+  // Reference: Lewart, C. R., "Algorithms SCALE1, SCALE2, and SCALE3 for
+  // Determination of Scales on Computer Generated Plots", Communications of
+  // the ACM, 10 (1973), 639-640.
   // Also cited as ACM Algorithm 463.
 
   double a;
   int b, x;
 
-  magform ((hi-lo)/ticint, a, b);
+  magform ((hi - lo) / ticint, a, b);
 
   static const double sqrt_2 = sqrt (2.0);
   static const double sqrt_10 = sqrt (10.0);
@@ -6914,12 +6724,10 @@
     x = 10;
 
   return x * std::pow (10., b);
-
-}
-
-// Attempt to make "nice" limits from the actual max and min of the
-// data.  For log plots, we will also use the smallest strictly positive
-// value.
+}
+
+// Attempt to make "nice" limits from the actual max and min of the data.
+// For log plots, we will also use the smallest strictly positive value.
 
 Matrix
 axes::properties::get_axis_limits (double xmin, double xmax,
@@ -6942,15 +6750,15 @@
         {
           if (xisinf (min_pos) && xisinf (max_neg))
             {
-              // TODO -- max_neg is needed for "loglog ([0 -Inf])"
-              //         This is the only place where max_neg is needed.
-              //         Is there another way?
+              // FIXME: max_neg is needed for "loglog ([0 -Inf])"
+              //        This is the *only* place where max_neg is needed.
+              //        Is there another way?
               retval = default_lim ();
               retval(0) = pow (10., retval(0));
               retval(1) = pow (10., retval(1));
               return retval;
             }
-          if ((min_val <= 0 && max_val > 0))
+          if (min_val <= 0 && max_val > 0)
             {
               warning ("axis: omitting non-positive data in log plot");
               min_val = min_pos;
@@ -6999,7 +6807,7 @@
               max_val += 0.1 * std::abs (max_val);
             }
 
-          double tick_sep = calc_tick_sep (min_val , max_val);
+          double tick_sep = calc_tick_sep (min_val, max_val);
           double min_tick = gnulib::floor (min_val / tick_sep);
           double max_tick = std::ceil (max_val / tick_sep);
           // Prevent round-off from cropping ticks
@@ -7027,8 +6835,8 @@
   if (lims.get ().is_empty ())
     return;
 
-  double lo = (lims.get ().matrix_value ()) (0);
-  double hi = (lims.get ().matrix_value ()) (1);
+  double lo = (lims.get ().matrix_value ())(0);
+  double hi = (lims.get ().matrix_value ())(1);
   bool is_negative = lo < 0 && hi < 0;
   double tmp;
   // FIXME: should this be checked for somewhere else? (i.e. set{x,y,z}lim)
@@ -7060,22 +6868,22 @@
         tick_sep = 0;
     }
   else
-    tick_sep = calc_tick_sep (lo , hi);
+    tick_sep = calc_tick_sep (lo, hi);
 
   int i1 = static_cast<int> (gnulib::floor (lo / tick_sep));
   int i2 = static_cast<int> (std::ceil (hi / tick_sep));
 
   if (limmode_is_auto)
     {
-      // adjust limits to include min and max tics
+      // Adjust limits to include min and max ticks
       Matrix tmp_lims (1,2);
       tmp_lims(0) = std::min (tick_sep * i1, lo);
       tmp_lims(1) = std::max (tick_sep * i2, hi);
 
       if (is_logscale)
         {
-          tmp_lims(0) = std::pow (10.,tmp_lims(0));
-          tmp_lims(1) = std::pow (10.,tmp_lims(1));
+          tmp_lims(0) = std::pow (10., tmp_lims(0));
+          tmp_lims(1) = std::pow (10., tmp_lims(1));
           if (tmp_lims(0) <= 0)
             tmp_lims(0) = std::pow (10., lo);
           if (is_negative)
@@ -7087,20 +6895,28 @@
         }
       lims = tmp_lims;
     }
+  else
+    {
+      // adjust min and max ticks to be within limits
+      if (i1*tick_sep < lo)
+        i1++;
+      if (i2*tick_sep > hi && i2 > i1)
+        i2--;
+    }
 
   Matrix tmp_ticks (1, i2-i1+1);
   for (int i = 0; i <= i2-i1; i++)
     {
-      tmp_ticks (i) = tick_sep * (i+i1);
+      tmp_ticks(i) = tick_sep * (i+i1);
       if (is_logscale)
-        tmp_ticks (i) = std::pow (10., tmp_ticks (i));
+        tmp_ticks(i) = std::pow (10., tmp_ticks(i));
     }
   if (is_logscale && is_negative)
     {
       Matrix rev_ticks (1, i2-i1+1);
       rev_ticks = -tmp_ticks;
       for (int i = 0; i <= i2-i1; i++)
-        tmp_ticks (i) = rev_ticks (i2-i1-i);
+        tmp_ticks(i) = rev_ticks(i2-i1-i);
     }
 
   ticks = tmp_ticks;
@@ -7110,15 +6926,28 @@
 
   for (int i = 0; i < tmp_ticks.numel ()-1; i++)
     {
-      double d = (tmp_ticks (i+1) - tmp_ticks (i)) / (n+1);
+      double d = (tmp_ticks(i+1) - tmp_ticks(i)) / (n + 1);
       for (int j = 0; j < n; j++)
         {
-          tmp_mticks (n*i+j) = tmp_ticks (i) + d * (j+1);
+          tmp_mticks(n*i+j) = tmp_ticks(i) + d * (j+1);
         }
     }
   mticks = tmp_mticks;
 }
 
+/*
+%!test  # Bug #45356
+%! hf = figure ("visible", "off");
+%! unwind_protect
+%!   plot (1:10);
+%!   xlim ([4.75, 8.5]);
+%!   tics = get (gca, "xtick");
+%!   assert (tics, [5 6 7 8]);
+%! unwind_protect_cleanup
+%!   close (hf);
+%! end_unwind_protect
+*/
+
 void
 axes::properties::calc_ticklabels (const array_property& ticks,
                                    any_property& labels, bool logscale)
@@ -7131,8 +6960,8 @@
     {
       double significand;
       double exponent;
-      double exp_max = 0.;
-      double exp_min = 0.;
+      double exp_max = 0.0;
+      double exp_min = 0.0;
 
       for (int i = 0; i < values.numel (); i++)
         {
@@ -7142,23 +6971,29 @@
 
       for (int i = 0; i < values.numel (); i++)
         {
-          if (values(i) < 0.)
+          if (values(i) < 0.0)
             exponent = gnulib::floor (std::log10 (-values(i)));
           else
             exponent = gnulib::floor (std::log10 (values(i)));
           significand = values(i) * std::pow (10., -exponent);
+
           os.str (std::string ());
-          os << significand;
-          if (exponent < 0.)
-            {
-              os << "e-";
+          if ((std::abs (significand) - 1) >
+              std::numeric_limits<double>::epsilon())
+            os << significand << ".";
+          else if (significand < 0)
+            os << "-";
+
+          os << "10^{";
+
+          if (exponent < 0.0)
+            {
+              os << "-";
               exponent = -exponent;
             }
-          else
-            os << "e+";
           if (exponent < 10. && (exp_max > 9 || exp_min < -9))
             os << "0";
-          os << exponent;
+          os << exponent << "}";
           c(i) = os.str ();
         }
     }
@@ -7186,7 +7021,7 @@
 
   Matrix ext (1, 2, 0.0);
   double wmax, hmax;
-  wmax = hmax = 0.;
+  wmax = hmax = 0.0;
   int n = std::min (ticklabels.numel (), ticks.numel ());
   for (int i = 0; i < n; i++)
     {
@@ -7197,7 +7032,8 @@
           label.erase (0, label.find_first_not_of (" "));
           label = label.substr (0, label.find_last_not_of (" ")+1);
 #ifdef HAVE_FREETYPE
-          ext = text_renderer.get_extent (label, 0.0, "none");
+          ext = text_renderer.get_extent (label, 0.0,
+                                          get_ticklabelinterpreter ());
           wmax = std::max (wmax, ext(0));
           hmax = std::max (hmax, ext(1));
 #else
@@ -7226,11 +7062,11 @@
     case 'x':
       for (octave_idx_type i = 0; i < n; i++)
         {
-          graphics_object obj = gh_manager::get_object (kids(i));
-
-          if (obj.is_xliminclude ())
-            {
-              octave_value lim = obj.get_xlim ();
+          graphics_object go = gh_manager::get_object (kids(i));
+
+          if (go.is_xliminclude ())
+            {
+              octave_value lim = go.get_xlim ();
 
               check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
             }
@@ -7240,11 +7076,11 @@
     case 'y':
       for (octave_idx_type i = 0; i < n; i++)
         {
-          graphics_object obj = gh_manager::get_object (kids(i));
-
-          if (obj.is_yliminclude ())
-            {
-              octave_value lim = obj.get_ylim ();
+          graphics_object go = gh_manager::get_object (kids(i));
+
+          if (go.is_yliminclude ())
+            {
+              octave_value lim = go.get_ylim ();
 
               check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
             }
@@ -7254,11 +7090,11 @@
     case 'z':
       for (octave_idx_type i = 0; i < n; i++)
         {
-          graphics_object obj = gh_manager::get_object (kids(i));
-
-          if (obj.is_zliminclude ())
-            {
-              octave_value lim = obj.get_zlim ();
+          graphics_object go = gh_manager::get_object (kids(i));
+
+          if (go.is_zliminclude ())
+            {
+              octave_value lim = go.get_zlim ();
 
               check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
             }
@@ -7268,11 +7104,11 @@
     case 'c':
       for (octave_idx_type i = 0; i < n; i++)
         {
-          graphics_object obj = gh_manager::get_object (kids(i));
-
-          if (obj.is_climinclude ())
-            {
-              octave_value lim = obj.get_clim ();
+          graphics_object go = gh_manager::get_object (kids(i));
+
+          if (go.is_climinclude ())
+            {
+              octave_value lim = go.get_clim ();
 
               check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
             }
@@ -7282,11 +7118,11 @@
     case 'a':
       for (octave_idx_type i = 0; i < n; i++)
         {
-          graphics_object obj = gh_manager::get_object (kids(i));
-
-          if (obj.is_aliminclude ())
-            {
-              octave_value lim = obj.get_alim ();
+          graphics_object go = gh_manager::get_object (kids(i));
+
+          if (go.is_aliminclude ())
+            {
+              octave_value lim = go.get_alim ();
 
               check_limit_vals (min_val, max_val, min_pos, max_neg, lim);
             }
@@ -7501,7 +7337,6 @@
     }
 
   xproperties.update_transform ();
-
 }
 
 void
@@ -7944,11 +7779,10 @@
     new_view(0) += 360.0;
 
   // Snapping
-  double snapMargin = 1.0;
+  double snapmargin = 1.0;
   for (int a = -90; a <= 90; a += 90)
     {
-      if ((a - snapMargin) < new_view(1)
-          && new_view(1) < (a + snapMargin))
+      if ((a - snapmargin) < new_view(1) && new_view(1) < (a + snapmargin))
         {
           new_view(1) = a;
           break;
@@ -7956,8 +7790,7 @@
     }
 
   for (int a = -180; a <= 180; a += 180)
-    if ((a - snapMargin) < new_view(0)
-        && new_view(0) < (a + snapMargin))
+    if ((a - snapmargin) < new_view(0) && new_view(0) < (a + snapmargin))
       {
         if (a == 180)
           new_view(0) = -180;
@@ -8128,16 +7961,14 @@
 }
 
 void
-text::properties::set_fontunits (const octave_value& v)
-{
-  if (! error_state)
-    {
-      caseless_str old_fontunits = get_fontunits ();
-      if (fontunits.set (v, true))
-        {
-          update_fontunits (old_fontunits);
-          mark_modified ();
-        }
+text::properties::set_fontunits (const octave_value& val)
+{
+  caseless_str old_fontunits = get_fontunits ();
+
+  if (fontunits.set (val, true))
+    {
+      update_fontunits (old_fontunits);
+      mark_modified ();
     }
 }
 
@@ -8146,7 +7977,7 @@
 {
   caseless_str new_units = get_fontunits ();
   double parent_height = 0;
-  double fsz = get_fontsize ();
+  double fontsz = get_fontsize ();
 
   if (new_units == "normalized")
     {
@@ -8156,9 +7987,9 @@
       parent_height = ax.get_properties ().get_boundingbox (true).elem (3);
     }
 
-  fsz = convert_font_size (fsz, old_units, new_units, parent_height);
-
-  set_fontsize (octave_value (fsz));
+  fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
+
+  set_fontsize (octave_value (fontsz));
 }
 
 void
@@ -8243,9 +8074,8 @@
 
   pos = convert_text_position (pos, *this, cached_units, get_units ());
 
-  // FIXME: if the current axes view is 2D, then one should
-  // probably drop the z-component of "pos" and leave "zliminclude"
-  // to "off".
+  // FIXME: if the current axes view is 2D, then one should probably drop
+  // the z-component of "pos" and leave "zliminclude" to "off".
 
   bool autopos = positionmode_is ("auto");
 
@@ -8268,7 +8098,7 @@
 double
 text::properties::get_fontsize_points (double box_pix_height) const
 {
-  double fs = get_fontsize ();
+  double fontsz = get_fontsize ();
   double parent_height = box_pix_height;
 
   if (fontunits_is ("normalized") && parent_height <= 0)
@@ -8279,7 +8109,7 @@
       parent_height = ax.get_properties ().get_boundingbox (true).elem (3);
     }
 
-  return convert_font_size (fs, get_fontunits (), "points", parent_height);
+  return convert_font_size (fontsz, get_fontunits (), "points", parent_height);
 }
 
 // ---------------------------------------------------------------------
@@ -8287,8 +8117,7 @@
 octave_value
 image::properties::get_color_data (void) const
 {
-  return convert_cdata (*this, get_cdata (),
-                        cdatamapping_is ("scaled"), 3);
+  return convert_cdata (*this, get_cdata (), cdatamapping_is ("scaled"), 3);
 }
 
 // ---------------------------------------------------------------------
@@ -8320,7 +8149,7 @@
   if (xd.dims () != yd.dims ()
       || (xd.dims () != zd.dims () && ! zd.is_empty ()))
     {
-      bad_data_msg = "x/y/zdata should have the same dimensions";
+      bad_data_msg = "x/y/zdata must have the same dimensions";
       return;
     }
 
@@ -8465,7 +8294,6 @@
       has_zd = true;
     }
 
-
   for (octave_idx_type jj = 0; jj < nfaces; jj++)
     {
       for (octave_idx_type ii = 0; ii < idx.rows (); ii++)
@@ -8608,30 +8436,30 @@
 void
 hggroup::properties::update_limits (void) const
 {
-  graphics_object obj = gh_manager::get_object (__myhandle__);
-
-  if (obj)
-    {
-      obj.update_axis_limits ("xlim");
-      obj.update_axis_limits ("ylim");
-      obj.update_axis_limits ("zlim");
-      obj.update_axis_limits ("clim");
-      obj.update_axis_limits ("alim");
+  graphics_object go = gh_manager::get_object (__myhandle__);
+
+  if (go)
+    {
+      go.update_axis_limits ("xlim");
+      go.update_axis_limits ("ylim");
+      go.update_axis_limits ("zlim");
+      go.update_axis_limits ("clim");
+      go.update_axis_limits ("alim");
     }
 }
 
 void
 hggroup::properties::update_limits (const graphics_handle& h) const
 {
-  graphics_object obj = gh_manager::get_object (__myhandle__);
-
-  if (obj)
-    {
-      obj.update_axis_limits ("xlim", h);
-      obj.update_axis_limits ("ylim", h);
-      obj.update_axis_limits ("zlim", h);
-      obj.update_axis_limits ("clim", h);
-      obj.update_axis_limits ("alim", h);
+  graphics_object go = gh_manager::get_object (__myhandle__);
+
+  if (go)
+    {
+      go.update_axis_limits ("xlim", h);
+      go.update_axis_limits ("ylim", h);
+      go.update_axis_limits ("zlim", h);
+      go.update_axis_limits ("clim", h);
+      go.update_axis_limits ("alim", h);
     }
 }
 
@@ -8699,7 +8527,7 @@
     }
   else
     {
-      limits.resize (4,1);
+      limits.resize (4, 1);
       limits(0) = min_val;
       limits(1) = max_val;
       limits(2) = min_pos;
@@ -8881,7 +8709,7 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect;
- */
+*/
 
 // ---------------------------------------------------------------------
 
@@ -8890,10 +8718,9 @@
 {
   Matrix m = extent.get ().matrix_value ();
 
-  graphics_object parent_obj =
-    gh_manager::get_object (get_parent ());
-  Matrix parent_bbox = parent_obj.get_properties ().get_boundingbox (true),
-         parent_size = parent_bbox.extract_n (0, 2, 1, 2);
+  graphics_object parent_go = gh_manager::get_object (get_parent ());
+  Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (true);
+  Matrix parent_size = parent_bbox.extract_n (0, 2, 1, 2);
 
   return convert_position (m, "pixels", get_units (), parent_size);
 }
@@ -8920,7 +8747,7 @@
   box = text_renderer.get_extent (elt, 0);
   delete elt;
 
-  Matrix ext (1, 4, 0.0);
+  Matrix ext (1, 4);
 
   // FIXME: also handle left and bottom components
 
@@ -8938,9 +8765,9 @@
 {
   Matrix pos = get_position ().matrix_value ();
 
-  graphics_object parent_obj = gh_manager::get_object (get_parent ());
-  Matrix parent_bbox = parent_obj.get_properties ().get_boundingbox (true),
-         parent_size = parent_bbox.extract_n (0, 2, 1, 2);
+  graphics_object parent_go = gh_manager::get_object (get_parent ());
+  Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (true);
+  Matrix parent_size = parent_bbox.extract_n (0, 2, 1, 2);
 
   pos = convert_position (pos, cached_units, get_units (), parent_size);
   set_position (pos);
@@ -8964,13 +8791,13 @@
   Matrix pos = get_position ().matrix_value ();
   Matrix parent_size (parent_pix_size);
 
-  if (parent_size.numel () == 0)
-    {
-      graphics_object obj = gh_manager::get_object (get_parent ());
-
-      if (obj.valid_object ())
+  if (parent_size.is_empty ())
+    {
+      graphics_object go = gh_manager::get_object (get_parent ());
+
+      if (go.valid_object ())
         parent_size =
-          obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
+          go.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
       else
         parent_size = default_figure_position ();
     }
@@ -8985,16 +8812,14 @@
 }
 
 void
-uicontrol::properties::set_fontunits (const octave_value& v)
-{
-  if (! error_state)
-    {
-      caseless_str old_fontunits = get_fontunits ();
-      if (fontunits.set (v, true))
-        {
-          update_fontunits (old_fontunits);
-          mark_modified ();
-        }
+uicontrol::properties::set_fontunits (const octave_value& val)
+{
+  caseless_str old_fontunits = get_fontunits ();
+
+  if (fontunits.set (val, true))
+    {
+      update_fontunits (old_fontunits);
+      mark_modified ();
     }
 }
 
@@ -9003,23 +8828,23 @@
 {
   caseless_str new_units = get_fontunits ();
   double parent_height = get_boundingbox (false).elem (3);
-  double fsz = get_fontsize ();
-
-  fsz = convert_font_size (fsz, old_units, new_units, parent_height);
-
-  fontsize.set (octave_value (fsz), true);
+  double fontsz = get_fontsize ();
+
+  fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
+
+  fontsize.set (octave_value (fontsz), true);
 }
 
 double
 uicontrol::properties::get_fontsize_points (double box_pix_height) const
 {
-  double fs = get_fontsize ();
+  double fontsz = get_fontsize ();
   double parent_height = box_pix_height;
 
   if (fontunits_is ("normalized") && parent_height <= 0)
     parent_height = get_boundingbox (false).elem (3);
 
-  return convert_font_size (fs, get_fontunits (), "points", parent_height);
+  return convert_font_size (fontsz, get_fontunits (), "points", parent_height);
 }
 
 // ---------------------------------------------------------------------
@@ -9031,12 +8856,12 @@
   Matrix pos = get_position ().matrix_value ();
   Matrix parent_size (parent_pix_size);
 
-  if (parent_size.numel () == 0)
-    {
-      graphics_object obj = gh_manager::get_object (get_parent ());
+  if (parent_size.is_empty ())
+    {
+      graphics_object go = gh_manager::get_object (get_parent ());
 
       parent_size =
-        obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
+        go.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2);
     }
 
   pos = convert_position (pos, get_units (), "pixels", parent_size);
@@ -9067,26 +8892,26 @@
 
       if (! get_title ().empty ())
         {
-          double fs = get_fontsize ();
+          double fontsz = get_fontsize ();
 
           if (! fontunits_is ("pixels"))
             {
               double res = xget (0, "screenpixelsperinch").double_value ();
 
               if (fontunits_is ("points"))
-                fs *= (res / 72.0);
+                fontsz *= (res / 72.0);
               else if (fontunits_is ("inches"))
-                fs *= res;
+                fontsz *= res;
               else if (fontunits_is ("centimeters"))
-                fs *= (res / 2.54);
+                fontsz *= (res / 2.54);
               else if (fontunits_is ("normalized"))
-                fs *= outer_height;
+                fontsz *= outer_height;
             }
 
           if (titleposition_is ("lefttop") || titleposition_is ("centertop")
               || titleposition_is ("righttop"))
-            pos(1) += (fs / 2);
-          pos(3) -= (fs / 2);
+            pos(1) += (fontsz / 2);
+          pos(3) -= (fontsz / 2);
         }
     }
 
@@ -9094,16 +8919,14 @@
 }
 
 void
-uipanel::properties::set_units (const octave_value& v)
-{
-  if (! error_state)
-    {
-      caseless_str old_units = get_units ();
-      if (units.set (v, true))
-        {
-          update_units (old_units);
-          mark_modified ();
-        }
+uipanel::properties::set_units (const octave_value& val)
+{
+  caseless_str old_units = get_units ();
+
+  if (units.set (val, true))
+    {
+      update_units (old_units);
+      mark_modified ();
     }
 }
 
@@ -9112,25 +8935,23 @@
 {
   Matrix pos = get_position ().matrix_value ();
 
-  graphics_object parent_obj = gh_manager::get_object (get_parent ());
-  Matrix parent_bbox = parent_obj.get_properties ().get_boundingbox (true),
-         parent_size = parent_bbox.extract_n (0, 2, 1, 2);
+  graphics_object parent_go = gh_manager::get_object (get_parent ());
+  Matrix parent_bbox = parent_go.get_properties ().get_boundingbox (true);
+  Matrix parent_size = parent_bbox.extract_n (0, 2, 1, 2);
 
   pos = convert_position (pos, old_units, get_units (), parent_size);
   set_position (pos);
 }
 
 void
-uipanel::properties::set_fontunits (const octave_value& v)
-{
-  if (! error_state)
-    {
-      caseless_str old_fontunits = get_fontunits ();
-      if (fontunits.set (v, true))
-        {
-          update_fontunits (old_fontunits);
-          mark_modified ();
-        }
+uipanel::properties::set_fontunits (const octave_value& val)
+{
+  caseless_str old_fontunits = get_fontunits ();
+
+  if (fontunits.set (val, true))
+    {
+      update_fontunits (old_fontunits);
+      mark_modified ();
     }
 }
 
@@ -9139,38 +8960,38 @@
 {
   caseless_str new_units = get_fontunits ();
   double parent_height = get_boundingbox (false).elem (3);
-  double fsz = get_fontsize ();
-
-  fsz = convert_font_size (fsz, old_units, new_units, parent_height);
-
-  set_fontsize (octave_value (fsz));
+  double fontsz = get_fontsize ();
+
+  fontsz = convert_font_size (fontsz, old_units, new_units, parent_height);
+
+  set_fontsize (octave_value (fontsz));
 }
 
 double
 uipanel::properties::get_fontsize_points (double box_pix_height) const
 {
-  double fs = get_fontsize ();
+  double fontsz = get_fontsize ();
   double parent_height = box_pix_height;
 
   if (fontunits_is ("normalized") && parent_height <= 0)
     parent_height = get_boundingbox (false).elem (3);
 
-  return convert_font_size (fs, get_fontunits (), "points", parent_height);
+  return convert_font_size (fontsz, get_fontunits (), "points", parent_height);
 }
 
 // ---------------------------------------------------------------------
 
 octave_value
-uitoolbar::get_default (const caseless_str& name) const
-{
-  octave_value retval = default_properties.lookup (name);
+uitoolbar::get_default (const caseless_str& pname) const
+{
+  octave_value retval = default_properties.lookup (pname);
 
   if (retval.is_undefined ())
     {
-      graphics_handle parent = get_parent ();
-      graphics_object parent_obj = gh_manager::get_object (parent);
-
-      retval = parent_obj.get_default (name);
+      graphics_handle parent_h = get_parent ();
+      graphics_object parent_go = gh_manager::get_object (parent_h);
+
+      retval = parent_go.get_default (pname);
     }
 
   return retval;
@@ -9182,27 +9003,26 @@
   // empty list of local defaults
   default_properties = property_list ();
 
-  xreset_default_properties (get_handle (),
-                             xproperties.factory_defaults ());
+  xreset_default_properties (get_handle (), xproperties.factory_defaults ());
 }
 
 // ---------------------------------------------------------------------
 
 octave_value
-base_graphics_object::get_default (const caseless_str& name) const
-{
-  graphics_handle parent = get_parent ();
-  graphics_object parent_obj = gh_manager::get_object (parent);
-
-  return parent_obj.get_default (type () + name);
+base_graphics_object::get_default (const caseless_str& pname) const
+{
+  graphics_handle parent_h = get_parent ();
+  graphics_object parent_go = gh_manager::get_object (parent_h);
+
+  return parent_go.get_default (type () + pname);
 }
 
 octave_value
 base_graphics_object::get_factory_default (const caseless_str& name) const
 {
-  graphics_object parent_obj = gh_manager::get_object (0);
-
-  return parent_obj.get_factory_default (type () + name);
+  graphics_object parent_go = gh_manager::get_object (0);
+
+  return parent_go.get_factory_default (type () + name);
 }
 
 // We use a random value for the handle to avoid issues with plots and
@@ -9237,19 +9057,19 @@
 {
   graphics_handle h = get_handle (integer_figure_handle);
 
-  base_graphics_object *go = 0;
-
-  go = make_graphics_object_from_type (go_name, h, p);
-
-  if (go)
-    {
-      graphics_object obj (go);
-
-      handle_map[h] = obj;
+  base_graphics_object *bgo = 0;
+
+  bgo = make_graphics_object_from_type (go_name, h, p);
+
+  if (bgo)
+    {
+      graphics_object go (bgo);
+
+      handle_map[h] = go;
 
       // Overriding defaults will work now because the handle is valid
       // and we can find parent objects (not just handles).
-      obj.override_defaults ();
+      go.override_defaults ();
 
       if (go_name == "axes")
         {
@@ -9258,7 +9078,7 @@
           // constructed.
 
           axes::properties& props =
-            dynamic_cast<axes::properties&> (obj.get_properties ());
+            dynamic_cast<axes::properties&> (go.get_properties ());
 
           graphics_object tgo;
 
@@ -9276,11 +9096,11 @@
         }
 
       if (do_createfcn)
-        go->get_properties ().execute_createfcn ();
+        bgo->get_properties ().execute_createfcn ();
 
       // Notify graphics toolkit.
       if (do_notify_toolkit)
-        obj.initialize ();
+        go.initialize ();
     }
   else
     error ("gh_manager::do_make_graphics_handle: invalid object type '%s'",
@@ -9294,16 +9114,16 @@
 {
   graphics_handle h = val;
 
-  base_graphics_object* go = new figure (h, 0);
-  graphics_object obj (go);
-
-  handle_map[h] = obj;
+  base_graphics_object* bgo = new figure (h, 0);
+  graphics_object go (bgo);
+
+  handle_map[h] = go;
 
   // Notify graphics toolkit.
   if (do_notify_toolkit)
-    obj.initialize ();
-
-  obj.override_defaults ();
+    go.initialize ();
+
+  go.override_defaults ();
 
   return h;
 }
@@ -9496,8 +9316,7 @@
   callback_objects.pop_front ();
 
   xset_gcbo (callback_objects.empty ()
-             ? graphics_handle ()
-             : callback_objects.front ().get_handle ());
+             ? graphics_handle () : callback_objects.front ().get_handle ());
 }
 
 void
@@ -9541,8 +9360,6 @@
           xset_gcbo (h);
         }
 
-      BEGIN_INTERRUPT_WITH_EXCEPTIONS;
-
       // Copy CB because "function_value" method is non-const.
 
       octave_value cb = cb_arg;
@@ -9564,11 +9381,9 @@
           Cell c = cb.cell_value ();
 
           fcn = c(0).function_value ();
-          if (! error_state)
-            {
-              for (int i = 1; i < c.length () ; i++)
-                args(1+i) = c(i);
-            }
+
+          for (int i = 1; i < c.numel () ; i++)
+            args(1+i) = c(i);
         }
       else
         {
@@ -9577,10 +9392,8 @@
                  nm.c_str ());
         }
 
-      if (fcn && ! error_state)
+      if (fcn)
         feval (fcn, args);
-
-      END_INTERRUPT_WITH_EXCEPTIONS;
     }
 }
 
@@ -9775,14 +9588,10 @@
 {
   gh_manager::auto_lock guard;
 
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = is_handle (args(0));
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (is_handle (args(0)));
 }
 
 static bool
@@ -9808,15 +9617,12 @@
     {
       const NDArray handles = val.array_value ();
 
-      if (! error_state)
-        {
-          boolNDArray result (handles.dims ());
-
-          for (octave_idx_type i = 0; i < handles.numel (); i++)
-            result.xelem (i) = is_handle_visible (handles (i));
-
-          retval = result;
-        }
+      boolNDArray result (handles.dims ());
+
+      for (octave_idx_type i = 0; i < handles.numel (); i++)
+        result.xelem (i) = is_handle_visible (handles(i));
+
+      retval = result;
     }
 
   return retval;
@@ -9828,14 +9634,10 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = is_handle_visible (args(0));
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (is_handle_visible (args(0)));
 }
 
 DEFUN (reset, args, ,
@@ -9853,25 +9655,17 @@
 @seealso{cla, clf, newplot}\n\
 @end deftypefn")
 {
-  int nargin = args.length ();
-
-  if (nargin != 1)
+  if (args.length () != 1)
     print_usage ();
-  else
-    {
-      // get vector of graphics handles
-      ColumnVector hcv (args(0).vector_value ());
-
-      if (! error_state)
-        {
-          // loop over graphics objects
-          for (octave_idx_type n = 0; n < hcv.length (); n++)
-            gh_manager::get_object (hcv(n)).reset_default_properties ();
-
-          if (! error_state)
-            Fdrawnow ();
-        }
-    }
+
+  // get vector of graphics handles
+  ColumnVector hcv = args(0).xvector_value ("reset: H must be a graphics handle");
+
+  // loop over graphics objects
+  for (octave_idx_type n = 0; n < hcv.numel (); n++)
+    gh_manager::get_object (hcv(n)).reset_default_properties ();
+
+  Fdrawnow ();
 
   return octave_value ();
 }
@@ -10070,113 +9864,103 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
-    {
-      // get vector of graphics handles
-      ColumnVector hcv (args(0).vector_value ());
-
-      if (! error_state)
-        {
-          bool request_drawnow = false;
-
-          // loop over graphics objects
-          for (octave_idx_type n = 0; n < hcv.length (); n++)
-            {
-              graphics_object obj = gh_manager::get_object (hcv(n));
-
-              if (obj)
+  if (nargin == 0)
+    print_usage ();
+
+  // get vector of graphics handles
+  ColumnVector hcv = args(0).xvector_value ("set: H must be a graphics handle");
+
+  bool request_drawnow = false;
+
+  // loop over graphics objects
+  for (octave_idx_type n = 0; n < hcv.numel (); n++)
+    {
+      graphics_object go = gh_manager::get_object (hcv(n));
+
+      if (go)
+        {
+          if (nargin == 3
+              && args(1).is_cellstr () && args(2).is_cell ())
+            {
+              if (args(2).cell_value ().rows () == 1)
+                {
+                  go.set (args(1).cellstr_value (),
+                          args(2).cell_value (), 0);
+                }
+              else if (hcv.numel () == args(2).cell_value ().rows ())
                 {
-                  if (nargin == 3 && args(1).is_cellstr ()
-                      && args(2).is_cell ())
-                    {
-                      if (args(2).cell_value ().rows () == 1)
-                        {
-                          obj.set (args(1).cellstr_value (),
-                                   args(2).cell_value (), 0);
-                        }
-                      else if (hcv.length () == args(2).cell_value ().rows ())
-                        {
-                          obj.set (args(1).cellstr_value (),
-                                   args(2).cell_value (), n);
-                        }
-                      else
-                        {
-                          error ("set: number of graphics handles must match number of value rows (%d != %d)",
-                                 hcv.length (), args(2).cell_value ().rows ());
-                          break;
-
-                        }
-                    }
-                  else if (nargin == 2 && args(1).is_map ())
-                    {
-                      obj.set (args(1).map_value ());
-                    }
-                  else if (nargin == 2 && args(1).is_string ())
-                    {
-                      std::string property = args(1).string_value ();
-
-                      octave_map pmap = obj.values_as_struct ();
-
-                      if (obj.has_readonly_property (property))
-                        if (nargout != 0)
-                          retval = Matrix ();
-                        else
-                          octave_stdout << "set: " << property
-                                        <<" is read-only" << std::endl;
-                      else if (pmap.isfield (property))
-                        {
-                          if (nargout != 0)
-                            retval = pmap.getfield (property)(0);
-                          else
-                            {
-                              std::string s = obj.value_as_string (property);
-                              if (! error_state)
-                                octave_stdout << s;
-                            }
-                        }
-                      else
-                        {
-                          error ("set: unknown property");
-                          break;
-                        }
-                    }
-                  else if (nargin == 1)
-                    {
-                      if (nargout != 0)
-                        retval = obj.values_as_struct ();
-                      else
-                        {
-                          std::string s = obj.values_as_string ();
-                          if (! error_state)
-                            octave_stdout << s;
-                        }
-                    }
+                  go.set (args(1).cellstr_value (),
+                          args(2).cell_value (), n);
+                }
+              else
+                {
+                  error ("set: number of graphics handles must match number of value rows (%d != %d)",
+                         hcv.numel (), args(2).cell_value ().rows ());
+                  break;
+
+                }
+            }
+          else if (nargin == 2 && args(1).is_map ())
+            {
+              go.set (args(1).map_value ());
+            }
+          else if (nargin == 2 && args(1).is_string ())
+            {
+              std::string property = args(1).string_value ();
+
+              octave_map pmap = go.values_as_struct ();
+
+              if (go.has_readonly_property (property))
+                if (nargout != 0)
+                  retval = Matrix ();
+                else
+                  octave_stdout << "set: " << property
+                                <<" is read-only" << std::endl;
+              else if (pmap.isfield (property))
+                {
+                  if (nargout != 0)
+                    retval = pmap.getfield (property)(0);
                   else
                     {
-                      obj.set (args.splice (0, 1));
-                      request_drawnow = true;
+                      std::string s = go.value_as_string (property);
+
+                      octave_stdout << s;
                     }
                 }
               else
                 {
-                  error ("set: invalid handle (= %g)", hcv(n));
+                  error ("set: unknown property");
                   break;
                 }
-
-              if (error_state)
-                break;
-
+            }
+          else if (nargin == 1)
+            {
+              if (nargout != 0)
+                retval = go.values_as_struct ();
+              else
+                {
+                  std::string s = go.values_as_string ();
+
+                  octave_stdout << s;
+                }
+            }
+          else
+            {
+              go.set (args.splice (0, 1));
               request_drawnow = true;
             }
-
-          if (! error_state && request_drawnow)
-            Vdrawnow_requested = true;
         }
       else
-        error ("set: expecting graphics handle as first argument");
-    }
-  else
-    print_usage ();
+        {
+          error ("set: invalid handle (= %g)", hcv(n));
+          break;
+        }
+
+      request_drawnow = true;
+    }
+
+  if (request_drawnow)
+    Vdrawnow_requested = true;
 
   return retval;
 }
@@ -10186,10 +9970,10 @@
 {
   std::string retval;
 
-  graphics_object obj = gh_manager::get_object (val);
-
-  if (obj)
-    retval = obj.type ();
+  graphics_object go = gh_manager::get_object (val);
+
+  if (go)
+    retval = go.type ();
   else
     error ("get: invalid handle (= %g)", val);
 
@@ -10220,149 +10004,114 @@
 
   bool use_cell_format = false;
 
-  if (nargin == 1 || nargin == 2)
-    {
-      if (args(0).is_empty ())
-        {
-          retval = Matrix ();
-          return retval;
-        }
-
-      ColumnVector hcv (args(0).vector_value ());
-
-      if (! error_state)
-        {
-          octave_idx_type len = hcv.length ();
-
-          if (nargin == 1 && len > 1)
-            {
-              std::string t0 = get_graphics_object_type (hcv(0));
-
-              if (! error_state)
-                {
-                  for (octave_idx_type n = 1; n < len; n++)
-                    {
-                      std::string t = get_graphics_object_type (hcv(n));
-
-                      if (error_state)
-                        break;
-
-                      if (t != t0)
-                        {
-                          error ("get: vector of handles must all have same type");
-                          break;
-                        }
-                    }
-
-                }
-            }
-
-          if (! error_state)
-            {
-              if (nargin > 1 && args(1).is_cellstr ())
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  if (args(0).is_empty ())
+    {
+      retval = Matrix ();
+      return retval;
+    }
+
+  ColumnVector hcv = args(0).xvector_value ("get: H must be a graphics handle");
+
+  octave_idx_type hcv_len = hcv.numel ();
+
+  if (nargin == 1 && hcv_len > 1)
+    {
+      std::string typ0 = get_graphics_object_type (hcv(0));
+
+      for (octave_idx_type n = 1; n < hcv_len; n++)
+        {
+          std::string typ = get_graphics_object_type (hcv(n));
+
+          if (typ != typ0)
+            {
+              error ("get: vector of handles must all have the same type");
+              break;
+            }
+        }
+    }
+
+  if (nargin > 1 && args(1).is_cellstr ())
+    {
+      Array<std::string> plist = args(1).cellstr_value ();
+
+      octave_idx_type plen = plist.numel ();
+
+      use_cell_format = true;
+
+      vals.resize (dim_vector (hcv_len, plen));
+
+      for (octave_idx_type n = 0; n < hcv_len; n++)
+        {
+          graphics_object go = gh_manager::get_object (hcv(n));
+
+          if (go)
+            {
+              for (octave_idx_type m = 0; m < plen; m++)
                 {
-                  Array<std::string> plist = args(1).cellstr_value ();
-
-                  if (! error_state)
-                    {
-                      octave_idx_type plen = plist.numel ();
-
-                      use_cell_format = true;
-
-                      vals.resize (dim_vector (len, plen));
-
-                      for (octave_idx_type n = 0; ! error_state && n < len; n++)
-                        {
-                          graphics_object obj = gh_manager::get_object (hcv(n));
-
-                          if (obj)
-                            {
-                              for (octave_idx_type m = 0;
-                                   ! error_state && m < plen;
-                                   m++)
-                                {
-                                  caseless_str property = plist(m);
-
-                                  vals(n, m) = obj.get (property);
-                                }
-                            }
-                          else
-                            {
-                              error ("get: invalid handle (= %g)", hcv(n));
-                              break;
-                            }
-                        }
-                    }
-                  else
-                    error ("get: expecting property name or cell array of property names as second argument");
+                  caseless_str property = plist(m);
+
+                  vals(n, m) = go.get (property);
                 }
+            }
+          else
+            {
+              error ("get: invalid handle (= %g)", hcv(n));
+              break;
+            }
+        }
+    }
+  else
+    {
+      caseless_str property;
+
+      if (nargin > 1)
+        property = args(1).xstring_value ("get: second argument must be property name or cell array of property names");
+
+      vals.resize (dim_vector (hcv_len, 1));
+
+      for (octave_idx_type n = 0; n < hcv_len; n++)
+        {
+          graphics_object go = gh_manager::get_object (hcv(n));
+
+          if (go)
+            {
+              if (nargin == 1)
+                vals(n) = go.get ();
               else
-                {
-                  caseless_str property;
-
-                  if (nargin > 1)
-                    {
-                      property = args(1).string_value ();
-
-                      if (error_state)
-                        error ("get: expecting property name or cell array of property names as second argument");
-                    }
-
-                  vals.resize (dim_vector (len, 1));
-
-                  if (! error_state)
-                    {
-                      for (octave_idx_type n = 0; ! error_state && n < len; n++)
-                        {
-                          graphics_object obj = gh_manager::get_object (hcv(n));
-
-                          if (obj)
-                            {
-                              if (nargin == 1)
-                                vals(n) = obj.get ();
-                              else
-                                vals(n) = obj.get (property);
-                            }
-                          else
-                            {
-                              error ("get: invalid handle (= %g)", hcv(n));
-                              break;
-                            }
-                        }
-                    }
-                }
-            }
+                vals(n) = go.get (property);
+            }
+          else
+            {
+              error ("get: invalid handle (= %g)", hcv(n));
+              break;
+            }
+        }
+    }
+
+  if (use_cell_format)
+    retval = vals;
+  else
+    {
+      octave_idx_type vals_len = vals.numel ();
+
+      if (vals_len == 0)
+        retval = Matrix ();
+      else if (vals_len == 1)
+        retval = vals(0);
+      else if (vals_len > 1 && nargin == 1)
+        {
+          OCTAVE_LOCAL_BUFFER (octave_scalar_map, tmp, vals_len);
+
+          for (octave_idx_type n = 0; n < vals_len; n++)
+            tmp[n] = vals(n).scalar_map_value ();
+
+          retval = octave_map::cat (0, vals_len, tmp);
         }
       else
-        error ("get: expecting graphics handle as first argument");
-    }
-  else
-    print_usage ();
-
-  if (! error_state)
-    {
-      if (use_cell_format)
         retval = vals;
-      else
-        {
-          octave_idx_type len = vals.numel ();
-
-          if (len == 0)
-            retval = Matrix ();
-          else if (len == 1)
-            retval = vals(0);
-          else if (len > 1 && nargin == 1)
-            {
-              OCTAVE_LOCAL_BUFFER (octave_scalar_map, tmp, len);
-
-              for (octave_idx_type n = 0; n < len; n++)
-                tmp[n] = vals(n).scalar_map_value ();
-
-              retval = octave_map::cat (0, len, tmp);
-            }
-          else
-            retval = vals;
-        }
     }
 
   return retval;
@@ -10388,46 +10137,34 @@
 
   Cell vals;
 
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      ColumnVector hcv (args(0).vector_value ());
-
-      if (! error_state)
-        {
-          octave_idx_type len = hcv.length ();
-
-          vals.resize (dim_vector (len, 1));
-
-          for (octave_idx_type n = 0; n < len; n++)
-            {
-              graphics_object obj = gh_manager::get_object (hcv(n));
-
-              if (obj)
-                vals(n) = obj.get (true);
-              else
-                {
-                  error ("get: invalid handle (= %g)", hcv(n));
-                  break;
-                }
-            }
-        }
+  if (args.length () != 1)
+    print_usage ();
+
+  ColumnVector hcv = args(0).xvector_value ("get: H must be a graphics handle");
+
+  octave_idx_type hcv_len = hcv.numel ();
+
+  vals.resize (dim_vector (hcv_len, 1));
+
+  for (octave_idx_type n = 0; n < hcv_len; n++)
+    {
+      graphics_object go = gh_manager::get_object (hcv(n));
+
+      if (go)
+        vals(n) = go.get (true);
       else
-        error ("get: expecting graphics handle as first argument");
-    }
-  else
-    print_usage ();
-
-  if (! error_state)
-    {
-      octave_idx_type len = vals.numel ();
-
-      if (len > 1)
-        retval = vals;
-      else if (len == 1)
-        retval = vals(0);
-    }
+        {
+          error ("get: invalid handle (= %g)", hcv(n));
+          break;
+        }
+    }
+
+  octave_idx_type vals_len = vals.numel ();
+
+  if (vals_len > 1)
+    retval = vals;
+  else if (vals_len == 1)
+    retval = vals(0);
 
   return retval;
 }
@@ -10446,57 +10183,52 @@
   caseless_str p ("parent");
 
   for (int i = 0; i < xargs.length (); i++)
-    if (xargs(i).is_string ()
-        && p.compare (xargs(i).string_value ()))
-      {
-        if (i < (xargs.length () - 1))
-          {
-            val = xargs(i+1).double_value ();
-
-            if (! error_state)
-              {
-                xargs = xargs.splice (i, 2);
-                break;
-              }
-          }
-        else
-          error ("__go_%s__: missing value for parent property",
-                 go_name.c_str ());
-      }
-
-  if (! error_state && xisnan (val))
-    val = args(0).double_value ();
-
-  if (! error_state)
-    {
-      graphics_handle parent = gh_manager::lookup (val);
-
-      if (parent.ok ())
-        {
-          graphics_handle h
-            = gh_manager::make_graphics_handle (go_name, parent,
+    {
+      if (xargs(i).is_string () && p.compare (xargs(i).string_value ()))
+        {
+          if (i < (xargs.length () - 1))
+            {
+              val = xargs(i+1).double_value ();
+
+              xargs = xargs.splice (i, 2);
+              break;
+            }
+          else
+            error ("__go_%s__: missing value for parent property",
+                   go_name.c_str ());
+        }
+    }
+
+  if (xisnan (val))
+    val = args(0).xdouble_value ("__go_%s__: invalid parent", go_name.c_str ());
+
+  graphics_handle parent = gh_manager::lookup (val);
+
+  if (parent.ok ())
+    {
+      graphics_handle h;
+
+      try
+        {
+          h = gh_manager::make_graphics_handle (go_name, parent,
                                                 integer_figure_handle,
                                                 false, false);
-
-          if (! error_state)
-            {
-              adopt (parent, h);
-
-              xset (h, xargs);
-              xcreatefcn (h);
-              xinitialize (h);
-
-              retval = h.value ();
-
-              if (! error_state)
-                Vdrawnow_requested = true;
-            }
-          else
-            error ("__go%s__: unable to create graphics handle",
-                   go_name.c_str ());
-        }
-      else
-        error ("__go_%s__: invalid parent", go_name.c_str ());
+        }
+      catch (octave_execution_exception& e)
+        {
+          error (e, "__go%s__: unable to create graphics handle",
+                 go_name.c_str ());
+        }
+
+      adopt (parent, h);
+
+      xset (h, xargs);
+      xcreatefcn (h);
+      xinitialize (h);
+
+      retval = h.value ();
+
+      Vdrawnow_requested = true;
     }
   else
     error ("__go_%s__: invalid parent", go_name.c_str ());
@@ -10514,91 +10246,81 @@
 
   octave_value retval;
 
-  if (args.length () > 0)
-    {
-      double val = args(0).double_value ();
-
-      if (! error_state)
-        {
-          if (is_figure (val))
-            {
-              graphics_handle h = gh_manager::lookup (val);
-
-              xset (h, args.splice (0, 1));
-
-              retval = h.value ();
-            }
-          else
-            {
-              bool int_fig_handle = true;
-
-              octave_value_list xargs = args.splice (0, 1);
-
-              graphics_handle h = octave_NaN;
-
-              if (xisnan (val))
+  if (args.length () == 0)
+    print_usage ();
+
+  double val = args(0).xdouble_value ("__go_figure__: figure number must be a double value");
+
+  if (is_figure (val))
+    {
+      graphics_handle h = gh_manager::lookup (val);
+
+      xset (h, args.splice (0, 1));
+
+      retval = h.value ();
+    }
+  else
+    {
+      bool int_fig_handle = true;
+
+      octave_value_list xargs = args.splice (0, 1);
+
+      graphics_handle h = octave_NaN;
+
+      if (xisnan (val))
+        {
+          caseless_str pname ("integerhandle");
+
+          for (int i = 0; i < xargs.length (); i++)
+            {
+              if (xargs(i).is_string ()
+                  && pname.compare (xargs(i).string_value ()))
                 {
-                  caseless_str p ("integerhandle");
-
-                  for (int i = 0; i < xargs.length (); i++)
+                  if (i < (xargs.length () - 1))
                     {
-                      if (xargs(i).is_string ()
-                          && p.compare (xargs(i).string_value ()))
-                        {
-                          if (i < (xargs.length () - 1))
-                            {
-                              std::string pval = xargs(i+1).string_value ();
-
-                              if (! error_state)
-                                {
-                                  caseless_str on ("on");
-                                  int_fig_handle = on.compare (pval);
-                                  xargs = xargs.splice (i, 2);
-                                  break;
-                                }
-                            }
-                        }
-                    }
-
-                  h = gh_manager::make_graphics_handle ("figure", 0,
-                                                        int_fig_handle,
-                                                        false, false);
-
-                  if (! int_fig_handle)
-                    {
-                      // We need to intiailize the integerhandle
-                      // property without calling the set_integerhandle
-                      // method, because doing that will generate a new
-                      // handle value...
-
-                      graphics_object go = gh_manager::get_object (h);
-                      go.get_properties ().init_integerhandle ("off");
+                      std::string pval = xargs(i+1).string_value ();
+
+                      caseless_str on ("on");
+                      int_fig_handle = on.compare (pval);
+                      xargs = xargs.splice (i, 2);
+
+                      break;
                     }
                 }
-              else if (val > 0 && D_NINT (val) == val)
-                h = gh_manager::make_figure_handle (val, false);
-
-              if (! error_state && h.ok ())
-                {
-                  adopt (0, h);
-
-                  gh_manager::push_figure (h);
-
-                  xset (h, xargs);
-                  xcreatefcn (h);
-                  xinitialize (h);
-
-                  retval = h.value ();
-                }
-              else
-                error ("__go_figure__: failed to create figure handle");
-            }
+            }
+
+          h = gh_manager::make_graphics_handle ("figure", 0,
+                                                int_fig_handle,
+                                                false, false);
+
+          if (! int_fig_handle)
+            {
+              // We need to initialize the integerhandle property
+              // without calling the set_integerhandle method,
+              // because doing that will generate a new handle value...
+
+              graphics_object go = gh_manager::get_object (h);
+              go.get_properties ().init_integerhandle ("off");
+            }
+        }
+      else if (val > 0 && D_NINT (val) == val)
+        h = gh_manager::make_figure_handle (val, false);
+
+      if (h.ok ())
+        {
+          adopt (0, h);
+
+          gh_manager::push_figure (h);
+
+          xset (h, xargs);
+          xcreatefcn (h);
+          xinitialize (h);
+
+          retval = h.value ();
         }
       else
-        error ("__go_figure__: expecting figure number to be double value");
-    }
-  else
-    print_usage ();
+        error ("__go_figure__: failed to create figure handle");
+    }
 
   return retval;
 }
@@ -10606,19 +10328,14 @@
 #define GO_BODY(TYPE) \
   gh_manager::auto_lock guard; \
  \
-  octave_value retval; \
- \
-  if (args.length () > 0) \
-    retval = make_graphics_object (#TYPE, false, args);  \
-  else \
+  if (args.length () == 0) \
     print_usage (); \
  \
-  return retval
+  return octave_value (make_graphics_object (#TYPE, false, args)); \
 
 int
 calc_dimensions (const graphics_object& go)
 {
-
   int nd = 2;
 
   if (go.isa ("surface"))
@@ -10630,13 +10347,13 @@
     {
       Matrix kids = go.get_properties ().get_children ();
 
-      for (octave_idx_type i = 0; i < kids.length (); i++)
-        {
-          graphics_handle hnd = gh_manager::lookup (kids(i));
-
-          if (hnd.ok ())
-            {
-              const graphics_object& kid = gh_manager::get_object (hnd);
+      for (octave_idx_type i = 0; i < kids.numel (); i++)
+        {
+          graphics_handle hkid = gh_manager::lookup (kids(i));
+
+          if (hkid.ok ())
+            {
+              const graphics_object& kid = gh_manager::get_object (hkid);
 
               if (kid.valid_object ())
                 nd = calc_dimensions (kid);
@@ -10660,22 +10377,12 @@
 {
   gh_manager::auto_lock guard;
 
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      double h = args(0).double_value ();
-      if (! error_state)
-        retval = calc_dimensions (gh_manager::get_object (h));
-      else
-        error ("__calc_dimensions__: expecting graphics handle as only argument");
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  double h = args(0).xdouble_value ("__calc_dimensions__: first argument must be a graphics handle");
+
+  return octave_value (calc_dimensions (gh_manager::get_object (h)));
 }
 
 DEFUN (__go_axes__, args, ,
@@ -10814,38 +10521,28 @@
 
   octave_value_list retval;
 
-  if (args.length () == 1)
-    {
-      graphics_handle h = octave_NaN;
-
-      const NDArray vals = args(0).array_value ();
-
-      if (! error_state)
-        {
-          // Check is all the handles to delete are valid first
-          // as callbacks might delete one of the handles we
-          // later want to delete
-          for (octave_idx_type i = 0; i < vals.numel (); i++)
-            {
-              h = gh_manager::lookup (vals.elem (i));
-
-              if (! h.ok ())
-                {
-                  error ("delete: invalid graphics object (= %g)",
-                         vals.elem (i));
-                  break;
-                }
-            }
-
-          if (! error_state)
-            delete_graphics_objects (vals);
-        }
-      else
-        error ("delete: invalid graphics object");
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
+  graphics_handle h = octave_NaN;
+
+  const NDArray vals = args(0).xarray_value ("delete: invalid graphics object");
+
+  // Check all the handles to delete are valid first, as callbacks
+  // might delete one of the handles we later want to delete
+  for (octave_idx_type i = 0; i < vals.numel (); i++)
+    {
+      h = gh_manager::lookup (vals(i));
+
+      if (! h.ok ())
+        {
+          error ("delete: invalid graphics object (= %g)", vals(i));
+          break;
+        }
+    }
+
+  delete_graphics_objects (vals);
+
   return retval;
 }
 
@@ -10864,43 +10561,31 @@
   std::string mode = "";
 
   if (nargin == 2)
-    {
-      mode = args(1).string_value ();
-
-      if (error_state)
-        return retval;
-    }
-
-  if (nargin == 1 || nargin == 2)
-    {
-      graphics_handle h = octave_NaN;
-
-      double val = args(0).double_value ();
-
-      if (! error_state)
-        {
-          h = gh_manager::lookup (val);
-
-          if (h.ok ())
-            {
-              graphics_object obj = gh_manager::get_object (h);
-
-              obj.set_defaults (mode);
-
-              h = gh_manager::lookup (val);
-              if (! h.ok ())
-                error ("__go_axes_init__: axis deleted during initialization (= %g)",
-                       val);
-            }
-          else
-            error ("__go_axes_init__: invalid graphics object (= %g)", val);
-        }
-      else
-        error ("__go_axes_init__: invalid graphics object");
-    }
-  else
+    mode = args(1).string_value ();
+
+  if (nargin < 1 || nargin > 2)
     print_usage ();
 
+  graphics_handle h = octave_NaN;
+
+  double val = args(0).xdouble_value ("__go_axes_init__: invalid graphics object");
+
+  h = gh_manager::lookup (val);
+
+  if (h.ok ())
+    {
+      graphics_object go = gh_manager::get_object (h);
+
+      go.set_defaults (mode);
+
+      h = gh_manager::lookup (val);
+      if (! h.ok ())
+        error ("__go_axes_init__: axis deleted during initialization (= %g)",
+               val);
+    }
+  else
+    error ("__go_axes_init__: invalid graphics object (= %g)", val);
+
   return retval;
 }
 
@@ -10947,37 +10632,24 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
-    {
-      double val = args(0).double_value ();
-
-      if (! error_state)
-        {
-          graphics_handle h = gh_manager::lookup (val);
-
-          if (h.ok ())
-            {
-              std::string name = args(1).string_value ();
-
-              if (! error_state)
-                {
-                  if (nargin == 2)
-                    gh_manager::execute_callback (h, name);
-                  else
-                    gh_manager::execute_callback (h, name, args(2));
-                }
-              else
-                error ("__go_execute_callback__: invalid callback name");
-            }
-          else
-            error ("__go_execute_callback__: invalid graphics object (= %g)",
-                   val);
-        }
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  double val = args(0).xdouble_value ("__go_execute_callback__: invalid graphics object");
+
+  graphics_handle h = gh_manager::lookup (val);
+
+  if (h.ok ())
+    {
+      std::string name = args(1).xstring_value ("__go_execute_callback__: invalid callback name");
+
+      if (nargin == 2)
+        gh_manager::execute_callback (h, name);
       else
-        error ("__go_execute_callback__: invalid graphics object");
-    }
-  else
-    print_usage ();
+        gh_manager::execute_callback (h, name, args(2));
+    }
+  else
+    error ("__go_execute_callback__: invalid graphics object (= %g)", val);
 
   return retval;
 }
@@ -10990,34 +10662,25 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      double h = args(0).double_value ();
-
-      if (! error_state)
-        {
-          graphics_object fobj = gh_manager::get_object (h);
-          if (fobj &&  fobj.isa ("image"))
-            {
-              image::properties& ip =
-                dynamic_cast<image::properties&> (fobj.get_properties ());
-
-              Matrix dp =  Matrix (1, 2, 0);
-              dp(0, 0) = ip.pixel_xsize ();
-              dp(0, 1) = ip.pixel_ysize ();
-              retval = dp;
-            }
-          else
-            error ("__image_pixel_size__: object is not an image");
-        }
-      else
-        error ("__image_pixel_size__: argument is not a handle");
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
+  double h = args(0).xdouble_value ("__image_pixel_size__: argument is not a handle");
+
+  graphics_object go = gh_manager::get_object (h);
+  if (go && go.isa ("image"))
+    {
+      image::properties& ip =
+        dynamic_cast<image::properties&> (go.get_properties ());
+
+      Matrix dp = Matrix (1, 2);
+      dp(0) = ip.pixel_xsize ();
+      dp(1) = ip.pixel_ysize ();
+      retval = dp;
+    }
+  else
+    error ("__image_pixel_size__: object is not an image");
+
   return retval;
 }
 
@@ -11051,10 +10714,9 @@
               args(0) = dtk;
               feval ("graphics_toolkit", args);
 
-              if (! error_state)
-                pl = loaded_toolkits.find (dtk);
-
-              if (error_state || pl == loaded_toolkits.end ())
+              pl = loaded_toolkits.find (dtk);
+
+              if (pl == loaded_toolkits.end ())
                 error ("failed to load %s graphics toolkit", dtk.c_str ());
               else
                 retval = pl->second;
@@ -11135,19 +10797,13 @@
 
   gh_manager::auto_lock guard;
 
-  if (args.length () == 1)
-    {
-      if (args(0).is_string ())
-        {
-          std::string name = args(0).string_value ();
-          gtk_manager::register_toolkit (name);
-        }
-      else
-        error ("register_graphics_toolkit: TOOLKIT must be a string");
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
+  std::string name = args(0).xstring_value ("register_graphics_toolkit: TOOLKIT must be a string");
+
+  gtk_manager::register_toolkit (name);
+
   return retval;
 }
 
@@ -11184,11 +10840,14 @@
 
   octave_value retval;
 
+  if (args.length () > 4)
+    print_usage ();
+
   gh_manager::lock ();
 
   unwind_protect frame;
+
   frame.protect_var (Vdrawnow_requested, false);
-
   frame.protect_var (drawnow_executing);
 
   if (++drawnow_executing <= 1)
@@ -11197,7 +10856,7 @@
         {
           Matrix hlist = gh_manager::figure_handle_list (true);
 
-          for (int i = 0; ! error_state && i < hlist.length (); i++)
+          for (int i = 0; i < hlist.numel (); i++)
             {
               graphics_handle h = gh_manager::lookup (hlist(i));
 
@@ -11227,13 +10886,13 @@
 
           if (args.length () == 1)
             {
-              caseless_str val (args(0).string_value ());
-
-              if (! error_state && val.compare ("expose"))
+              caseless_str val (args(0).xstring_value ("drawnow: first argument must be a string"));
+
+              if (val.compare ("expose"))
                 do_events = false;
               else
                 {
-                  error ("drawnow: invalid argument, expected 'expose' as argument");
+                  error ("drawnow: invalid argument, 'expose' is only valid option");
 
                   gh_manager::unlock ();
 
@@ -11255,107 +10914,85 @@
           std::string term, file, debug_file;
           bool mono;
 
-          term = args(0).string_value ();
-
-          if (! error_state)
-            {
-              file = args(1).string_value ();
-
-              if (! error_state)
+          term = args(0).xstring_value ("drawnow: TERM must be a string");
+
+          file = args(1).xstring_value ("drawnow: FILE must be a string");
+
+          size_t pos_p = file.find_first_of ("|");
+          size_t pos_c = file.find_first_not_of ("| ");
+
+          if (pos_p == std::string::npos &&
+              pos_c == std::string::npos)
+            {
+              error ("drawnow: empty output ''");
+
+              gh_manager::unlock ();
+
+              return retval;
+            }
+          else if (pos_c == std::string::npos)
+            {
+              error ("drawnow: empty pipe '|'");
+
+              gh_manager::unlock ();
+
+              return retval;
+            }
+          else if (pos_p != std::string::npos && pos_p < pos_c)
+            {
+              // Strip leading pipe character
+              file = file.substr (pos_c);
+            }
+          else
+            {
+              size_t pos = file.find_last_of (file_ops::dir_sep_chars ());
+
+              if (pos != std::string::npos)
                 {
-                  size_t pos_p = file.find_first_of ("|");
-                  size_t pos_c = file.find_first_not_of ("| ");
-
-                  if (pos_p == std::string::npos &&
-                      pos_c == std::string::npos)
+                  std::string dirname = file.substr (pos_c, pos+1);
+
+                  file_stat fs (dirname);
+
+                  if (! (fs && fs.is_dir ()))
                     {
-                      error ("drawnow: empty output ''");
-
-                      gh_manager::unlock ();
-
-                      return retval;
-                    }
-                  else if (pos_c == std::string::npos)
-                    {
-                      error ("drawnow: empty pipe '|'");
+                      error ("drawnow: nonexistent directory '%s'",
+                             dirname.c_str ());
 
                       gh_manager::unlock ();
 
                       return retval;
                     }
-                  else if (pos_p != std::string::npos && pos_p < pos_c)
-                    {
-                      // Strip leading pipe character
-                      file = file.substr (pos_c);
-                    }
-                  else
-                    {
-                      size_t pos = file.find_last_of (file_ops::dir_sep_chars ());
-
-                      if (pos != std::string::npos)
-                        {
-                          std::string dirname = file.substr (pos_c, pos+1);
-
-                          file_stat fs (dirname);
-
-                          if (! (fs && fs.is_dir ()))
-                            {
-                              error ("drawnow: nonexistent directory '%s'",
-                                     dirname.c_str ());
-
-                              gh_manager::unlock ();
-
-                              return retval;
-                            }
-                        }
-                    }
-
-                  mono = (args.length () >= 3 ? args(2).bool_value () : false);
-
-                  if (! error_state)
-                    {
-                      debug_file = (args.length () > 3 ? args(3).string_value ()
-                                    : "");
-
-                      if (! error_state)
-                        {
-                          graphics_handle h = gcf ();
-
-                          if (h.ok ())
-                            {
-                              graphics_object go = gh_manager::get_object (h);
-
-                              // FIXME: when using qt toolkit the print_figure
-                              // method returns immediately and Canvas::print 
-                              // doesn't have enough time to lock the mutex 
-                              // before we lock it here again. We thus wait 
-                              // 50 ms (which may not be enough) to give it 
-                              // a chance: see
-                              // http://octave.1599824.n4.nabble.com/Printing-issues-with-Qt-toolkit-tp4673270.html
-                              gh_manager::unlock ();
-
-                              go.get_toolkit ().print_figure (go, term, file,
-                                                              mono, debug_file);
-                              Fsleep (octave_value (0.05));
-                              gh_manager::lock ();
-                            }
-                          else
-                            error ("drawnow: nothing to draw");
-                        }
-                      else
-                        error ("drawnow: invalid DEBUG_FILE, expected a string value");
-                    }
-                  else
-                    error ("drawnow: invalid colormode MONO, expected a boolean value");
                 }
-              else
-                error ("drawnow: invalid FILE, expected a string value");
+            }
+
+          mono = (args.length () >= 3 ? args(2).xbool_value ("drawnow: MONO colormode must be a boolean value") : false);
+
+          debug_file = (args.length () > 3 ? args(3).xstring_value ("drawnow: DEBUG_FILE must be a string") : "");
+
+          graphics_handle h = gcf ();
+
+          if (h.ok ())
+            {
+              graphics_object go = gh_manager::get_object (h);
+
+              // FIXME: when using qt toolkit the print_figure method
+              // returns immediately and Canvas::print doesn't have
+              // enough time to lock the mutex before we lock it here
+              // again.  We thus wait 50 ms (which may not be enough) to
+              // give it a chance: see http://octave.1599824.n4.nabble.com/Printing-issues-with-Qt-toolkit-tp4673270.html
+
+              gh_manager::unlock ();
+
+              go.get_toolkit ().print_figure (go, term, file, mono,
+                                              debug_file);
+
+              Fsleep (octave_value (0.05));
+
+              gh_manager::lock ();
             }
           else
-            error ("drawnow: invalid terminal TERM, expected a string value");
-        }
-      else
-        print_usage ();
+            error ("drawnow: nothing to draw");
+        }
     }
 
   gh_manager::unlock ();
@@ -11402,44 +11039,31 @@
 
   octave_value retval;
 
-  if (args.length () >= 3 && args.length () <= 4)
-    {
-      double h = args(0).double_value ();
-
-      if (! error_state)
-        {
-          std::string pname = args(1).string_value ();
-
-          if (! error_state)
-            {
-              graphics_handle gh = gh_manager::lookup (h);
-
-              if (gh.ok ())
-                {
-                  graphics_object go = gh_manager::get_object (gh);
-
-                  go.add_property_listener (pname, args(2), POSTSET);
-
-                  if (args.length () == 4)
-                    {
-                      caseless_str persistent = args(3).string_value ();
-                      if (persistent.compare ("persistent"))
-                        go.add_property_listener (pname, args(2), PERSISTENT);
-                    }
-                }
-              else
-                error ("addlistener: invalid graphics object (= %g)",
-                       h);
-            }
-          else
-            error ("addlistener: invalid property name, expected a string value");
-        }
-      else
-        error ("addlistener: invalid handle");
-    }
-  else
+  if (args.length () < 3 || args.length () > 4)
     print_usage ();
 
+  double h = args(0).xdouble_value ("addlistener: invalid handle H");
+
+  std::string pname = args(1).xstring_value ("addlistener: PROP must be a string");
+
+  graphics_handle gh = gh_manager::lookup (h);
+
+  if (gh.ok ())
+    {
+      graphics_object go = gh_manager::get_object (gh);
+
+      go.add_property_listener (pname, args(2), POSTSET);
+
+      if (args.length () == 4)
+        {
+          caseless_str persistent = args(3).string_value ();
+          if (persistent.compare ("persistent"))
+            go.add_property_listener (pname, args(2), PERSISTENT);
+        }
+    }
+  else
+    error ("addlistener: invalid graphics object (= %g)", h);
+
   return retval;
 }
 
@@ -11475,51 +11099,37 @@
 
   octave_value retval;
 
-  if (args.length () == 3 || args.length () == 2)
-    {
-      double h = args(0).double_value ();
-
-      if (! error_state)
-        {
-          std::string pname = args(1).string_value ();
-
-          if (! error_state)
-            {
-              graphics_handle gh = gh_manager::lookup (h);
-
-              if (gh.ok ())
-                {
-                  graphics_object go = gh_manager::get_object (gh);
-
-                  if (args.length () == 2)
-                    go.delete_property_listener (pname, octave_value (),
-                                                 POSTSET);
-                  else
-                    {
-                      if (args(2).is_string ()
-                          && args(2).string_value () == "persistent")
-                        {
-                          go.delete_property_listener (pname, octave_value (),
-                                                       PERSISTENT);
-                          go.delete_property_listener (pname, octave_value (),
-                                                       POSTSET);
-                        }
-                      else
-                        go.delete_property_listener (pname, args(2), POSTSET);
-                    }
-                }
-              else
-                error ("dellistener: invalid graphics object (= %g)",
-                       h);
+  if (args.length () < 2 || args.length () > 3)
+    print_usage ();
+
+  double h = args(0).xdouble_value ("dellistener: invalid handle");
+
+  std::string pname = args(1).xstring_value ("dellistener: PROP must be a string");
+
+  graphics_handle gh = gh_manager::lookup (h);
+
+  if (gh.ok ())
+    {
+      graphics_object go = gh_manager::get_object (gh);
+
+      if (args.length () == 2)
+        go.delete_property_listener (pname, octave_value (), POSTSET);
+      else
+        {
+          if (args(2).is_string ()
+              && args(2).string_value () == "persistent")
+            {
+              go.delete_property_listener (pname, octave_value (),
+                                           PERSISTENT);
+              go.delete_property_listener (pname, octave_value (),
+                                           POSTSET);
             }
           else
-            error ("dellistener: invalid property name, expected a string value");
-        }
-      else
-        error ("dellistener: invalid handle");
-    }
-  else
-    print_usage ();
+            go.delete_property_listener (pname, args(2), POSTSET);
+        }
+    }
+  else
+    error ("dellistener: invalid graphics object (= %g)", h);
 
   return retval;
 }
@@ -11600,52 +11210,34 @@
 
   octave_value retval;
 
-  if (args.length () >= 3)
-    {
-      std::string name = args(0).string_value ();
-
-      if (! error_state)
-        {
-          double h = args(1).double_value ();
-
-          if (! error_state)
-            {
-              graphics_handle gh = gh_manager::lookup (h);
-
-              if (gh.ok ())
-                {
-                  graphics_object go = gh_manager::get_object (gh);
-
-                  std::string type = args(2).string_value ();
-
-                  if (! error_state)
-                    {
-                      if (! go.get_properties ().has_property (name))
-                        {
-                          property p = property::create (name, gh, type,
-                                                         args.splice (0, 3));
-
-                          if (! error_state)
-                            go.get_properties ().insert_property (name, p);
-                        }
-                      else
-                        error ("addproperty: a '%s' property already exists in the graphics object",
-                               name.c_str ());
-                    }
-                  else
-                    error ("addproperty: invalid property TYPE, expected a string value");
-                }
-              else
-                error ("addproperty: invalid graphics object (= %g)", h);
-            }
-          else
-            error ("addproperty: invalid handle value");
+  if (args.length () < 3)
+    print_usage ();
+
+  std::string name = args(0).xstring_value ("addproperty: NAME must be a string");
+
+  double h = args(1).xdouble_value ("addproperty: invalid handle H");
+
+  graphics_handle gh = gh_manager::lookup (h);
+
+  if (gh.ok ())
+    {
+      graphics_object go = gh_manager::get_object (gh);
+
+      std::string type = args(2).xstring_value ("addproperty: TYPE must be a string");
+
+      if (! go.get_properties ().has_property (name))
+        {
+          property p = property::create (name, gh, type,
+                                         args.splice (0, 3));
+
+          go.get_properties ().insert_property (name, p);
         }
       else
-        error ("addproperty: invalid property NAME, expected a string value");
-    }
-  else
-    print_usage ();
+        error ("addproperty: a '%s' property already exists in the graphics object",
+               name.c_str ());
+    }
+  else
+    error ("addproperty: invalid graphics object (= %g)", h);
 
   return retval;
 }
@@ -11656,11 +11248,11 @@
 {
   gh_manager::auto_lock guard;
 
-  graphics_object obj = gh_manager::get_object (handle);
   octave_value retval;
-
-  if (obj)
-    retval = obj.get (caseless_str (property));
+  graphics_object go = gh_manager::get_object (handle);
+
+  if (go)
+    retval = go.get (caseless_str (property));
   else
     error ("%s: invalid handle (= %g)", func.c_str (), handle);
 
@@ -11673,15 +11265,14 @@
 {
   gh_manager::auto_lock guard;
 
-  graphics_object obj = gh_manager::get_object (handle);
   int ret = false;
-
-  if (obj)
-    {
-      obj.set (caseless_str (property), arg);
-
-      if (! error_state)
-        ret = true;
+  graphics_object go = gh_manager::get_object (handle);
+
+  if (go)
+    {
+      go.set (caseless_str (property), arg);
+
+      ret = true;
     }
   else
     error ("%s: invalid handle (= %g)", func.c_str (), handle);
@@ -11690,16 +11281,16 @@
 }
 
 static bool
-compare_property_values (const octave_value& o1, const octave_value& o2)
+compare_property_values (const octave_value& ov1, const octave_value& ov2)
 {
   octave_value_list args(2);
 
-  args(0) = o1;
-  args(1) = o2;
+  args(0) = ov1;
+  args(1) = ov2;
 
   octave_value_list result = feval ("isequal", args, 1);
 
-  if (! error_state && result.length () > 0)
+  if (result.length () > 0)
     return result(0).bool_value ();
 
   return false;
@@ -11723,29 +11314,23 @@
     {
       double h = c(2).double_value ();
 
-      if (! error_state)
-        {
-          caseless_str pname = c(3).string_value ();
-
-          if (! error_state)
-            {
-              gh_manager::auto_lock guard;
-
-              graphics_handle handle = gh_manager::lookup (h);
-
-              if (handle.ok ())
-                {
-                  graphics_object go = gh_manager::get_object (handle);
-
-                  if (go.get_properties ().has_property (pname))
-                    {
-                      go.get_properties ().delete_listener (pname, listener,
-                                                            mode);
-                      if (mode == POSTSET)
-                        go.get_properties ().delete_listener (pname, listener,
-                                                              PERSISTENT);
-                    }
-                }
+      caseless_str pname = c(3).string_value ();
+
+      gh_manager::auto_lock guard;
+
+      graphics_handle gh = gh_manager::lookup (h);
+
+      if (gh.ok ())
+        {
+          graphics_object go = gh_manager::get_object (gh);
+
+          if (go.get_properties ().has_property (pname))
+            {
+              go.get_properties ().delete_listener (pname, listener, mode);
+
+              if (mode == POSTSET)
+                go.get_properties ().delete_listener (pname, listener,
+                                                      PERSISTENT);
             }
         }
     }
@@ -11766,36 +11351,27 @@
     {
       uint32_t id = args(2).uint32_scalar_value ().value ();
 
-      if (! error_state)
-        {
-          if (args.length () > 5)
-            {
-              double h = args(0).double_value ();
-
-              if (! error_state)
-                {
-                  caseless_str pname = args(4).string_value ();
-
-                  if (! error_state)
-                    {
-                      gh_manager::auto_lock guard;
-
-                      graphics_handle handle = gh_manager::lookup (h);
-
-                      if (handle.ok ())
-                        {
-                          graphics_object go = gh_manager::get_object (handle);
-                          octave_value pvalue = go.get (pname);
-
-                          if (compare_property_values (pvalue, args(5)))
-                            waitfor_results[id] = true;
-                        }
-                    }
-                }
-            }
-          else
-            waitfor_results[id] = true;
-        }
+      if (args.length () > 5)
+        {
+          double h = args(0).double_value ();
+
+          caseless_str pname = args(4).string_value ();
+
+          gh_manager::auto_lock guard;
+
+          graphics_handle gh = gh_manager::lookup (h);
+
+          if (gh.ok ())
+            {
+              graphics_object go = gh_manager::get_object (gh);
+              octave_value pvalue = go.get (pname);
+
+              if (compare_property_values (pvalue, args(5)))
+                waitfor_results[id] = true;
+            }
+        }
+      else
+        waitfor_results[id] = true;
     }
 
   return octave_value_list ();
@@ -11808,8 +11384,7 @@
     {
       uint32_t id = args(2).uint32_scalar_value ().value ();
 
-      if (! error_state)
-        waitfor_results[id] = true;
+      waitfor_results[id] = true;
     }
 
   return octave_value_list ();
@@ -11857,221 +11432,201 @@
 @seealso{waitforbuttonpress, isequal}\n\
 @end deftypefn")
 {
-  if (args.length () > 0)
-    {
-      double h = args(0).double_value ();
-
-      if (! error_state)
-        {
-          caseless_str pname;
-
-          unwind_protect frame;
-
-          static uint32_t id_counter = 0;
-          uint32_t id = 0;
-
-          int max_arg_index = 0;
-          int timeout_index = -1;
-
-          int timeout = 0;
-
-          if (args.length () > 1)
-            {
-              pname = args(1).string_value ();
-              if (! error_state
-                  && ! pname.empty ()
-                  && ! pname.compare ("timeout"))
+  if (args.length () == 0)
+    print_usage ();
+
+  double h = args(0).xdouble_value ("waitfor: invalid handle value");
+
+  caseless_str pname;
+
+  unwind_protect frame;
+
+  static uint32_t id_counter = 0;
+  uint32_t id = 0;
+
+  int max_arg_index = 0;
+  int timeout_index = -1;
+
+  int timeout = 0;
+
+  if (args.length () > 1)
+    {
+      pname = args(1).xstring_value ("waitfor: PROP must be a string");
+
+      if (! pname.empty () && ! pname.compare ("timeout"))
+        {
+          if (pname.compare ("\\timeout"))
+            pname = "timeout";
+
+          static octave_value wf_listener;
+
+          if (! wf_listener.is_defined ())
+            wf_listener =
+              octave_value (new octave_builtin (waitfor_listener,
+                                                "waitfor_listener"));
+
+          max_arg_index++;
+          if (args.length () > 2)
+            {
+              if (args(2).is_string ())
                 {
-                  if (pname.compare ("\\timeout"))
-                    pname = "timeout";
-
-                  static octave_value wf_listener;
-
-                  if (! wf_listener.is_defined ())
-                    wf_listener =
-                      octave_value (new octave_builtin (waitfor_listener,
-                                                        "waitfor_listener"));
-
-                  max_arg_index++;
-                  if (args.length () > 2)
+                  caseless_str s = args(2).string_value ();
+
+                  if (s.compare ("timeout"))
+                    timeout_index = 2;
+                  else
+                    max_arg_index++;
+                }
+              else
+                max_arg_index++;
+            }
+
+          Cell listener (1, max_arg_index >= 2 ? 5 : 4);
+
+          id = id_counter++;
+          frame.add_fcn (cleanup_waitfor_id, id);
+          waitfor_results[id] = false;
+
+          listener(0) = wf_listener;
+          listener(1) = octave_uint32 (id);
+          listener(2) = h;
+          listener(3) = pname;
+
+          if (max_arg_index >= 2)
+            listener(4) = args(2);
+
+          octave_value ov_listener (listener);
+
+          gh_manager::auto_lock guard;
+
+          graphics_handle gh = gh_manager::lookup (h);
+
+          if (gh.ok ())
+            {
+              graphics_object go = gh_manager::get_object (gh);
+
+              if (max_arg_index >= 2
+                  && compare_property_values (go.get (pname),
+                                              args(2)))
+                waitfor_results[id] = true;
+              else
+                {
+
+                  frame.add_fcn (cleanup_waitfor_postset_listener,
+                                 ov_listener);
+                  go.add_property_listener (pname, ov_listener,
+                                            POSTSET);
+                  go.add_property_listener (pname, ov_listener,
+                                            PERSISTENT);
+
+                  if (go.get_properties ()
+                      .has_dynamic_property (pname))
                     {
-                      if (args(2).is_string ())
-                        {
-                          caseless_str s = args(2).string_value ();
-
-                          if (s.compare ("timeout"))
-                            timeout_index = 2;
-                          else
-                            max_arg_index++;
-                        }
-                      else
-                        max_arg_index++;
-                    }
-
-                  Cell listener (1, max_arg_index >= 2 ? 5 : 4);
-
-                  id = id_counter++;
-                  frame.add_fcn (cleanup_waitfor_id, id);
-                  waitfor_results[id] = false;
-
-                  listener(0) = wf_listener;
-                  listener(1) = octave_uint32 (id);
-                  listener(2) = h;
-                  listener(3) = pname;
-
-                  if (max_arg_index >= 2)
-                    listener(4) = args(2);
-
-                  octave_value ov_listener (listener);
-
-                  gh_manager::auto_lock guard;
-
-                  graphics_handle handle = gh_manager::lookup (h);
-
-                  if (handle.ok ())
-                    {
-                      graphics_object go = gh_manager::get_object (handle);
-
-                      if (max_arg_index >= 2
-                          && compare_property_values (go.get (pname),
-                                                      args(2)))
-                        waitfor_results[id] = true;
-                      else
-                        {
-
-                          frame.add_fcn (cleanup_waitfor_postset_listener,
-                                         ov_listener);
-                          go.add_property_listener (pname, ov_listener,
-                                                    POSTSET);
-                          go.add_property_listener (pname, ov_listener,
-                                                    PERSISTENT);
-
-                          if (go.get_properties ()
-                              .has_dynamic_property (pname))
-                            {
-                              static octave_value wf_del_listener;
-
-                              if (! wf_del_listener.is_defined ())
-                                wf_del_listener =
-                                  octave_value (new octave_builtin
-                                                (waitfor_del_listener,
-                                                 "waitfor_del_listener"));
-
-                              Cell del_listener (1, 4);
-
-                              del_listener(0) = wf_del_listener;
-                              del_listener(1) = octave_uint32 (id);
-                              del_listener(2) = h;
-                              del_listener(3) = pname;
-
-                              octave_value ov_del_listener (del_listener);
-
-                              frame.add_fcn (cleanup_waitfor_predelete_listener,
-                                             ov_del_listener);
-                              go.add_property_listener (pname, ov_del_listener,
-                                                        PREDELETE);
-                            }
-                        }
+                      static octave_value wf_del_listener;
+
+                      if (! wf_del_listener.is_defined ())
+                        wf_del_listener =
+                          octave_value (new octave_builtin
+                                        (waitfor_del_listener,
+                                         "waitfor_del_listener"));
+
+                      Cell del_listener (1, 4);
+
+                      del_listener(0) = wf_del_listener;
+                      del_listener(1) = octave_uint32 (id);
+                      del_listener(2) = h;
+                      del_listener(3) = pname;
+
+                      octave_value ov_del_listener (del_listener);
+
+                      frame.add_fcn (cleanup_waitfor_predelete_listener,
+                                     ov_del_listener);
+                      go.add_property_listener (pname, ov_del_listener,
+                                                PREDELETE);
                     }
                 }
-              else if (error_state || pname.empty ())
-                error ("waitfor: invalid property name, expected a non-empty string value");
-            }
-
-          if (! error_state
-              && timeout_index < 0
-              && args.length () > (max_arg_index + 1))
-            {
-              caseless_str s = args(max_arg_index + 1).string_value ();
-
-              if (! error_state)
-                {
-                  if (s.compare ("timeout"))
-                    timeout_index = max_arg_index + 1;
-                  else
-                    error ("waitfor: invalid parameter '%s'", s.c_str ());
-                }
-              else
-                error ("waitfor: invalid parameter, expected 'timeout'");
-            }
-
-          if (! error_state && timeout_index >= 0)
-            {
-              if (args.length () > (timeout_index + 1))
-                {
-                  timeout = static_cast<int>
-                            (args(timeout_index + 1).scalar_value ());
-
-                  if (! error_state)
-                    {
-                      if (timeout < 1)
-                        {
-                          warning ("waitfor: the timeout value must be >= 1, using 1 instead");
-                          timeout = 1;
-                        }
-                    }
-                  else
-                    error ("waitfor: invalid timeout value, expected a value >= 1");
-                }
-              else
-                error ("waitfor: missing timeout value");
-            }
-
-          // FIXME: There is still a "hole" in the following loop. The code
-          //        assumes that an object handle is unique, which is a fair
-          //        assumption, except for figures. If a figure is destroyed
-          //        then recreated with the same figure ID, within the same
-          //        run of event hooks, then the figure destruction won't be
-          //        caught and the loop will not stop. This is an unlikely
-          //        possibility in practice, though.
-          //
-          //        Using deletefcn callback is also unreliable as it could be
-          //        modified during a callback execution and the waitfor loop
-          //        would not stop.
-          //
-          //        The only "good" implementation would require object
-          //        listeners, similar to property listeners.
-
-          time_t start = 0;
-
-          if (timeout > 0)
-            start = time (0);
-
-          while (! error_state)
-            {
-              if (true)
-                {
-                  gh_manager::auto_lock guard;
-
-                  graphics_handle handle = gh_manager::lookup (h);
-
-                  if (handle.ok ())
-                    {
-                      if (! pname.empty () && waitfor_results[id])
-                        break;
-                    }
-                  else
-                    break;
-                }
-
-              octave_usleep (100000);
-
-              OCTAVE_QUIT;
-
-              command_editor::run_event_hooks ();
-
-              if (timeout > 0)
-                {
-                  if (start + timeout < time (0))
-                    break;
-                }
+            }
+        }
+      else if (pname.empty ())
+        error ("waitfor: PROP must be a non-empty string");
+    }
+
+  if (timeout_index < 0 && args.length () > (max_arg_index + 1))
+    {
+      caseless_str s = args(max_arg_index + 1).xstring_value ("waitfor: invalid parameter, expected 'timeout'");
+
+      if (s.compare ("timeout"))
+        timeout_index = max_arg_index + 1;
+      else
+        error ("waitfor: invalid parameter '%s'", s.c_str ());
+    }
+
+  if (timeout_index >= 0)
+    {
+      if (args.length () > (timeout_index + 1))
+        {
+          timeout = static_cast<int>
+            (args(timeout_index + 1).xscalar_value ("waitfor: TIMEOUT must be a scalar >= 1"));
+
+          if (timeout < 1)
+            {
+              warning ("waitfor: TIMEOUT value must be >= 1, using 1 instead");
+              timeout = 1;
             }
         }
       else
-        error ("waitfor: invalid handle value.");
-    }
-  else
-    print_usage ();
+        error ("waitfor: missing TIMEOUT value");
+    }
+
+  // FIXME: There is still a "hole" in the following loop. The code
+  //        assumes that an object handle is unique, which is a fair
+  //        assumption, except for figures.  If a figure is destroyed
+  //        then recreated with the same figure ID, within the same
+  //        run of event hooks, then the figure destruction won't be
+  //        caught and the loop will not stop.  This is an unlikely
+  //        possibility in practice, though.
+  //
+  //        Using deletefcn callback is also unreliable as it could be
+  //        modified during a callback execution and the waitfor loop
+  //        would not stop.
+  //
+  //        The only "good" implementation would require object
+  //        listeners, similar to property listeners.
+
+  time_t start = 0;
+
+  if (timeout > 0)
+    start = time (0);
+
+  while (true)
+    {
+      if (true)
+        {
+          gh_manager::auto_lock guard;
+
+          graphics_handle gh = gh_manager::lookup (h);
+
+          if (gh.ok ())
+            {
+              if (! pname.empty () && waitfor_results[id])
+                break;
+            }
+          else
+            break;
+        }
+
+      octave_usleep (100000);
+
+      OCTAVE_QUIT;
+
+      command_editor::run_event_hooks ();
+
+      if (timeout > 0)
+        {
+          if (start + timeout < time (0))
+            break;
+        }
+    }
 
   return octave_value ();
 }
@@ -12089,16 +11644,10 @@
   int nargin = args.length ();
 
   if (nargin != 2 && nargin != 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   double h = args(0).double_value ();
 
-  if (error_state)
-    return retval;
-
   gh_manager::auto_lock guard;
 
   graphics_handle handle = gh_manager::lookup (h);
@@ -12118,9 +11667,6 @@
     {
       std::string opt = args(1).string_value ();
 
-      if (error_state)
-        return retval;
-
       if (opt == "out" || opt == "reset")
         {
           if (opt == "out")
@@ -12130,7 +11676,6 @@
             }
           else
             ax_props.clear_zoom_stack (false);
-
         }
     }
   else
@@ -12138,12 +11683,10 @@
       std::string mode = args(1).string_value ();
       double factor = args(2).scalar_value ();
 
-      if (error_state)
-        return retval;
-
       ax_props.zoom (mode, factor);
       Vdrawnow_requested = true;
     }
 
   return retval;
 }
+
--- a/libinterp/corefcn/graphics.in.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/graphics.in.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_graphics_h)
+#if ! defined (octave_graphics_h)
 #define octave_graphics_h 1
 
 #ifdef HAVE_CONFIG_H
@@ -49,7 +49,7 @@
 // FIXME: maybe this should be a configure option?
 // Matlab defaults to "Helvetica", but that causes problems for many
 // gnuplot users.
-#if !defined (OCTAVE_DEFAULT_FONTNAME)
+#if ! defined (OCTAVE_DEFAULT_FONTNAME)
 #define OCTAVE_DEFAULT_FONTNAME "*"
 #endif
 
@@ -536,10 +536,10 @@
   {
     std::string s;
 
-    for (octave_idx_type i = 0; i < str.length (); i++)
+    for (octave_idx_type i = 0; i < str.numel (); i++)
       {
         s += str[i];
-        if (i != str.length () - 1)
+        if (i != str.numel () - 1)
           s += separator;
       }
 
@@ -636,9 +636,9 @@
 
         string_vector strings = new_cell.cellstr_value ();
 
-        octave_idx_type nel = strings.length ();
-
-        if (nel != str.length ())
+        octave_idx_type nel = strings.numel ();
+
+        if (nel != str.numel ())
           replace = true;
         else
           {
@@ -718,14 +718,9 @@
           {
             double d = c(i).double_value ();
 
-            if (! error_state)
-              {
-                std::ostringstream buf;
-                buf << d;
-                value[i] = buf.str ();
-              }
-            else
-              break;
+            std::ostringstream buf;
+            buf << d;
+            value[i] = buf.str ();
           }
       }
   }
@@ -795,14 +790,9 @@
               {
                 double d = c(i).double_value ();
 
-                if (! error_state)
-                  {
-                    std::ostringstream buf;
-                    buf << d;
-                    value[i] = buf.str ();
-                  }
-                else
-                  return false;
+                std::ostringstream buf;
+                buf << d;
+                value[i] = buf.str ();
               }
           }
 
@@ -810,30 +800,30 @@
       }
     else
       {
-        NDArray nda = val.array_value ();
-
-        if (! error_state)
+        NDArray nda;
+
+        try
+          {
+            nda = val.array_value ();
+          }
+        catch (octave_execution_exception& e)
           {
-            octave_idx_type nel = nda.numel ();
-
-            value.resize (nel);
-
-            for (octave_idx_type i = 0; i < nel; i++)
-              {
-                std::ostringstream buf;
-                buf << nda(i);
-                value[i] = buf.str ();
-              }
-
-            stored_type = char_t;
+            error (e, "set: invalid string property value for \"%s\"",
+                   get_name ().c_str ());
           }
-        else
+
+        octave_idx_type nel = nda.numel ();
+
+        value.resize (nel);
+
+        for (octave_idx_type i = 0; i < nel; i++)
           {
-            error ("set: invalid string property value for \"%s\"",
-                   get_name ().c_str ());
-
-            return false;
+            std::ostringstream buf;
+            buf << nda(i);
+            value[i] = buf.str ();
           }
+
+        stored_type = char_t;
       }
 
     return true;
@@ -1066,10 +1056,7 @@
     for (int i = 0; i < 3; i++)
       {
         if (xrgb(i) < 0 ||  xrgb(i) > 1)
-          {
-            error ("invalid RGB color specification");
-            break;
-          }
+          error ("invalid RGB color specification");
       }
   }
 
@@ -1146,7 +1133,7 @@
   Matrix rgb (void) const
   {
     if (current_type != color_t)
-      error ("color has no rgb value");
+      error ("color has no RGB value");
 
     return color_val.rgb ();
   }
@@ -1488,23 +1475,18 @@
   {
     bool retval = array_property::do_set (v);
 
-    if (! error_state)
+    dim_vector dv = data.dims ();
+
+    if (dv(0) > 1 && dv(1) == 1)
       {
-        dim_vector dv = data.dims ();
-
-        if (dv(0) > 1 && dv(1) == 1)
-          {
-            int tmp = dv(0);
-            dv(0) = dv(1);
-            dv(1) = tmp;
-
-            data = data.reshape (dv);
-          }
-
-        return retval;
+        int tmp = dv(0);
+        dv(0) = dv(1);
+        dv(1) = tmp;
+
+        data = data.reshape (dv);
       }
 
-    return false;
+    return retval;
   }
 
 private:
@@ -1712,7 +1694,16 @@
 protected:
   bool do_set (const octave_value& val)
   {
-    const Matrix new_kids = val.matrix_value ();
+    Matrix new_kids;
+
+    try
+      {
+        new_kids = val.matrix_value ();
+      }
+    catch (octave_execution_exception& e)
+      {
+        error (e, "set: children must be an array of graphics handles");
+      }
 
     octave_idx_type nel = new_kids.numel ();
 
@@ -1721,33 +1712,25 @@
     bool is_ok = true;
     bool add_hidden = true;
 
-    if (! error_state)
+    const Matrix visible_kids = do_get_children (false);
+
+    if (visible_kids.numel () == new_kids.numel ())
       {
-        const Matrix visible_kids = do_get_children (false);
-
-        if (visible_kids.numel () == new_kids.numel ())
-          {
-            Matrix t1 = visible_kids.sort ();
-            Matrix t2 = new_kids_column.sort ();
-            Matrix t3 = get_hidden ().sort ();
-
-            if (t1 != t2)
-              is_ok = false;
-
-            if (t1 == t3)
-              add_hidden = false;
-          }
-        else
+        Matrix t1 = visible_kids.sort ();
+        Matrix t2 = new_kids_column.sort ();
+        Matrix t3 = get_hidden ().sort ();
+
+        if (t1 != t2)
           is_ok = false;
 
-        if (! is_ok)
-          error ("set: new children must be a permutation of existing children");
+        if (t1 == t3)
+          add_hidden = false;
       }
     else
-      {
-        is_ok = false;
-        error ("set: expecting children to be array of graphics handles");
-      }
+      is_ok = false;
+
+    if (! is_ok)
+      error ("set: new children must be a permutation of existing children");
 
     if (is_ok)
       {
@@ -2365,7 +2348,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create gh_manager!");
+        error ("unable to create gh_manager!");
 
         retval = false;
       }
@@ -3218,29 +3201,25 @@
     // See the genprops.awk script for an explanation of the
     // properties declarations.
 
-    // FIXME: Properties that still dont have callbacks are:
-    // language, monitorpositions, pointerlocation, pointerwindow.
+    // FIXME: Properties that still don't have callbacks are:
+    // monitorpositions, pointerlocation, pointerwindow.
     // Note that these properties are not yet used by Octave, so setting
     // them will have no effect.
 
+    // FIXME: The commandwindowsize property has been deprecated in Matlab
+    //        and is now available through matlab.desktop.comandwindow.size.
+    //        Until Octave has something similar, keep this property in root.
+
     // Programming note: Keep property list sorted if new ones are added.
 
     BEGIN_PROPERTIES (root_figure, root)
       handle_property callbackobject Sr , graphics_handle ()
       array_property commandwindowsize r , Matrix (1, 2, 0)
       handle_property currentfigure S , graphics_handle ()
-      bool_property diary GS , "off"
-      string_property diaryfile GS , "diary"
-      bool_property echo GS , "off"
-      string_property errormessage Gr , ""
       string_property fixedwidthfontname , "Courier"
-      radio_property format GS , "+|bank|bit|hex|long|longe|longeng|longg|native-bit|native-hex|none|rat|{short}|shorte|shorteng|shortg"
-      radio_property formatspacing GS , "compact|{loose}"
-      string_property language , "ascii"
-      array_property monitorpositions , Matrix (1, 4, 0)
+      array_property monitorpositions r , Matrix (1, 4, 0)
       array_property pointerlocation , Matrix (1, 2, 0)
       double_property pointerwindow r , 0.0
-      double_property recursionlimit GS , 256.0
       double_property screendepth r , default_screendepth ()
       double_property screenpixelsperinch r , default_screenpixelsperinch ()
       array_property screensize r , default_screensize ()
@@ -3399,28 +3378,21 @@
 
     void set___graphics_toolkit__ (const octave_value& val)
     {
-      if (! error_state)
+      if (val.is_string ())
         {
-          if (val.is_string ())
+          std::string nm = val.string_value ();
+          graphics_toolkit b = gtk_manager::find_toolkit (nm);
+
+          if (b.get_name () != nm)
+            error ("set___graphics_toolkit__: invalid graphics toolkit");
+          else if (nm != get___graphics_toolkit__ ())
             {
-              std::string nm = val.string_value ();
-              graphics_toolkit b = gtk_manager::find_toolkit (nm);
-              if (b.get_name () != nm)
-                {
-                  error ("set___graphics_toolkit__: invalid graphics toolkit");
-                }
-              else
-                {
-                  if (nm != get___graphics_toolkit__ ())
-                    {
-                      set_toolkit (b);
-                      mark_modified ();
-                    }
-                }
+              set_toolkit (b);
+              mark_modified ();
             }
-          else
-            error ("set___graphics_toolkit__ must be a string");
         }
+      else
+        error ("set___graphics_toolkit__ must be a string");
     }
 
     void adopt (const graphics_handle& h);
@@ -3449,6 +3421,12 @@
 
     // See the genprops.awk script for an explanation of the
     // properties declarations.
+    // FIXME: Several properties have been deleted from Matlab.
+    //        We should either immediately remove them or figure out a way
+    //        to deprecate them for a release or two.
+    // Obsolete properties: doublebuffer, mincolormap, wvisual, wvisualmode,
+    // xdisplay, xvisual, xvisualmode
+
     // Programming note: Keep property list sorted if new ones are added.
 
     BEGIN_PROPERTIES (figure)
@@ -3456,7 +3434,7 @@
       callback_property buttondownfcn , Matrix ()
       callback_property closerequestfcn , "closereq"
       color_property color , color_property (color_values (1, 1, 1), radio_values ("none"))
-      array_property colormap , jet_colormap ()
+      array_property colormap , viridis_colormap ()
       handle_property currentaxes S , graphics_handle ()
       string_property currentcharacter r , ""
       handle_property currentobject r , graphics_handle ()
@@ -3464,6 +3442,7 @@
       bool_property dockcontrols , "off"
       bool_property doublebuffer , "on"
       string_property filename , ""
+      bool_property graphicssmoothing , "on"
       bool_property integerhandle S , "on"
       bool_property inverthardcopy , "off"
       callback_property keypressfcn , Matrix ()
@@ -3471,6 +3450,8 @@
       radio_property menubar , "none|{figure}"
       double_property mincolormap , 64
       string_property name , ""
+      // FIXME: Need RO property which returns current figure number.
+      // double_property number r ,
       radio_property nextplot , "new|{add}|replacechildren|replace"
       bool_property numbertitle , "on"
       array_property outerposition s , Matrix (1, 4, -1.0)
@@ -3489,6 +3470,9 @@
       bool_property resize , "on"
       callback_property resizefcn , Matrix ()
       radio_property selectiontype , "{normal}|open|alt|extend"
+      // FIXME: This is the new name for the resizefcn from Matlab.
+      //        Need to try supporting both for some amount of time.
+      callback_property sizechangedfcn , Matrix ()
       radio_property toolbar , "none|{auto}|figure"
       radio_property units Su , "inches|centimeters|normalized|points|{pixels}|characters"
       callback_property windowbuttondownfcn , Matrix ()
@@ -3504,14 +3488,14 @@
       string_property xvisual , ""
       radio_property xvisualmode , "{auto}|manual"
       // Octave-specific properties
-      radio_property __mouse_mode__ hS , "{none}|pan|rotate|select|text|zoom"
-      any_property __pan_mode__ h , Matrix ()
-      any_property __rotate_mode__ h , Matrix ()
-      any_property __zoom_mode__ h , Matrix ()
       bool_property __enhanced__ h , "on"
       string_property __graphics_toolkit__ hs , gtk_manager::default_toolkit ()
       any_property __guidata__ h , Matrix ()
+      radio_property __mouse_mode__ hS , "{none}|pan|rotate|select|text|zoom"
+      any_property __pan_mode__ h , Matrix ()
       any_property __plot_stream__ h , Matrix ()
+      any_property __rotate_mode__ h , Matrix ()
+      any_property __zoom_mode__ h , Matrix ()
     END_PROPERTIES
 
   protected:
@@ -3867,6 +3851,12 @@
 
     // See the genprops.awk script for an explanation of the
     // properties declarations.
+
+    // FIXME: Several properties have been deleted from Matlab.
+    //        We should either immediately remove them or figure out a way
+    //        to deprecate them for a release or two.
+    // Obsolete properties: drawmode
+
     // Programming note: Keep property list sorted if new ones are added.
 
     BEGIN_PROPERTIES (axes)
@@ -3875,53 +3865,70 @@
       radio_property alimmode , "{auto}|manual"
       color_property ambientlightcolor , color_values (1, 1, 1)
       bool_property box , "on"
+      radio_property boxstyle , "{back}|full"
       array_property cameraposition m , Matrix (1, 3, 0.0)
       radio_property camerapositionmode , "{auto}|manual"
       array_property cameratarget m , Matrix (1, 3, 0.0)
       radio_property cameratargetmode , "{auto}|manual"
       array_property cameraupvector m , Matrix (1, 3, 0.0)
       radio_property cameraupvectormode , "{auto}|manual"
-      double_property cameraviewangle m , 10.0
+      double_property cameraviewangle m , 6.6086
       radio_property cameraviewanglemode , "{auto}|manual"
       row_vector_property clim m , default_lim ()
       radio_property climmode al , "{auto}|manual"
+      radio_property clippingstyle , "{3dbox}|rectangle"
       color_property color , color_property (color_values (1, 1, 1), radio_values ("none"))
       array_property colororder , default_colororder ()
+      double_property colororderindex , 1.0
       array_property currentpoint , Matrix (2, 3, 0.0)
       array_property dataaspectratio mu , Matrix (1, 3, 1.0)
       radio_property dataaspectratiomode u , "{auto}|manual"
       radio_property drawmode , "{normal}|fast"
-      radio_property fontangle u , "{normal}|italic|oblique"
+      radio_property fontangle u , "{normal}|italic"
       string_property fontname u , OCTAVE_DEFAULT_FONTNAME
       double_property fontsize u , 10
-      radio_property fontunits SU , "{points}|normalized|inches|centimeters|pixels"
-      radio_property fontweight u , "{normal}|light|demi|bold"
-      radio_property gridlinestyle , "-|--|{:}|-.|none"
-      // NOTE: interpreter is not a Matlab axis property, but it makes
-      //       more sense to have it so that axis ticklabels can use it.
-      radio_property interpreter , "tex|{none}|latex"
+      radio_property fontunits SU , "{points}|inches|centimeters|normalized|pixels"
+      bool_property fontsmoothing , "on"
+      radio_property fontweight u , "{normal}|bold"
+      double_property gridalpha , 0.15
+      radio_property gridalphamode , "{auto}|manual"
+      color_property gridcolor , color_property (color_values (0.15, 0.15, 0.15), radio_values ("none"))
+      radio_property gridcolormode , "{auto}|manual"
+      radio_property gridlinestyle , "{:}|-|--|-.|none"
+      double_property labelfontsizemultiplier , 1.1
       radio_property layer u , "{bottom}|top"
       // FIXME: should be kind of string array.
       any_property linestyleorder S , "-"
+      double_property linestyleorderindex , 1.0
       double_property linewidth , 0.5
-      radio_property minorgridlinestyle , "-|--|{:}|-.|none"
-      double_property mousewheelzoom , 0.5
-      radio_property nextplot , "add|replacechildren|{replace}"
+      double_property minorgridalpha , 0.25
+      radio_property minorgridalphamode , "{auto}|manual"
+      color_property minorgridcolor , color_property (color_values (0.1, 0.1, 0.1), radio_values ("none"))
+      radio_property minorgridcolormode , "{auto}|manual"
+      radio_property minorgridlinestyle , "{:}|-|--|-.|none"
+      radio_property nextplot , "{replace}|add|replacechildren"
       array_property outerposition u , default_axes_outerposition ()
       array_property plotboxaspectratio mu , Matrix (1, 3, 1.0)
       radio_property plotboxaspectratiomode u , "{auto}|manual"
+      radio_property pickableparts , "{visible}|all|none"
       array_property position u , default_axes_position ()
       radio_property projection , "{orthographic}|perspective"
+      radio_property sortmethod , "{depth}|childorder"
       radio_property tickdir mu , "{in}|out"
       radio_property tickdirmode u , "{auto}|manual"
+      // FIXME: Added recently to Matlab, should replace interpreter property.
+      radio_property ticklabelinterpreter , "{tex}|latex|none"
       array_property ticklength u , default_axes_ticklength ()
       array_property tightinset r , Matrix (1, 4, 0.0)
       handle_property title SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
+      double_property titlefontsizemultiplier , 1.1
+      radio_property titlefontweight , "{bold}|normal"
       // FIXME: uicontextmenu should be moved here.
       radio_property units SU , "{normalized}|inches|centimeters|points|pixels|characters"
       array_property view u , default_axes_view ()
       radio_property xaxislocation u , "{bottom}|top|zero"
       color_property xcolor , color_values (0, 0, 0)
+      radio_property xcolormode , "{auto}|manual"
       radio_property xdir u , "{normal}|reverse"
       bool_property xgrid , "off"
       handle_property xlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
@@ -3934,9 +3941,11 @@
       // FIXME: should be kind of string array.
       any_property xticklabel S , ""
       radio_property xticklabelmode u , "{auto}|manual"
+      double_property xticklabelrotation , 0.0
       radio_property xtickmode u , "{auto}|manual"
       radio_property yaxislocation u , "{left}|right|zero"
       color_property ycolor , color_values (0, 0, 0)
+      radio_property ycolormode , "{auto}|manual"
       radio_property ydir u , "{normal}|reverse"
       bool_property ygrid , "off"
       handle_property ylabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
@@ -3948,8 +3957,10 @@
       row_vector_property ytick mu , default_axes_tick ()
       any_property yticklabel S , ""
       radio_property yticklabelmode u , "{auto}|manual"
+      double_property yticklabelrotation , 0.0
       radio_property ytickmode u , "{auto}|manual"
       color_property zcolor , color_values (0, 0, 0)
+      radio_property zcolormode , "{auto}|manual"
       radio_property zdir u , "{normal}|reverse"
       bool_property zgrid , "off"
       handle_property zlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false, false, false)
@@ -3961,8 +3972,10 @@
       row_vector_property ztick mu , default_axes_tick ()
       any_property zticklabel S , ""
       radio_property zticklabelmode u , "{auto}|manual"
+      double_property zticklabelrotation , 0.0
       radio_property ztickmode u , "{auto}|manual"
       // Octave-specific properties
+      double_property mousewheelzoom , 0.5
       bool_property __hold_all__ h , "off"
       // hidden properties for alignment of subplots
       radio_property autopos_tag h , "{none}|subplot"
@@ -4398,7 +4411,7 @@
     // Programming note: Keep property list sorted if new ones are added.
 
     BEGIN_PROPERTIES (line)
-      color_property color , color_values (0, 0, 0)
+      color_property color , color_property (color_values (0, 0, 0), radio_values ("none"))
       string_property displayname , ""
       radio_property erasemode , "{normal}|none|xor|background"
       // FIXME: interpreter is not a property of Matlab line objects.
@@ -4478,27 +4491,24 @@
 
     void set_position (const octave_value& val)
     {
-      if (! error_state)
+      octave_value new_val (val);
+
+      if (new_val.numel () == 2)
         {
-          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");
+          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
@@ -5308,7 +5318,7 @@
     // Programming note: Keep property list sorted if new ones are added.
 
     BEGIN_PROPERTIES (uimenu)
-      any_property __object__ , Matrix ()
+      any_property __object__ h , Matrix ()
       string_property accelerator , ""
       callback_property callback , Matrix ()
       bool_property checked , "off"
@@ -5374,7 +5384,7 @@
     // Programming note: Keep property list sorted if new ones are added.
 
     BEGIN_PROPERTIES (uicontextmenu)
-      any_property __object__ , Matrix ()
+      any_property __object__ h , Matrix ()
       callback_property callback , Matrix ()
       array_property position , Matrix (1, 2, 0.0)
     END_PROPERTIES
@@ -5436,7 +5446,7 @@
     // Programming note: Keep property list sorted if new ones are added.
 
     BEGIN_PROPERTIES (uicontrol)
-      any_property __object__ , Matrix ()
+      any_property __object__ h , Matrix ()
       color_property backgroundcolor , color_values (1, 1, 1)
       callback_property callback , Matrix ()
       array_property cdata , Matrix ()
@@ -5534,7 +5544,7 @@
     // Programming note: Keep property list sorted if new ones are added.
 
     BEGIN_PROPERTIES (uipanel)
-      any_property __object__ , Matrix ()
+      any_property __object__ h , Matrix ()
       color_property backgroundcolor , color_values (1, 1, 1)
       radio_property bordertype , "none|{etchedin}|etchedout|beveledin|beveledout|line"
       double_property borderwidth , 1
@@ -5602,7 +5612,7 @@
     // Programming note: Keep property list sorted if new ones are added.
 
     BEGIN_PROPERTIES (uitoolbar)
-      any_property __object__ , Matrix ()
+      any_property __object__ h , Matrix ()
     END_PROPERTIES
 
   protected:
@@ -5702,7 +5712,7 @@
     // Programming note: Keep property list sorted if new ones are added.
 
     BEGIN_PROPERTIES (uipushtool)
-      any_property __object__ , Matrix ()
+      any_property __object__ h , Matrix ()
       array_property cdata , Matrix ()
       callback_property clickedcallback , Matrix ()
       bool_property enable , "on"
@@ -5758,7 +5768,7 @@
     // Programming note: Keep property list sorted if new ones are added.
 
     BEGIN_PROPERTIES (uitoggletool)
-      any_property __object__ , Matrix ()
+      any_property __object__ h , Matrix ()
       array_property cdata , Matrix ()
       callback_property clickedcallback , Matrix ()
       bool_property enable , "on"
@@ -5913,7 +5923,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create gh_manager!");
+        error ("unable to create gh_manager!");
 
         retval = false;
       }
@@ -6059,8 +6069,7 @@
           cb = go.get (name);
       }
 
-    if (! error_state)
-      execute_callback (h, cb, data);
+    execute_callback (h, cb, data);
   }
 
   static void execute_callback (const graphics_handle& h,
--- a/libinterp/corefcn/gripes.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/gripes.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -86,7 +86,16 @@
 void
 gripe_user_supplied_eval (const char *name)
 {
-  error ("%s: evaluation of user-supplied function failed", name);
+  octave_execution_exception e;
+
+  gripe_user_supplied_eval (e, name);
+}
+
+void
+gripe_user_supplied_eval (octave_execution_exception& e,
+                          const char *name)
+{
+  error (e, "%s: evaluation of user-supplied function failed", name);
 }
 
 void
@@ -134,8 +143,17 @@
 void
 gripe_wrong_type_arg (const char *name, const char *s, bool is_error)
 {
+  octave_execution_exception e;
+
+  gripe_wrong_type_arg (e, name, s, is_error);
+}
+
+void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const char *name, const char *s, bool is_error)
+{
   if (is_error)
-    error ("%s: wrong type argument '%s'", name, s);
+    error (e, "%s: wrong type argument '%s'", name, s);
   else
     warning ("%s: wrong type argument '%s'", name, s);
 }
@@ -143,23 +161,102 @@
 void
 gripe_wrong_type_arg (const char *name, const std::string& s, bool is_error)
 {
-  gripe_wrong_type_arg (name, s.c_str (), is_error);
+  octave_execution_exception e;
+
+  gripe_wrong_type_arg (e, name, s.c_str (), is_error);
+}
+
+void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const char *name, const std::string& s, bool is_error)
+{
+  gripe_wrong_type_arg (e, name, s.c_str (), is_error);
 }
 
 void
 gripe_wrong_type_arg (const char *name, const octave_value& tc,
                       bool is_error)
 {
+  octave_execution_exception e;
+
+  gripe_wrong_type_arg (e, name, tc, is_error);
+}
+
+void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const char *name, const octave_value& tc,
+                      bool is_error)
+{
   std::string type = tc.type_name ();
 
-  gripe_wrong_type_arg (name, type, is_error);
+  gripe_wrong_type_arg (e, name, type, is_error);
 }
 
 void
 gripe_wrong_type_arg (const std::string& name, const octave_value& tc,
                       bool is_error)
 {
-  gripe_wrong_type_arg (name.c_str (), tc, is_error);
+  octave_execution_exception e;
+
+  gripe_wrong_type_arg (e, name, tc, is_error);
+}
+
+void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const std::string& name, const octave_value& tc,
+                      bool is_error)
+{
+  gripe_wrong_type_arg (e, name.c_str (), tc, is_error);
+}
+
+void
+gripe_wrong_type_arg (const char *s, bool is_error)
+{
+  octave_execution_exception e;
+
+  gripe_wrong_type_arg (e, s, is_error);
+}
+
+void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const char *s, bool is_error)
+{
+  if (is_error)
+    error (e, "wrong type argument '%s'", s);
+  else
+    warning ("wrong type argument '%s'", s);
+}
+
+void
+gripe_wrong_type_arg (const std::string& s, bool is_error)
+{
+  octave_execution_exception e;
+
+  gripe_wrong_type_arg (e, s, is_error);
+}
+
+void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const std::string& s, bool is_error)
+{
+  gripe_wrong_type_arg (e, s.c_str (), is_error);
+}
+
+void
+gripe_wrong_type_arg (const octave_value& tc, bool is_error)
+{
+  octave_execution_exception e;
+
+  gripe_wrong_type_arg (e, tc, is_error);
+}
+
+void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const octave_value& tc, bool is_error)
+{
+  std::string type = tc.type_name ();
+
+  gripe_wrong_type_arg (e, type, is_error);
 }
 
 void
@@ -205,15 +302,6 @@
 }
 
 void
-gripe_library_execution_error (void)
-{
-  octave_exception_state = octave_no_exception;
-
-  if (! error_state)
-    error ("caught execution error in library function");
-}
-
-void
 gripe_invalid_inquiry_subscript (void)
 {
   error ("invalid dimension inquiry of a non-existent value");
--- a/libinterp/corefcn/gripes.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/gripes.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_gripes_h)
+#if ! defined (octave_gripes_h)
 #define octave_gripes_h 1
 
 #include <string>
@@ -28,6 +28,7 @@
 #include "lo-array-gripes.h"
 
 class octave_value;
+class octave_execution_exception;
 
 extern OCTINTERP_API void
 gripe_not_supported (const char *);
@@ -58,6 +59,10 @@
 gripe_user_supplied_eval (const char *name);
 
 extern OCTINTERP_API void
+gripe_user_supplied_eval (octave_execution_exception& e,
+                          const char *name);
+
+extern OCTINTERP_API void
 gripe_user_returned_invalid (const char *name);
 
 extern OCTINTERP_API void
@@ -83,18 +88,59 @@
                       bool is_error = true);
 
 extern OCTINTERP_API void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const char *name, const char *s,
+                      bool is_error = true);
+
+extern OCTINTERP_API void
 gripe_wrong_type_arg (const char *name, const std::string& s,
                       bool is_error = true);
 
 extern OCTINTERP_API void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const char *name, const std::string& s,
+                      bool is_error = true);
+
+extern OCTINTERP_API void
 gripe_wrong_type_arg (const char *name, const octave_value& tc,
                       bool is_error = true);
 
 extern OCTINTERP_API void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const char *name, const octave_value& tc,
+                      bool is_error = true);
+
+extern OCTINTERP_API void
 gripe_wrong_type_arg (const std::string& name, const octave_value& tc,
                       bool is_error = true);
 
 extern OCTINTERP_API void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const std::string& name, const octave_value& tc,
+                      bool is_error = true);
+
+extern OCTINTERP_API void
+gripe_wrong_type_arg (const char *s, bool is_error = true);
+
+extern OCTINTERP_API void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const char *s, bool is_error = true);
+
+extern OCTINTERP_API void
+gripe_wrong_type_arg (const std::string& s, bool is_error = true);
+
+extern OCTINTERP_API void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const std::string& s, bool is_error = true);
+
+extern OCTINTERP_API void
+gripe_wrong_type_arg (const octave_value& tc, bool is_error = true);
+
+extern OCTINTERP_API void
+gripe_wrong_type_arg (octave_execution_exception& e,
+                      const octave_value& tc, bool is_error = true);
+
+extern OCTINTERP_API void
 gripe_wrong_type_arg_for_unary_op (const octave_value& op);
 
 extern OCTINTERP_API void
@@ -114,9 +160,6 @@
 gripe_logical_conversion (void);
 
 extern OCTINTERP_API void
-gripe_library_execution_error (void);
-
-extern OCTINTERP_API void
 gripe_invalid_inquiry_subscript (void);
 
 extern OCTINTERP_API void
--- a/libinterp/corefcn/help.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/help.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -783,7 +783,7 @@
 {
   string_vector retval (lst.size ());
   int j = 0;
-  for (map_iter iter = lst.begin (); iter != lst.end (); iter ++)
+  for (map_iter iter = lst.begin (); iter != lst.end (); iter++)
     retval[j++] = iter->first;
   return retval;
 }
@@ -797,22 +797,22 @@
 string_vector
 make_name_list (void)
 {
-  const int key_len = keyword_names.length ();
+  const int key_len = keyword_names.numel ();
 
   const string_vector bif = symbol_table::built_in_function_names ();
-  const int bif_len = bif.length ();
+  const int bif_len = bif.numel ();
 
   const string_vector cfl = symbol_table::cmdline_function_names ();
-  const int cfl_len = cfl.length ();
+  const int cfl_len = cfl.numel ();
 
   const string_vector lcl = symbol_table::variable_names ();
-  const int lcl_len = lcl.length ();
+  const int lcl_len = lcl.numel ();
 
   const string_vector ffl = load_path::fcn_names ();
-  const int ffl_len = ffl.length ();
+  const int ffl_len = ffl.numel ();
 
   const string_vector afl = autoloaded_functions ();
-  const int afl_len = afl.length ();
+  const int afl_len = afl.numel ();
 
   const int total_len
     = key_len + bif_len + cfl_len + lcl_len + ffl_len + afl_len;
@@ -935,16 +935,17 @@
   bool found;
 
   found = raw_help_from_symbol_table (nm, h, w, symbol_found);
-  if (! found && ! error_state)
+
+  if (! found)
     {
       found = raw_help_from_file (nm, h, f, symbol_found);
-      if (! found && ! error_state)
+
+      if (! found)
         {
           found = raw_help_from_map (nm, h, operators_map, symbol_found);
-          if (! found && ! error_state)
-            {
-              raw_help_from_map (nm, h, keywords_map, symbol_found);
-            }
+
+          if (! found)
+            raw_help_from_map (nm, h, keywords_map, symbol_found);
         }
     }
 
@@ -1090,25 +1091,18 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 1)
-    {
-      const std::string name = args(0).string_value ();
+  if (args.length () != 1)
+    print_usage ();
 
-      if (! error_state)
-        {
-          std::string text;
-          std::string format;
+  const std::string name = args(0).xstring_value ("get_help_text: NAME must be a string");
 
-          do_get_help_text (name, text, format);
+  std::string text;
+  std::string format;
 
-          retval(1) = format;
-          retval(0) = text;
-        }
-      else
-        error ("get_help_text: invalid input");
-    }
-  else
-    print_usage ();
+  do_get_help_text (name, text, format);
+
+  retval(1) = format;
+  retval(0) = text;
 
   return retval;
 }
@@ -1160,25 +1154,18 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 1)
-    {
-      const std::string fname = args(0).string_value ();
+  if (args.length () != 1)
+    print_usage ();
 
-      if (! error_state)
-        {
-          std::string text;
-          std::string format;
+  const std::string fname = args(0).xstring_value ("get_help_text_from_file: NAME must be a string");
 
-          do_get_help_text_from_file (fname, text, format);
+  std::string text;
+  std::string format;
 
-          retval(1) = format;
-          retval(0) = text;
-        }
-      else
-        error ("get_help_text_from_file: invalid input");
-    }
-  else
-    print_usage ();
+  do_get_help_text_from_file (fname, text, format);
+
+  retval(1) = format;
+  retval(0) = text;
 
   return retval;
 }
@@ -1297,46 +1284,37 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   string_vector argv = args.make_argv ("which");
 
-  if (! error_state)
-    {
-      int argc = argv.length ();
+  int argc = argv.numel ();
 
-      if (argc > 1)
-        {
-          octave_map m (dim_vector (1, argc-1));
+  if (argc < 2)
+    print_usage ();
 
-          Cell names (1, argc-1);
-          Cell files (1, argc-1);
-          Cell types (1, argc-1);
+  octave_map m (dim_vector (1, argc-1));
 
-          for (int i = 1; i < argc; i++)
-            {
-              std::string name = argv[i];
+  Cell names (1, argc-1);
+  Cell files (1, argc-1);
+  Cell types (1, argc-1);
 
-              std::string type;
-
-              std::string file = do_which (name, type);
+  for (int i = 1; i < argc; i++)
+    {
+      std::string name = argv[i];
 
-              names(i-1) = name;
-              files(i-1) = file;
-              types(i-1) = type;
-            }
+      std::string type;
 
-          m.assign ("name", names);
-          m.assign ("file", files);
-          m.assign ("type", types);
+      std::string file = do_which (name, type);
 
-          retval = m;
-        }
-      else
-        print_usage ();
+      names(i-1) = name;
+      files(i-1) = file;
+      types(i-1) = type;
     }
 
-  return retval;
+  m.assign ("name", names);
+  m.assign ("file", files);
+  m.assign ("type", types);
+
+  return octave_value (m);
 }
 
 // FIXME: Are we sure this function always does the right thing?
@@ -1353,7 +1331,7 @@
       int num_seps = 0;
       for (int i = dir_len; i < filename_len; i++)
         if (file_ops::is_dir_sep (filename[i]))
-          num_seps ++;
+          num_seps++;
 
       return (num_seps <= max_allowed_seps);
     }
@@ -1380,24 +1358,19 @@
 
   if (args.length () == 0)
     retval = Cell (ffl.append (afl));
-  else if (args(0).is_string ())
+  else
     {
-      std::string dir = args(0).string_value ();
+      std::string dir = args(0).xstring_value ("__list_functions__: DIRECTORY argument must be a string");
 
       string_vector fl = load_path::files (dir, true);
 
-      if (! error_state)
-        {
-          // Return a sorted list with unique entries (in case of
-          // .m and .oct versions of the same function in a given
-          // directory, for example).
-          fl.sort (true);
+      // Return a sorted list with unique entries (in case of
+      // .m and .oct versions of the same function in a given
+      // directory, for example).
+      fl.sort (true);
 
-          retval = Cell (fl);
-        }
+      retval = Cell (fl);
     }
-  else
-    error ("__list_functions__: DIRECTORY argument must be a string");
 
   return retval;
 }
--- a/libinterp/corefcn/help.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/help.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_help_h)
+#if ! defined (octave_help_h)
 #define octave_help_h 1
 
 #include <iosfwd>
--- a/libinterp/corefcn/hess.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/hess.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -66,13 +66,8 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 1 || nargout > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 1 || nargout > 2)
+    print_usage ();
 
   octave_value arg = args(0);
 
@@ -98,34 +93,28 @@
         {
           FloatMatrix tmp = arg.float_matrix_value ();
 
-          if (! error_state)
-            {
-              FloatHESS result (tmp);
+          FloatHESS result (tmp);
 
-              if (nargout <= 1)
-                retval(0) = result.hess_matrix ();
-              else
-                {
-                  retval(1) = result.hess_matrix ();
-                  retval(0) = result.unitary_hess_matrix ();
-                }
+          if (nargout <= 1)
+            retval(0) = result.hess_matrix ();
+          else
+            {
+              retval(1) = result.hess_matrix ();
+              retval(0) = result.unitary_hess_matrix ();
             }
         }
       else if (arg.is_complex_type ())
         {
           FloatComplexMatrix ctmp = arg.float_complex_matrix_value ();
 
-          if (! error_state)
-            {
-              FloatComplexHESS result (ctmp);
+          FloatComplexHESS result (ctmp);
 
-              if (nargout <= 1)
-                retval(0) = result.hess_matrix ();
-              else
-                {
-                  retval(1) = result.hess_matrix ();
-                  retval(0) = result.unitary_hess_matrix ();
-                }
+          if (nargout <= 1)
+            retval(0) = result.hess_matrix ();
+          else
+            {
+              retval(1) = result.hess_matrix ();
+              retval(0) = result.unitary_hess_matrix ();
             }
         }
     }
@@ -135,34 +124,28 @@
         {
           Matrix tmp = arg.matrix_value ();
 
-          if (! error_state)
-            {
-              HESS result (tmp);
+          HESS result (tmp);
 
-              if (nargout <= 1)
-                retval(0) = result.hess_matrix ();
-              else
-                {
-                  retval(1) = result.hess_matrix ();
-                  retval(0) = result.unitary_hess_matrix ();
-                }
+          if (nargout <= 1)
+            retval(0) = result.hess_matrix ();
+          else
+            {
+              retval(1) = result.hess_matrix ();
+              retval(0) = result.unitary_hess_matrix ();
             }
         }
       else if (arg.is_complex_type ())
         {
           ComplexMatrix ctmp = arg.complex_matrix_value ();
 
-          if (! error_state)
-            {
-              ComplexHESS result (ctmp);
+          ComplexHESS result (ctmp);
 
-              if (nargout <= 1)
-                retval(0) = result.hess_matrix ();
-              else
-                {
-                  retval(1) = result.hess_matrix ();
-                  retval(0) = result.unitary_hess_matrix ();
-                }
+          if (nargout <= 1)
+            retval(0) = result.hess_matrix ();
+          else
+            {
+              retval(1) = result.hess_matrix ();
+              retval(0) = result.unitary_hess_matrix ();
             }
         }
       else
--- a/libinterp/corefcn/hex2num.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/hex2num.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -65,12 +65,14 @@
 @seealso{num2hex, hex2dec, dec2hex}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
   int nargin = args.length ();
-  octave_value retval;
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
-  else if (nargin == 2 && ! args(1).is_string ())
+
+  if (nargin == 2 && ! args(1).is_string ())
     error ("hex2num: CLASS must be a string");
   else
     {
@@ -83,7 +85,7 @@
         error ("hex2num: S must be no more than %d characters", nchars);
       else if (prec != "double" && prec != "single")
         error ("hex2num: CLASS must be either \"double\" or \"single\"");
-      else if (! error_state)
+      else
         {
           octave_idx_type nr = cmat.rows ();
           octave_idx_type nc = cmat.columns ();
@@ -123,19 +125,13 @@
                         }
                     }
 
-                  if (error_state)
-                    break;
-                  else
-                    {
-                      if (nc < nchars)
-                        num.ival <<= (nchars - nc) * 4;
+                  if (nc < nchars)
+                    num.ival <<= (nchars - nc) * 4;
 
-                      m(i) = num.dval;
-                    }
+                  m(i) = num.dval;
                 }
 
-              if (! error_state)
-                retval =  m;
+              retval =  m;
             }
           else
             {
@@ -172,19 +168,13 @@
                         }
                     }
 
-                  if (error_state)
-                    break;
-                  else
-                    {
-                      if (nc < nchars)
-                        num.ival <<= (nchars - nc) * 4;
+                  if (nc < nchars)
+                    num.ival <<= (nchars - nc) * 4;
 
-                      m(i) = num.dval;
-                    }
+                  m(i) = num.dval;
                 }
 
-              if (! error_state)
-                retval =  m;
+              retval =  m;
             }
         }
     }
@@ -230,84 +220,78 @@
 @seealso{hex2num, hex2dec, dec2hex}\n\
 @end deftypefn")
 {
-  int nargin = args.length ();
   octave_value retval;
 
-  if (nargin != 1)
+  if (args.length () != 1)
     print_usage ();
-  else if (args(0).is_single_type ())
+
+  if (args(0).is_single_type ())
     {
       const FloatColumnVector v (args(0).float_vector_value ());
 
-      if (! error_state)
-        {
-          octave_idx_type nchars = 8;
-          octave_idx_type nr = v.length ();
-          charMatrix m (nr, nchars);
-          const float *pv = v.fortran_vec ();
+      octave_idx_type nchars = 8;
+      octave_idx_type nr = v.numel ();
+      charMatrix m (nr, nchars);
+      const float *pv = v.fortran_vec ();
 
-          for (octave_idx_type i = 0; i < nr; i++)
-            {
-              union
-              {
-                uint32_t ival;
-                float dval;
-              } num;
+      for (octave_idx_type i = 0; i < nr; i++)
+        {
+          union
+          {
+            uint32_t ival;
+            float dval;
+          } num;
+
+          num.dval = *pv++;
 
-              num.dval = *pv++;
+          for (octave_idx_type j = 0; j < nchars; j++)
+            {
+              unsigned char ch =
+                static_cast<char>(num.ival >> ((nchars - 1 - j) * 4) & 0xF);
+              if (ch >= 10)
+                ch += 'a' - 10;
+              else
+                ch += '0';
 
-              for (octave_idx_type j = 0; j < nchars; j++)
-                {
-                  unsigned char ch =
-                    static_cast<char>(num.ival >> ((nchars - 1 - j) * 4) & 0xF);
-                  if (ch >= 10)
-                    ch += 'a' - 10;
-                  else
-                    ch += '0';
+              m.elem (i, j) = ch;
+            }
+        }
 
-                  m.elem (i, j) = ch;
-                }
-            }
-
-          retval = m;
-        }
+      retval = m;
     }
   else
     {
       const ColumnVector v (args(0).vector_value ());
 
-      if (! error_state)
-        {
-          octave_idx_type nchars = 16;
-          octave_idx_type nr = v.length ();
-          charMatrix m (nr, nchars);
-          const double *pv = v.fortran_vec ();
+      octave_idx_type nchars = 16;
+      octave_idx_type nr = v.numel ();
+      charMatrix m (nr, nchars);
+      const double *pv = v.fortran_vec ();
 
-          for (octave_idx_type i = 0; i < nr; i++)
-            {
-              union
-              {
-                uint64_t ival;
-                double dval;
-              } num;
+      for (octave_idx_type i = 0; i < nr; i++)
+        {
+          union
+          {
+            uint64_t ival;
+            double dval;
+          } num;
+
+          num.dval = *pv++;
 
-              num.dval = *pv++;
+          for (octave_idx_type j = 0; j < nchars; j++)
+            {
+              unsigned char ch =
+                static_cast<char>(num.ival >> ((nchars - 1 - j) * 4) & 0xF);
+              if (ch >= 10)
+                ch += 'a' - 10;
+              else
+                ch += '0';
 
-              for (octave_idx_type j = 0; j < nchars; j++)
-                {
-                  unsigned char ch =
-                    static_cast<char>(num.ival >> ((nchars - 1 - j) * 4) & 0xF);
-                  if (ch >= 10)
-                    ch += 'a' - 10;
-                  else
-                    ch += '0';
+              m.elem (i, j) = ch;
+            }
+        }
 
-                  m.elem (i, j) = ch;
-                }
-            }
-
-          retval = m;
-        }
+      retval = m;
     }
 
   return retval;
--- a/libinterp/corefcn/hook-fcn.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/hook-fcn.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_hook_fcn_h)
+#if ! defined (octave_hook_fcn_h)
 #define octave_hook_fcn_h 1
 
 #include <string>
--- a/libinterp/corefcn/input.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/input.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -199,16 +199,33 @@
 
   if (Vdrawnow_requested && interactive)
     {
-      feval ("drawnow");
+      bool eval_error = false;
+
+      try
+        {
+          feval ("drawnow");
+        }
+      catch (const octave_execution_exception& e)
+        {
+          eval_error = true;
+
+          std::string stack_trace = e.info ();
+
+          if (! stack_trace.empty ())
+            std::cerr << stack_trace;
+
+          if (interactive)
+            recover_from_exception ();
+        }
 
       flush_octave_stdout ();
 
-      // We set Vdrawnow_requested to false even if there is an error
-      // in drawnow so that the error doesn't reappear at every prompt.
+      // We set Vdrawnow_requested to false even if there is an error in
+      // drawnow so that the error doesn't reappear at every prompt.
 
       Vdrawnow_requested = false;
 
-      if (error_state)
+      if (eval_error)
         return "\n";
     }
 
@@ -328,7 +345,7 @@
   return command_editor::get_input_stream ();
 }
 
-// FIXME: make this generate file names when appropriate.
+// FIXME: make this generate filenames when appropriate.
 
 static string_vector
 generate_possible_completions (const std::string& text, std::string& prefix,
@@ -408,13 +425,13 @@
       else
         name_list = generate_possible_completions (text, prefix, hint);
 
-      name_list_len = name_list.length ();
+      name_list_len = name_list.numel ();
 
       file_name_list = command_editor::generate_filename_completions (text);
 
       name_list.append (file_name_list);
 
-      name_list_total_len = name_list.length ();
+      name_list_total_len = name_list.numel ();
 
       hint_len = hint.length ();
 
@@ -600,27 +617,38 @@
 
   while (Vdebugging)
     {
-      unwind_protect middle_frame;
+      try
+        {
+          reset_error_handler ();
 
-      reset_error_handler ();
+          curr_parser.reset ();
+
+          int retval = curr_parser.run ();
 
-      curr_parser.reset ();
-
-      int retval = curr_parser.run ();
+          if (command_editor::interrupt (false))
+            break;
+          else
+            {
+              if (retval == 0 && curr_parser.stmt_list)
+                {
+                  curr_parser.stmt_list->accept (*current_evaluator);
 
-      if (command_editor::interrupt (false))
-        break;
-      else
+                  if (octave_completion_matches_called)
+                    octave_completion_matches_called = false;
+                }
+
+              octave_quit ();
+            }
+        }
+      catch (const octave_execution_exception& e)
         {
-          if (retval == 0 && curr_parser.stmt_list)
-            {
-              curr_parser.stmt_list->accept (*current_evaluator);
+          std::string stack_trace = e.info ();
 
-              if (octave_completion_matches_called)
-                octave_completion_matches_called = false;
-            }
+          if (! stack_trace.empty ())
+            std::cerr << stack_trace;
 
-          octave_quit ();
+          // Ignore errors when in debugging mode;
+          recover_from_exception ();
         }
     }
 }
@@ -681,20 +709,12 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
-
   int read_as_string = 0;
 
-  if (nargin == 2)
+  if (args.length () == 2)
     read_as_string++;
 
-  std::string prompt = args(0).string_value ();
-
-  if (error_state)
-    {
-      error ("input: unrecognized argument");
-      return retval;
-    }
+  std::string prompt = args(0).xstring_value ("input: unrecognized argument");
 
   flush_octave_stdout ();
 
@@ -707,7 +727,7 @@
 
   std::string input_buf = interactive_input (prompt.c_str (), eof);
 
-  if (! (error_state || input_buf.empty ()))
+  if (! input_buf.empty ())
     {
       size_t len = input_buf.length ();
 
@@ -782,16 +802,12 @@
 @seealso{yes_or_no, kbhit, pause, menu, listdlg}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    retval = get_user_input (args, std::max (nargout, 1));
-  else
+  if (nargin < 1 || nargin > 2)
     print_usage ();
 
-  return retval;
+  return get_user_input (args, std::max (nargout, 1));
 }
 
 bool
@@ -828,31 +844,17 @@
 @seealso{input}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
-  if (nargin == 0 || nargin == 1)
-    {
-      std::string prompt;
-
-      if (nargin == 1)
-        {
-          if (args(0).is_string ())
-            prompt = args(0).string_value ();
-          else
-            {
-              error ("yes_or_no: PROMPT must be a string");
-              return retval;
-            }
-        }
-
-      retval = octave_yes_or_no (prompt);
-    }
-  else
+  if (nargin > 1)
     print_usage ();
 
-  return retval;
+  std::string prompt;
+
+  if (nargin == 1)
+    prompt = args(0).xstring_value ("yes_or_no: PROMPT must be a string");
+
+  return octave_value (octave_yes_or_no (prompt));
 }
 
 octave_value
@@ -888,8 +890,7 @@
   if (nargin > 0)
     prompt = args(0).string_value ();
 
-  if (! error_state)
-    get_debug_input (prompt);
+  get_debug_input (prompt);
 
   return retval;
 }
@@ -914,27 +915,23 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
+  if (args.length () > 1)
+    print_usage ();
 
-  if (nargin == 0 || nargin == 1)
-    {
-      unwind_protect frame;
+  unwind_protect frame;
 
-      frame.add_fcn (octave_call_stack::restore_frame,
-                     octave_call_stack::current_frame ());
+  frame.add_fcn (octave_call_stack::restore_frame,
+                 octave_call_stack::current_frame ());
 
-      // Skip the frame assigned to the keyboard function.
-      octave_call_stack::goto_frame_relative (0);
-
-      tree_evaluator::debug_mode = true;
-      tree_evaluator::quiet_breakpoint_flag = false;
+  // Skip the frame assigned to the keyboard function.
+  octave_call_stack::goto_frame_relative (0);
 
-      tree_evaluator::current_frame = octave_call_stack::current_frame ();
+  tree_evaluator::debug_mode = true;
+  tree_evaluator::quiet_breakpoint_flag = false;
 
-      do_keyboard (args);
-    }
-  else
-    print_usage ();
+  tree_evaluator::current_frame = octave_call_stack::current_frame ();
+
+  do_keyboard (args);
 
   return retval;
 }
@@ -972,16 +969,11 @@
 {
   octave_value_list retval;
 
-  int argc = args.length () + 1;
-
   string_vector argv = args.make_argv ("echo");
 
-  if (error_state)
-    return retval;
-
-  switch (argc)
+  switch (args.length ())
     {
-    case 1:
+    case 0:
       {
         if ((Vecho_executing_commands & ECHO_SCRIPTS)
             || (Vecho_executing_commands & ECHO_FUNCTIONS))
@@ -991,7 +983,7 @@
       }
       break;
 
-    case 2:
+    case 1:
       {
         std::string arg = argv[1];
 
@@ -1004,7 +996,7 @@
       }
       break;
 
-    case 3:
+    case 2:
       {
         std::string arg = argv[1];
 
@@ -1028,6 +1020,53 @@
   return retval;
 }
 
+/*
+%!test
+%! state = echo_executing_commands ();
+%! unwind_protect
+%!   echo ();
+%!   s1 = echo_executing_commands ();
+%!   assert (s1 != state);
+%!   echo ();
+%!   s2 = echo_executing_commands ();
+%!   assert (s2 != s1);
+%! unwind_protect_cleanup
+%!   echo_executing_commands (state);
+%! end_unwind_protect
+
+%!test
+%! state = echo_executing_commands ();
+%! unwind_protect
+%!   echo ("off");
+%!   assert (echo_executing_commands () == 0);
+%!   echo ("on");
+%!   assert (echo_executing_commands () != 0);
+%!   echo ("off");
+%!   assert (echo_executing_commands () == 0);
+%! unwind_protect_cleanup
+%!   echo_executing_commands (state);
+%! end_unwind_protect
+
+%!#test  # FIXME: Uncommend when ug #45209 is fixed
+%! state = echo_executing_commands ();
+%! unwind_protect
+%!   echo ("on", "all");
+%!   assert (echo_executing_commands () != 0);
+%!   echo ("off", "all");
+%!   assert (echo_executing_commands () == 0);
+%! unwind_protect_cleanup
+%!   echo_executing_commands (state);
+%! end_unwind_protect
+
+%!error echo ([])
+%!error echo (0)
+%!error echo ("")
+%!error echo ("Octave")
+%!error echo ("off", "invalid")
+%!error echo ("on", "invalid")
+%!error echo ("on", "all", "all")
+*/
+
 DEFUN (__echostate__, , ,
        "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {@var{state} =} __echostate__ ()\n\
@@ -1050,69 +1089,77 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
+
+  std::string hint = args(0).string_value ();
 
-  if (nargin == 1)
+  int n = 32;
+
+  string_vector list (n);
+
+  int k = 0;
+
+  for (;;)
     {
-      std::string hint = args(0).string_value ();
+      std::string cmd = generate_completion (hint, k);
 
-      if (! error_state)
+      if (! cmd.empty ())
         {
-          int n = 32;
-
-          string_vector list (n);
-
-          int k = 0;
-
-          for (;;)
+          if (k == n)
             {
-              std::string cmd = generate_completion (hint, k);
-
-              if (! cmd.empty ())
-                {
-                  if (k == n)
-                    {
-                      n *= 2;
-                      list.resize (n);
-                    }
-
-                  list[k++] = cmd;
-                }
-              else
-                {
-                  list.resize (k);
-                  break;
-                }
+              n *= 2;
+              list.resize (n);
             }
 
-          if (nargout > 0)
-            {
-              if (! list.empty ())
-                retval = list;
-              else
-                retval = "";
-            }
-          else
-            {
-              // We don't use string_vector::list_in_columns here
-              // because it will be easier for Emacs if the names
-              // appear in a single column.
-
-              int len = list.length ();
-
-              for (int i = 0; i < len; i++)
-                octave_stdout << list[i] << "\n";
-            }
-
-          octave_completion_matches_called = true;
+          list[k++] = cmd;
+        }
+      else
+        {
+          list.resize (k);
+          break;
         }
     }
+
+  if (nargout > 0)
+    {
+      if (! list.empty ())
+        retval = list;
+      else
+        retval = "";
+    }
   else
-    print_usage ();
+    {
+      // We don't use string_vector::list_in_columns here
+      // because it will be easier for Emacs if the names
+      // appear in a single column.
+
+      int len = list.numel ();
+
+      for (int i = 0; i < len; i++)
+        octave_stdout << list[i] << "\n";
+    }
+
+  octave_completion_matches_called = true;
 
   return retval;
 }
 
+/*
+%!assert (ischar (completion_matches ("")))
+%!assert (ischar (completion_matches ("a")))
+%!assert (ischar (completion_matches (" ")))
+%!assert (isempty (completion_matches (" ")))
+%!assert (any (strcmp ("abs", deblank (cellstr (completion_matches (""))))))
+%!assert (any (strcmp ("abs", deblank (cellstr (completion_matches ("a"))))))
+%!assert (any (strcmp ("abs", deblank (cellstr (completion_matches ("ab"))))))
+%!assert (any (strcmp ("abs", deblank (cellstr (completion_matches ("abs"))))))
+%!assert (! any (strcmp ("abs", deblank (cellstr (completion_matches ("absa"))))))
+
+%!error completion_matches ()
+%!error completion_matches (1, 2)
+*/
+
 DEFUN (readline_read_init_file, args, ,
        "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} readline_read_init_file (@var{file})\n\
@@ -1130,17 +1177,17 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 0)
     command_editor::read_init_file ();
-  else if (nargin == 1)
+  else
     {
       std::string file = args(0).string_value ();
 
-      if (! error_state)
-        command_editor::read_init_file (file);
+      command_editor::read_init_file (file);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1157,11 +1204,11 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 0)
-    command_editor::re_read_init_file ();
-  else
+  if (args.length () != 0)
     print_usage ();
 
+  command_editor::re_read_init_file ();
+
   return retval;
 }
 
@@ -1196,35 +1243,24 @@
 @seealso{remove_input_event_hook}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_value user_data;
-
-      if (nargin == 2)
-        user_data = args(1);
-
-      hook_function hook_fcn (args(0), user_data);
-
-      if (! error_state)
-        {
-          if (input_event_hook_functions.empty ())
-            command_editor::add_event_hook (internal_input_event_hook_fcn);
-
-          input_event_hook_functions.insert (hook_fcn.id (), hook_fcn);
-
-          retval = hook_fcn.id ();
-        }
-      else
-        error ("add_input_event_hook: FCN must be a function handle or string");
-    }
-  else
+  if (nargin < 1 || nargin > 2)
     print_usage ();
 
-  return retval;
+  octave_value user_data;
+
+  if (nargin == 2)
+    user_data = args(1);
+
+  hook_function hook_fcn (args(0), user_data);
+
+  if (input_event_hook_functions.empty ())
+    command_editor::add_event_hook (internal_input_event_hook_fcn);
+
+  input_event_hook_functions.insert (hook_fcn.id (), hook_fcn);
+
+  return octave_value (hook_fcn.id ());
 }
 
 DEFUN (remove_input_event_hook, args, ,
@@ -1241,31 +1277,24 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      std::string hook_fcn_id = args(0).string_value ();
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-      bool warn = (nargin < 2);
+  std::string hook_fcn_id = args(0).string_value ("remove_input_event_hook: argument not valid as a hook function name or id");
 
-      if (! error_state)
-        {
-          hook_function_list::iterator p
-            = input_event_hook_functions.find (hook_fcn_id);
+  bool warn = (nargin < 2);
 
-          if (p != input_event_hook_functions.end ())
-            input_event_hook_functions.erase (p);
-          else if (warn)
-            warning ("remove_input_event_hook: %s not found in list",
-                     hook_fcn_id.c_str ());
+  hook_function_list::iterator p
+    = input_event_hook_functions.find (hook_fcn_id);
 
-          if (input_event_hook_functions.empty ())
-            command_editor::remove_event_hook (internal_input_event_hook_fcn);
-        }
-      else
-        error ("remove_input_event_hook: argument not valid as a hook function name or id");
-    }
-  else
-    print_usage ();
+  if (p != input_event_hook_functions.end ())
+    input_event_hook_functions.erase (p);
+  else if (warn)
+    warning ("remove_input_event_hook: %s not found in list",
+             hook_fcn_id.c_str ());
+
+  if (input_event_hook_functions.empty ())
+    command_editor::remove_event_hook (internal_input_event_hook_fcn);
 
   return retval;
 }
@@ -1417,12 +1446,13 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 0)
     Vdrawnow_requested = true;
-  else if (nargin == 1)
+  else
     Vdrawnow_requested = args(0).bool_value ();
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1437,12 +1467,13 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 0)
     retval = Vgud_mode;
-  else if (nargin == 1)
+  else
     Vgud_mode = args(0).bool_value ();
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1487,7 +1518,7 @@
   octave_value retval = SET_INTERNAL_VARIABLE (filemarker);
 
   // The character passed must not be a legal character for a function name
-  if (! error_state && (::isalnum (Vfilemarker) || Vfilemarker == '_'))
+  if (::isalnum (Vfilemarker) || Vfilemarker == '_')
     {
       Vfilemarker = tmp;
       error ("filemarker: character can not be a valid character for a function name");
--- a/libinterp/corefcn/input.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/input.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 // Use the GNU readline library for command line editing and hisory.
 
-#if !defined (octave_input_h)
+#if ! defined (octave_input_h)
 #define octave_input_h 1
 
 #include <cstdio>
--- a/libinterp/corefcn/inv.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/inv.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -60,13 +60,8 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 1)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 1)
+    print_usage ();
 
   octave_value arg = args(0);
 
@@ -138,22 +133,18 @@
       if (arg.is_real_type ())
         {
           FloatMatrix m = arg.float_matrix_value ();
-          if (! error_state)
-            {
-              MatrixType mattyp = args(0).matrix_type ();
-              result = m.inverse (mattyp, info, frcond, 1);
-              args(0).matrix_type (mattyp);
-            }
+
+          MatrixType mattyp = args(0).matrix_type ();
+          result = m.inverse (mattyp, info, frcond, 1);
+          args(0).matrix_type (mattyp);
         }
       else if (arg.is_complex_type ())
         {
           FloatComplexMatrix m = arg.float_complex_matrix_value ();
-          if (! error_state)
-            {
-              MatrixType mattyp = args(0).matrix_type ();
-              result = m.inverse (mattyp, info, frcond, 1);
-              args(0).matrix_type (mattyp);
-            }
+
+          MatrixType mattyp = args(0).matrix_type ();
+          result = m.inverse (mattyp, info, frcond, 1);
+          args(0).matrix_type (mattyp);
         }
     }
   else
@@ -163,22 +154,18 @@
           if (arg.is_sparse_type ())
             {
               SparseMatrix m = arg.sparse_matrix_value ();
-              if (! error_state)
-                {
-                  MatrixType mattyp = args(0).matrix_type ();
-                  result = m.inverse (mattyp, info, rcond, 1);
-                  args(0).matrix_type (mattyp);
-                }
+
+              MatrixType mattyp = args(0).matrix_type ();
+              result = m.inverse (mattyp, info, rcond, 1);
+              args(0).matrix_type (mattyp);
             }
           else
             {
               Matrix m = arg.matrix_value ();
-              if (! error_state)
-                {
-                  MatrixType mattyp = args(0).matrix_type ();
-                  result = m.inverse (mattyp, info, rcond, 1);
-                  args(0).matrix_type (mattyp);
-                }
+
+              MatrixType mattyp = args(0).matrix_type ();
+              result = m.inverse (mattyp, info, rcond, 1);
+              args(0).matrix_type (mattyp);
             }
         }
       else if (arg.is_complex_type ())
@@ -186,51 +173,44 @@
           if (arg.is_sparse_type ())
             {
               SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
-              if (! error_state)
-                {
-                  MatrixType mattyp = args(0).matrix_type ();
-                  result = m.inverse (mattyp, info, rcond, 1);
-                  args(0).matrix_type (mattyp);
-                }
+
+              MatrixType mattyp = args(0).matrix_type ();
+              result = m.inverse (mattyp, info, rcond, 1);
+              args(0).matrix_type (mattyp);
             }
           else
             {
               ComplexMatrix m = arg.complex_matrix_value ();
-              if (! error_state)
-                {
-                  MatrixType mattyp = args(0).matrix_type ();
-                  result = m.inverse (mattyp, info, rcond, 1);
-                  args(0).matrix_type (mattyp);
-                }
+
+              MatrixType mattyp = args(0).matrix_type ();
+              result = m.inverse (mattyp, info, rcond, 1);
+              args(0).matrix_type (mattyp);
             }
         }
       else
         gripe_wrong_type_arg ("inv", arg);
     }
 
-  if (! error_state)
-    {
-      if (nargout > 1)
-        retval(1) = isfloat ? octave_value (frcond) : octave_value (rcond);
+  if (nargout > 1)
+    retval(1) = isfloat ? octave_value (frcond) : octave_value (rcond);
 
-      retval(0) = result;
+  retval(0) = result;
 
-      bool rcond_plus_one_eq_one = false;
+  bool rcond_plus_one_eq_one = false;
 
-      if (isfloat)
-        {
-          volatile float xrcond = frcond;
-          rcond_plus_one_eq_one = xrcond + 1.0F == 1.0F;
-        }
-      else
-        {
-          volatile double xrcond = rcond;
-          rcond_plus_one_eq_one = xrcond + 1.0 == 1.0;
-        }
+  if (isfloat)
+    {
+      volatile float xrcond = frcond;
+      rcond_plus_one_eq_one = xrcond + 1.0F == 1.0F;
+    }
+  else
+    {
+      volatile double xrcond = rcond;
+      rcond_plus_one_eq_one = xrcond + 1.0 == 1.0;
+    }
 
-      if (nargout < 2 && (info == -1 || rcond_plus_one_eq_one))
-        gripe_singular_matrix (isfloat ? frcond : rcond);
-    }
+  if (nargout < 2 && (info == -1 || rcond_plus_one_eq_one))
+    gripe_singular_matrix (isfloat ? frcond : rcond);
 
   return retval;
 }
--- a/libinterp/corefcn/jit-ir.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/jit-ir.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 // Author: Max Brister <max@2bass.com>
 
-#if !defined (octave_jit_ir_h)
+#if ! defined (octave_jit_ir_h)
 #define octave_jit_ir_h 1
 
 #ifdef HAVE_LLVM
--- a/libinterp/corefcn/jit-typeinfo.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/jit-typeinfo.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -115,7 +115,7 @@
 octave_jit_compute_nelem (double base, double limit, double inc)
 {
   Range rng = Range (base, limit, inc);
-  return rng.nelem ();
+  return rng.numel ();
 }
 
 extern "C" void
@@ -215,41 +215,22 @@
 extern "C" void
 octave_jit_gripe_nan_to_logical_conversion (void)
 {
-  try
-    {
-      gripe_nan_to_logical_conversion ();
-    }
-  catch (const octave_execution_exception&)
-    {
-      gripe_library_execution_error ();
-    }
+  gripe_nan_to_logical_conversion ();
 }
 
 extern "C" void
 octave_jit_ginvalid_index (void)
 {
-  try
-    {
-      gripe_invalid_index ();
-    }
-  catch (const octave_execution_exception&)
-    {
-      gripe_library_execution_error ();
-    }
+  // FIXME: 0-argument form of gripe_invalid_index removed in cset dd6345fd8a97
+  //        Report -1 as the bad index for all occurrences.
+  gripe_invalid_index (-1);
 }
 
 extern "C" void
 octave_jit_gindex_range (int nd, int dim, octave_idx_type iext,
                          octave_idx_type ext)
 {
-  try
-    {
-      gripe_index_out_of_range (nd, dim, iext, ext);
-    }
-  catch (const octave_execution_exception&)
-    {
-      gripe_library_execution_error ();
-    }
+  gripe_index_out_of_range (nd, dim, iext, ext);
 }
 
 extern "C" jit_matrix
@@ -257,7 +238,7 @@
                                 double value)
 {
   NDArray *array = mat->array;
-  if (array->nelem () < index)
+  if (array->numel () < index)
     array->resize1 (index);
 
   double *data = array->fortran_vec ();
@@ -281,19 +262,12 @@
                          octave_idx_type idx_count)
 {
   // FIXME: Replace this with a more optimal version
-  try
-    {
-      Array<idx_vector> idx;
-      make_indices (indicies, idx_count, idx);
+  Array<idx_vector> idx;
+  make_indices (indicies, idx_count, idx);
 
-      Array<double> ret = mat->array->index (idx);
-      return ret.xelem (0);
-    }
-  catch (const octave_execution_exception&)
-    {
-      gripe_library_execution_error ();
-      return 0;
-    }
+  Array<double> ret = mat->array->index (idx);
+
+  return ret.xelem (0);
 }
 
 extern "C" jit_matrix
@@ -302,20 +276,14 @@
 {
   // FIXME: Replace this with a more optimal version
   jit_matrix ret;
-  try
-    {
-      Array<idx_vector> idx;
-      make_indices (indices, idx_count, idx);
+
+  Array<idx_vector> idx;
+  make_indices (indices, idx_count, idx);
 
-      Matrix temp (1, 1);
-      temp.xelem(0) = value;
-      mat->array->assign (idx, temp);
-      ret.update (mat->array);
-    }
-  catch (const octave_execution_exception&)
-    {
-      gripe_library_execution_error ();
-    }
+  Matrix temp (1, 1);
+  temp.xelem(0) = value;
+  mat->array->assign (idx, temp);
+  ret.update (mat->array);
 
   return ret;
 }
--- a/libinterp/corefcn/jit-typeinfo.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/jit-typeinfo.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 // Author: Max Brister <max@2bass.com>
 
-#if !defined (octave_jit_typeinfo_h)
+#if ! defined (octave_jit_typeinfo_h)
 #define octave_jit_typeinfo_h 1
 
 #ifdef HAVE_LLVM
@@ -45,7 +45,7 @@
 jit_range
 {
   jit_range (const Range& from) : base (from.base ()), limit (from.limit ()),
-                                  inc (from.inc ()), nelem (from.nelem ())
+                                  inc (from.inc ()), nelem (from.numel ())
   { }
 
   operator Range () const
@@ -79,7 +79,7 @@
   {
     ref_count = array->jit_ref_count ();
     slice_data = array->jit_slice_data () - 1;
-    slice_len = array->capacity ();
+    slice_len = array->numel ();
     dimensions = array->jit_dimensions ();
   }
 
--- a/libinterp/corefcn/jit-util.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/jit-util.h	Thu Dec 10 12:50:06 2015 -0800
@@ -24,14 +24,14 @@
 
 // Some utility classes and functions used throughout jit
 
-#if !defined (octave_jit_util_h)
+#if ! defined (octave_jit_util_h)
 #define octave_jit_util_h 1
 
 #ifdef HAVE_LLVM
 
 #include <stdexcept>
 
-#if defined(HAVE_LLVM_IR_DATALAYOUT_H) || defined(HAVE_LLVM_DATALAYOUT_H)
+#if defined (HAVE_LLVM_IR_DATALAYOUT_H) || defined (HAVE_LLVM_DATALAYOUT_H)
 #define HAVE_LLVM_DATALAYOUT
 #endif
 
--- a/libinterp/corefcn/kron.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/kron.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -268,17 +268,17 @@
 
   int nargin = args.length ();
 
-  if (nargin >= 2)
-    {
-      octave_value a = args(0);
-      octave_value b = args(1);
-      retval = dispatch_kron (a, b);
-      for (octave_idx_type i = 2; i < nargin; i++)
-        retval = dispatch_kron (retval, args(i));
-    }
-  else
+  if (nargin < 2)
     print_usage ();
 
+  octave_value a = args(0);
+  octave_value b = args(1);
+
+  retval = dispatch_kron (a, b);
+
+  for (octave_idx_type i = 2; i < nargin; i++)
+    retval = dispatch_kron (retval, args(i));
+
   return retval;
 }
 
--- a/libinterp/corefcn/load-path.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/load-path.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -91,12 +91,12 @@
                   initialize ();
                 }
             }
-          catch (octave_execution_exception)
+          catch (const octave_execution_exception&)
             {
-              // Skip updating if we don't know where we are, but
+              // Skip updating if we don't know where we are but
               // don't treat it as an error.
 
-              error_state = 0;
+              recover_from_exception ();
             }
         }
       else if (fs.mtime () + fs.time_resolution () > dir_time_last_checked)
@@ -159,9 +159,12 @@
 
           abs_dir_cache[abs_name] = *this;
         }
-      catch (octave_execution_exception)
+      catch (const octave_execution_exception&)
         {
-          // Skip updating if we don't know where we are.
+          // Skip updating if we don't know where we are but don't treat
+          // it as an error.
+
+          recover_from_exception ();
         }
     }
   else
@@ -180,7 +183,7 @@
     {
       string_vector flist = dir.read ();
 
-      octave_idx_type len = flist.length ();
+      octave_idx_type len = flist.numel ();
 
       all_files.resize (len);
       fcn_files.resize (len);
@@ -250,7 +253,7 @@
     {
       string_vector flist = dir.read ();
 
-      octave_idx_type len = flist.length ();
+      octave_idx_type len = flist.numel ();
 
       for (octave_idx_type i = 0; i < len; i++)
         {
@@ -332,11 +335,7 @@
     }
 
   if (! instance)
-    {
-      ::error ("unable to create load path object!");
-
-      retval = false;
-    }
+    error ("unable to create load path object!");
 
   return retval;
 }
@@ -408,7 +407,7 @@
 load_path::loader::move_fcn_map (const std::string& dir_name,
                                  const string_vector& fcn_files, bool at_end)
 {
-  octave_idx_type len = fcn_files.length ();
+  octave_idx_type len = fcn_files.numel ();
 
   for (octave_idx_type k = 0; k < len; k++)
     {
@@ -768,18 +767,15 @@
             {
               dir_info di (dir);
 
-              if (! error_state)
-                {
-                  if (at_end)
-                    dir_info_list.push_back (di);
-                  else
-                    dir_info_list.push_front (di);
-
-                  add (di, at_end);
-
-                  if (add_hook)
-                    add_hook (dir);
-                }
+              if (at_end)
+                dir_info_list.push_back (di);
+              else
+                dir_info_list.push_front (di);
+
+              add (di, at_end);
+
+              if (add_hook)
+                add_hook (dir);
             }
           else if (warn)
             warning ("addpath: %s: not a directory", dir_arg.c_str ());
@@ -803,7 +799,7 @@
 load_path::loader::remove_fcn_map (const std::string& dir,
                                    const string_vector& fcn_files)
 {
-  octave_idx_type len = fcn_files.length ();
+  octave_idx_type len = fcn_files.numel ();
 
   for (octave_idx_type k = 0; k < len; k++)
     {
@@ -985,7 +981,7 @@
 
       di.update ();
 
-      add (di, true);
+      add (di, true, "", true);
     }
 }
 
@@ -1373,7 +1369,7 @@
         {
           string_vector all_files = p->all_files;
 
-          octave_idx_type len = all_files.length ();
+          octave_idx_type len = all_files.numel ();
 
           for (octave_idx_type i = 0; i < len; i++)
             {
@@ -1488,7 +1484,7 @@
   std::string dir_name;
   std::string file_name;
 
-  octave_idx_type flen = flist.length ();
+  octave_idx_type flen = flist.numel ();
   octave_idx_type rel_flen = 0;
 
   string_vector rel_flist (flen);
@@ -1534,7 +1530,7 @@
     {
       string_vector all_files = p->all_files;
 
-      octave_idx_type len = all_files.length ();
+      octave_idx_type len = all_files.numel ();
 
       for (octave_idx_type i = 0; i < len; i++)
         {
@@ -1567,7 +1563,7 @@
   std::string dir_name;
   std::string file_name;
 
-  octave_idx_type flen = flist.length ();
+  octave_idx_type flen = flist.numel ();
   octave_idx_type rel_flen = 0;
 
   string_vector rel_flist (flen);
@@ -1612,7 +1608,7 @@
     {
       string_vector all_files = p->all_files;
 
-      octave_idx_type len = all_files.length ();
+      octave_idx_type len = all_files.numel ();
 
       for (octave_idx_type i = 0; i < len; i++)
         {
@@ -1670,7 +1666,7 @@
 
   if (omit_exts)
     {
-      octave_idx_type len = retval.length ();
+      octave_idx_type len = retval.numel ();
 
       for (octave_idx_type i = 0; i < len; i++)
         {
@@ -1716,7 +1712,7 @@
 
   string_vector xdirs = load_path::dirs ();
 
-  octave_idx_type len = xdirs.length ();
+  octave_idx_type len = xdirs.numel ();
 
   if (len > 0)
     xpath = xdirs[0];
@@ -1866,11 +1862,11 @@
 
 void
 load_path::add (const dir_info& di, bool at_end,
-                const std::string& pname) const
+                const std::string& pname, bool updating) const
 {
   loader& l = get_loader (pname);
 
-  l.add (di, at_end);
+  l.add (di, at_end, updating);
 
   dir_info::package_dir_map_type package_dir_map = di.package_dir_map;
 
@@ -1887,13 +1883,14 @@
 }
 
 void
-load_path::loader::add_to_fcn_map (const dir_info& di, bool at_end)
+load_path::loader::add_to_fcn_map (const dir_info& di, bool at_end,
+                                   bool updating)
 {
   std::string dir_name = di.dir_name;
 
   string_vector fcn_files = di.fcn_files;
 
-  octave_idx_type len = fcn_files.length ();
+  octave_idx_type len = fcn_files.numel ();
 
   for (octave_idx_type i = 0; i < len; i++)
     {
@@ -1932,15 +1929,23 @@
 
       if (p == file_info_list.end ())
         {
-          file_info fi (dir_name, t);
-
-          if (at_end)
-            file_info_list.push_back (fi);
-          else
+          // Warn if a built-in or library function is being shadowed,
+          // but not if we are just updating (rehashing) the list.
+
+          if (! updating)
             {
-              // Warn if a built-in or library function is being shadowed.
-
-              if (! file_info_list.empty ())
+              if (file_info_list.empty ())
+                {
+                  if (symbol_table::is_built_in_function_name (base))
+                    {
+                      std::string fcn_path = file_ops::concat (dir_name, fname);
+
+                      warning_with_id ("Octave:shadowed-function",
+                                       "function %s shadows a built-in function",
+                                       fcn_path.c_str ());
+                    }
+                }
+              else if (! at_end)
                 {
                   file_info& old = file_info_list.front ();
 
@@ -1962,16 +1967,14 @@
                                        fcn_path.c_str ());
                     }
                 }
-              else if (symbol_table::is_built_in_function_name (base))
-                {
-                  std::string fcn_path = file_ops::concat (dir_name, fname);
-                  warning_with_id ("Octave:shadowed-function",
-                                   "function %s shadows a built-in function",
-                                   fcn_path.c_str ());
-                }
-
-              file_info_list.push_front (fi);
             }
+
+          file_info fi (dir_name, t);
+
+          if (at_end)
+            file_info_list.push_back (fi);
+          else
+            file_info_list.push_front (fi);
         }
       else
         {
@@ -2150,7 +2153,7 @@
 
       string_vector dirlist = dir.read ().sort (false);
 
-      octave_idx_type len = dirlist.length ();
+      octave_idx_type len = dirlist.numel ();
 
       for (octave_idx_type i = 0; i < len; i++)
         {
@@ -2161,7 +2164,7 @@
 
           if (! skip_p)
             {
-              for (octave_idx_type j = 0; j < skip.length (); j++)
+              for (octave_idx_type j = 0; j < skip.numel (); j++)
                 {
                   skip_p = (elt == skip[j]);
                   if (skip_p)
@@ -2240,38 +2243,28 @@
 {
   octave_value retval;
 
-  octave_idx_type nargin = args.length ();
+  int nargin = args.length ();
+
+  if (nargin == 0)
+    print_usage ();
 
   if (nargin == 1)
     {
-      std::string dirname = args(0).string_value ();
-
-      if (! error_state)
-        retval = genpath (dirname);
-      else
-        error ("genpath: DIR must be a string");
+      std::string dirname = args(0).xstring_value ("genpath: DIR must be a string");
+
+      retval = genpath (dirname);
     }
-  else if (nargin > 1)
+  else
     {
-      std::string dirname = args(0).string_value ();
+      std::string dirname = args(0).xstring_value ("genpath: all arguments must be strings");
 
       string_vector skip (nargin - 1);
 
       for (octave_idx_type i = 1; i < nargin; i++)
-        {
-          skip[i-1] = args(i).string_value ();
-
-          if (error_state)
-            break;
-        }
-
-      if (! error_state)
-        retval = genpath (dirname, skip);
-      else
-        error ("genpath: all arguments must be strings");
+        skip[i-1] = args(i).xstring_value ("genpath: all arguments must be strings");
+
+      retval = genpath (dirname, skip);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -2341,7 +2334,9 @@
 
 DEFUN (path, args, nargout,
        "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} path (@dots{})\n\
+@deftypefn  {Built-in Function} {} path ()\n\
+@deftypefnx {Built-in Function} {@var{str} =} path ()\n\
+@deftypefnx {Built-in Function} {@var{str} =} path (@var{path1}, @dots{})\n\
 Modify or display Octave's load path.\n\
 \n\
 If @var{nargin} and @var{nargout} are zero, display the elements of\n\
@@ -2358,42 +2353,37 @@
 @seealso{addpath, rmpath, genpath, pathdef, savepath, pathsep}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int argc = args.length () + 1;
+  int nargin = args.length ();
 
   string_vector argv = args.make_argv ("path");
 
-  if (! error_state)
+  if (nargin > 0)
     {
-      if (argc > 1)
-        {
-          std::string path = argv[1];
-
-          for (int i = 2; i < argc; i++)
-            path += dir_path::path_sep_str () + argv[i];
-
-          load_path::set (path, true);
-
-          rehash_internal ();
-        }
-
-      if (nargout > 0)
-        retval = load_path::path ();
-      else if (argc == 1 && nargout == 0)
-        {
-          octave_stdout <<
-                        "\nOctave's search path contains the following directories:\n\n";
-
-          string_vector dirs = load_path::dirs ();
-
-          dirs.list_in_columns (octave_stdout);
-
-          octave_stdout << "\n";
-        }
+      std::string path = argv[1];
+
+      for (int i = 2; i <= nargin; i++)
+        path += dir_path::path_sep_str () + argv[i];
+
+      load_path::set (path, true);
+
+      rehash_internal ();
     }
 
-  return retval;
+  if (nargout > 0)
+    return octave_value (load_path::path ());
+  else if (nargin == 0 && nargout == 0)
+    {
+      octave_stdout <<
+        "\nOctave's search path contains the following directories:\n\n";
+
+      string_vector dirs = load_path::dirs ();
+
+      dirs.list_in_columns (octave_stdout);
+
+      octave_stdout << "\n";
+    }
+
+  return octave_value ();
 }
 
 DEFUN (addpath, args, nargout,
@@ -2426,89 +2416,71 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
+  if (nargin == 0)
+    print_usage ();
+
+  bool append = false;
+
+  octave_value option_arg = args(nargin-1);
+
+  if (option_arg.is_string ())
     {
-      bool append = false;
-
-      octave_value option_arg = args(nargin-1);
-
-      if (option_arg.is_string ())
+      std::string option = option_arg.string_value ();
+
+      if (option == "-end")
         {
-          std::string option = option_arg.string_value ();
-
-          if (option == "-end")
-            {
-              append = true;
-              nargin--;
-            }
-          else if (option == "-begin")
-            nargin--;
+          append = true;
+          nargin--;
         }
-      else if (option_arg.is_numeric_type ())
+      else if (option == "-begin")
+        nargin--;
+    }
+  else if (option_arg.is_numeric_type ())
+    {
+      int val = option_arg.xint_value ("addpath: OPTION must be '-begin'/0 or '-end'/1");
+
+      if (val == 0)
+        nargin--;
+      else if (val == 1)
         {
-          int val = option_arg.int_value ();
-
-          if (! error_state)
-            {
-              if (val == 0)
-                nargin--;
-              else if (val == 1)
-                {
-                  append = true;
-                  nargin--;
-                }
-              else
-                {
-                  error ("addpath: expecting final argument to be 1 or 0");
-                  return retval;
-                }
-            }
+          append = true;
+          nargin--;
+        }
+      else
+        error ("addpath: OPTION must be '-begin'/0 or '-end'/1");
+    }
+
+  bool need_to_update = false;
+
+  for (int i = 0; i < nargin; i++)
+    {
+      std::string arg = args(i).xstring_value ("addpath: all arguments must be strings");
+
+      std::list<std::string> dir_elts = split_path (arg);
+
+      if (! append)
+        std::reverse (dir_elts.begin (), dir_elts.end ());
+
+      for (std::list<std::string>::const_iterator p = dir_elts.begin ();
+           p != dir_elts.end ();
+           p++)
+        {
+          std::string dir = *p;
+
+          //dir = regexprep (dir_elts{j}, '//+', "/");
+          //dir = regexprep (dir, '/$', "");
+
+          if (append)
+            load_path::append (dir, true);
           else
-            {
-              error ("addpath: expecting final argument to be 1 or 0");
-              return retval;
-            }
+            load_path::prepend (dir, true);
+
+          need_to_update = true;
         }
-
-      bool need_to_update = false;
-
-      for (int i = 0; i < nargin; i++)
-        {
-          if (args(i).is_string ())
-            {
-              std::string arg = args(i).string_value ();
-
-              std::list<std::string> dir_elts = split_path (arg);
-
-              if (! append)
-                std::reverse (dir_elts.begin (), dir_elts.end ());
-
-              for (std::list<std::string>::const_iterator p = dir_elts.begin ();
-                   p != dir_elts.end ();
-                   p++)
-                {
-                  std::string dir = *p;
-
-                  //dir = regexprep (dir_elts{j}, '//+', "/");
-                  //dir = regexprep (dir, '/$', "");
-
-                  if (append)
-                    load_path::append (dir, true);
-                  else
-                    load_path::prepend (dir, true);
-
-                  need_to_update = true;
-                }
-            }
-          else
-            error ("addpath: all arguments must be strings");
-        }
-
-      if (need_to_update)
-        rehash_internal ();
     }
-  else
-    print_usage ();
+
+  if (need_to_update)
+    rehash_internal ();
 
   return retval;
 }
@@ -2527,7 +2499,7 @@
 @seealso{path, addpath, genpath, pathdef, savepath, pathsep}\n\
 @end deftypefn")
 {
-  // Originally by Etienne Grossmann. Heavily modified and translated
+  // Originally written by Etienne Grossmann.  Heavily modified and translated
   // to C++ by jwe.
 
   octave_value retval;
@@ -2537,41 +2509,34 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
+  if (nargin == 0)
+    print_usage ();
+
+  bool need_to_update = false;
+
+  for (int i = 0; i < nargin; i++)
     {
-      bool need_to_update = false;
-
-      for (int i = 0; i < nargin; i++)
+      std::string arg = args(i).xstring_value ("rmpath: all arguments must be strings");
+      std::list<std::string> dir_elts = split_path (arg);
+
+      for (std::list<std::string>::const_iterator p = dir_elts.begin ();
+           p != dir_elts.end ();
+           p++)
         {
-          if (args(i).is_string ())
-            {
-              std::string arg = args(i).string_value ();
-              std::list<std::string> dir_elts = split_path (arg);
-
-              for (std::list<std::string>::const_iterator p = dir_elts.begin ();
-                   p != dir_elts.end ();
-                   p++)
-                {
-                  std::string dir = *p;
-
-                  //dir = regexprep (dir_elts{j}, '//+', "/");
-                  //dir = regexprep (dir, '/$', "");
-
-                  if (! load_path::remove (dir))
-                    warning ("rmpath: %s: not found", dir.c_str ());
-                  else
-                    need_to_update = true;
-                }
-            }
+          std::string dir = *p;
+
+          //dir = regexprep (dir_elts{j}, '//+', "/");
+          //dir = regexprep (dir, '/$', "");
+
+          if (! load_path::remove (dir))
+            warning ("rmpath: %s: not found", dir.c_str ());
           else
-            error ("addpath: all arguments must be strings");
+            need_to_update = true;
         }
-
-      if (need_to_update)
-        rehash_internal ();
     }
-  else
-    print_usage ();
+
+  if (need_to_update)
+    rehash_internal ();
 
   return retval;
 }
--- a/libinterp/corefcn/load-path.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/load-path.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_load_path_h)
+#if ! defined (octave_load_path_h)
 #define octave_load_path_h 1
 
 #include <iosfwd>
@@ -446,10 +446,10 @@
   // private files (those found in the special "private" subdirectory)
   // in each directory.
   //
-  // Second, a map from file names (the union of all "public" files for all
+  // Second, a map from filenames (the union of all "public" files for all
   // directories, but without filename extensions) to a list of
   // corresponding information (directory name and file types).  This
-  // way, we can quickly find shadowed file names and look up all
+  // way, we can quickly find shadowed filenames and look up all
   // overloaded functions (in the "@" directories used to implement
   // classes).
 
@@ -514,14 +514,14 @@
       return *this;
     }
 
-    void add (const dir_info& di, bool at_end)
+    void add (const dir_info& di, bool at_end, bool updating)
     {
       if (at_end)
         dir_list.push_back (di.dir_name);
       else
         dir_list.push_front (di.dir_name);
 
-      add_to_fcn_map (di, at_end);
+      add_to_fcn_map (di, at_end, updating);
 
       add_to_private_fcn_map (di);
 
@@ -565,7 +565,7 @@
     string_vector fcn_names (void) const;
 
   private:
-    void add_to_fcn_map (const dir_info& di, bool at_end);
+    void add_to_fcn_map (const dir_info& di, bool at_end, bool updating);
 
     void add_to_private_fcn_map (const dir_info& di);
 
@@ -722,7 +722,8 @@
   { return command_line_path; }
 
   void add (const dir_info& di, bool at_end,
-            const std::string& pname = std::string ()) const;
+            const std::string& pname = std::string (),
+            bool updating = false) const;
 
   friend dir_info::fcn_file_map_type get_fcn_files (const std::string& d);
 };
--- a/libinterp/corefcn/load-save.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/load-save.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -59,6 +59,7 @@
 #include "gripes.h"
 #include "load-path.h"
 #include "load-save.h"
+#include "oct-hdf5.h"
 #include "oct-obj.h"
 #include "oct-map.h"
 #include "ov-cell.h"
@@ -76,7 +77,7 @@
 #include "ls-mat-ascii.h"
 #include "ls-mat4.h"
 #include "ls-mat5.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-oct-binary.h"
 
 // Remove gnulib definitions, if any.
@@ -188,6 +189,7 @@
     {
       if (! quiet)
         error ("load: unable to read read binary file");
+
       return -1;
     }
 
@@ -269,7 +271,7 @@
               std::string type_val = extract_keyword (file, "type");
 
               if (name_val.empty () != true && type_val.empty () != true)
-                retval = LS_ASCII;
+                retval = LS_TEXT;
               else
                 {
                   file.clear ();
@@ -362,8 +364,8 @@
 
       switch (format.type)
         {
-        case LS_ASCII:
-          name = read_ascii_data (stream, orig_fname, global, tc, count);
+        case LS_TEXT:
+          name = read_text_data (stream, orig_fname, global, tc, count);
           break;
 
         case LS_BINARY:
@@ -397,9 +399,9 @@
           break;
         }
 
-      if (error_state || stream.eof () || name.empty ())
+      if (stream.eof () || name.empty ())
         break;
-      else if (! error_state && ! name.empty ())
+      else
         {
           if (tc.is_defined ())
             {
@@ -454,14 +456,6 @@
           else
             error ("load: unable to load variable '%s'", name.c_str ());
         }
-      else
-        {
-          if (count == 0)
-            error ("load: are you sure '%s' is an Octave data file?",
-                   orig_fname.c_str ());
-
-          break;
-        }
     }
 
   if (list_only && count)
@@ -641,9 +635,6 @@
 
   string_vector argv = args.make_argv ("load");
 
-  if (error_state)
-    return retval;
-
   int i = 1;
   std::string orig_fname = "";
 
@@ -707,7 +698,6 @@
           format = LS_HDF5;
 #else /* ! HAVE_HDF5 */
           error ("load: octave executable was not linked with HDF5 library");
-          return retval;
 #endif /* ! HAVE_HDF5 */
         }
       else if (argv[i] == "-import" || argv[i] == "-i")
@@ -716,7 +706,7 @@
         }
       else if (argv[i] == "-text" || argv[i] == "-t")
         {
-          format = LS_ASCII;
+          format = LS_TEXT;
         }
       else
         break;
@@ -725,12 +715,9 @@
   if (orig_fname == "")
     {
       if (i == argc)
-        {
-          print_usage ();
-          return retval;
-        }
-      else
-        orig_fname = argv[i];
+        print_usage ();
+
+      orig_fname = argv[i];
     }
   else
     i--;
@@ -768,9 +755,6 @@
 
       fname = find_file_to_load (fname, orig_fname);
 
-      if (error_state)
-        return retval;
-
       bool use_zlib = false;
 
       if (format == LS_UNKNOWN)
@@ -935,8 +919,8 @@
 {
   switch (fmt.type)
     {
-    case LS_ASCII:
-      save_ascii_data (os, tc, name, global, 0);
+    case LS_TEXT:
+      save_text_data (os, tc, name, global, 0);
       break;
 
     case LS_BINARY:
@@ -1037,9 +1021,6 @@
     {
       do_save (os, *p, fmt, save_as_floats);
 
-      if (error_state)
-        break;
-
       saved++;
     }
 
@@ -1052,7 +1033,7 @@
                     bool &save_as_floats, bool &use_zlib)
 {
   string_vector retval;
-  int argc = argv.length ();
+  int argc = argv.numel ();
 
   bool do_double = false;
   bool do_tabs = false;
@@ -1077,7 +1058,7 @@
         }
       else if (argv[i] == "-text" || argv[i] == "-t")
         {
-          format = LS_ASCII;
+          format = LS_TEXT;
         }
       else if (argv[i] == "-binary" || argv[i] == "-b")
         {
@@ -1203,16 +1184,17 @@
       {
         char const * versionmagic;
         int16_t number = *(reinterpret_cast<const int16_t *>("\x00\x01"));
-        struct tm bdt;
-        time_t now;
         char headertext[128];
+        octave_gmtime now;
 
-        time (&now);
-        bdt = *gnulib::gmtime (&now);
+        // ISO 8601 format date
+        const char *matlab_format = "MATLAB 5.0 MAT-file, written by Octave "
+            OCTAVE_VERSION ", %Y-%m-%d %T UTC";
+        std::string comment_string = now.strftime (matlab_format);
+
+        size_t len = std::min (comment_string.length (), static_cast<size_t> (124));
         memset (headertext, ' ', 124);
-        // ISO 8601 format date
-        nstrftime (headertext, 124, "MATLAB 5.0 MAT-file, written by Octave "
-                   OCTAVE_VERSION ", %Y-%m-%d %T UTC", &bdt, 1, 0);
+        memcpy (headertext, comment_string.data (), len);
 
         // The first pair of bytes give the version of the MAT file
         // format.  The second pair of bytes form a magic number which
@@ -1235,7 +1217,7 @@
 #ifdef HAVE_HDF5
     case LS_HDF5:
 #endif /* HAVE_HDF5 */
-    case LS_ASCII:
+    case LS_TEXT:
       {
         octave_localtime now;
 
@@ -1292,27 +1274,18 @@
   else if (argv[argv_idx] == "-struct")
     {
       if (++argv_idx >= argc)
-        {
-          error ("save: missing struct name");
-          return;
-        }
+        error ("save: missing struct name");
 
       std::string struct_name = argv[argv_idx];
 
       if (! symbol_table::is_variable (struct_name))
-        {
-          error ("save: no such variable: '%s'", struct_name.c_str ());
-          return;
-        }
+        error ("save: no such variable: '%s'", struct_name.c_str ());
 
       octave_value struct_var = symbol_table::varval (struct_name);
 
       if (! struct_var.is_map () || struct_var.numel () != 1)
-        {
-          error ("save: '%s' is not a scalar structure",
-                 struct_name.c_str ());
-          return;
-        }
+        error ("save: '%s' is not a scalar structure", struct_name.c_str ());
+
       octave_scalar_map struct_var_map = struct_var.scalar_map_value ();
 
       ++argv_idx;
@@ -1378,9 +1351,6 @@
               save_mem_size += val_size;
 
               do_save (os, val, name, help, global, fmt, save_as_floats);
-
-              if (error_state)
-                break;
             }
         }
     }
@@ -1393,7 +1363,7 @@
 {
   if (Vcrash_dumps_octave_core)
     {
-      // FIXME: should choose better file name?
+      // FIXME: should choose better filename?
 
       const char *fname = Voctave_core_file_name.c_str ();
 
@@ -1439,7 +1409,8 @@
               file.close ();
             }
           else
-            warning ("unable to open '%s' for writing...", fname);
+            warning ("dump_octave_core: unable to open '%s' for writing...",
+                     fname);
         }
       else
 #endif /* HAVE_HDF5 */
@@ -1458,7 +1429,8 @@
                   file.close ();
                 }
               else
-                warning ("unable to open '%s' for writing...", fname);
+                warning ("dump_octave_core: unable to open '%s' for writing...",
+                         fname);
             }
           else
 #endif
@@ -1472,7 +1444,8 @@
                   file.close ();
                 }
               else
-                warning ("unable to open '%s' for writing...", fname);
+                warning ("dump_octave_core: unable to open '%s' for writing...",
+                         fname);
             }
         }
     }
@@ -1613,15 +1586,12 @@
 
   string_vector argv = args.make_argv ();
 
-  if (error_state)
-    return retval;
-
   // Here is where we would get the default save format if it were
   // stored in a user preference variable.
 
   bool save_as_floats = false;
 
-  load_save_format format = LS_ASCII;
+  load_save_format format = LS_TEXT;
 
   bool append = false;
 
@@ -1634,23 +1604,14 @@
   // override from command line
   argv = parse_save_options (argv, format, append, save_as_floats,
                              use_zlib);
-  int argc = argv.length ();
+  int argc = argv.numel ();
   int i = 0;
 
-  if (error_state)
-    return retval;
-
   if (i == argc)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
-  if (save_as_floats && format == LS_ASCII)
-    {
-      error ("save: cannot specify both -ascii and -float-binary");
-      return retval;
-    }
+  if (save_as_floats && format == LS_TEXT)
+    error ("save: cannot specify both -text and -float-binary");
 
   if (argv[i] == "-")
     {
@@ -1681,10 +1642,7 @@
   // Guard against things like 'save a*', which are probably mistakes...
 
   else if (i == argc - 1 && glob_pattern_p (argv[i]))
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
   else
     {
       std::string fname = file_ops::tilde_expand (argv[i]);
@@ -1712,10 +1670,7 @@
         {
           // FIXME: It should be possible to append to HDF5 files.
           if (append)
-            {
-              error ("save: appending to HDF5 files is not implemented");
-              return retval;
-            }
+            error ("save: appending to HDF5 files is not implemented");
 
           bool write_header_info
             = ! (append && H5Fis_hdf5 (fname.c_str ()) > 0);
--- a/libinterp/corefcn/load-save.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/load-save.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_load_save_h)
+#if ! defined (octave_load_save_h)
 #define octave_load_save_h 1
 
 #include <iosfwd>
@@ -35,7 +35,7 @@
 // Similarly, save_as_floats may be an option for LS_BINARY, LS_HDF5 etc.
 enum load_save_format_type
 {
-  LS_ASCII,
+  LS_TEXT,
   LS_BINARY,
   LS_MAT_ASCII,
   LS_MAT_BINARY,
--- a/libinterp/corefcn/lookup.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/lookup.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -243,10 +243,7 @@
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 3 || (nargin == 3 && ! args(2).is_string ()))
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value table = args(0);
   octave_value y = args(1);
@@ -283,12 +280,8 @@
   else if (str_case && (left_inf || right_inf))
     error ("lookup: l, r are not recognized for string lookups");
 
-  if (error_state)
-    return retval;
-
   if (num_case)
     {
-
       // In the case of a complex array, absolute values will be used for
       // compatibility (though it's not too meaningful).
 
@@ -324,7 +317,6 @@
                                     y.array_value (),
                                     left_inf, right_inf,
                                     match_idx, match_bool);
-
     }
   else if (str_case)
     {
--- a/libinterp/corefcn/ls-ascii-helper.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ls-ascii-helper.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ls_ascii_helper_h)
+#if ! defined (octave_ls_ascii_helper_h)
 #define octave_ls_ascii_helper_h 1
 
 #include <iosfwd>
--- a/libinterp/corefcn/ls-hdf5.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ls-hdf5.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -55,7 +55,7 @@
 #include "error.h"
 #include "gripes.h"
 #include "load-save.h"
-#include "oct-hdf5-id.h"
+#include "oct-hdf5.h"
 #include "oct-obj.h"
 #include "oct-map.h"
 #include "ov-cell.h"
@@ -72,6 +72,57 @@
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
+hdf5_fstreambase::hdf5_fstreambase (const char *name, int mode, int /* prot */)
+  : file_id (-1), current_item (-1)
+{
+  if (mode & std::ios::in)
+    file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT);
+  else if (mode & std::ios::out)
+    {
+      if (mode & std::ios::app && H5Fis_hdf5 (name) > 0)
+        file_id = H5Fopen (name, H5F_ACC_RDWR, H5P_DEFAULT);
+      else
+        file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT,
+                             H5P_DEFAULT);
+    }
+  if (file_id < 0)
+    std::ios::setstate (std::ios::badbit);
+
+  current_item = 0;
+}
+
+void
+hdf5_fstreambase::close (void)
+{
+  if (file_id >= 0)
+    {
+      if (H5Fclose (file_id) < 0)
+        std::ios::setstate (std::ios::badbit);
+      file_id = -1;
+    }
+}
+
+void
+hdf5_fstreambase::open (const char *name, int mode, int)
+{
+  clear ();
+
+  if (mode & std::ios::in)
+    file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT);
+  else if (mode & std::ios::out)
+    {
+      if (mode & std::ios::app && H5Fis_hdf5 (name) > 0)
+        file_id = H5Fopen (name, H5F_ACC_RDWR, H5P_DEFAULT);
+      else
+        file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT,
+                             H5P_DEFAULT);
+    }
+  if (file_id < 0)
+    std::ios::setstate (std::ios::badbit);
+
+  current_item = 0;
+}
+
 static std::string
 make_valid_identifier (const std::string& nm)
 {
@@ -104,7 +155,7 @@
 // which is all we need it for
 
 bool
-hdf5_types_compatible (hid_t t1, hid_t t2)
+hdf5_types_compatible (octave_hdf5_id t1, octave_hdf5_id t2)
 {
   int n;
   if ((n = H5Tget_nmembers (t1)) != H5Tget_nmembers (t2))
@@ -129,7 +180,7 @@
 // otherwise.
 
 bool
-hdf5_check_attr (hid_t loc_id, const char *attr_name)
+hdf5_check_attr (octave_hdf5_id loc_id, const char *attr_name)
 {
   bool retval = false;
 
@@ -170,7 +221,7 @@
 }
 
 bool
-hdf5_get_scalar_attr (hid_t loc_id, hid_t type_id,
+hdf5_get_scalar_attr (octave_hdf5_id loc_id, octave_hdf5_id type_id,
                       const char *attr_name, void *buf)
 {
   bool retval = false;
@@ -224,8 +275,8 @@
 // H5T_NATIVE_DOUBLE to save as 'double'). Note that any necessary
 // conversions are handled automatically by HDF5.
 
-hid_t
-hdf5_make_complex_type (hid_t num_type)
+octave_hdf5_id
+hdf5_make_complex_type (octave_hdf5_id num_type)
 {
   hid_t type_id = H5Tcreate (H5T_COMPOUND, sizeof (double) * 2);
 
@@ -245,8 +296,8 @@
 // -1 on error, and 0 to tell H5Giterate to continue on to the next item
 // (e.g. if NAME was a data type we don't recognize).
 
-herr_t
-hdf5_read_next_data (hid_t group_id, const char *name, void *dv)
+octave_hdf5_err
+hdf5_read_next_data (octave_hdf5_id group_id, const char *name, void *dv)
 {
   hdf5_callback_data *d = static_cast<hdf5_callback_data *> (dv);
   hid_t type_id = -1;
@@ -364,7 +415,7 @@
     }
   else if (info.type == H5G_DATASET && ident_valid)
     {
-      // For backwards compatiability.
+      // For backwards compatibility.
 #if HAVE_HDF5_18
       data_id = H5Dopen (group_id, name, H5P_DEFAULT);
 #else
@@ -588,7 +639,7 @@
                 bool& global, octave_value& tc, std::string& doc,
                 const string_vector& argv, int argv_idx, int argc)
 {
-  check_hdf5_id_type ();
+  check_hdf5_types ();
 
   std::string retval;
 
@@ -663,8 +714,8 @@
 
 // Add an attribute named attr_name to loc_id (a simple scalar
 // attribute with value 1).  Return value is >= 0 on success.
-herr_t
-hdf5_add_attr (hid_t loc_id, const char *attr_name)
+octave_hdf5_err
+hdf5_add_attr (octave_hdf5_id loc_id, const char *attr_name)
 {
   herr_t retval = 0;
 
@@ -698,8 +749,8 @@
   return retval;
 }
 
-herr_t
-hdf5_add_scalar_attr (hid_t loc_id, hid_t type_id,
+octave_hdf5_err
+hdf5_add_scalar_attr (octave_hdf5_id loc_id, octave_hdf5_id type_id,
                       const char *attr_name, void *buf)
 {
   herr_t retval = 0;
@@ -737,7 +788,7 @@
 //    = 0  Not an empty matrix; did nothing
 //    < 0  Error condition
 int
-save_hdf5_empty (hid_t loc_id, const char *name, const dim_vector d)
+save_hdf5_empty (octave_hdf5_id loc_id, const char *name, const dim_vector d)
 {
   hsize_t sz = d.length ();
   OCTAVE_LOCAL_BUFFER (octave_idx_type, dims, sz);
@@ -787,7 +838,7 @@
 //    = 0  Not an empty matrix; did nothing
 //    < 0  Error condition
 int
-load_hdf5_empty (hid_t loc_id, const char *name, dim_vector &d)
+load_hdf5_empty (octave_hdf5_id loc_id, const char *name, dim_vector &d)
 {
   if (! hdf5_check_attr (loc_id, "OCTAVE_EMPTY_MATRIX"))
     return 0;
@@ -826,7 +877,7 @@
 
 // return the HDF5 type id corresponding to the Octave save_type
 
-hid_t
+octave_hdf5_id
 save_type_to_hdf5 (save_type st)
 {
   switch (st)
@@ -865,7 +916,7 @@
 // (stored as HDF5 groups).
 
 bool
-add_hdf5_data (hid_t loc_id, const octave_value& tc,
+add_hdf5_data (octave_hdf5_id loc_id, const octave_value& tc,
                const std::string& name, const std::string& doc,
                bool mark_as_global, bool save_as_floats)
 {
@@ -955,7 +1006,7 @@
                 const std::string& name, const std::string& doc,
                 bool mark_as_global, bool save_as_floats)
 {
-  check_hdf5_id_type ();
+  check_hdf5_types ();
 
   hdf5_ofstream& hs = dynamic_cast<hdf5_ofstream&> (os);
 
--- a/libinterp/corefcn/ls-hdf5.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ls-hdf5.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,12 +20,12 @@
 
 */
 
-#if !defined (octave_ls_hdf5_h)
+#if ! defined (octave_ls_hdf5_h)
 #define octave_ls_hdf5_h 1
 
 #if defined (HAVE_HDF5)
 
-#include "oct-hdf5.h"
+#include "oct-hdf5-types.h"
 
 // first, we need to define our own dummy stream subclass, since
 // HDF5 needs to do its own file i/o
@@ -38,7 +38,7 @@
 public:
 
   // HDF5 uses an "id" to refer to an open file
-  hid_t file_id;
+  octave_hdf5_id file_id;
 
   // keep track of current item index in the file
   int current_item;
@@ -47,54 +47,11 @@
 
   ~hdf5_fstreambase () { close (); }
 
-  hdf5_fstreambase (const char *name, int mode, int /* prot */ = 0)
-    : file_id (-1), current_item (-1)
-  {
-    if (mode & std::ios::in)
-      file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT);
-    else if (mode & std::ios::out)
-      {
-        if (mode & std::ios::app && H5Fis_hdf5 (name) > 0)
-          file_id = H5Fopen (name, H5F_ACC_RDWR, H5P_DEFAULT);
-        else
-          file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT,
-                               H5P_DEFAULT);
-      }
-    if (file_id < 0)
-      std::ios::setstate (std::ios::badbit);
-
-    current_item = 0;
-  }
+  hdf5_fstreambase (const char *name, int mode, int /* prot */ = 0);
 
-  void close ()
-  {
-    if (file_id >= 0)
-      {
-        if (H5Fclose (file_id) < 0)
-          std::ios::setstate (std::ios::badbit);
-        file_id = -1;
-      }
-  }
-
-  void open (const char *name, int mode, int)
-  {
-    clear ();
+  void close (void);
 
-    if (mode & std::ios::in)
-      file_id = H5Fopen (name, H5F_ACC_RDONLY, H5P_DEFAULT);
-    else if (mode & std::ios::out)
-      {
-        if (mode & std::ios::app && H5Fis_hdf5 (name) > 0)
-          file_id = H5Fopen (name, H5F_ACC_RDWR, H5P_DEFAULT);
-        else
-          file_id = H5Fcreate (name, H5F_ACC_TRUNC, H5P_DEFAULT,
-                               H5P_DEFAULT);
-      }
-    if (file_id < 0)
-      std::ios::setstate (std::ios::badbit);
-
-    current_item = 0;
-  }
+  void open (const char *name, int mode, int);
 };
 
 // input and output streams, subclassing istream and ostream
@@ -154,29 +111,29 @@
 };
 
 #if HAVE_HDF5_INT2FLOAT_CONVERSIONS
-extern OCTINTERP_API hid_t
+extern OCTINTERP_API octave_hdf5_id
 save_type_to_hdf5 (save_type st)
 #endif
 
-extern OCTINTERP_API hid_t
-hdf5_make_complex_type (hid_t num_type);
+extern OCTINTERP_API octave_hdf5_id
+hdf5_make_complex_type (octave_hdf5_id num_type);
 
 extern OCTINTERP_API bool
-hdf5_types_compatible (hid_t t1, hid_t t2);
+hdf5_types_compatible (octave_hdf5_id t1, octave_hdf5_id t2);
 
-extern OCTINTERP_API herr_t
-hdf5_read_next_data (hid_t group_id, const char *name, void *dv);
+extern OCTINTERP_API octave_hdf5_err
+hdf5_read_next_data (octave_hdf5_id group_id, const char *name, void *dv);
 
 extern OCTINTERP_API bool
-add_hdf5_data (hid_t loc_id, const octave_value& tc,
+add_hdf5_data (octave_hdf5_id loc_id, const octave_value& tc,
                const std::string& name, const std::string& doc,
                bool mark_as_global, bool save_as_floats);
 
 extern OCTINTERP_API int
-save_hdf5_empty (hid_t loc_id, const char *name, const dim_vector d);
+save_hdf5_empty (octave_hdf5_id loc_id, const char *name, const dim_vector d);
 
 extern OCTINTERP_API int
-load_hdf5_empty (hid_t loc_id, const char *name, dim_vector &d);
+load_hdf5_empty (octave_hdf5_id loc_id, const char *name, dim_vector &d);
 
 extern OCTINTERP_API std::string
 read_hdf5_data (std::istream& is,  const std::string& filename, bool& global,
@@ -189,26 +146,20 @@
                 bool mark_as_global, bool save_as_floats);
 
 extern OCTINTERP_API bool
-hdf5_check_attr (hid_t loc_id, const char *attr_name);
+hdf5_check_attr (octave_hdf5_id loc_id, const char *attr_name);
 
 extern OCTINTERP_API bool
-hdf5_get_scalar_attr (hid_t loc_id, hid_t type_id, const char *attr_name,
-                      void *buf);
+hdf5_get_scalar_attr (octave_hdf5_id loc_id, octave_hdf5_id type_id,
+                      const char *attr_name, void *buf);
 
-extern OCTINTERP_API herr_t
-hdf5_add_attr (hid_t loc_id, const char *attr_name);
+extern OCTINTERP_API octave_hdf5_err
+hdf5_add_attr (octave_hdf5_id loc_id, const char *attr_name);
 
 
-extern OCTINTERP_API herr_t
-hdf5_add_scalar_attr (hid_t loc_id, hid_t type_id,
+extern OCTINTERP_API octave_hdf5_err
+hdf5_add_scalar_attr (octave_hdf5_id loc_id, octave_hdf5_id type_id,
                       const char *attr_name, void *buf);
 
-#ifdef USE_64_BIT_IDX_T
-#define H5T_NATIVE_IDX H5T_NATIVE_INT64
-#else
-#define H5T_NATIVE_IDX H5T_NATIVE_INT
-#endif
-
 #endif
 
 #endif
--- a/libinterp/corefcn/ls-mat-ascii.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ls-mat-ascii.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -59,6 +59,7 @@
 #include "pager.h"
 #include "pt-exp.h"
 #include "sysdep.h"
+#include "toplev.h"
 #include "unwind-prot.h"
 #include "utils.h"
 #include "variables.h"
@@ -119,7 +120,7 @@
   nr = 0;
   nc = 0;
 
-  while (is && ! error_state)
+  while (is)
     {
       octave_quit ();
 
@@ -270,7 +271,7 @@
 
       octave_quit ();
 
-      if (! error_state && nr > 0 && nc > 0)
+      if (nr > 0 && nc > 0)
         {
           Matrix tmp (nr, nc);
 
@@ -369,15 +370,20 @@
   if (val.is_complex_type ())
     warning ("save: omitting imaginary part for ASCII file");
 
-  Matrix m = val.matrix_value (true);
+  Matrix m;
 
-  if (error_state)
+  try
     {
+      m = val.matrix_value (true);
+    }
+  catch (const octave_execution_exception& e)
+    {
+      recover_from_exception ();
+
       success = false;
+    }
 
-      error_state = 0;
-    }
-  else
+  if (success)
     {
       long old_precision = os.precision ();
 
--- a/libinterp/corefcn/ls-mat-ascii.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ls-mat-ascii.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ls_mat_ascii_h)
+#if ! defined (octave_ls_mat_ascii_h)
 #define octave_ls_mat_ascii_h 1
 
 extern std::string
--- a/libinterp/corefcn/ls-mat4.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ls-mat4.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -166,6 +166,7 @@
     {
       if (! quiet)
         error ("load: can't read binary file");
+
       return -1;
     }
 
@@ -277,16 +278,10 @@
   flt_fmt = mopt_digit_to_float_format (mach);
 
   if (flt_fmt == oct_mach_info::flt_fmt_unknown)
-    {
-      error ("load: unrecognized binary format!");
-      return retval;
-    }
+    error ("load: unrecognized binary format!");
 
   if (imag && type == 1)
-    {
-      error ("load: encountered complex matrix with string flag set!");
-      return retval;
-    }
+    error ("load: encountered complex matrix with string flag set!");
 
   // LEN includes the terminating character, and the file is also
   // supposed to include it, but apparently not all files do.  Either
@@ -373,11 +368,8 @@
 
         read_mat_binary_data (is, re.fortran_vec (), prec, dlen, swap, flt_fmt);
 
-        if (! is || error_state)
-          {
-            error ("load: reading matrix data for '%s'", name);
-            goto data_read_error;
-          }
+        if (! is)
+          error ("load: reading matrix data for '%s'", name);
 
         if (imag)
           {
@@ -386,11 +378,8 @@
             read_mat_binary_data (is, im.fortran_vec (), prec, dlen, swap,
                                   flt_fmt);
 
-            if (! is || error_state)
-              {
-                error ("load: reading imaginary matrix data for '%s'", name);
-                goto data_read_error;
-              }
+            if (! is)
+              error ("load: reading imaginary matrix data for '%s'", name);
 
             ComplexMatrix ctmp (nr, nc);
 
@@ -498,7 +487,7 @@
       Range r = tc.range_value ();
       double base = r.base ();
       double inc = r.inc ();
-      octave_idx_type nel = r.nelem ();
+      octave_idx_type nel = r.numel ();
       for (octave_idx_type i = 0; i < nel; i++)
         {
           double x = base + i * inc;
--- a/libinterp/corefcn/ls-mat4.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ls-mat4.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ls_mat4_h)
+#if ! defined (octave_ls_mat4_h)
 #define octave_ls_mat4_h 1
 
 extern oct_mach_info::float_format
--- a/libinterp/corefcn/ls-mat5.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ls-mat5.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -376,21 +376,15 @@
         std::streampos tmp_pos; \
   \
         if (read_mat5_tag (is, swap, type, len, is_small_data_element)) \
-          { \
-            error ("load: reading matrix data for '%s'", retval.c_str ()); \
-            goto data_read_error; \
-          } \
+          error ("load: reading matrix data for '%s'", retval.c_str ()); \
   \
         octave_idx_type n = re.numel (); \
         tmp_pos = is.tellg (); \
         read_mat5_integer_data (is, re.fortran_vec (), n, swap, \
                                 static_cast<enum mat5_data_type> (type)); \
   \
-        if (! is || error_state) \
-          { \
-            error ("load: reading matrix data for '%s'", retval.c_str ()); \
-            goto data_read_error; \
-          } \
+        if (! is) \
+          error ("load: reading matrix data for '%s'", retval.c_str ()); \
   \
         is.seekg (tmp_pos + static_cast<std::streamoff>\
                   (READ_PAD (is_small_data_element, len))); \
@@ -401,22 +395,16 @@
             NDArray im (dims); \
   \
             if (read_mat5_tag (is, swap, type, len, is_small_data_element)) \
-              { \
-                error ("load: reading matrix data for '%s'", \
-                       retval.c_str ()); \
-                goto data_read_error; \
-              } \
+              error ("load: reading matrix data for '%s'", \
+                     retval.c_str ()); \
   \
             n = im.numel (); \
             read_mat5_binary_data (is, im.fortran_vec (), n, swap, \
                                    static_cast<enum mat5_data_type> (type), flt_fmt); \
   \
-            if (! is || error_state) \
-              { \
-                error ("load: reading imaginary matrix data for '%s'", \
-                       retval.c_str ()); \
-                goto data_read_error; \
-              } \
+            if (! is) \
+              error ("load: reading imaginary matrix data for '%s'", \
+                     retval.c_str ()); \
   \
             ComplexNDArray ctmp (dims); \
   \
@@ -619,7 +607,6 @@
     {
       pos = is.tellg ();
       error ("load: invalid element type = %d", type);
-      goto early_read_error;
     }
 
   if (element_length == 0)
@@ -634,10 +621,7 @@
   int32_t len;
   if (read_mat5_tag (is, swap, type, len, is_small_data_element)
       || type != miUINT32 || len != 8 || is_small_data_element)
-    {
-      error ("load: invalid array flags subelement");
-      goto early_read_error;
-    }
+    error ("load: invalid array flags subelement");
 
   int32_t flags;
   read_int (is, swap, flags);
@@ -661,10 +645,7 @@
 
       if (read_mat5_tag (is, swap, type, dim_len, is_small_data_element)
           || type != miINT32)
-        {
-          error ("load: invalid dimensions array subelement");
-          goto early_read_error;
-        }
+        error ("load: invalid dimensions array subelement");
 
       int ndims = dim_len / 4;
       if (ndims == 1)
@@ -697,10 +678,7 @@
 
   if (read_mat5_tag (is, swap, type, len, is_small_data_element)
       || ! INT8(type))
-    {
-      error ("load: invalid array name subelement");
-      goto early_read_error;
-    }
+    error ("load: invalid array name subelement");
 
   {
     OCTAVE_LOCAL_BUFFER (char, name, len+1);
@@ -737,11 +715,8 @@
             std::string nm
               = read_mat5_binary_element (is, filename, swap, global, tc2);
 
-            if (! is || error_state)
-              {
-                error ("load: reading cell data for '%s'", nm.c_str ());
-                goto data_read_error;
-              }
+            if (! is)
+              error ("load: reading cell data for '%s'", nm.c_str ());
 
             cell_array(i) = tc2;
           }
@@ -780,55 +755,40 @@
         std::streampos tmp_pos;
 
         if (read_mat5_tag (is, swap, type, len, is_small_data_element))
-          {
-            error ("load: reading sparse row data for '%s'", retval.c_str ());
-            goto data_read_error;
-          }
+          error ("load: reading sparse row data for '%s'", retval.c_str ());
 
         tmp_pos = is.tellg ();
 
         read_mat5_integer_data (is, ridx, nzmax, swap,
                                 static_cast<enum mat5_data_type> (type));
 
-        if (! is || error_state)
-          {
-            error ("load: reading sparse row data for '%s'", retval.c_str ());
-            goto data_read_error;
-          }
+        if (! is)
+          error ("load: reading sparse row data for '%s'", retval.c_str ());
 
         is.seekg (tmp_pos + static_cast<std::streamoff>
                   (READ_PAD (is_small_data_element, len)));
 
         // col indices
         if (read_mat5_tag (is, swap, type, len, is_small_data_element))
-          {
-            error ("load: reading sparse column data for '%s'",
-                   retval.c_str ());
-            goto data_read_error;
-          }
+          error ("load: reading sparse column data for '%s'",
+                 retval.c_str ());
 
         tmp_pos = is.tellg ();
 
         read_mat5_integer_data (is, cidx, nc + 1, swap,
                                 static_cast<enum mat5_data_type> (type));
 
-        if (! is || error_state)
-          {
-            error ("load: reading sparse column data for '%s'",
-                   retval.c_str ());
-            goto data_read_error;
-          }
+        if (! is)
+          error ("load: reading sparse column data for '%s'",
+                 retval.c_str ());
 
         is.seekg (tmp_pos + static_cast<std::streamoff>
                   (READ_PAD (is_small_data_element, len)));
 
         // real data subelement
         if (read_mat5_tag (is, swap, type, len, is_small_data_element))
-          {
-            error ("load: reading sparse matrix data for '%s'",
-                   retval.c_str ());
-            goto data_read_error;
-          }
+          error ("load: reading sparse matrix data for '%s'",
+                 retval.c_str ());
 
         octave_idx_type nnz = cidx[nc];
         NDArray re;
@@ -843,12 +803,9 @@
                                static_cast<enum mat5_data_type> (type),
                                flt_fmt);
 
-        if (! is || error_state)
-          {
-            error ("load: reading sparse matrix data for '%s'",
-                   retval.c_str ());
-            goto data_read_error;
-          }
+        if (! is)
+          error ("load: reading sparse matrix data for '%s'",
+                 retval.c_str ());
 
         is.seekg (tmp_pos + static_cast<std::streamoff>
                   (READ_PAD (is_small_data_element, len)));
@@ -859,22 +816,16 @@
             NDArray im (dim_vector (static_cast<int> (nnz), 1));
 
             if (read_mat5_tag (is, swap, type, len, is_small_data_element))
-              {
-                error ("load: reading sparse matrix data for '%s'",
-                       retval.c_str ());
-                goto data_read_error;
-              }
+              error ("load: reading sparse matrix data for '%s'",
+                     retval.c_str ());
 
             read_mat5_binary_data (is, im.fortran_vec (), nnz, swap,
                                    static_cast<enum mat5_data_type> (type),
                                    flt_fmt);
 
-            if (! is || error_state)
-              {
-                error ("load: reading imaginary sparse matrix data for '%s'",
-                       retval.c_str ());
-                goto data_read_error;
-              }
+            if (! is)
+              error ("load: reading imaginary sparse matrix data for '%s'",
+                     retval.c_str ());
 
             for (octave_idx_type i = 0; i < nnz; i++)
               scm.xdata (i) = Complex (re (i), im (i));
@@ -892,7 +843,7 @@
         std::string nm
           = read_mat5_binary_element (is, filename, swap, global, tc2);
 
-        if (! is || error_state)
+        if (! is)
           goto data_read_error;
 
         // Octave can handle both "/" and "\" as a directory seperator
@@ -1066,24 +1017,15 @@
                 if (fh)
                   tc = new octave_fcn_handle (fh->fcn_val (), "@<anonymous>");
                 else
-                  {
-                    error ("load: failed to load anonymous function handle");
-                    goto skip_ahead;
-                  }
+                  error ("load: failed to load anonymous function handle");
               }
             else
-              {
-                error ("load: failed to load anonymous function handle");
-                goto skip_ahead;
-              }
+              error ("load: failed to load anonymous function handle");
 
             frame.run ();
           }
         else
-          {
-            error ("load: invalid function handle type");
-            goto skip_ahead;
-          }
+          error ("load: invalid function handle type");
       }
       break;
 
@@ -1099,10 +1041,7 @@
             int32_t fn_len;
             if (read_mat5_tag (is, swap, fn_type, fn_len, is_small_data_element)
                 || ! INT8(fn_type))
-              {
-                error ("load: invalid field name subelement");
-                goto data_read_error;
-              }
+              error ("load: invalid field name subelement");
 
             OCTAVE_LOCAL_BUFFER (char, elname, fn_len + 1);
 
@@ -1139,7 +1078,7 @@
                     octave_value fieldtc;
                     read_mat5_binary_element (is, filename, swap, global,
                                               fieldtc);
-                    if (! is || error_state)
+                    if (! is)
                       goto data_read_error;
 
                     elt[i](j) = fieldtc;
@@ -1161,10 +1100,7 @@
 
         if (read_mat5_tag (is, swap, type, len, is_small_data_element)
             || ! INT8(type))
-          {
-            error ("load: invalid class name");
-            goto skip_ahead;
-          }
+          error ("load: invalid class name");
 
         {
           OCTAVE_LOCAL_BUFFER (char, name, len+1);
@@ -1198,10 +1134,7 @@
         // that eventually someone will recognize that's a waste of space.
         if (read_mat5_tag (is, swap, fn_type, fn_len, is_small_data_element)
             || fn_type != miINT32)
-          {
-            error ("load: invalid field name length subelement");
-            goto data_read_error;
-          }
+          error ("load: invalid field name length subelement");
 
         if (! is.read (reinterpret_cast<char *> (&field_name_length), fn_len))
           goto data_read_error;
@@ -1213,10 +1146,7 @@
         // us how many fields there are.
         if (read_mat5_tag (is, swap, fn_type, fn_len, is_small_data_element)
             || ! INT8(fn_type))
-          {
-            error ("load: invalid field name subelement");
-            goto data_read_error;
-          }
+          error ("load: invalid field name subelement");
 
         octave_idx_type n_fields = fn_len/field_name_length;
 
@@ -1282,12 +1212,16 @@
                     if (load_path::find_method (classname, "loadobj")
                         != std::string ())
                       {
-                        octave_value_list tmp = feval ("loadobj", tc, 1);
-
-                        if (! error_state)
-                          tc = tmp(0);
-                        else
-                          goto data_read_error;
+                        try
+                          {
+                            octave_value_list tmp = feval ("loadobj", tc, 1);
+
+                            tc = tmp(0);
+                          }
+                        catch (const octave_execution_exception&)
+                          {
+                            goto data_read_error;
+                          }
                       }
                   }
                 else
@@ -1362,10 +1296,7 @@
         std::streampos tmp_pos;
 
         if (read_mat5_tag (is, swap, type, len, is_small_data_element))
-          {
-            error ("load: reading matrix data for '%s'", retval.c_str ());
-            goto data_read_error;
-          }
+          error ("load: reading matrix data for '%s'", retval.c_str ());
 
         octave_idx_type n = re.numel ();
         tmp_pos = is.tellg ();
@@ -1373,11 +1304,8 @@
                                static_cast<enum mat5_data_type> (type),
                                flt_fmt);
 
-        if (! is || error_state)
-          {
-            error ("load: reading matrix data for '%s'", retval.c_str ());
-            goto data_read_error;
-          }
+        if (! is)
+          error ("load: reading matrix data for '%s'", retval.c_str ());
 
         is.seekg (tmp_pos + static_cast<std::streamoff>
                   (READ_PAD (is_small_data_element, len)));
@@ -1389,22 +1317,16 @@
             FloatNDArray im (dims);
 
             if (read_mat5_tag (is, swap, type, len, is_small_data_element))
-              {
-                error ("load: reading matrix data for '%s'", retval.c_str ());
-                goto data_read_error;
-              }
+              error ("load: reading matrix data for '%s'", retval.c_str ());
 
             n = im.numel ();
             read_mat5_binary_data (is, im.fortran_vec (), n, swap,
                                    static_cast<enum mat5_data_type> (type),
                                    flt_fmt);
 
-            if (! is || error_state)
-              {
-                error ("load: reading imaginary matrix data for '%s'",
-                       retval.c_str ());
-                goto data_read_error;
-              }
+            if (! is)
+              error ("load: reading imaginary matrix data for '%s'",
+                     retval.c_str ());
 
             FloatComplexNDArray ctmp (dims);
 
@@ -1431,10 +1353,7 @@
         std::streampos tmp_pos;
 
         if (read_mat5_tag (is, swap, type, len, is_small_data_element))
-          {
-            error ("load: reading matrix data for '%s'", retval.c_str ());
-            goto data_read_error;
-          }
+          error ("load: reading matrix data for '%s'", retval.c_str ());
 
         octave_idx_type n = re.numel ();
         tmp_pos = is.tellg ();
@@ -1442,11 +1361,8 @@
                                static_cast<enum mat5_data_type> (type),
                                flt_fmt);
 
-        if (! is || error_state)
-          {
-            error ("load: reading matrix data for '%s'", retval.c_str ());
-            goto data_read_error;
-          }
+        if (! is)
+          error ("load: reading matrix data for '%s'", retval.c_str ());
 
         is.seekg (tmp_pos + static_cast<std::streamoff>
                   (READ_PAD (is_small_data_element, len)));
@@ -1471,22 +1387,16 @@
             NDArray im (dims);
 
             if (read_mat5_tag (is, swap, type, len, is_small_data_element))
-              {
-                error ("load: reading matrix data for '%s'", retval.c_str ());
-                goto data_read_error;
-              }
+              error ("load: reading matrix data for '%s'", retval.c_str ());
 
             n = im.numel ();
             read_mat5_binary_data (is, im.fortran_vec (), n, swap,
                                    static_cast<enum mat5_data_type> (type),
                                    flt_fmt);
 
-            if (! is || error_state)
-              {
-                error ("load: reading imaginary matrix data for '%s'",
-                       retval.c_str ());
-                goto data_read_error;
-              }
+            if (! is)
+              error ("load: reading imaginary matrix data for '%s'",
+                     retval.c_str ());
 
             ComplexNDArray ctmp (dims);
 
@@ -1556,12 +1466,11 @@
   return retval;
 
 data_read_error:
-early_read_error:
   error ("load: trouble reading binary file '%s'", filename.c_str ());
   return std::string ();
 
 skip_ahead:
-  warning ("skipping over '%s'", retval.c_str ());
+  warning ("load: skipping over '%s'", retval.c_str ());
   is.seekg (pos + static_cast<std::streamoff> (element_length));
   return read_mat5_binary_element (is, filename, swap, global, tc);
 }
@@ -1611,7 +1520,7 @@
       bool global;
       read_mat5_binary_element (is, filename, swap, global, tc);
 
-      if (!is || error_state)
+      if (! is)
         return -1;
 
       if (tc.is_uint8_type ())
@@ -1631,7 +1540,7 @@
 
           read_mat5_binary_element (fh_ws, filename, swap, global, subsys_ov);
 
-          if (error_state)
+          if (! is)
             return -1;
         }
       else
@@ -1769,8 +1678,7 @@
         break;
 
       default:
-        (*current_liboctave_error_handler)
-          ("unrecognized data format requested");
+        error ("unrecognized data format requested");
         break;
       }
   }
@@ -1855,8 +1763,7 @@
         break;
 
       default:
-        (*current_liboctave_error_handler)
-          ("unrecognized data format requested");
+        error ("unrecognized data format requested");
         break;
       }
   }
@@ -2419,10 +2326,7 @@
               os.write (out_buf, destLen);
             }
           else
-            {
-              error ("save: error compressing data element");
-              ret = false;
-            }
+            error ("save: error compressing data element");
         }
 
       return ret;
@@ -2705,11 +2609,16 @@
           && load_path::find_method (tc.class_name (),
                                      "saveobj") != std::string ())
         {
-          octave_value_list tmp = feval ("saveobj", tc, 1);
-          if (! error_state)
-            m = tmp(0).map_value ();
-          else
-            goto error_cleanup;
+          try
+            {
+              octave_value_list tmp = feval ("saveobj", tc, 1);
+
+              m = tmp(0).map_value ();
+            }
+          catch (const octave_execution_exception&)
+            {
+              goto error_cleanup;
+            }
         }
       else
         m = tc.map_value ();
--- a/libinterp/corefcn/ls-mat5.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ls-mat5.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ls_mat5_h)
+#if ! defined (octave_ls_mat5_h)
 #define octave_ls_mat5_h 1
 
 enum mat5_data_type
--- a/libinterp/corefcn/ls-oct-ascii.cc	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,433 +0,0 @@
-/*
-
-Copyright (C) 1996-2015 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/>.
-
-*/
-
-// Author: John W. Eaton.
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <cstring>
-#include <cctype>
-
-#include <fstream>
-#include <iomanip>
-#include <iostream>
-#include <sstream>
-#include <string>
-
-#include "byte-swap.h"
-#include "data-conv.h"
-#include "file-ops.h"
-#include "glob-match.h"
-#include "lo-mappers.h"
-#include "mach-info.h"
-#include "oct-env.h"
-#include "oct-time.h"
-#include "quit.h"
-#include "str-vec.h"
-
-#include "Cell.h"
-#include "defun.h"
-#include "error.h"
-#include "gripes.h"
-#include "load-save.h"
-#include "ls-ascii-helper.h"
-#include "ls-oct-ascii.h"
-#include "oct-obj.h"
-#include "oct-map.h"
-#include "ov-cell.h"
-#include "pager.h"
-#include "pt-exp.h"
-#include "unwind-prot.h"
-#include "utils.h"
-#include "variables.h"
-#include "version.h"
-#include "dMatrix.h"
-
-// The number of decimal digits to use when writing ascii data.
-static int Vsave_precision = 16;
-
-// Functions for reading ascii data.
-
-// Extract a KEYWORD and its value from stream IS, returning the
-// associated value in a new string.
-//
-// Input should look something like:
-//
-//  [%#][ \t]*keyword[ \t]*:[ \t]*string-value[ \t]*\n
-
-std::string
-extract_keyword (std::istream& is, const char *keyword, const bool next_only)
-{
-  std::string retval;
-
-  int ch = is.peek ();
-  if (next_only && ch != '%' && ch != '#')
-    return retval;
-
-  char c;
-  while (is.get (c))
-    {
-      if (c == '%' || c == '#')
-        {
-          std::ostringstream buf;
-
-          while (is.get (c) && (c == ' ' || c == '\t' || c == '%' || c == '#'))
-            ; // Skip whitespace and comment characters.
-
-          if (isalpha (c))
-            buf << c;
-
-          while (is.get (c) && isalpha (c))
-            buf << c;
-
-          std::string tmp = buf.str ();
-          bool match = (tmp.compare (0, strlen (keyword), keyword) == 0);
-
-          if (match)
-            {
-              std::ostringstream value;
-              while (is.get (c) && (c == ' ' || c == '\t' || c == ':'))
-                ; // Skip whitespace and the colon.
-
-              is.putback (c);
-              retval = read_until_newline (is, false);
-              break;
-            }
-          else if (next_only)
-            break;
-          else
-            skip_until_newline (is, false);
-        }
-    }
-
-  int len = retval.length ();
-
-  if (len > 0)
-    {
-      while (len)
-        {
-          c = retval[len-1];
-
-          if (c == ' ' || c == '\t')
-            len--;
-          else
-            {
-              retval.resize (len);
-              break;
-            }
-        }
-    }
-
-  return retval;
-}
-
-// Extract one value (scalar, matrix, string, etc.) from stream IS and
-// place it in TC, returning the name of the variable.  If the value
-// is tagged as global in the file, return TRUE in GLOBAL.
-//
-// Each type supplies its own function to load the data, and so this
-// function is extensible.
-//
-// FILENAME is used for error messages.
-//
-// The data is expected to be in the following format:
-//
-// The input file must have a header followed by some data.
-//
-// All lines in the header must begin with a '#' character.
-//
-// The header must contain a list of keyword and value pairs with the
-// keyword and value separated by a colon.
-//
-// Keywords must appear in the following order:
-//
-// # name: <name>
-// # type: <type>
-// # <info>
-//
-// Where, for the built in types are:
-//
-//  <name> : a valid identifier
-//
-//  <type> : <typename>
-//         | global <typename>
-//
-//  <typename> : scalar
-//             | complex scalar
-//             | matrix
-//             | complex matrix
-//             | bool
-//             | bool matrix
-//             | string
-//             | range
-//
-//  <info> : <matrix info>
-//         | <string info>
-//
-//  <matrix info> : # rows: <integer>
-//                : # columns: <integer>
-//
-//  <string info> : # elements: <integer>
-//                : # length: <integer> (once before each string)
-//
-//  For backward compatibility the type "string array" is treated as a
-// "string" type. Also "string" can have a single element with no elements
-// line such that
-//
-//  <string info> : # length: <integer>
-//
-// Formatted ASCII data follows the header.
-//
-// Example:
-//
-//  # name: foo
-//  # type: matrix
-//  # rows: 2
-//  # columns: 2
-//    2  4
-//    1  3
-//
-// Example:
-//
-//  # name: foo
-//  # type: string
-//  # elements: 5
-//  # length: 4
-//  this
-//  # length: 2
-//  is
-//  # length: 1
-//  a
-//  # length: 6
-//  string
-//  # length: 5
-//  array
-//
-// FIXME: this format is fairly rigid, and doesn't allow for
-// arbitrary comments.  Someone should fix that. It does allow arbitrary
-// types however.
-
-// Ugh.  The signature of the compare method is not standard in older
-// versions of the GNU libstdc++.  Do this instead:
-
-#define SUBSTRING_COMPARE_EQ(s, pos, n, t) (s.substr (pos, n) == t)
-
-std::string
-read_ascii_data (std::istream& is, const std::string& filename, bool& global,
-                 octave_value& tc, octave_idx_type count)
-{
-  // Read name for this entry or break on EOF.
-
-  std::string name = extract_keyword (is, "name");
-
-  if (name.empty ())
-    {
-      if (count == 0)
-        error ("load: empty name keyword or no data found in file '%s'",
-               filename.c_str ());
-
-      return std::string ();
-    }
-
-  if (! (name == ".nargin." || name == ".nargout."
-         || name == CELL_ELT_TAG || valid_identifier (name)))
-    {
-      error ("load: bogus identifier '%s' found in file '%s'",
-             name.c_str (), filename.c_str ());
-      return std::string ();
-    }
-
-  // Look for type keyword.
-
-  std::string tag = extract_keyword (is, "type");
-
-  if (! tag.empty ())
-    {
-      std::string typ;
-      size_t pos = tag.rfind (' ');
-
-      if (pos != std::string::npos)
-        {
-          global = SUBSTRING_COMPARE_EQ (tag, 0, 6, "global");
-
-          typ = global ? tag.substr (7) : tag;
-        }
-      else
-        typ = tag;
-
-      // Special case for backward compatiablity. A small bit of cruft
-      if (SUBSTRING_COMPARE_EQ (typ, 0, 12, "string array"))
-        tc = charMatrix ();
-      else
-        tc = octave_value_typeinfo::lookup_type (typ);
-
-      if (! tc.load_ascii (is))
-        error ("load: trouble reading ascii file '%s'", filename.c_str ());
-    }
-  else
-    error ("load: failed to extract keyword specifying value type");
-
-  if (error_state)
-    {
-      error ("load: reading file %s", filename.c_str ());
-      return std::string ();
-    }
-
-  return name;
-}
-
-// Save the data from TC along with the corresponding NAME, and global
-// flag MARK_AS_GLOBAL on stream OS in the plain text format described
-// above for load_ascii_data.  If NAME is empty, the name: line is not
-// generated.  PRECISION specifies the number of decimal digits to print.
-//
-// Assumes ranges and strings cannot contain Inf or NaN values.
-//
-// Returns 1 for success and 0 for failure.
-
-// FIXME: should probably write the help string here too.
-
-bool
-save_ascii_data (std::ostream& os, const octave_value& val_arg,
-                 const std::string& name, bool mark_as_global,
-                 int precision)
-{
-  bool success = true;
-
-  if (! name.empty ())
-    os << "# name: " << name << "\n";
-
-  octave_value val = val_arg;
-
-  if (mark_as_global)
-    os << "# type: global " << val.type_name () << "\n";
-  else
-    os << "# type: " << val.type_name () << "\n";
-
-  if (! precision)
-    precision = Vsave_precision;
-
-  long old_precision = os.precision ();
-  os.precision (precision);
-
-  success = val.save_ascii (os);
-
-  // Insert an extra pair of newline characters after the data so that
-  // multiple data elements may be handled separately by gnuplot (see
-  // the description of the index qualifier for the plot command in the
-  // gnuplot documentation).
-  os << "\n\n";
-
-  os.precision (old_precision);
-
-  return (os && success);
-}
-
-bool
-save_ascii_data_for_plotting (std::ostream& os, const octave_value& t,
-                              const std::string& name)
-{
-  return save_ascii_data (os, t, name, false, 6);
-}
-
-// Maybe this should be a static function in tree-plot.cc?
-
-// If TC is matrix, save it on stream OS in a format useful for
-// making a 3-dimensional plot with gnuplot.  If PARAMETRIC is
-// TRUE, assume a parametric 3-dimensional plot will be generated.
-
-bool
-save_three_d (std::ostream& os, const octave_value& tc, bool parametric)
-{
-  bool fail = false;
-
-  octave_idx_type nr = tc.rows ();
-  octave_idx_type nc = tc.columns ();
-
-  if (tc.is_real_matrix ())
-    {
-      os << "# 3-D data...\n"
-         << "# type: matrix\n"
-         << "# total rows: " << nr << "\n"
-         << "# total columns: " << nc << "\n";
-
-      long old_precision = os.precision ();
-      os.precision (6);
-
-      if (parametric)
-        {
-          octave_idx_type extras = nc % 3;
-          if (extras)
-            warning ("ignoring last %d columns", extras);
-
-          Matrix tmp = tc.matrix_value ();
-          nr = tmp.rows ();
-
-          for (octave_idx_type i = 0; i < nc-extras; i += 3)
-            {
-              os << tmp.extract (0, i, nr-1, i+2);
-              if (i+3 < nc-extras)
-                os << "\n";
-            }
-        }
-      else
-        {
-          Matrix tmp = tc.matrix_value ();
-          nr = tmp.rows ();
-
-          for (octave_idx_type i = 0; i < nc; i++)
-            {
-              os << tmp.extract (0, i, nr-1, i);
-              if (i+1 < nc)
-                os << "\n";
-            }
-        }
-
-      os.precision (old_precision);
-    }
-  else
-    {
-      ::error ("for now, I can only save real matrices in 3-D format");
-      fail = true;
-    }
-
-  return (os && ! fail);
-}
-
-DEFUN (save_precision, args, nargout,
-       "-*- texinfo -*-\n\
-@deftypefn  {Built-in Function} {@var{val} =} save_precision ()\n\
-@deftypefnx {Built-in Function} {@var{old_val} =} save_precision (@var{new_val})\n\
-@deftypefnx {Built-in Function} {} save_precision (@var{new_val}, \"local\")\n\
-Query or set the internal variable that specifies the number of digits to\n\
-keep when saving data in text format.\n\
-\n\
-When called from inside a function with the @qcode{\"local\"} option, the\n\
-variable is changed locally for the function and any subroutines it calls.\n\
-The original variable value is restored when exiting the function.\n\
-@end deftypefn")
-{
-  return SET_INTERNAL_VARIABLE_WITH_LIMITS (save_precision, -1,
-                                            std::numeric_limits<int>::max ());
-}
--- a/libinterp/corefcn/ls-oct-ascii.h	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,189 +0,0 @@
-/*
-
-Copyright (C) 2003-2015 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_ls_oct_ascii_h)
-#define octave_ls_oct_ascii_h 1
-
-#include <cfloat>
-
-#include <sstream>
-#include <string>
-
-#include "str-vec.h"
-
-#include "ls-ascii-helper.h"
-
-// Flag for cell elements
-#define CELL_ELT_TAG "<cell-element>"
-
-// Used when converting Inf to something that gnuplot can read.
-
-#ifndef OCT_RBV
-#define OCT_RBV (std::numeric_limits<double>::max () / 100.0)
-#endif
-
-extern OCTINTERP_API std::string
-extract_keyword (std::istream& is, const char *keyword,
-                 const bool next_only = false);
-
-extern OCTINTERP_API std::string
-read_ascii_data (std::istream& is, const std::string& filename, bool& global,
-                 octave_value& tc, octave_idx_type count);
-
-extern OCTINTERP_API bool
-save_ascii_data (std::ostream& os, const octave_value& val_arg,
-                 const std::string& name, bool mark_as_global, int precision);
-
-extern OCTINTERP_API bool
-save_ascii_data_for_plotting (std::ostream& os, const octave_value& t,
-                              const std::string& name);
-
-extern OCTINTERP_API bool
-save_three_d (std::ostream& os, const octave_value& t,
-              bool parametric = false);
-
-// Match KEYWORD on stream IS, placing the associated value in VALUE,
-// returning TRUE if successful and FALSE otherwise.
-//
-// Input should look something like:
-//
-//  [%#][ \t]*keyword[ \t]*int-value.*\n
-
-template <class T>
-bool
-extract_keyword (std::istream& is, const char *keyword, T& value,
-                 const bool next_only = false)
-{
-  bool status = false;
-  value = T ();
-
-  char c;
-  while (is.get (c))
-    {
-      if (c == '%' || c == '#')
-        {
-          std::ostringstream buf;
-
-          while (is.get (c) && (c == ' ' || c == '\t' || c == '%' || c == '#'))
-            ; // Skip whitespace and comment characters.
-
-          if (isalpha (c))
-            buf << c;
-
-          while (is.get (c) && isalpha (c))
-            buf << c;
-
-          std::string tmp = buf.str ();
-          bool match = (tmp.compare (0, strlen (keyword), keyword) == 0);
-
-          if (match)
-            {
-              while (is.get (c) && (c == ' ' || c == '\t' || c == ':'))
-                ; // Skip whitespace and the colon.
-
-              is.putback (c);
-              if (c != '\n' && c != '\r')
-                is >> value;
-              if (is)
-                status = true;
-              skip_until_newline (is, false);
-              break;
-            }
-          else if (next_only)
-            break;
-        }
-    }
-  return status;
-}
-
-template <class T>
-bool
-extract_keyword (std::istream& is, const std::string& kw, T& value,
-                 const bool next_only = false)
-{
-  return extract_keyword (is, kw.c_str (), value, next_only);
-}
-
-// Match one of the elements in KEYWORDS on stream IS, placing the
-// matched keyword in KW and the associated value in VALUE,
-// returning TRUE if successful and FALSE otherwise.
-//
-// Input should look something like:
-//
-//  [%#][ \t]*keyword[ \t]*int-value.*\n
-
-template <class T>
-bool
-extract_keyword (std::istream& is, const string_vector& keywords,
-                 std::string& kw, T& value, const bool next_only = false)
-{
-  bool status = false;
-  kw = "";
-  value = 0;
-
-  char c;
-  while (is.get (c))
-    {
-      if (c == '%' || c == '#')
-        {
-          std::ostringstream buf;
-
-          while (is.get (c) && (c == ' ' || c == '\t' || c == '%' || c == '#'))
-            ; // Skip whitespace and comment characters.
-
-          if (isalpha (c))
-            buf << c;
-
-          while (is.get (c) && isalpha (c))
-            buf << c;
-
-          std::string tmp = buf.str ();
-
-          for (int i = 0; i < keywords.length (); i++)
-            {
-              int match = (tmp == keywords[i]);
-
-              if (match)
-                {
-                  kw = keywords[i];
-
-                  while (is.get (c) && (c == ' ' || c == '\t' || c == ':'))
-                    ; // Skip whitespace and the colon.
-
-                  is.putback (c);
-                  if (c != '\n' && c != '\r')
-                    is >> value;
-                  if (is)
-                    status = true;
-                  skip_until_newline (is, false);
-                  return status;
-                }
-            }
-
-          if (next_only)
-            break;
-        }
-    }
-  return status;
-}
-
-#endif
--- a/libinterp/corefcn/ls-oct-binary.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ls-oct-binary.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -113,7 +113,7 @@
 // to create an octave_value of the correct type. The specific load/save
 // function is then called.
 //
-// For backward compatiablity "data type" can also be a value between 1
+// For backward compatibility "data type" can also be a value between 1
 // and 7, where this defines a hardcoded octave_value of the type
 //
 //   data type                  octave_value
--- a/libinterp/corefcn/ls-oct-binary.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ls-oct-binary.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ls_oct_binary_h)
+#if ! defined (octave_ls_oct_binary_h)
 #define octave_ls_oct_binary_h 1
 
 extern OCTINTERP_API bool
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/corefcn/ls-oct-text.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,420 @@
+/*
+
+Copyright (C) 1996-2015 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/>.
+
+*/
+
+// Author: John W. Eaton.
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cstring>
+#include <cctype>
+
+#include <fstream>
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+#include <string>
+
+#include "byte-swap.h"
+#include "data-conv.h"
+#include "file-ops.h"
+#include "glob-match.h"
+#include "lo-mappers.h"
+#include "mach-info.h"
+#include "oct-env.h"
+#include "oct-time.h"
+#include "quit.h"
+#include "str-vec.h"
+
+#include "Cell.h"
+#include "defun.h"
+#include "error.h"
+#include "gripes.h"
+#include "load-save.h"
+#include "ls-ascii-helper.h"
+#include "ls-oct-text.h"
+#include "oct-obj.h"
+#include "oct-map.h"
+#include "ov-cell.h"
+#include "pager.h"
+#include "pt-exp.h"
+#include "unwind-prot.h"
+#include "utils.h"
+#include "variables.h"
+#include "version.h"
+#include "dMatrix.h"
+
+// The number of decimal digits to use when writing ascii data.
+static int Vsave_precision = 16;
+
+// Functions for reading octave format text data.
+
+// Extract a KEYWORD and its value from stream IS, returning the
+// associated value in a new string.
+//
+// Input should look something like:
+//
+//  [%#][ \t]*keyword[ \t]*:[ \t]*string-value[ \t]*\n
+
+std::string
+extract_keyword (std::istream& is, const char *keyword, const bool next_only)
+{
+  std::string retval;
+
+  int ch = is.peek ();
+  if (next_only && ch != '%' && ch != '#')
+    return retval;
+
+  char c;
+  while (is.get (c))
+    {
+      if (c == '%' || c == '#')
+        {
+          std::ostringstream buf;
+
+          while (is.get (c) && (c == ' ' || c == '\t' || c == '%' || c == '#'))
+            ; // Skip whitespace and comment characters.
+
+          if (isalpha (c))
+            buf << c;
+
+          while (is.get (c) && isalpha (c))
+            buf << c;
+
+          std::string tmp = buf.str ();
+          bool match = (tmp.compare (0, strlen (keyword), keyword) == 0);
+
+          if (match)
+            {
+              std::ostringstream value;
+              while (is.get (c) && (c == ' ' || c == '\t' || c == ':'))
+                ; // Skip whitespace and the colon.
+
+              is.putback (c);
+              retval = read_until_newline (is, false);
+              break;
+            }
+          else if (next_only)
+            break;
+          else
+            skip_until_newline (is, false);
+        }
+    }
+
+  int len = retval.length ();
+
+  if (len > 0)
+    {
+      while (len)
+        {
+          c = retval[len-1];
+
+          if (c == ' ' || c == '\t')
+            len--;
+          else
+            {
+              retval.resize (len);
+              break;
+            }
+        }
+    }
+
+  return retval;
+}
+
+// Extract one value (scalar, matrix, string, etc.) from stream IS and
+// place it in TC, returning the name of the variable.  If the value
+// is tagged as global in the file, return TRUE in GLOBAL.
+//
+// Each type supplies its own function to load the data, and so this
+// function is extensible.
+//
+// FILENAME is used for error messages.
+//
+// The data is expected to be in the following format:
+//
+// The input file must have a header followed by some data.
+//
+// All lines in the header must begin with a '#' character.
+//
+// The header must contain a list of keyword and value pairs with the
+// keyword and value separated by a colon.
+//
+// Keywords must appear in the following order:
+//
+// # name: <name>
+// # type: <type>
+// # <info>
+//
+// Where, for the built in types are:
+//
+//  <name> : a valid identifier
+//
+//  <type> : <typename>
+//         | global <typename>
+//
+//  <typename> : scalar
+//             | complex scalar
+//             | matrix
+//             | complex matrix
+//             | bool
+//             | bool matrix
+//             | string
+//             | range
+//
+//  <info> : <matrix info>
+//         | <string info>
+//
+//  <matrix info> : # rows: <integer>
+//                : # columns: <integer>
+//
+//  <string info> : # elements: <integer>
+//                : # length: <integer> (once before each string)
+//
+//  For backward compatibility the type "string array" is treated as a
+// "string" type. Also "string" can have a single element with no elements
+// line such that
+//
+//  <string info> : # length: <integer>
+//
+// Formatted ASCII data follows the header.
+//
+// Example:
+//
+//  # name: foo
+//  # type: matrix
+//  # rows: 2
+//  # columns: 2
+//    2  4
+//    1  3
+//
+// Example:
+//
+//  # name: foo
+//  # type: string
+//  # elements: 5
+//  # length: 4
+//  this
+//  # length: 2
+//  is
+//  # length: 1
+//  a
+//  # length: 6
+//  string
+//  # length: 5
+//  array
+//
+// FIXME: This format is fairly rigid, and doesn't allow for arbitrary comments.
+// Someone should fix that.  It does allow arbitrary types however.
+
+// Ugh.  The signature of the compare method is not standard in older
+// versions of the GNU libstdc++.  Do this instead:
+
+#define SUBSTRING_COMPARE_EQ(s, pos, n, t) (s.substr (pos, n) == t)
+
+std::string
+read_text_data (std::istream& is, const std::string& filename, bool& global,
+                 octave_value& tc, octave_idx_type count)
+{
+  // Read name for this entry or break on EOF.
+
+  std::string name = extract_keyword (is, "name");
+
+  if (name.empty ())
+    {
+      if (count == 0)
+        error ("load: empty name keyword or no data found in file '%s'",
+               filename.c_str ());
+
+      return std::string ();
+    }
+
+  if (! (name == ".nargin." || name == ".nargout."
+         || name == CELL_ELT_TAG || valid_identifier (name)))
+    error ("load: invalid identifier '%s' found in file '%s'",
+           name.c_str (), filename.c_str ());
+
+  // Look for type keyword.
+
+  std::string tag = extract_keyword (is, "type");
+
+  if (! tag.empty ())
+    {
+      std::string typ;
+      size_t pos = tag.rfind (' ');
+
+      if (pos != std::string::npos)
+        {
+          global = SUBSTRING_COMPARE_EQ (tag, 0, 6, "global");
+
+          typ = global ? tag.substr (7) : tag;
+        }
+      else
+        typ = tag;
+
+      // Special case for backward compatibility.  A small bit of cruft
+      if (SUBSTRING_COMPARE_EQ (typ, 0, 12, "string array"))
+        tc = charMatrix ();
+      else
+        tc = octave_value_typeinfo::lookup_type (typ);
+
+      if (! tc.load_ascii (is))
+        error ("load: trouble reading ascii file '%s'", filename.c_str ());
+    }
+  else
+    error ("load: failed to extract keyword specifying value type");
+
+  return name;
+}
+
+// Save the data from TC along with the corresponding NAME, and global
+// flag MARK_AS_GLOBAL on stream OS in the plain text format described
+// above for load_text_data.  If NAME is empty, the name: line is not
+// generated.  PRECISION specifies the number of decimal digits to print.
+//
+// Assumes ranges and strings cannot contain Inf or NaN values.
+//
+// Returns 1 for success and 0 for failure.
+
+// FIXME: should probably write the help string here too.
+
+bool
+save_text_data (std::ostream& os, const octave_value& val_arg,
+                const std::string& name, bool mark_as_global,
+                int precision)
+{
+  bool success = true;
+
+  if (! name.empty ())
+    os << "# name: " << name << "\n";
+
+  octave_value val = val_arg;
+
+  if (mark_as_global)
+    os << "# type: global " << val.type_name () << "\n";
+  else
+    os << "# type: " << val.type_name () << "\n";
+
+  if (! precision)
+    precision = Vsave_precision;
+
+  long old_precision = os.precision ();
+  os.precision (precision);
+
+  success = val.save_ascii (os);
+
+  // Insert an extra pair of newline characters after the data so that
+  // multiple data elements may be handled separately by gnuplot (see
+  // the description of the index qualifier for the plot command in the
+  // gnuplot documentation).
+  os << "\n\n";
+
+  os.precision (old_precision);
+
+  return (os && success);
+}
+
+bool
+save_text_data_for_plotting (std::ostream& os, const octave_value& t,
+                             const std::string& name)
+{
+  return save_text_data (os, t, name, false, 6);
+}
+
+// Maybe this should be a static function in tree-plot.cc?
+
+// If TC is matrix, save it on stream OS in a format useful for
+// making a 3-dimensional plot with gnuplot.  If PARAMETRIC is
+// TRUE, assume a parametric 3-dimensional plot will be generated.
+
+bool
+save_three_d (std::ostream& os, const octave_value& tc, bool parametric)
+{
+  bool fail = false;
+
+  octave_idx_type nr = tc.rows ();
+  octave_idx_type nc = tc.columns ();
+
+  if (tc.is_real_matrix ())
+    {
+      os << "# 3-D data...\n"
+         << "# type: matrix\n"
+         << "# total rows: " << nr << "\n"
+         << "# total columns: " << nc << "\n";
+
+      long old_precision = os.precision ();
+      os.precision (6);
+
+      if (parametric)
+        {
+          octave_idx_type extras = nc % 3;
+          if (extras)
+            warning ("ignoring last %d columns", extras);
+
+          Matrix tmp = tc.matrix_value ();
+          nr = tmp.rows ();
+
+          for (octave_idx_type i = 0; i < nc-extras; i += 3)
+            {
+              os << tmp.extract (0, i, nr-1, i+2);
+              if (i+3 < nc-extras)
+                os << "\n";
+            }
+        }
+      else
+        {
+          Matrix tmp = tc.matrix_value ();
+          nr = tmp.rows ();
+
+          for (octave_idx_type i = 0; i < nc; i++)
+            {
+              os << tmp.extract (0, i, nr-1, i);
+              if (i+1 < nc)
+                os << "\n";
+            }
+        }
+
+      os.precision (old_precision);
+    }
+  else
+    error ("for now, I can only save real matrices in 3-D format");
+
+  return (os && ! fail);
+}
+
+DEFUN (save_precision, args, nargout,
+       "-*- texinfo -*-\n\
+@deftypefn  {Built-in Function} {@var{val} =} save_precision ()\n\
+@deftypefnx {Built-in Function} {@var{old_val} =} save_precision (@var{new_val})\n\
+@deftypefnx {Built-in Function} {} save_precision (@var{new_val}, \"local\")\n\
+Query or set the internal variable that specifies the number of digits to\n\
+keep when saving data in text format.\n\
+\n\
+When called from inside a function with the @qcode{\"local\"} option, the\n\
+variable is changed locally for the function and any subroutines it calls.\n\
+The original variable value is restored when exiting the function.\n\
+@end deftypefn")
+{
+  return SET_INTERNAL_VARIABLE_WITH_LIMITS (save_precision, -1,
+                                            std::numeric_limits<int>::max ());
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/corefcn/ls-oct-text.h	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,189 @@
+/*
+
+Copyright (C) 2003-2015 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_ls_oct_text_h)
+#define octave_ls_oct_text_h 1
+
+#include <cfloat>
+
+#include <sstream>
+#include <string>
+
+#include "str-vec.h"
+
+#include "ls-ascii-helper.h"
+
+// Flag for cell elements
+#define CELL_ELT_TAG "<cell-element>"
+
+// Used when converting Inf to something that gnuplot can read.
+
+#ifndef OCT_RBV
+#define OCT_RBV (std::numeric_limits<double>::max () / 100.0)
+#endif
+
+extern OCTINTERP_API std::string
+extract_keyword (std::istream& is, const char *keyword,
+                 const bool next_only = false);
+
+extern OCTINTERP_API std::string
+read_text_data (std::istream& is, const std::string& filename, bool& global,
+                 octave_value& tc, octave_idx_type count);
+
+extern OCTINTERP_API bool
+save_text_data (std::ostream& os, const octave_value& val_arg,
+                 const std::string& name, bool mark_as_global, int precision);
+
+extern OCTINTERP_API bool
+save_text_data_for_plotting (std::ostream& os, const octave_value& t,
+                              const std::string& name);
+
+extern OCTINTERP_API bool
+save_three_d (std::ostream& os, const octave_value& t,
+              bool parametric = false);
+
+// Match KEYWORD on stream IS, placing the associated value in VALUE,
+// returning TRUE if successful and FALSE otherwise.
+//
+// Input should look something like:
+//
+//  [%#][ \t]*keyword[ \t]*int-value.*\n
+
+template <class T>
+bool
+extract_keyword (std::istream& is, const char *keyword, T& value,
+                 const bool next_only = false)
+{
+  bool status = false;
+  value = T ();
+
+  char c;
+  while (is.get (c))
+    {
+      if (c == '%' || c == '#')
+        {
+          std::ostringstream buf;
+
+          while (is.get (c) && (c == ' ' || c == '\t' || c == '%' || c == '#'))
+            ; // Skip whitespace and comment characters.
+
+          if (isalpha (c))
+            buf << c;
+
+          while (is.get (c) && isalpha (c))
+            buf << c;
+
+          std::string tmp = buf.str ();
+          bool match = (tmp.compare (0, strlen (keyword), keyword) == 0);
+
+          if (match)
+            {
+              while (is.get (c) && (c == ' ' || c == '\t' || c == ':'))
+                ; // Skip whitespace and the colon.
+
+              is.putback (c);
+              if (c != '\n' && c != '\r')
+                is >> value;
+              if (is)
+                status = true;
+              skip_until_newline (is, false);
+              break;
+            }
+          else if (next_only)
+            break;
+        }
+    }
+  return status;
+}
+
+template <class T>
+bool
+extract_keyword (std::istream& is, const std::string& kw, T& value,
+                 const bool next_only = false)
+{
+  return extract_keyword (is, kw.c_str (), value, next_only);
+}
+
+// Match one of the elements in KEYWORDS on stream IS, placing the
+// matched keyword in KW and the associated value in VALUE,
+// returning TRUE if successful and FALSE otherwise.
+//
+// Input should look something like:
+//
+//  [%#][ \t]*keyword[ \t]*int-value.*\n
+
+template <class T>
+bool
+extract_keyword (std::istream& is, const string_vector& keywords,
+                 std::string& kw, T& value, const bool next_only = false)
+{
+  bool status = false;
+  kw = "";
+  value = 0;
+
+  char c;
+  while (is.get (c))
+    {
+      if (c == '%' || c == '#')
+        {
+          std::ostringstream buf;
+
+          while (is.get (c) && (c == ' ' || c == '\t' || c == '%' || c == '#'))
+            ; // Skip whitespace and comment characters.
+
+          if (isalpha (c))
+            buf << c;
+
+          while (is.get (c) && isalpha (c))
+            buf << c;
+
+          std::string tmp = buf.str ();
+
+          for (int i = 0; i < keywords.numel (); i++)
+            {
+              int match = (tmp == keywords[i]);
+
+              if (match)
+                {
+                  kw = keywords[i];
+
+                  while (is.get (c) && (c == ' ' || c == '\t' || c == ':'))
+                    ; // Skip whitespace and the colon.
+
+                  is.putback (c);
+                  if (c != '\n' && c != '\r')
+                    is >> value;
+                  if (is)
+                    status = true;
+                  skip_until_newline (is, false);
+                  return status;
+                }
+            }
+
+          if (next_only)
+            break;
+        }
+    }
+  return status;
+}
+
+#endif
--- a/libinterp/corefcn/ls-utils.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ls-utils.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ls_utils_h)
+#if ! defined (octave_ls_utils_h)
 #define octave_ls_utils 1
 
 extern save_type
--- a/libinterp/corefcn/lsode.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/lsode.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -70,12 +70,15 @@
 
   if (lsode_fcn)
     {
-      octave_value_list tmp = lsode_fcn->do_multi_index_op (1, args);
+      octave_value_list tmp;
 
-      if (error_state)
+      try
         {
-          gripe_user_supplied_eval ("lsode");
-          return retval;
+          tmp = lsode_fcn->do_multi_index_op (1, args);
+        }
+      catch (octave_execution_exception& e)
+        {
+          gripe_user_supplied_eval (e, "lsode");
         }
 
       if (tmp.length () > 0 && tmp(0).is_defined ())
@@ -86,9 +89,9 @@
               warned_fcn_imaginary = true;
             }
 
-          retval = ColumnVector (tmp(0).vector_value ());
+          retval = tmp(0).xvector_value ("lsode: expecting user supplied function to return numeric vector");
 
-          if (error_state || retval.length () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("lsode");
         }
       else
@@ -109,12 +112,15 @@
 
   if (lsode_jac)
     {
-      octave_value_list tmp = lsode_jac->do_multi_index_op (1, args);
+      octave_value_list tmp;
 
-      if (error_state)
+      try
         {
-          gripe_user_supplied_eval ("lsode");
-          return retval;
+          tmp = lsode_jac->do_multi_index_op (1, args);
+        }
+      catch (octave_execution_exception& e)
+        {
+          gripe_user_supplied_eval (e, "lsode");
         }
 
       if (tmp.length () > 0 && tmp(0).is_defined ())
@@ -125,9 +131,9 @@
               warned_jac_imaginary = true;
             }
 
-          retval = tmp(0).matrix_value ();
+          retval = tmp(0).xmatrix_value ("lsode: expecting user supplied jacobian function to return numeric array");
 
-          if (error_state || retval.length () == 0)
+          if (retval.numel () == 0)
             gripe_user_supplied_eval ("lsode");
         }
       else
@@ -137,25 +143,6 @@
   return retval;
 }
 
-#define LSODE_ABORT() \
-  return retval
-
-#define LSODE_ABORT1(msg) \
-  do \
-    { \
-      ::error ("lsode: " msg); \
-      LSODE_ABORT (); \
-    } \
-  while (0)
-
-#define LSODE_ABORT2(fmt, arg) \
-  do \
-    { \
-      ::error ("lsode: " fmt, arg); \
-      LSODE_ABORT (); \
-    } \
-  while (0)
-
 DEFUN (lsode, args, nargout,
        "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {[@var{x}, @var{istate}, @var{msg}] =} lsode (@var{fcn}, @var{x_0}, @var{t})\n\
@@ -285,192 +272,173 @@
   call_depth++;
 
   if (call_depth > 1)
-    LSODE_ABORT1 ("invalid recursive call");
+    error ("lsode: invalid recursive call");
 
   int nargin = args.length ();
 
-  if (nargin > 2 && nargin < 5 && nargout < 4)
+  if (nargin < 3 || nargin > 4 || nargout > 3)
+    print_usage ();
+
+  std::string fcn_name, fname, jac_name, jname;
+  lsode_fcn = 0;
+  lsode_jac = 0;
+
+  octave_value f_arg = args(0);
+
+  if (f_arg.is_cell ())
     {
-      std::string fcn_name, fname, jac_name, jname;
-      lsode_fcn = 0;
-      lsode_jac = 0;
-
-      octave_value f_arg = args(0);
+      Cell c = f_arg.cell_value ();
+      if (c.numel () == 1)
+        f_arg = c(0);
+      else if (c.numel () == 2)
+        {
+          if (c(0).is_function_handle () || c(0).is_inline_function ())
+            lsode_fcn = c(0).function_value ();
+          else
+            {
+              fcn_name = unique_symbol_name ("__lsode_fcn__");
+              fname = "function y = ";
+              fname.append (fcn_name);
+              fname.append (" (x, t) y = ");
+              lsode_fcn = extract_function (c(0), "lsode", fcn_name, fname,
+                                            "; endfunction");
+            }
 
-      if (f_arg.is_cell ())
+          if (lsode_fcn)
+            {
+              if (c(1).is_function_handle () || c(1).is_inline_function ())
+                lsode_jac = c(1).function_value ();
+              else
+                {
+                  jac_name = unique_symbol_name ("__lsode_jac__");
+                  jname = "function jac = ";
+                  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 ())
+                        clear_function (fcn_name);
+                      lsode_fcn = 0;
+                    }
+                }
+            }
+        }
+      else
+        error ("lsode: incorrect number of elements in cell array");
+    }
+
+  if (!lsode_fcn && ! f_arg.is_cell ())
+    {
+      if (f_arg.is_function_handle () || f_arg.is_inline_function ())
+        lsode_fcn = f_arg.function_value ();
+      else
         {
-          Cell c = f_arg.cell_value ();
-          if (c.length () == 1)
-            f_arg = c(0);
-          else if (c.length () == 2)
+          switch (f_arg.rows ())
             {
-              if (c(0).is_function_handle () || c(0).is_inline_function ())
-                lsode_fcn = c(0).function_value ();
-              else
+            case 1:
+              do
                 {
                   fcn_name = unique_symbol_name ("__lsode_fcn__");
                   fname = "function y = ";
                   fname.append (fcn_name);
                   fname.append (" (x, t) y = ");
-                  lsode_fcn = extract_function (c(0), "lsode", fcn_name, fname,
-                                                "; endfunction");
+                  lsode_fcn = extract_function (f_arg, "lsode", fcn_name,
+                                                fname, "; endfunction");
                 }
+              while (0);
+              break;
 
-              if (lsode_fcn)
-                {
-                  if (c(1).is_function_handle () || c(1).is_inline_function ())
-                    lsode_jac = c(1).function_value ();
-                  else
-                    {
-                      jac_name = unique_symbol_name ("__lsode_jac__");
-                      jname = "function jac = ";
-                      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 ())
-                            clear_function (fcn_name);
-                          lsode_fcn = 0;
-                        }
-                    }
-                }
-            }
-          else
-            LSODE_ABORT1 ("incorrect number of elements in cell array");
-        }
+            case 2:
+              {
+                string_vector tmp = f_arg.all_strings ();
 
-      if (!lsode_fcn && ! f_arg.is_cell ())
-        {
-          if (f_arg.is_function_handle () || f_arg.is_inline_function ())
-            lsode_fcn = f_arg.function_value ();
-          else
-            {
-              switch (f_arg.rows ())
-                {
-                case 1:
-                  do
-                    {
-                      fcn_name = unique_symbol_name ("__lsode_fcn__");
-                      fname = "function y = ";
-                      fname.append (fcn_name);
-                      fname.append (" (x, t) y = ");
-                      lsode_fcn = extract_function (f_arg, "lsode", fcn_name,
-                                                    fname, "; endfunction");
-                    }
-                  while (0);
-                  break;
-
-                case 2:
-                  {
-                    string_vector tmp = f_arg.all_strings ();
+                fcn_name = unique_symbol_name ("__lsode_fcn__");
+                fname = "function y = ";
+                fname.append (fcn_name);
+                fname.append (" (x, t) y = ");
+                lsode_fcn = extract_function (tmp(0), "lsode", fcn_name,
+                                              fname, "; endfunction");
 
-                    if (! error_state)
-                      {
-                        fcn_name = unique_symbol_name ("__lsode_fcn__");
-                        fname = "function y = ";
-                        fname.append (fcn_name);
-                        fname.append (" (x, t) y = ");
-                        lsode_fcn = extract_function (tmp(0), "lsode", fcn_name,
-                                                      fname, "; endfunction");
+                if (lsode_fcn)
+                  {
+                    jac_name = unique_symbol_name ("__lsode_jac__");
+                    jname = "function jac = ";
+                    jname.append (jac_name);
+                    jname.append (" (x, t) jac = ");
+                    lsode_jac = extract_function (tmp(1), "lsode",
+                                                  jac_name, jname,
+                                                  "; endfunction");
 
-                        if (lsode_fcn)
-                          {
-                            jac_name = unique_symbol_name ("__lsode_jac__");
-                            jname = "function jac = ";
-                            jname.append (jac_name);
-                            jname.append (" (x, t) jac = ");
-                            lsode_jac = extract_function (tmp(1), "lsode",
-                                                          jac_name, jname,
-                                                          "; endfunction");
-
-                            if (!lsode_jac)
-                              {
-                                if (fcn_name.length ())
-                                  clear_function (fcn_name);
-                                lsode_fcn = 0;
-                              }
-                          }
+                    if (!lsode_jac)
+                      {
+                        if (fcn_name.length ())
+                          clear_function (fcn_name);
+                        lsode_fcn = 0;
                       }
                   }
-                  break;
-
-                default:
-                  LSODE_ABORT1
-                  ("first arg should be a string or 2-element string array");
-                }
-            }
-        }
-
-      if (error_state || ! lsode_fcn)
-        LSODE_ABORT ();
-
-      ColumnVector state (args(1).vector_value ());
-
-      if (error_state)
-        LSODE_ABORT1 ("expecting state vector as second argument");
-
-      ColumnVector out_times (args(2).vector_value ());
-
-      if (error_state)
-        LSODE_ABORT1 ("expecting output time vector as third argument");
-
-      ColumnVector crit_times;
-
-      int crit_times_set = 0;
-      if (nargin > 3)
-        {
-          crit_times = ColumnVector (args(3).vector_value ());
-
-          if (error_state)
-            LSODE_ABORT1 ("expecting critical time vector as fourth argument");
-
-          crit_times_set = 1;
-        }
+              }
+              break;
 
-      double tzero = out_times (0);
-
-      ODEFunc func (lsode_user_function);
-      if (lsode_jac)
-        func.set_jacobian_function (lsode_user_jacobian);
-
-      LSODE ode (state, tzero, func);
-
-      ode.set_options (lsode_opts);
-
-      Matrix output;
-      if (crit_times_set)
-        output = ode.integrate (out_times, crit_times);
-      else
-        output = ode.integrate (out_times);
-
-      if (fcn_name.length ())
-        clear_function (fcn_name);
-      if (jac_name.length ())
-        clear_function (jac_name);
-
-      if (! error_state)
-        {
-          std::string msg = ode.error_message ();
-
-          retval(2) = msg;
-          retval(1) = static_cast<double> (ode.integration_state ());
-
-          if (ode.integration_ok ())
-            retval(0) = output;
-          else
-            {
-              retval(0) = Matrix ();
-
-              if (nargout < 2)
-                error ("lsode: %s", msg.c_str ());
+            default:
+              error ("lsode: first arg should be a string or 2-element string array");
             }
         }
     }
+
+  if (! lsode_fcn)
+    error ("lsode: FCN argument is not a valid function name or handle");
+
+  ColumnVector state = args(1).xvector_value ("lsode: initial state X_0 must be a vector");
+  ColumnVector out_times = args(2).xvector_value ("lsode: output time variable T must be a vector");
+
+  ColumnVector crit_times;
+
+  int crit_times_set = 0;
+  if (nargin > 3)
+    {
+      crit_times = args(3).xvector_value ("lsode: list of critical times T_CRIT must be a vector");
+
+      crit_times_set = 1;
+    }
+
+  double tzero = out_times (0);
+
+  ODEFunc func (lsode_user_function);
+  if (lsode_jac)
+    func.set_jacobian_function (lsode_user_jacobian);
+
+  LSODE ode (state, tzero, func);
+
+  ode.set_options (lsode_opts);
+
+  Matrix output;
+  if (crit_times_set)
+    output = ode.integrate (out_times, crit_times);
   else
-    print_usage ();
+    output = ode.integrate (out_times);
+
+  if (fcn_name.length ())
+    clear_function (fcn_name);
+  if (jac_name.length ())
+    clear_function (jac_name);
+
+  std::string msg = ode.error_message ();
+
+  retval(2) = msg;
+  retval(1) = static_cast<double> (ode.integration_state ());
+
+  if (ode.integration_ok ())
+    retval(0) = output;
+  else
+    {
+      retval(0) = Matrix ();
+
+      if (nargout < 2)
+        error ("lsode: %s", msg.c_str ());
+    }
 
   return retval;
 }
--- a/libinterp/corefcn/lu.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/lu.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -145,20 +145,17 @@
   octave_value_list retval;
   int nargin = args.length ();
   bool issparse = (nargin > 0 && args(0).is_sparse_type ());
-  bool scale = (nargout  == 5);
 
   if (nargin < 1 || (issparse && (nargin > 3 || nargout > 5))
-      || (!issparse && (nargin > 2 || nargout > 3)))
-    {
-      print_usage ();
-      return retval;
-    }
+      || (! issparse && (nargin > 2 || nargout > 3)))
+    print_usage ();
 
+  bool scale = (nargout == 5);
   bool vecout = false;
   Matrix thres;
 
   int n = 1;
-  while (n < nargin && ! error_state)
+  while (n < nargin)
     {
       if (args(n).is_string ())
         {
@@ -173,21 +170,18 @@
         {
           Matrix tmp = args(n++).matrix_value ();
 
-          if (! error_state)
+          if (!issparse)
+            error ("lu: can not define pivoting threshold THRES for full matrices");
+          else if (tmp.numel () == 1)
             {
-              if (!issparse)
-                error ("lu: can not define pivoting threshold THRES for full matrices");
-              else if (tmp.nelem () == 1)
-                {
-                  thres.resize (1,2);
-                  thres(0) = tmp(0);
-                  thres(1) = tmp(0);
-                }
-              else if (tmp.nelem () == 2)
-                thres = tmp;
-              else
-                error ("lu: expecting 2-element vector for THRES");
+              thres.resize (1,2);
+              thres(0) = tmp(0);
+              thres(1) = tmp(0);
             }
+          else if (tmp.numel () == 2)
+            thres = tmp;
+          else
+            error ("lu: THRES must be a 1 or 2-element vector");
         }
     }
 
@@ -360,76 +354,70 @@
             {
               FloatMatrix m = arg.float_matrix_value ();
 
-              if (! error_state)
-                {
-                  FloatLU fact (m);
+              FloatLU fact (m);
 
-                  switch (nargout)
-                    {
-                    case 0:
-                    case 1:
-                      retval(0) = fact.Y ();
-                      break;
+              switch (nargout)
+                {
+                case 0:
+                case 1:
+                  retval(0) = fact.Y ();
+                  break;
 
-                    case 2:
-                      {
-                        PermMatrix P = fact.P ();
-                        FloatMatrix L = P.transpose () * fact.L ();
-                        retval(1) = get_lu_u (fact);
-                        retval(0) = L;
-                      }
-                      break;
+                case 2:
+                  {
+                    PermMatrix P = fact.P ();
+                    FloatMatrix L = P.transpose () * fact.L ();
+                    retval(1) = get_lu_u (fact);
+                    retval(0) = L;
+                  }
+                  break;
 
-                    case 3:
-                    default:
-                      {
-                        if (vecout)
-                          retval(2) = fact.P_vec ();
-                        else
-                          retval(2) = fact.P ();
-                        retval(1) = get_lu_u (fact);
-                        retval(0) = get_lu_l (fact);
-                      }
-                      break;
-                    }
+                case 3:
+                default:
+                  {
+                    if (vecout)
+                      retval(2) = fact.P_vec ();
+                    else
+                      retval(2) = fact.P ();
+                    retval(1) = get_lu_u (fact);
+                    retval(0) = get_lu_l (fact);
+                  }
+                  break;
                 }
             }
           else
             {
               Matrix m = arg.matrix_value ();
 
-              if (! error_state)
-                {
-                  LU fact (m);
+              LU fact (m);
 
-                  switch (nargout)
-                    {
-                    case 0:
-                    case 1:
-                      retval(0) = fact.Y ();
-                      break;
+              switch (nargout)
+                {
+                case 0:
+                case 1:
+                  retval(0) = fact.Y ();
+                  break;
 
-                    case 2:
-                      {
-                        PermMatrix P = fact.P ();
-                        Matrix L = P.transpose () * fact.L ();
-                        retval(1) = get_lu_u (fact);
-                        retval(0) = L;
-                      }
-                      break;
+                case 2:
+                  {
+                    PermMatrix P = fact.P ();
+                    Matrix L = P.transpose () * fact.L ();
+                    retval(1) = get_lu_u (fact);
+                    retval(0) = L;
+                  }
+                  break;
 
-                    case 3:
-                    default:
-                      {
-                        if (vecout)
-                          retval(2) = fact.P_vec ();
-                        else
-                          retval(2) = fact.P ();
-                        retval(1) = get_lu_u (fact);
-                        retval(0) = get_lu_l (fact);
-                      }
-                      break;
-                    }
+                case 3:
+                default:
+                  {
+                    if (vecout)
+                      retval(2) = fact.P_vec ();
+                    else
+                      retval(2) = fact.P ();
+                    retval(1) = get_lu_u (fact);
+                    retval(0) = get_lu_l (fact);
+                  }
+                  break;
                 }
             }
         }
@@ -439,76 +427,70 @@
             {
               FloatComplexMatrix m = arg.float_complex_matrix_value ();
 
-              if (! error_state)
-                {
-                  FloatComplexLU fact (m);
+              FloatComplexLU fact (m);
 
-                  switch (nargout)
-                    {
-                    case 0:
-                    case 1:
-                      retval(0) = fact.Y ();
-                      break;
+              switch (nargout)
+                {
+                case 0:
+                case 1:
+                  retval(0) = fact.Y ();
+                  break;
 
-                    case 2:
-                      {
-                        PermMatrix P = fact.P ();
-                        FloatComplexMatrix L = P.transpose () * fact.L ();
-                        retval(1) = get_lu_u (fact);
-                        retval(0) = L;
-                      }
-                      break;
+                case 2:
+                  {
+                    PermMatrix P = fact.P ();
+                    FloatComplexMatrix L = P.transpose () * fact.L ();
+                    retval(1) = get_lu_u (fact);
+                    retval(0) = L;
+                  }
+                  break;
 
-                    case 3:
-                    default:
-                      {
-                        if (vecout)
-                          retval(2) = fact.P_vec ();
-                        else
-                          retval(2) = fact.P ();
-                        retval(1) = get_lu_u (fact);
-                        retval(0) = get_lu_l (fact);
-                      }
-                      break;
-                    }
+                case 3:
+                default:
+                  {
+                    if (vecout)
+                      retval(2) = fact.P_vec ();
+                    else
+                      retval(2) = fact.P ();
+                    retval(1) = get_lu_u (fact);
+                    retval(0) = get_lu_l (fact);
+                  }
+                  break;
                 }
             }
           else
             {
               ComplexMatrix m = arg.complex_matrix_value ();
 
-              if (! error_state)
-                {
-                  ComplexLU fact (m);
+              ComplexLU fact (m);
 
-                  switch (nargout)
-                    {
-                    case 0:
-                    case 1:
-                      retval(0) = fact.Y ();
-                      break;
+              switch (nargout)
+                {
+                case 0:
+                case 1:
+                  retval(0) = fact.Y ();
+                  break;
 
-                    case 2:
-                      {
-                        PermMatrix P = fact.P ();
-                        ComplexMatrix L = P.transpose () * fact.L ();
-                        retval(1) = get_lu_u (fact);
-                        retval(0) = L;
-                      }
-                      break;
+                case 2:
+                  {
+                    PermMatrix P = fact.P ();
+                    ComplexMatrix L = P.transpose () * fact.L ();
+                    retval(1) = get_lu_u (fact);
+                    retval(0) = L;
+                  }
+                  break;
 
-                    case 3:
-                    default:
-                      {
-                        if (vecout)
-                          retval(2) = fact.P_vec ();
-                        else
-                          retval(2) = fact.P ();
-                        retval(1) = get_lu_u (fact);
-                        retval(0) = get_lu_l (fact);
-                      }
-                      break;
-                    }
+                case 3:
+                default:
+                  {
+                    if (vecout)
+                      retval(2) = fact.P_vec ();
+                    else
+                      retval(2) = fact.P ();
+                    retval(1) = get_lu_u (fact);
+                    retval(0) = get_lu_l (fact);
+                  }
+                  break;
                 }
             }
         }
@@ -644,16 +626,13 @@
 @seealso{lu, cholupdate, qrupdate}\n\
 @end deftypefn")
 {
-  octave_idx_type nargin = args.length ();
   octave_value_list retval;
-
-  bool pivoted = nargin == 5;
+  int nargin = args.length ();
 
   if (nargin != 4 && nargin != 5)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
+
+  bool pivoted = (nargin == 5);
 
   octave_value argl = args(0);
   octave_value argu = args(1);
--- a/libinterp/corefcn/luinc.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/luinc.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -101,279 +101,234 @@
   int nargin = args.length ();
   octave_value_list retval;
 
-  if (nargin == 0)
+  if (nargin < 2 || nargin > 3)
     print_usage ();
-  else if (nargin < 2 || nargin > 3)
-    error ("luinc: incorrect number of arguments");
-  else
-    {
-      bool zero_level = false;
-      bool milu = false;
-      bool udiag = false;
-      Matrix thresh;
-      double droptol = -1.;
-      bool vecout = false;
+
+  bool zero_level = false;
+  bool milu = false;
+  bool udiag = false;
+  Matrix thresh;
+  double droptol = -1.;
+  bool vecout = false;
 
-      if (args(1).is_string ())
-        {
-          if (args(1).string_value () == "0")
-            zero_level = true;
-          else
-            error ("luinc: unrecognized string argument");
-        }
-      else if (args(1).is_map ())
-        {
-          octave_scalar_map map = args(1).scalar_map_value ();
-
-          if (! error_state)
-            {
-              octave_value tmp;
-
-              tmp = map.getfield ("droptol");
-              if (tmp.is_defined ())
-                droptol = tmp.double_value ();
-
-              tmp = map.getfield ("milu");
-              if (tmp.is_defined ())
-                {
-                  double val = tmp.double_value ();
-
-                  milu = (val == 0. ? false : true);
-                }
+  if (args(1).is_string ())
+    {
+      if (args(1).string_value () == "0")
+        zero_level = true;
+      else
+        error ("luinc: unrecognized string argument");
+    }
+  else if (args(1).is_map ())
+    {
+      octave_scalar_map map = args(1).xscalar_map_value ("luinc: OPTS must be a scalar structure");
 
-              tmp = map.getfield ("udiag");
-              if (tmp.is_defined ())
-                {
-                  double val = tmp.double_value ();
+      octave_value tmp;
 
-                  udiag = (val == 0. ? false : true);
-                }
-
-              tmp = map.getfield ("thresh");
-              if (tmp.is_defined ())
-                {
-                  thresh = tmp.matrix_value ();
+      tmp = map.getfield ("droptol");
+      if (tmp.is_defined ())
+        droptol = tmp.double_value ();
 
-                  if (thresh.nelem () == 1)
-                    {
-                      thresh.resize (1,2);
-                      thresh(1) = thresh(0);
-                    }
-                  else if (thresh.nelem () != 2)
-                    {
-                      error ("luinc: expecting 2-element vector for thresh");
-                      return retval;
-                    }
-                }
-            }
-          else
-            {
-              error ("luinc: OPTS must be a scalar structure");
-              return retval;
-            }
+      tmp = map.getfield ("milu");
+      if (tmp.is_defined ())
+        {
+          double val = tmp.double_value ();
+
+          milu = (val == 0. ? false : true);
         }
-      else
-        droptol = args(1).double_value ();
-
-      if (nargin == 3)
-        {
-          std::string tmp = args(2).string_value ();
 
-          if (! error_state)
-            {
-              if (tmp.compare ("vector") == 0)
-                vecout = true;
-              else
-                error ("luinc: unrecognized string argument");
-            }
+      tmp = map.getfield ("udiag");
+      if (tmp.is_defined ())
+        {
+          double val = tmp.double_value ();
+
+          udiag = (val == 0. ? false : true);
         }
 
-      // FIXME: Add code for zero-level factorization
-      if (zero_level)
-        error ("luinc: zero-level factorization not implemented");
+      tmp = map.getfield ("thresh");
+      if (tmp.is_defined ())
+        {
+          thresh = tmp.matrix_value ();
 
-      if (!error_state)
-        {
-          if (args(0).type_name () == "sparse matrix")
+          if (thresh.numel () == 1)
             {
-              SparseMatrix sm = args(0).sparse_matrix_value ();
-              octave_idx_type sm_nr = sm.rows ();
-              octave_idx_type sm_nc = sm.cols ();
-              ColumnVector Qinit (sm_nc);
+              thresh.resize (1,2);
+              thresh(1) = thresh(0);
+            }
+          else if (thresh.numel () != 2)
+            error ("luinc: THRESH must be a 1 or 2-element vector");
+        }
+    }
+  else
+    droptol = args(1).double_value ();
 
-              for (octave_idx_type i = 0; i < sm_nc; i++)
-                Qinit (i) = i;
+  if (nargin == 3)
+    {
+      std::string tmp = args(2).string_value ();
+
+      if (tmp.compare ("vector") == 0)
+        vecout = true;
+      else
+        error ("luinc: unrecognized string argument");
+    }
+
+  // FIXME: Add code for zero-level factorization
+  if (zero_level)
+    error ("luinc: zero-level factorization not implemented");
 
-              if (! error_state)
-                {
-                  switch (nargout)
-                    {
-                    case 0:
-                    case 1:
-                    case 2:
-                      {
-                        SparseLU fact (sm, Qinit, thresh, false, true, droptol,
-                                       milu, udiag);
+  if (args(0).type_name () == "sparse matrix")
+    {
+      SparseMatrix sm = args(0).sparse_matrix_value ();
+      octave_idx_type sm_nr = sm.rows ();
+      octave_idx_type sm_nc = sm.cols ();
+      ColumnVector Qinit (sm_nc);
+
+      for (octave_idx_type i = 0; i < sm_nc; i++)
+        Qinit (i) = i;
 
-                        if (! error_state)
-                          {
-                            SparseMatrix P = fact.Pr ();
-                            SparseMatrix L = P.transpose () * fact.L ();
-                            retval(1)
-                              = octave_value (fact.U (),
-                                              MatrixType (MatrixType::Upper));
-                            retval(0)
-                              = octave_value (L, MatrixType
-                                                   (MatrixType::Permuted_Lower,
-                                                    sm_nr, fact.row_perm ()));
-                          }
-                      }
-                      break;
+      switch (nargout)
+        {
+        case 0:
+        case 1:
+        case 2:
+          {
+            SparseLU fact (sm, Qinit, thresh, false, true, droptol,
+                           milu, udiag);
 
-                    case 3:
-                      {
-                        SparseLU fact (sm, Qinit, thresh, false, true, droptol,
-                                       milu, udiag);
+            SparseMatrix P = fact.Pr ();
+            SparseMatrix L = P.transpose () * fact.L ();
+
+            retval(1)
+              = octave_value (fact.U (), MatrixType (MatrixType::Upper));
+
+            retval(0)
+              = octave_value (L, MatrixType (MatrixType::Permuted_Lower,
+                                             sm_nr, fact.row_perm ()));
+          }
+          break;
 
-                        if (! error_state)
-                          {
-                            if (vecout)
-                              retval(2) = fact.Pr_vec ();
-                            else
-                              retval(2) = fact.Pr_mat ();
-                            retval(1)
-                              = octave_value (fact.U (),
-                                              MatrixType (MatrixType::Upper));
-                            retval(0)
-                              = octave_value (fact.L (),
-                                              MatrixType (MatrixType::Lower));
-                          }
-                      }
-                      break;
+        case 3:
+          {
+            SparseLU fact (sm, Qinit, thresh, false, true, droptol,
+                           milu, udiag);
+
+            if (vecout)
+              retval(2) = fact.Pr_vec ();
+            else
+              retval(2) = fact.Pr_mat ();
 
-                    case 4:
-                    default:
-                      {
-                        SparseLU fact (sm, Qinit, thresh, false, false, droptol,
-                                       milu, udiag);
+            retval(1)
+              = octave_value (fact.U (), MatrixType (MatrixType::Upper));
+
+            retval(0)
+              = octave_value (fact.L (), MatrixType (MatrixType::Lower));
+          }
+          break;
+
+        case 4:
+        default:
+          {
+            SparseLU fact (sm, Qinit, thresh, false, false, droptol,
+                           milu, udiag);
 
-                        if (! error_state)
-                          {
-                            if (vecout)
-                              {
-                                retval(3) = fact.Pc_vec ();
-                                retval(2) = fact.Pr_vec ();
-                              }
-                            else
-                              {
-                                retval(3) = fact.Pc_mat ();
-                                retval(2) = fact.Pr_mat ();
-                              }
-                            retval(1)
-                              = octave_value (fact.U (),
-                                              MatrixType (MatrixType::Upper));
-                            retval(0)
-                              = octave_value (fact.L (),
-                                              MatrixType (MatrixType::Lower));
-                          }
-                      }
-                      break;
-                    }
-                }
-            }
-          else if (args(0).type_name () == "sparse complex matrix")
-            {
-              SparseComplexMatrix sm =
-                args(0).sparse_complex_matrix_value ();
-              octave_idx_type sm_nr = sm.rows ();
-              octave_idx_type sm_nc = sm.cols ();
-              ColumnVector Qinit (sm_nc);
+            if (vecout)
+              {
+                retval(3) = fact.Pc_vec ();
+                retval(2) = fact.Pr_vec ();
+              }
+            else
+              {
+                retval(3) = fact.Pc_mat ();
+                retval(2) = fact.Pr_mat ();
+              }
+
+            retval(1)
+              = octave_value (fact.U (), MatrixType (MatrixType::Upper));
 
-              for (octave_idx_type i = 0; i < sm_nc; i++)
-                Qinit (i) = i;
+            retval(0)
+              = octave_value (fact.L (), MatrixType (MatrixType::Lower));
+          }
+          break;
+        }
+    }
+  else if (args(0).type_name () == "sparse complex matrix")
+    {
+      SparseComplexMatrix sm =
+        args(0).sparse_complex_matrix_value ();
+      octave_idx_type sm_nr = sm.rows ();
+      octave_idx_type sm_nc = sm.cols ();
+      ColumnVector Qinit (sm_nc);
 
-              if (! error_state)
-                {
-                  switch (nargout)
-                    {
-                    case 0:
-                    case 1:
-                    case 2:
-                      {
-                        SparseComplexLU fact (sm, Qinit, thresh, false, true,
-                                              droptol, milu, udiag);
+      for (octave_idx_type i = 0; i < sm_nc; i++)
+        Qinit (i) = i;
+
+      switch (nargout)
+        {
+        case 0:
+        case 1:
+        case 2:
+          {
+            SparseComplexLU fact (sm, Qinit, thresh, false, true,
+                                  droptol, milu, udiag);
 
 
-                        if (! error_state)
-                          {
-                            SparseMatrix P = fact.Pr ();
-                            SparseComplexMatrix L = P.transpose () * fact.L ();
-                            retval(1)
-                              = octave_value (fact.U (),
-                                              MatrixType (MatrixType::Upper));
-                            retval(0)
-                              = octave_value (L, MatrixType
-                                                  (MatrixType::Permuted_Lower,
-                                                   sm_nr, fact.row_perm ()));
-                          }
-                      }
-                      break;
+            SparseMatrix P = fact.Pr ();
+            SparseComplexMatrix L = P.transpose () * fact.L ();
+
+            retval(1)
+              = octave_value (fact.U (), MatrixType (MatrixType::Upper));
+
+            retval(0)
+              = octave_value (L, MatrixType (MatrixType::Permuted_Lower,
+                                             sm_nr, fact.row_perm ()));
+          }
+          break;
 
-                    case 3:
-                      {
-                        SparseComplexLU fact (sm, Qinit, thresh, false, true,
-                                              droptol, milu, udiag);
+        case 3:
+          {
+            SparseComplexLU fact (sm, Qinit, thresh, false, true,
+                                  droptol, milu, udiag);
+
+            if (vecout)
+              retval(2) = fact.Pr_vec ();
+            else
+              retval(2) = fact.Pr_mat ();
+
+            retval(1)
+              = octave_value (fact.U (), MatrixType (MatrixType::Upper));
 
-                        if (! error_state)
-                          {
-                            if (vecout)
-                              retval(2) = fact.Pr_vec ();
-                            else
-                              retval(2) = fact.Pr_mat ();
-                            retval(1)
-                              = octave_value (fact.U (),
-                                              MatrixType (MatrixType::Upper));
-                            retval(0)
-                              = octave_value (fact.L (),
-                                              MatrixType (MatrixType::Lower));
-                          }
-                      }
-                      break;
+            retval(0)
+              = octave_value (fact.L (), MatrixType (MatrixType::Lower));
+          }
+          break;
 
-                    case 4:
-                    default:
-                      {
-                        SparseComplexLU fact (sm, Qinit, thresh, false, false,
-                                              droptol, milu, udiag);
+        case 4:
+        default:
+          {
+            SparseComplexLU fact (sm, Qinit, thresh, false, false,
+                                  droptol, milu, udiag);
 
-                        if (! error_state)
-                          {
-                            if (vecout)
-                              {
-                                retval(3) = fact.Pc_vec ();
-                                retval(2) = fact.Pr_vec ();
-                              }
-                            else
-                              {
-                                retval(3) = fact.Pc_mat ();
-                                retval(2) = fact.Pr_mat ();
-                              }
-                            retval(1)
-                              = octave_value (fact.U (),
-                                              MatrixType (MatrixType::Upper));
-                            retval(0)
-                              = octave_value (fact.L (),
-                                              MatrixType (MatrixType::Lower));
-                          }
-                      }
-                      break;
-                    }
-                }
-            }
-          else
-            error ("luinc: matrix A must be sparse");
+            if (vecout)
+              {
+                retval(3) = fact.Pc_vec ();
+                retval(2) = fact.Pr_vec ();
+              }
+            else
+              {
+                retval(3) = fact.Pc_mat ();
+                retval(2) = fact.Pr_mat ();
+              }
+
+            retval(1)
+              = octave_value (fact.U (), MatrixType (MatrixType::Upper));
+
+            retval(0)
+              = octave_value (fact.L (), MatrixType (MatrixType::Lower));
+          }
+          break;
         }
     }
+  else
+    error ("luinc: matrix A must be sparse");
 
   return retval;
 }
--- a/libinterp/corefcn/mappers.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/mappers.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -60,13 +60,10 @@
 @seealso{arg}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).abs ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).abs ());
 }
 
 /*
@@ -93,13 +90,10 @@
 @seealso{cos, acosd}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).acos ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).acos ());
 }
 
 /*
@@ -142,13 +136,10 @@
 @seealso{cosh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).acosh ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).acosh ());
 }
 
 /*
@@ -184,13 +175,10 @@
 @seealso{arg}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).arg ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).arg ());
 }
 
 DEFUN (arg, args, ,
@@ -219,13 +207,10 @@
 @seealso{abs}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).arg ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).arg ());
 }
 
 /*
@@ -258,13 +243,10 @@
 @seealso{sin, asind}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).asin ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).asin ());
 }
 
 /*
@@ -306,13 +288,10 @@
 @seealso{sinh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).asinh ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).asinh ());
 }
 
 /*
@@ -337,13 +316,10 @@
 @seealso{tan, atand}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).atan ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).atan ());
 }
 
 /*
@@ -372,13 +348,10 @@
 @seealso{tanh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).atanh ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).atanh ());
 }
 
 /*
@@ -406,13 +379,10 @@
 @seealso{nthroot}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).cbrt ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).cbrt ());
 }
 
 /*
@@ -448,13 +418,10 @@
 @seealso{floor, round, fix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).ceil ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).ceil ());
 }
 
 /*
@@ -489,13 +456,10 @@
 @seealso{real, imag}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).conj ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).conj ());
 }
 
 /*
@@ -522,13 +486,10 @@
 @seealso{acos, cosd, cosh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).cos ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).cos ());
 }
 
 /*
@@ -559,13 +520,10 @@
 @seealso{acosh, sinh, tanh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).cosh ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).cosh ());
 }
 
 /*
@@ -610,13 +568,10 @@
 @seealso{erfc, erfcx, erfi, dawson, erfinv, erfcinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).erf ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).erf ());
 }
 
 /*
@@ -668,13 +623,10 @@
 @seealso{erf, erfc, erfcx, erfi, dawson, erfcinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).erfinv ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).erfinv ());
 }
 
 /*
@@ -708,13 +660,10 @@
 @seealso{erfc, erf, erfcx, erfi, dawson, erfinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).erfcinv ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).erfcinv ());
 }
 
 /*
@@ -750,13 +699,10 @@
 @seealso{erfcinv, erfcx, erfi, dawson, erf, erfinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).erfc ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).erfc ());
 }
 
 /*
@@ -789,13 +735,10 @@
 @seealso{erfc, erf, erfi, dawson, erfinv, erfcinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).erfcx ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).erfcx ());
 }
 
 /*
@@ -834,13 +777,10 @@
 @seealso{erfc, erf, erfcx, dawson, erfinv, erfcinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).erfi ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).erfi ());
 }
 
 /*
@@ -874,13 +814,10 @@
 @seealso{erfc, erf, erfcx, erfi, erfinv, erfcinv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).dawson ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).dawson ());
 }
 
 /*
@@ -911,13 +848,10 @@
 @seealso{log}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).exp ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).exp ());
 }
 
 /*
@@ -947,13 +881,10 @@
 @seealso{exp}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).expm1 ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).expm1 ());
 }
 
 /*
@@ -983,13 +914,10 @@
 @seealso{isinf, isnan, isna}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).finite ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).finite ());
 }
 
 /*
@@ -1022,13 +950,10 @@
 @seealso{ceil, floor, round}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).fix ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).fix ());
 }
 
 /*
@@ -1058,13 +983,10 @@
 @seealso{ceil, round, fix}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).floor ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).floor ());
 }
 
 /*
@@ -1110,13 +1032,10 @@
 @seealso{gammainc, gammaln, factorial}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).gamma ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).gamma ());
 }
 
 /*
@@ -1156,13 +1075,10 @@
 @seealso{real, conj}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).imag ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).imag ());
 }
 
 /*
@@ -1190,13 +1106,10 @@
 @seealso{isalpha, isdigit, ispunct, isspace, iscntrl}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisalnum ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisalnum ());
 }
 
 /*
@@ -1222,13 +1135,10 @@
 @seealso{isdigit, ispunct, isspace, iscntrl, isalnum, islower, isupper}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisalpha ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisalpha ());
 }
 
 /*
@@ -1251,13 +1161,10 @@
 not.\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisascii ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisascii ());
 }
 
 /*
@@ -1278,13 +1185,10 @@
 @seealso{ispunct, isspace, isalpha, isdigit}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xiscntrl ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xiscntrl ());
 }
 
 /*
@@ -1307,13 +1211,10 @@
 @seealso{isxdigit, isalpha, isletter, ispunct, isspace, iscntrl}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisdigit ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisdigit ());
 }
 
 /*
@@ -1344,13 +1245,10 @@
 @seealso{isfinite, isnan, isna}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).isinf ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).isinf ());
 }
 
 /*
@@ -1379,13 +1277,10 @@
 @seealso{isprint}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisgraph ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisgraph ());
 }
 
 /*
@@ -1407,13 +1302,10 @@
 @seealso{isupper, isalpha, isletter, isalnum}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xislower ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xislower ());
 }
 
 /*
@@ -1444,13 +1336,10 @@
 @seealso{isnan, isinf, isfinite}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).isna ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).isna ());
 }
 
 /*
@@ -1487,13 +1376,10 @@
 @seealso{isna, isinf, isfinite}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).isnan ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).isnan ());
 }
 
 /*
@@ -1522,13 +1408,10 @@
 @seealso{isgraph}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisprint ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisprint ());
 }
 
 /*
@@ -1550,13 +1433,10 @@
 @seealso{isalpha, isdigit, isspace, iscntrl}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xispunct ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xispunct ());
 }
 
 /*
@@ -1582,13 +1462,10 @@
 @seealso{iscntrl, ispunct, isalpha, isdigit}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisspace ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisspace ());
 }
 
 /*
@@ -1610,13 +1487,10 @@
 @seealso{islower, isalpha, isletter, isalnum}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisupper ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisupper ());
 }
 
 /*
@@ -1638,13 +1512,10 @@
 @seealso{isdigit}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xisxdigit ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xisxdigit ());
 }
 
 /*
@@ -1668,13 +1539,10 @@
 @seealso{gamma, gammainc}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).lgamma ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).lgamma ());
 }
 
 /*
@@ -1722,13 +1590,10 @@
 @seealso{exp, log1p, log2, log10, logspace}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).log ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).log ());
 }
 
 /*
@@ -1749,13 +1614,10 @@
 @seealso{log, log2, logspace, exp}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).log10 ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).log10 ());
 }
 
 /*
@@ -1780,13 +1642,10 @@
 @seealso{log, exp, expm1}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).log1p ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).log1p ());
 }
 
 /*
@@ -1804,13 +1663,10 @@
 @seealso{imag, conj}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).real ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).real ());
 }
 
 /*
@@ -1846,13 +1702,10 @@
 @seealso{ceil, floor, fix, roundb}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).round ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).round ());
 }
 
 /*
@@ -1887,13 +1740,10 @@
 @seealso{round}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).roundb ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).roundb ());
 }
 
 /*
@@ -1950,13 +1800,10 @@
 @seealso{signbit}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).signum ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).signum ());
 }
 
 /*
@@ -1990,16 +1837,12 @@
 @seealso{sign}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    {
-      retval = args(0).xsignbit ();
-      retval = (retval != 0);
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  octave_value tmp = args(0).xsignbit ();
+
+  return octave_value (tmp != 0);
 }
 
 /*
@@ -2024,13 +1867,10 @@
 @seealso{asin, sind, sinh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).sin ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).sin ());
 }
 
 /*
@@ -2059,13 +1899,10 @@
 @seealso{asinh, cosh, tanh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).sinh ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).sinh ());
 }
 
 /*
@@ -2094,13 +1931,10 @@
 @seealso{realsqrt, nthroot}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).sqrt ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).sqrt ());
 }
 
 /*
@@ -2125,13 +1959,10 @@
 @seealso{atan, tand, tanh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).tan ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).tan ());
 }
 
 /*
@@ -2160,13 +1991,10 @@
 @seealso{atanh, sinh, cosh}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).tanh ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).tanh ());
 }
 
 /*
@@ -2201,13 +2029,10 @@
 @seealso{char}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xtoascii ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xtoascii ());
 }
 
 /*
@@ -2241,13 +2066,10 @@
 @seealso{toupper}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xtolower ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xtolower ());
 }
 
 DEFALIAS (lower, tolower);
@@ -2303,13 +2125,10 @@
 @seealso{tolower}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  if (args.length () == 1)
-    retval = args(0).xtoupper ();
-  else
+  if (args.length () != 1)
     print_usage ();
-
-  return retval;
+  
+  return octave_value (args(0).xtoupper ());
 }
 
 DEFALIAS (upper, toupper);
--- a/libinterp/corefcn/matrix_type.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/matrix_type.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -119,404 +119,332 @@
 @code{matrix_type} will return the correct classification of the matrix.\n\
 @end deftypefn")
 {
+  octave_value retval;
   int nargin = args.length ();
-  octave_value retval;
 
-  if (nargin == 0)
+  if (nargin == 0 || nargin > 4)
     print_usage ();
-  else if (nargin > 4)
-    error ("matrix_type: incorrect number of arguments");
-  else
+
+  bool autocomp = true;
+  if (nargin == 2 && args(1).is_string ()
+      && args(1).string_value () == "nocompute")
     {
-      bool autocomp = true;
-      if (nargin == 2 && args(1).is_string ()
-          && args(1).string_value () == "nocompute")
-        {
-          nargin = 1;
-          autocomp = false;
-        }
+      nargin = 1;
+      autocomp = false;
+    }
 
-      if (args(0).is_scalar_type ())
+  if (args(0).is_scalar_type ())
+    {
+      if (nargin == 1)
+        retval = octave_value ("Diagonal");
+      else
+        retval = args(0);
+    }
+  else if (args(0).is_sparse_type ())
+    {
+      if (nargin == 1)
         {
-          if (nargin == 1)
-            retval = octave_value ("Diagonal");
-          else
-            retval = args(0);
-        }
-      else if (args(0).is_sparse_type ())
-        {
-          if (nargin == 1)
-            {
-              MatrixType mattyp;
+          MatrixType mattyp;
 
-              if (args(0).is_complex_type ())
-                {
-                  mattyp = args(0).matrix_type ();
+          if (args(0).is_complex_type ())
+            {
+              mattyp = args(0).matrix_type ();
 
-                  if (mattyp.is_unknown () && autocomp)
-                    {
-                      SparseComplexMatrix m =
-                        args(0).sparse_complex_matrix_value ();
-                      if (!error_state)
-                        {
-                          mattyp = MatrixType (m);
-                          args(0).matrix_type (mattyp);
-                        }
-                    }
-                }
-              else
+              if (mattyp.is_unknown () && autocomp)
                 {
-                  mattyp = args(0).matrix_type ();
-
-                  if (mattyp.is_unknown () && autocomp)
-                    {
-                      SparseMatrix m = args(0).sparse_matrix_value ();
-                      if (!error_state)
-                        {
-                          mattyp = MatrixType (m);
-                          args(0).matrix_type (mattyp);
-                        }
-                    }
-                }
-
-              int typ = mattyp.type ();
+                  SparseComplexMatrix m =
+                    args(0).sparse_complex_matrix_value ();
 
-              if (typ == MatrixType::Diagonal)
-                retval = octave_value ("Diagonal");
-              else if (typ == MatrixType::Permuted_Diagonal)
-                retval = octave_value ("Permuted Diagonal");
-              else if (typ == MatrixType::Upper)
-                retval = octave_value ("Upper");
-              else if (typ == MatrixType::Permuted_Upper)
-                retval = octave_value ("Permuted Upper");
-              else if (typ == MatrixType::Lower)
-                retval = octave_value ("Lower");
-              else if (typ == MatrixType::Permuted_Lower)
-                retval = octave_value ("Permuted Lower");
-              else if (typ == MatrixType::Banded)
-                retval = octave_value ("Banded");
-              else if (typ == MatrixType::Banded_Hermitian)
-                retval = octave_value ("Banded Positive Definite");
-              else if (typ == MatrixType::Tridiagonal)
-                retval = octave_value ("Tridiagonal");
-              else if (typ == MatrixType::Tridiagonal_Hermitian)
-                retval = octave_value ("Tridiagonal Positive Definite");
-              else if (typ == MatrixType::Hermitian)
-                retval = octave_value ("Positive Definite");
-              else if (typ == MatrixType::Rectangular)
-                {
-                  if (args(0).rows () == args(0).columns ())
-                    retval = octave_value ("Singular");
-                  else
-                    retval = octave_value ("Rectangular");
+                  mattyp = MatrixType (m);
+                  args(0).matrix_type (mattyp);
                 }
-              else if (typ == MatrixType::Full)
-                retval = octave_value ("Full");
-              else
-                retval = octave_value ("Unknown");
             }
           else
             {
-              // Ok, we're changing the matrix type
-              if (! args(1).is_string ())
-                error ("matrix_type: TYPE must be a string");
-              else
-                {
-                  std::string str_typ = args(1).string_value ();
-
-                  // FIXME: why do I have to explicitly call the constructor?
-                  MatrixType mattyp = MatrixType ();
-
-                  octave_idx_type nl = 0;
-                  octave_idx_type nu = 0;
-
-                  // Use STL function to convert to lower case
-                  std::transform (str_typ.begin (), str_typ.end (),
-                                  str_typ.begin (), tolower);
-
-                  if (str_typ == "diagonal")
-                    mattyp.mark_as_diagonal ();
-                  if (str_typ == "permuted diagonal")
-                    mattyp.mark_as_permuted_diagonal ();
-                  else if (str_typ == "upper")
-                    mattyp.mark_as_upper_triangular ();
-                  else if (str_typ == "lower")
-                    mattyp.mark_as_lower_triangular ();
-                  else if (str_typ == "banded"
-                           || str_typ == "banded positive definite")
-                    {
-                      if (nargin != 4)
-                        error ("matrix_type: banded matrix type requires 4 arguments");
-                      else
-                        {
-                          nl = args(2).nint_value ();
-                          nu = args(3).nint_value ();
-
-                          if (error_state)
-                            error ("matrix_type: band size NL, NU must be integers");
-                          else
-                            {
-                              if (nl == 1 && nu == 1)
-                                mattyp.mark_as_tridiagonal ();
-                              else
-                                mattyp.mark_as_banded (nu, nl);
+              mattyp = args(0).matrix_type ();
 
-                              if (str_typ == "banded positive definite")
-                                mattyp.mark_as_symmetric ();
-                            }
-                        }
-                    }
-                  else if (str_typ == "positive definite")
-                    {
-                      mattyp.mark_as_full ();
-                      mattyp.mark_as_symmetric ();
-                    }
-                  else if (str_typ == "singular")
-                    mattyp.mark_as_rectangular ();
-                  else if (str_typ == "full")
-                    mattyp.mark_as_full ();
-                  else if (str_typ == "unknown")
-                    mattyp.invalidate_type ();
-                  else
-                    error ("matrix_type: Unknown matrix type %s", str_typ.c_str ());
-
-                  if (! error_state)
-                    {
-                      if (nargin == 3
-                          && (str_typ == "upper" || str_typ == "lower"))
-                        {
-                          const ColumnVector perm =
-                            ColumnVector (args(2).vector_value ());
-
-                          if (error_state)
-                            error ("matrix_type: Invalid permutation vector PERM");
-                          else
-                            {
-                              octave_idx_type len = perm.length ();
-                              dim_vector dv = args(0).dims ();
+              if (mattyp.is_unknown () && autocomp)
+                {
+                  SparseMatrix m = args(0).sparse_matrix_value ();
 
-                              if (len != dv(0))
-                                error ("matrix_type: Invalid permutation vector PERM");
-                              else
-                                {
-                                  OCTAVE_LOCAL_BUFFER (octave_idx_type, p, len);
-
-                                  for (octave_idx_type i = 0; i < len; i++)
-                                    p[i] = static_cast<octave_idx_type>
-                                           (perm (i))
-                                           - 1;
-
-                                  if (str_typ == "upper")
-                                    mattyp.mark_as_permuted (len, p);
-                                  else
-                                    mattyp.mark_as_permuted (len, p);
-                                }
-                            }
-                        }
-                      else if (nargin != 2
-                               && str_typ != "banded positive definite"
-                               && str_typ != "banded")
-                        error ("matrix_type: Invalid number of arguments");
-
-                      if (! error_state)
-                        {
-                          // Set the matrix type
-                          if (args(0).is_complex_type ())
-                            retval =
-                              octave_value (args(0).sparse_complex_matrix_value (),
-                                            mattyp);
-                          else
-                            retval
-                              = octave_value (args(0).sparse_matrix_value (),
-                                              mattyp);
-                        }
-                    }
+                  mattyp = MatrixType (m);
+                  args(0).matrix_type (mattyp);
                 }
             }
+
+          int typ = mattyp.type ();
+
+          if (typ == MatrixType::Diagonal)
+            retval = octave_value ("Diagonal");
+          else if (typ == MatrixType::Permuted_Diagonal)
+            retval = octave_value ("Permuted Diagonal");
+          else if (typ == MatrixType::Upper)
+            retval = octave_value ("Upper");
+          else if (typ == MatrixType::Permuted_Upper)
+            retval = octave_value ("Permuted Upper");
+          else if (typ == MatrixType::Lower)
+            retval = octave_value ("Lower");
+          else if (typ == MatrixType::Permuted_Lower)
+            retval = octave_value ("Permuted Lower");
+          else if (typ == MatrixType::Banded)
+            retval = octave_value ("Banded");
+          else if (typ == MatrixType::Banded_Hermitian)
+            retval = octave_value ("Banded Positive Definite");
+          else if (typ == MatrixType::Tridiagonal)
+            retval = octave_value ("Tridiagonal");
+          else if (typ == MatrixType::Tridiagonal_Hermitian)
+            retval = octave_value ("Tridiagonal Positive Definite");
+          else if (typ == MatrixType::Hermitian)
+            retval = octave_value ("Positive Definite");
+          else if (typ == MatrixType::Rectangular)
+            {
+              if (args(0).rows () == args(0).columns ())
+                retval = octave_value ("Singular");
+              else
+                retval = octave_value ("Rectangular");
+            }
+          else if (typ == MatrixType::Full)
+            retval = octave_value ("Full");
+          else
+            retval = octave_value ("Unknown");
         }
       else
         {
-          if (nargin == 1)
-            {
-              MatrixType mattyp;
+          // Ok, we're changing the matrix type
+
+          std::string str_typ = args(1).xstring_value ("matrix_type: TYPE must be a string");
+
+          // FIXME: why do I have to explicitly call the constructor?
+          MatrixType mattyp = MatrixType ();
 
-              if (args(0).is_complex_type ())
-                {
-                  mattyp = args(0).matrix_type ();
+          octave_idx_type nl = 0;
+          octave_idx_type nu = 0;
+
+          // Use STL function to convert to lower case
+          std::transform (str_typ.begin (), str_typ.end (),
+                          str_typ.begin (), tolower);
 
-                  if (mattyp.is_unknown () && autocomp)
-                    {
-                      if (args(0).is_single_type ())
-                        {
-                          FloatComplexMatrix m;
-                          m = args(0).float_complex_matrix_value ();
-                          if (!error_state)
-                            {
-                              mattyp = MatrixType (m);
-                              args(0).matrix_type (mattyp);
-                            }
-                        }
-                      else
-                        {
-                          ComplexMatrix m = args(0).complex_matrix_value ();
-                          if (!error_state)
-                            {
-                              mattyp = MatrixType (m);
-                              args(0).matrix_type (mattyp);
-                            }
-                        }
-                    }
-                }
+          if (str_typ == "diagonal")
+            mattyp.mark_as_diagonal ();
+          if (str_typ == "permuted diagonal")
+            mattyp.mark_as_permuted_diagonal ();
+          else if (str_typ == "upper")
+            mattyp.mark_as_upper_triangular ();
+          else if (str_typ == "lower")
+            mattyp.mark_as_lower_triangular ();
+          else if (str_typ == "banded"
+                   || str_typ == "banded positive definite")
+            {
+              if (nargin != 4)
+                error ("matrix_type: banded matrix type requires 4 arguments");
               else
                 {
-                  mattyp = args(0).matrix_type ();
+                  nl = args(2).xnint_value ("matrix_type: band size NL, NU must be integers");
+                  nu = args(3).xnint_value ("matrix_type: band size NL, NU must be integers");
+
+                  if (nl == 1 && nu == 1)
+                    mattyp.mark_as_tridiagonal ();
+                  else
+                    mattyp.mark_as_banded (nu, nl);
+
+                  if (str_typ == "banded positive definite")
+                    mattyp.mark_as_symmetric ();
+                }
+            }
+          else if (str_typ == "positive definite")
+            {
+              mattyp.mark_as_full ();
+              mattyp.mark_as_symmetric ();
+            }
+          else if (str_typ == "singular")
+            mattyp.mark_as_rectangular ();
+          else if (str_typ == "full")
+            mattyp.mark_as_full ();
+          else if (str_typ == "unknown")
+            mattyp.invalidate_type ();
+          else
+            error ("matrix_type: Unknown matrix type %s", str_typ.c_str ());
+
+          if (nargin == 3
+              && (str_typ == "upper" || str_typ == "lower"))
+            {
+              const ColumnVector perm = args(2).vector_value ("matrix_type: Invalid permutation vector PERM");
+
+              octave_idx_type len = perm.numel ();
+              dim_vector dv = args(0).dims ();
 
-                  if (mattyp.is_unknown () && autocomp)
+              if (len != dv(0))
+                error ("matrix_type: Invalid permutation vector PERM");
+              else
+                {
+                  OCTAVE_LOCAL_BUFFER (octave_idx_type, p, len);
+
+                  for (octave_idx_type i = 0; i < len; i++)
+                    p[i] = static_cast<octave_idx_type> (perm (i)) - 1;
+
+                  mattyp.mark_as_permuted (len, p);
+                }
+            }
+          else if (nargin != 2
+                   && str_typ != "banded positive definite"
+                   && str_typ != "banded")
+            error ("matrix_type: Invalid number of arguments");
+
+          // Set the matrix type
+          if (args(0).is_complex_type ())
+            retval = octave_value (args(0).sparse_complex_matrix_value (),
+                                   mattyp);
+          else
+            retval = octave_value (args(0).sparse_matrix_value (),
+                                   mattyp);
+        }
+    }
+  else
+    {
+      if (nargin == 1)
+        {
+          MatrixType mattyp;
+
+          if (args(0).is_complex_type ())
+            {
+              mattyp = args(0).matrix_type ();
+
+              if (mattyp.is_unknown () && autocomp)
+                {
+                  if (args(0).is_single_type ())
                     {
-                      if (args(0).is_single_type ())
-                        {
-                          FloatMatrix m = args(0).float_matrix_value ();
-                          if (!error_state)
-                            {
-                              mattyp = MatrixType (m);
-                              args(0).matrix_type (mattyp);
-                            }
-                        }
-                      else
-                        {
-                          Matrix m = args(0).matrix_value ();
-                          if (!error_state)
-                            {
-                              mattyp = MatrixType (m);
-                              args(0).matrix_type (mattyp);
-                            }
-                        }
+                      FloatComplexMatrix m;
+                      m = args(0).float_complex_matrix_value ();
+
+                      mattyp = MatrixType (m);
+                      args(0).matrix_type (mattyp);
+                    }
+                  else
+                    {
+                      ComplexMatrix m = args(0).complex_matrix_value ();
+
+                      mattyp = MatrixType (m);
+                      args(0).matrix_type (mattyp);
                     }
                 }
-
-              int typ = mattyp.type ();
-
-              if (typ == MatrixType::Upper)
-                retval = octave_value ("Upper");
-              else if (typ == MatrixType::Permuted_Upper)
-                retval = octave_value ("Permuted Upper");
-              else if (typ == MatrixType::Lower)
-                retval = octave_value ("Lower");
-              else if (typ == MatrixType::Permuted_Lower)
-                retval = octave_value ("Permuted Lower");
-              else if (typ == MatrixType::Hermitian)
-                retval = octave_value ("Positive Definite");
-              else if (typ == MatrixType::Rectangular)
-                {
-                  if (args(0).rows () == args(0).columns ())
-                    retval = octave_value ("Singular");
-                  else
-                    retval = octave_value ("Rectangular");
-                }
-              else if (typ == MatrixType::Full)
-                retval = octave_value ("Full");
-              else
-                retval = octave_value ("Unknown");
             }
           else
             {
-              // Ok, we're changing the matrix type
-              if (! args(1).is_string ())
-                error ("matrix_type: TYPE must be a string");
+              mattyp = args(0).matrix_type ();
+
+              if (mattyp.is_unknown () && autocomp)
+                {
+                  if (args(0).is_single_type ())
+                    {
+                      FloatMatrix m = args(0).float_matrix_value ();
+
+                      mattyp = MatrixType (m);
+                      args(0).matrix_type (mattyp);
+                    }
+                  else
+                    {
+                      Matrix m = args(0).matrix_value ();
+
+                      mattyp = MatrixType (m);
+                      args(0).matrix_type (mattyp);
+                    }
+                }
+            }
+
+          int typ = mattyp.type ();
+
+          if (typ == MatrixType::Upper)
+            retval = octave_value ("Upper");
+          else if (typ == MatrixType::Permuted_Upper)
+            retval = octave_value ("Permuted Upper");
+          else if (typ == MatrixType::Lower)
+            retval = octave_value ("Lower");
+          else if (typ == MatrixType::Permuted_Lower)
+            retval = octave_value ("Permuted Lower");
+          else if (typ == MatrixType::Hermitian)
+            retval = octave_value ("Positive Definite");
+          else if (typ == MatrixType::Rectangular)
+            {
+              if (args(0).rows () == args(0).columns ())
+                retval = octave_value ("Singular");
+              else
+                retval = octave_value ("Rectangular");
+            }
+          else if (typ == MatrixType::Full)
+            retval = octave_value ("Full");
+          else
+            retval = octave_value ("Unknown");
+        }
+      else
+        {
+          // Ok, we're changing the matrix type
+
+          std::string str_typ = args(1).xstring_value ("matrix_type: TYPE must be a string");
+
+          // FIXME: why do I have to explicitly call the constructor?
+          MatrixType mattyp = MatrixType (MatrixType::Unknown, true);
+
+          // Use STL function to convert to lower case
+          std::transform (str_typ.begin (), str_typ.end (),
+                          str_typ.begin (), tolower);
+
+          if (str_typ == "upper")
+            mattyp.mark_as_upper_triangular ();
+          else if (str_typ == "lower")
+            mattyp.mark_as_lower_triangular ();
+          else if (str_typ == "positive definite")
+            {
+              mattyp.mark_as_full ();
+              mattyp.mark_as_symmetric ();
+            }
+          else if (str_typ == "singular")
+            mattyp.mark_as_rectangular ();
+          else if (str_typ == "full")
+            mattyp.mark_as_full ();
+          else if (str_typ == "unknown")
+            mattyp.invalidate_type ();
+          else
+            error ("matrix_type: Unknown matrix type %s", str_typ.c_str ());
+
+          if (nargin == 3 && (str_typ == "upper" || str_typ == "lower"))
+            {
+              const ColumnVector perm = args(2).vector_value ("matrix_type: Invalid permutation vector PERM");
+
+              octave_idx_type len = perm.numel ();
+              dim_vector dv = args(0).dims ();
+
+              if (len != dv(0))
+                error ("matrix_type: Invalid permutation vector PERM");
               else
                 {
-                  std::string str_typ = args(1).string_value ();
+                  OCTAVE_LOCAL_BUFFER (octave_idx_type, p, len);
 
-                  // FIXME: why do I have to explicitly call the constructor?
-                  MatrixType mattyp = MatrixType (MatrixType::Unknown, true);
-
-                  // Use STL function to convert to lower case
-                  std::transform (str_typ.begin (), str_typ.end (),
-                                  str_typ.begin (), tolower);
+                  for (octave_idx_type i = 0; i < len; i++)
+                    p[i] = static_cast<octave_idx_type> (perm (i)) - 1;
 
-                  if (str_typ == "upper")
-                    mattyp.mark_as_upper_triangular ();
-                  else if (str_typ == "lower")
-                    mattyp.mark_as_lower_triangular ();
-                  else if (str_typ == "positive definite")
-                    {
-                      mattyp.mark_as_full ();
-                      mattyp.mark_as_symmetric ();
-                    }
-                  else if (str_typ == "singular")
-                    mattyp.mark_as_rectangular ();
-                  else if (str_typ == "full")
-                    mattyp.mark_as_full ();
-                  else if (str_typ == "unknown")
-                    mattyp.invalidate_type ();
-                  else
-                    error ("matrix_type: Unknown matrix type %s",
-                           str_typ.c_str ());
-
-                  if (! error_state)
-                    {
-                      if (nargin == 3 && (str_typ == "upper"
-                                          || str_typ == "lower"))
-                        {
-                          const ColumnVector perm =
-                            ColumnVector (args(2).vector_value ());
-
-                          if (error_state)
-                            error ("matrix_type: Invalid permutation vector PERM");
-                          else
-                            {
-                              octave_idx_type len = perm.length ();
-                              dim_vector dv = args(0).dims ();
+                  mattyp.mark_as_permuted (len, p);
+                }
+            }
+          else if (nargin != 2)
+            error ("matrix_type: Invalid number of arguments");
 
-                              if (len != dv(0))
-                                error ("matrix_type: Invalid permutation vector PERM");
-                              else
-                                {
-                                  OCTAVE_LOCAL_BUFFER (octave_idx_type, p, len);
-
-                                  for (octave_idx_type i = 0; i < len; i++)
-                                    p[i] = static_cast<octave_idx_type>
-                                           (perm (i))
-                                           - 1;
-
-                                  if (str_typ == "upper")
-                                    mattyp.mark_as_permuted (len, p);
-                                  else
-                                    mattyp.mark_as_permuted (len, p);
-                                }
-                            }
-                        }
-                      else if (nargin != 2)
-                        error ("matrix_type: Invalid number of arguments");
-
-                      if (! error_state)
-                        {
-                          // Set the matrix type
-                          if (args(0).is_single_type ())
-                            {
-                              if (args(0).is_complex_type ())
-                                retval = octave_value
-                                         (args(0).float_complex_matrix_value (),
-                                          mattyp);
-                              else
-                                retval = octave_value
-                                         (args(0).float_matrix_value (),
-                                          mattyp);
-                            }
-                          else
-                            {
-                              if (args(0).is_complex_type ())
-                                retval = octave_value
-                                         (args(0).complex_matrix_value (),
-                                          mattyp);
-                              else
-                                retval = octave_value
-                                         (args(0).matrix_value (),
-                                          mattyp);
-                            }
-                        }
-                    }
-                }
+          // Set the matrix type
+          if (args(0).is_single_type ())
+            {
+              if (args(0).is_complex_type ())
+                retval = octave_value (args(0).float_complex_matrix_value (),
+                                       mattyp);
+              else
+                retval = octave_value (args(0).float_matrix_value (),
+                                       mattyp);
+            }
+          else
+            {
+              if (args(0).is_complex_type ())
+                retval = octave_value (args(0).complex_matrix_value (),
+                                       mattyp);
+              else
+                retval = octave_value (args(0).matrix_value (), mattyp);
             }
         }
     }
--- a/libinterp/corefcn/max.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/max.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -49,9 +49,6 @@
   octave_value_list retval;
   ArrayType array = octave_value_extract<ArrayType> (arg);
 
-  if (error_state)
-    return retval;
-
   if (nargout == 2)
     {
       retval.resize (2);
@@ -90,9 +87,6 @@
   octave_value_list retval;
   charNDArray array = octave_value_extract<charNDArray> (arg);
 
-  if (error_state)
-    return retval;
-
   if (nargout == 2)
     {
       retval.resize (2);
@@ -139,8 +133,8 @@
     {
       // any/all don't have indexed versions, so do it via a conversion.
       retval = do_minmax_red_op<int8NDArray> (arg, nargout, dim, ismin);
-      if (! error_state)
-        retval(0) = retval(0).bool_array_value ();
+
+      retval(0) = retval(0).bool_array_value ();
     }
 
   return retval;
@@ -160,9 +154,7 @@
       ScalarType x = octave_value_extract<ScalarType> (argx);
       ArrayType y = octave_value_extract<ArrayType> (argy);
 
-      if (error_state)
-        ;
-      else if (ismin)
+      if (ismin)
         retval = min (x, y);
       else
         retval = max (x, y);
@@ -172,9 +164,7 @@
       ArrayType x = octave_value_extract<ArrayType> (argx);
       ScalarType y = octave_value_extract<ScalarType> (argy);
 
-      if (error_state)
-        ;
-      else if (ismin)
+      if (ismin)
         retval = min (x, y);
       else
         retval = max (x, y);
@@ -184,9 +174,7 @@
       ArrayType x = octave_value_extract<ArrayType> (argx);
       ArrayType y = octave_value_extract<ArrayType> (argy);
 
-      if (error_state)
-        ;
-      else if (ismin)
+      if (ismin)
         retval = min (x, y);
       else
         retval = max (x, y);
@@ -213,9 +201,7 @@
   charNDArray x = octave_value_extract<charNDArray> (argx);
   charNDArray y = octave_value_extract<charNDArray> (argy);
 
-  if (error_state)
-    ;
-  else if (ismin)
+  if (ismin)
     {
       if (x.numel () == 1)
         retval = NDArray (min (x(0), y));
@@ -247,6 +233,9 @@
 
   int nargin = args.length ();
 
+  if (nargin < 1 || nargin > 3)
+    print_usage ();
+  
   if (nargin == 3 || nargin == 1)
     {
       octave_value arg = args(0);
@@ -254,11 +243,9 @@
       if (nargin == 3)
         {
           dim = args(2).int_value (true) - 1;
-          if (error_state || dim < 0)
-            {
-              error ("%s: DIM must be a valid dimension", func);
-              return retval;
-            }
+
+          if (dim < 0)
+            error ("%s: DIM must be a valid dimension", func);
 
           if (! args(1).is_empty ())
             warning ("%s: second argument is ignored", func);
@@ -271,7 +258,7 @@
             if (arg.is_range () && (dim == -1 || dim == 1))
               {
                 Range range = arg.range_value ();
-                if (range.nelem () < 1)
+                if (range.numel () < 1)
                   {
                     retval(0) = arg;
                     if (nargout > 1)
@@ -282,14 +269,14 @@
                     retval(0) = range.min ();
                     if (nargout > 1)
                       retval(1) = static_cast<double>
-                                  (range.inc () < 0 ? range.nelem () : 1);
+                                  (range.inc () < 0 ? range.numel () : 1);
                   }
                 else
                   {
                     retval(0) = range.max ();
                     if (nargout > 1)
                       retval(1) = static_cast<double>
-                                  (range.inc () >= 0 ? range.nelem () : 1);
+                                  (range.inc () >= 0 ? range.numel () : 1);
                   }
               }
             else if (arg.is_sparse_type ())
@@ -297,8 +284,10 @@
                                                        ismin);
             else
               retval = do_minmax_red_op<NDArray> (arg, nargout, dim, ismin);
-            break;
+
           }
+          break;
+
         case btyp_complex:
           {
             if (arg.is_sparse_type ())
@@ -307,22 +296,27 @@
             else
               retval = do_minmax_red_op<ComplexNDArray> (arg, nargout, dim,
                                                          ismin);
-            break;
           }
+          break;
+
         case btyp_float:
           retval = do_minmax_red_op<FloatNDArray> (arg, nargout, dim, ismin);
           break;
+
         case btyp_float_complex:
           retval = do_minmax_red_op<FloatComplexNDArray> (arg, nargout, dim,
                                                           ismin);
           break;
+
         case btyp_char:
           retval = do_minmax_red_op<charNDArray> (arg, nargout, dim, ismin);
           break;
-#define MAKE_INT_BRANCH(X) \
+
+#define MAKE_INT_BRANCH(X)                      \
         case btyp_ ## X: \
           retval = do_minmax_red_op<X ## NDArray> (arg, nargout, dim, ismin); \
           break;
+
         MAKE_INT_BRANCH (int8);
         MAKE_INT_BRANCH (int16);
         MAKE_INT_BRANCH (int32);
@@ -331,15 +325,18 @@
         MAKE_INT_BRANCH (uint16);
         MAKE_INT_BRANCH (uint32);
         MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
+
         case btyp_bool:
           retval = do_minmax_red_op<boolNDArray> (arg, nargout, dim, ismin);
           break;
+
         default:
           gripe_wrong_type_arg (func, arg);
         }
     }
-  else if (nargin == 2)
+  else
     {
       octave_value argx = args(0);
       octave_value argy = args(1);
@@ -366,8 +363,9 @@
               retval = do_minmax_bin_op<SparseMatrix> (argx, argy, ismin);
             else
               retval = do_minmax_bin_op<NDArray> (argx, argy, ismin);
-            break;
           }
+          break;
+
         case btyp_complex:
           {
             if ((argx.is_sparse_type ()
@@ -377,21 +375,26 @@
                                                               ismin);
             else
               retval = do_minmax_bin_op<ComplexNDArray> (argx, argy, ismin);
-            break;
           }
+          break;
+
         case btyp_float:
           retval = do_minmax_bin_op<FloatNDArray> (argx, argy, ismin);
           break;
+
         case btyp_float_complex:
           retval = do_minmax_bin_op<FloatComplexNDArray> (argx, argy, ismin);
           break;
+
         case btyp_char:
           retval = do_minmax_bin_op<charNDArray> (argx, argy, ismin);
           break;
+
 #define MAKE_INT_BRANCH(X) \
         case btyp_ ## X: \
           retval = do_minmax_bin_op<X ## NDArray> (argx, argy, ismin); \
           break;
+
         MAKE_INT_BRANCH (int8);
         MAKE_INT_BRANCH (int16);
         MAKE_INT_BRANCH (int32);
@@ -400,7 +403,9 @@
         MAKE_INT_BRANCH (uint16);
         MAKE_INT_BRANCH (uint32);
         MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
+
         /*
         FIXME: This is what should happen when boolNDArray has max()
         case btyp_bool:
@@ -417,8 +422,6 @@
         retval(0) = retval(0).bool_array_value ();
 
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -876,9 +879,6 @@
   octave_value_list retval;
   ArrayType array = octave_value_extract<ArrayType> (arg);
 
-  if (error_state)
-    return retval;
-
   if (nargout == 2)
     {
       retval.resize (2);
@@ -911,64 +911,68 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  octave_value arg = args(0);
+  int dim = -1;
+  if (nargin == 2)
     {
-      octave_value arg = args(0);
-      int dim = -1;
-      if (nargin == 2)
-        {
-          dim = args(1).int_value (true) - 1;
-          if (error_state || dim < 0)
-            {
-              error ("%s: DIM must be a valid dimension", func);
-              return retval;
-            }
-        }
+      dim = args(1).int_value (true) - 1;
+
+      if (dim < 0)
+        error ("%s: DIM must be a valid dimension", func);
+    }
+
+  switch (arg.builtin_type ())
+    {
+    case btyp_double:
+      retval = do_cumminmax_red_op<NDArray> (arg, nargout, dim, ismin);
+      break;
+
+    case btyp_complex:
+      retval = do_cumminmax_red_op<ComplexNDArray> (arg, nargout, dim,
+                                                    ismin);
+      break;
+
+    case btyp_float:
+      retval = do_cumminmax_red_op<FloatNDArray> (arg, nargout, dim, ismin);
+      break;
 
-      switch (arg.builtin_type ())
-        {
-        case btyp_double:
-          retval = do_cumminmax_red_op<NDArray> (arg, nargout, dim, ismin);
-          break;
-        case btyp_complex:
-          retval = do_cumminmax_red_op<ComplexNDArray> (arg, nargout, dim,
-                                                        ismin);
-          break;
-        case btyp_float:
-          retval = do_cumminmax_red_op<FloatNDArray> (arg, nargout, dim, ismin);
-          break;
-        case btyp_float_complex:
-          retval = do_cumminmax_red_op<FloatComplexNDArray> (arg, nargout, dim,
-                                                             ismin);
-          break;
+    case btyp_float_complex:
+      retval = do_cumminmax_red_op<FloatComplexNDArray> (arg, nargout, dim,
+                                                         ismin);
+      break;
+
 #define MAKE_INT_BRANCH(X) \
-        case btyp_ ## X: \
-          retval = do_cumminmax_red_op<X ## NDArray> (arg, nargout, dim, \
-                                                      ismin); \
-          break;
-        MAKE_INT_BRANCH (int8);
-        MAKE_INT_BRANCH (int16);
-        MAKE_INT_BRANCH (int32);
-        MAKE_INT_BRANCH (int64);
-        MAKE_INT_BRANCH (uint8);
-        MAKE_INT_BRANCH (uint16);
-        MAKE_INT_BRANCH (uint32);
-        MAKE_INT_BRANCH (uint64);
+      case btyp_ ## X: \
+        retval = do_cumminmax_red_op<X ## NDArray> (arg, nargout, dim, \
+                                                    ismin); \
+        break;
+
+      MAKE_INT_BRANCH (int8);
+      MAKE_INT_BRANCH (int16);
+      MAKE_INT_BRANCH (int32);
+      MAKE_INT_BRANCH (int64);
+      MAKE_INT_BRANCH (uint8);
+      MAKE_INT_BRANCH (uint16);
+      MAKE_INT_BRANCH (uint32);
+      MAKE_INT_BRANCH (uint64);
+
 #undef MAKE_INT_BRANCH
-        case btyp_bool:
-          {
-            retval = do_cumminmax_red_op<int8NDArray> (arg, nargout, dim,
-                                                       ismin);
-            if (retval.length () > 0)
-              retval(0) = retval(0).bool_array_value ();
-            break;
-          }
-        default:
-          gripe_wrong_type_arg (func, arg);
-        }
+
+    case btyp_bool:
+      {
+        retval = do_cumminmax_red_op<int8NDArray> (arg, nargout, dim,
+                                                   ismin);
+        if (retval.length () > 0)
+          retval(0) = retval(0).bool_array_value ();
+      }
+      break;
+
+    default:
+      gripe_wrong_type_arg (func, arg);
     }
-  else
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/corefcn/md5sum.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/md5sum.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -51,27 +51,22 @@
 
   if (nargin != 1 && nargin != 2)
     print_usage ();
+
+  bool have_str = false;
+  std::string str = args(0).string_value ();
+
+  if (nargin == 2)
+    have_str = args(1).bool_value ();
+
+  if (have_str)
+    retval = oct_md5 (str);
   else
     {
-      bool have_str = false;
-      std::string str = args(0).string_value ();
-
-      if (nargin == 2)
-        have_str = args(1).bool_value ();
+      std::string fname = file_ops::tilde_expand (str);
 
-      if (!error_state)
-        {
-          if (have_str)
-            retval = oct_md5 (str);
-          else
-            {
-              std::string fname = file_ops::tilde_expand (str);
+      fname = find_data_file_in_load_path ("md5sum", fname);
 
-              fname = find_data_file_in_load_path ("md5sum", fname);
-
-              retval = oct_md5_file (fname);
-            }
-        }
+      retval = oct_md5_file (fname);
     }
 
   return retval;
--- a/libinterp/corefcn/mex.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/mex.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -615,11 +615,16 @@
       ndims (ndims_arg < 2 ? 2 : ndims_arg),
       dims (static_cast<mwSize *> (mxArray::malloc (ndims * sizeof (mwSize))))
   {
-    if (ndims_arg < 2)
+    if (ndims_arg == 0)
       {
         dims[0] = 0;
         dims[1] = 0;
       }
+    else if (ndims_arg < 2)
+      {
+        dims[0] = 1;
+        dims[1] = 1;
+      }
 
     for (mwIndex i = 0; i < ndims_arg; i++)
       dims[i] = dims_arg[i];
@@ -2011,7 +2016,23 @@
 
   ~mex (void)
   {
-    if (! memlist.empty ())
+    // We can't use mex::free here because it modifies memlist.
+    while (! memlist.empty ())
+      {
+        std::set<void *>::iterator p = memlist.begin ();
+        xfree (*p);
+        memlist.erase (p);
+      }
+
+    // We can't use mex::free_value here because it modifies arraylist.
+    while (! arraylist.empty ())
+      {
+        std::set<mxArray *>::iterator p = arraylist.begin ();
+        delete *p;
+        arraylist.erase (p);
+      }
+
+    if (! (memlist.empty () && arraylist.empty ()))
       error ("mex: %s: cleanup failed", function_name ());
 
     mxFree (fname);
@@ -2035,26 +2056,6 @@
     return fname;
   }
 
-  // Free all unmarked pointers obtained from malloc and calloc.
-  static void cleanup (void *ptr)
-  {
-    mex *context = static_cast<mex *> (ptr);
-
-    // We can't use mex::free here because it modifies memlist.
-    for (std::set<void *>::iterator p = context->memlist.begin ();
-         p != context->memlist.end (); p++)
-      xfree (*p);
-
-    context->memlist.clear ();
-
-    // We can't use mex::free_value here because it modifies arraylist.
-    for (std::set<mxArray *>::iterator p = context->arraylist.begin ();
-         p != context->arraylist.end (); p++)
-      delete *p;
-
-    context->arraylist.clear ();
-  }
-
   // Allocate memory.
   void *malloc_unmarked (size_t n)
   {
@@ -2066,8 +2067,6 @@
 
         error ("%s: failed to allocate %d bytes of memory",
                function_name (), n);
-
-        abort ();
       }
 
     global_mark (ptr);
@@ -2267,12 +2266,6 @@
   // 1 if error should be returned to MEX file, 0 if abort.
   int trap_feval_error;
 
-  // longjmp return point if mexErrMsgTxt or error.
-  jmp_buf jump;
-
-  // Trigger a long jump back to the mex calling function.
-  void abort (void) { longjmp (jump, 1); }
-
 private:
 
   // Pointer to the mex function that corresponds to this mex context.
@@ -2713,12 +2706,13 @@
   return ptr->is_empty ();
 }
 
-// Just plain odd thing to ask of a value.
+// FIXME: Just plain odd thing to ask of a value.
+// Still, Octave is incompatible because it does not implement this.
 int
-mxIsFromGlobalWS (const mxArray */*ptr*/)
+mxIsFromGlobalWS (const mxArray * /*ptr*/)
 {
-  // FIXME
-  abort ();
+  mexErrMsgTxt ("mxIsFromGlobalWS() is unimplemented");
+
   return 0;
 }
 
@@ -3002,6 +2996,8 @@
 call_mex (bool have_fmex, void *f, const octave_value_list& args,
           int nargout_arg, octave_mex_function *curr_mex_fcn)
 {
+  octave_quit ();
+
   // Use at least 1 for nargout since even for zero specified args,
   // still want to be able to return an ans.
 
@@ -3024,52 +3020,41 @@
 
   mex context (curr_mex_fcn);
 
-  frame.add_fcn (mex::cleanup, static_cast<void *> (&context));
-
   for (int i = 0; i < nargin; i++)
     argin[i] = context.make_value (args(i));
 
-  if (setjmp (context.jump) == 0)
+  mex_context = &context;
+
+  if (have_fmex)
     {
-      mex_context = &context;
-
-      if (have_fmex)
-        {
-          fmex_fptr fcn = FCN_PTR_CAST (fmex_fptr, f);
-
-          int tmp_nargout = nargout;
-          int tmp_nargin = nargin;
-
-          fcn (tmp_nargout, argout, tmp_nargin, argin);
-        }
-      else
-        {
-          cmex_fptr fcn = FCN_PTR_CAST (cmex_fptr, f);
-
-          fcn (nargout, argout, nargin, argin);
-        }
+      fmex_fptr fcn = FCN_PTR_CAST (fmex_fptr, f);
+
+      int tmp_nargout = nargout;
+      int tmp_nargin = nargin;
+
+      fcn (tmp_nargout, argout, tmp_nargin, argin);
+    }
+  else
+    {
+      cmex_fptr fcn = FCN_PTR_CAST (cmex_fptr, f);
+
+      fcn (nargout, argout, nargin, argin);
     }
 
   // Convert returned array entries back into octave values.
 
   octave_value_list retval;
 
-  if (! error_state)
+  if (nargout == 0 && argout[0])
     {
-      if (nargout == 0 && argout[0])
-        {
-          // We have something for ans.
-          nargout = 1;
-        }
-
-      retval.resize (nargout);
-
-      for (int i = 0; i < nargout; i++)
-        retval(i) = mxArray::as_octave_value (argout[i]);
+      // We have something for ans.
+      nargout = 1;
     }
 
-  // Clean up mex resources.
-  frame.run ();
+  retval.resize (nargout);
+
+  for (int i = 0; i < nargout; i++)
+    retval(i) = mxArray::as_octave_value (argout[i]);
 
   return retval;
 }
@@ -3091,28 +3076,32 @@
   // FIXME: do we need unwind protect to clean up args?  Off hand, I
   // would say that this problem is endemic to Octave and we will
   // continue to have memory leaks after Ctrl-C until proper exception
-  // handling is implemented.  longjmp() only clears the stack, so any
-  // class which allocates data on the heap is going to leak.
+  // handling is implemented.
 
   args.resize (nargin);
 
   for (int i = 0; i < nargin; i++)
     args(i) = mxArray::as_octave_value (argin[i]);
 
-  octave_value_list retval = feval (fname, args, nargout);
-
-  if (error_state && mex_context->trap_feval_error == 0)
+  bool execution_error = false;
+
+  octave_value_list retval;
+
+  try
+    {
+      retval = feval (fname, args, nargout);
+    }
+  catch (const octave_execution_exception&)
     {
-      // FIXME: is this the correct way to clean up?  abort() is
-      // going to trigger a long jump, so the normal class destructors
-      // will not be called.  Hopefully this will reduce things to a
-      // tiny leak.  Maybe create a new octave memory tracer type
-      // which prints a friendly message every time it is
-      // created/copied/deleted to check this.
-
-      args.resize (0);
-      retval.resize (0);
-      mex_context->abort ();
+      if (mex_context->trap_feval_error)
+        recover_from_exception ();
+      else
+        {
+          args.resize (0);
+          retval.resize (0);
+
+          throw;
+        }
     }
 
   int num_to_copy = retval.length ();
@@ -3132,13 +3121,7 @@
   while (num_to_copy < nargout)
     argout[num_to_copy++] = 0;
 
-  if (error_state)
-    {
-      error_state = 0;
-      return 1;
-    }
-  else
-    return 0;
+  return execution_error ? 1 : 0;
 }
 
 void
@@ -3157,15 +3140,22 @@
 
   octave_value_list ret;
 
-  ret = eval_string (s, false, parse_status, 0);
-
-  if (parse_status || error_state)
+  bool execution_error = false;
+
+  try
+    {
+      ret = eval_string (s, false, parse_status, 0);
+    }
+  catch (const octave_execution_exception&)
     {
-      error_state = 0;
-
-      retval = 1;
+      recover_from_exception ();
+
+      execution_error = true;
     }
 
+  if (parse_status || execution_error)
+    retval = 1;
+
   return retval;
 }
 
@@ -3180,8 +3170,6 @@
       // Octave's error routine requires a non-null input so use a SPACE.
       error (" ");
     }
-
-  mex_context->abort ();
 }
 
 void
@@ -3204,8 +3192,6 @@
       // Octave's error routine requires a non-null input so use a SPACE.
       error (" ");
     }
-
-  mex_context->abort ();
 }
 
 void
@@ -3271,9 +3257,6 @@
             {
               octave_call_stack::goto_base_frame ();
 
-              if (error_state)
-                return retval;
-
               frame.add_fcn (octave_call_stack::pop);
             }
 
@@ -3334,9 +3317,6 @@
             {
               octave_call_stack::goto_base_frame ();
 
-              if (error_state)
-                return 1;
-
               frame.add_fcn (octave_call_stack::pop);
             }
 
@@ -3380,10 +3360,12 @@
 mexGet (double handle, const char *property)
 {
   mxArray *m = 0;
+
   octave_value ret = get_property_from_handle (handle, property, "mexGet");
 
-  if (!error_state && ret.is_defined ())
+  if (ret.is_defined ())
     m = ret.as_mxArray ();
+
   return m;
 }
 
--- a/libinterp/corefcn/mex.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/mex.h	Thu Dec 10 12:50:06 2015 -0800
@@ -52,7 +52,7 @@
 
 typedef void mxArray;
 
-#if ! defined (__cplusplus)
+#if ! defined (__cplusplus) && ! defined (bool)
 typedef int bool;
 #endif
 
--- a/libinterp/corefcn/mgorth.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/mgorth.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -45,7 +45,7 @@
 
   h(Vc) = xnorm (x);
   if (real (h(Vc)) > 0)
-    x = x / h(Vc);
+    x /= h(Vc);
 }
 
 DEFUN (mgorth, args, nargout,
@@ -69,13 +69,8 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 2 || nargout > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 2 || nargout > 2)
+    print_usage ();
 
   octave_value arg_x = args(0);
   octave_value arg_v = args(1);
--- a/libinterp/corefcn/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,282 +1,263 @@
-EXTRA_DIST += \
-  corefcn/module.mk \
-  corefcn/defaults.in.h \
-  corefcn/graphics.in.h \
-  corefcn/mxarray.in.h \
-  corefcn/oct-errno.in.cc \
-  corefcn/oct-tex-lexer.in.ll \
-  corefcn/oct-tex-parser.in.yy \
-  corefcn/oct-tex-symbols.in
-
 ## Options functions for Fortran packages like LSODE, DASPK.
 ## These are generated automagically by configure and Perl.
 OPT_HANDLERS = \
-  corefcn/DASPK-opts.cc \
-  corefcn/DASRT-opts.cc \
-  corefcn/DASSL-opts.cc \
-  corefcn/LSODE-opts.cc \
-  corefcn/Quad-opts.cc
+  libinterp/corefcn/DASPK-opts.cc \
+  libinterp/corefcn/DASRT-opts.cc \
+  libinterp/corefcn/DASSL-opts.cc \
+  libinterp/corefcn/LSODE-opts.cc \
+  libinterp/corefcn/Quad-opts.cc
 
-OPT_INC = \
-  $(top_builddir)/liboctave/numeric/DASPK-opts.h \
-  $(top_builddir)/liboctave/numeric/DASRT-opts.h \
-  $(top_builddir)/liboctave/numeric/DASSL-opts.h \
-  $(top_builddir)/liboctave/numeric/LSODE-opts.h \
-  $(top_builddir)/liboctave/numeric/Quad-opts.h
-
-$(OPT_HANDLERS): corefcn/%.cc : $(top_builddir)/liboctave/numeric/%.in
+$(OPT_HANDLERS): libinterp/corefcn/%.cc : $(top_builddir)/liboctave/numeric/%.in
 	$(AM_V_GEN)rm -f $@-t $@ && \
 	$(PERL) $(top_srcdir)/build-aux/mk-opts.pl --opt-handler-fcns $< > $@-t && \
 	mv $@-t $@
 
 $(OPT_HANDLERS): $(top_srcdir)/build-aux/mk-opts.pl
 
-$(OPT_INC) : %.h : %.in
-	$(AM_V_GEN)$(MAKE) -C $(top_builddir)/liboctave/numeric $(@F)
-
 JIT_INC = \
-  corefcn/jit-util.h \
-  corefcn/jit-typeinfo.h \
-  corefcn/jit-ir.h \
-  corefcn/pt-jit.h
+  libinterp/corefcn/jit-util.h \
+  libinterp/corefcn/jit-typeinfo.h \
+  libinterp/corefcn/jit-ir.h \
+  libinterp/corefcn/pt-jit.h
 
 TEX_PARSER_INC = \
-  corefcn/oct-tex-parser.h
+  libinterp/corefcn/oct-tex-parser.h
 
 COREFCN_INC = \
-  corefcn/Cell.h \
-  corefcn/c-file-ptr-stream.h \
-  corefcn/cdisplay.h \
-  corefcn/comment-list.h \
-  corefcn/cutils.h \
-  corefcn/data.h \
-  corefcn/debug.h \
-  corefcn/defun-dld.h \
-  corefcn/defun-int.h \
-  corefcn/defun.h \
-  corefcn/dirfns.h \
-  corefcn/display.h \
-  corefcn/dynamic-ld.h \
-  corefcn/error.h \
-  corefcn/event-queue.h \
-  corefcn/file-io.h \
-  corefcn/gl-render.h \
-  corefcn/gl2ps-renderer.h \
-  corefcn/gripes.h \
-  corefcn/help.h \
-  corefcn/hook-fcn.h \
-  corefcn/input.h \
-  corefcn/load-path.h \
-  corefcn/load-save.h \
-  corefcn/ls-ascii-helper.h \
-  corefcn/ls-hdf5.h \
-  corefcn/ls-mat-ascii.h \
-  corefcn/ls-mat4.h \
-  corefcn/ls-mat5.h \
-  corefcn/ls-oct-ascii.h \
-  corefcn/ls-oct-binary.h \
-  corefcn/ls-utils.h \
-  corefcn/mex.h \
-  corefcn/mexproto.h \
-  corefcn/oct-errno.h \
-  corefcn/oct-fstrm.h \
-  corefcn/oct-handle.h \
-  corefcn/oct-hdf5.h \
-  corefcn/oct-hdf5-id.h \
-  corefcn/oct-hist.h \
-  corefcn/oct-iostrm.h \
-  corefcn/oct-lvalue.h \
-  corefcn/oct-map.h \
-  corefcn/oct-obj.h \
-  corefcn/oct-prcstrm.h \
-  corefcn/oct-procbuf.h \
-  corefcn/oct-stdstrm.h \
-  corefcn/oct-stream.h \
-  corefcn/oct-strstrm.h \
-  corefcn/oct.h \
-  corefcn/octave-default-image.h \
-  corefcn/octave-link.h \
-  corefcn/pager.h \
-  corefcn/pr-output.h \
-  corefcn/procstream.h \
-  corefcn/profiler.h \
-  corefcn/sighandlers.h \
-  corefcn/siglist.h \
-  corefcn/sparse-xdiv.h \
-  corefcn/sparse-xpow.h \
-  corefcn/symtab.h \
-  corefcn/sysdep.h \
-  corefcn/toplev.h \
-  corefcn/txt-eng-ft.h \
-  corefcn/txt-eng.h \
-  corefcn/utils.h \
-  corefcn/variables.h \
-  corefcn/workspace-element.h \
-  corefcn/xdiv.h \
-  corefcn/xnorm.h \
-  corefcn/xpow.h \
-  corefcn/zfstream.h \
+  libinterp/corefcn/Cell.h \
+  libinterp/corefcn/c-file-ptr-stream.h \
+  libinterp/corefcn/cdisplay.h \
+  libinterp/corefcn/comment-list.h \
+  libinterp/corefcn/cutils.h \
+  libinterp/corefcn/data.h \
+  libinterp/corefcn/debug.h \
+  libinterp/corefcn/defun-dld.h \
+  libinterp/corefcn/defun-int.h \
+  libinterp/corefcn/defun.h \
+  libinterp/corefcn/dirfns.h \
+  libinterp/corefcn/display.h \
+  libinterp/corefcn/dynamic-ld.h \
+  libinterp/corefcn/error.h \
+  libinterp/corefcn/event-queue.h \
+  libinterp/corefcn/file-io.h \
+  libinterp/corefcn/gl-render.h \
+  libinterp/corefcn/gl2ps-renderer.h \
+  libinterp/corefcn/gripes.h \
+  libinterp/corefcn/help.h \
+  libinterp/corefcn/hook-fcn.h \
+  libinterp/corefcn/input.h \
+  libinterp/corefcn/load-path.h \
+  libinterp/corefcn/load-save.h \
+  libinterp/corefcn/ls-ascii-helper.h \
+  libinterp/corefcn/ls-hdf5.h \
+  libinterp/corefcn/ls-mat-ascii.h \
+  libinterp/corefcn/ls-mat4.h \
+  libinterp/corefcn/ls-mat5.h \
+  libinterp/corefcn/ls-oct-text.h \
+  libinterp/corefcn/ls-oct-binary.h \
+  libinterp/corefcn/ls-utils.h \
+  libinterp/corefcn/mex.h \
+  libinterp/corefcn/mexproto.h \
+  libinterp/corefcn/oct-errno.h \
+  libinterp/corefcn/oct-fstrm.h \
+  libinterp/corefcn/oct-handle.h \
+  libinterp/corefcn/oct-hdf5.h \
+  libinterp/corefcn/oct-hdf5-types.h \
+  libinterp/corefcn/oct-hist.h \
+  libinterp/corefcn/oct-iostrm.h \
+  libinterp/corefcn/oct-lvalue.h \
+  libinterp/corefcn/oct-map.h \
+  libinterp/corefcn/oct-obj.h \
+  libinterp/corefcn/oct-prcstrm.h \
+  libinterp/corefcn/oct-procbuf.h \
+  libinterp/corefcn/oct-stdstrm.h \
+  libinterp/corefcn/oct-stream.h \
+  libinterp/corefcn/oct-strstrm.h \
+  libinterp/corefcn/oct.h \
+  libinterp/corefcn/octave-default-image.h \
+  libinterp/corefcn/octave-link.h \
+  libinterp/corefcn/pager.h \
+  libinterp/corefcn/pr-output.h \
+  libinterp/corefcn/procstream.h \
+  libinterp/corefcn/profiler.h \
+  libinterp/corefcn/sighandlers.h \
+  libinterp/corefcn/siglist.h \
+  libinterp/corefcn/sparse-xdiv.h \
+  libinterp/corefcn/sparse-xpow.h \
+  libinterp/corefcn/symtab.h \
+  libinterp/corefcn/sysdep.h \
+  libinterp/corefcn/toplev.h \
+  libinterp/corefcn/txt-eng-ft.h \
+  libinterp/corefcn/txt-eng.h \
+  libinterp/corefcn/utils.h \
+  libinterp/corefcn/variables.h \
+  libinterp/corefcn/workspace-element.h \
+  libinterp/corefcn/xdiv.h \
+  libinterp/corefcn/xnorm.h \
+  libinterp/corefcn/xpow.h \
+  libinterp/corefcn/zfstream.h \
   $(JIT_INC) \
   $(TEX_PARSER_INC)
 
 JIT_SRC = \
-  corefcn/jit-util.cc \
-  corefcn/jit-typeinfo.cc \
-  corefcn/jit-ir.cc \
-  corefcn/pt-jit.cc
+  libinterp/corefcn/jit-util.cc \
+  libinterp/corefcn/jit-typeinfo.cc \
+  libinterp/corefcn/jit-ir.cc \
+  libinterp/corefcn/pt-jit.cc
 
 TEX_PARSER_SRC = \
-  corefcn/oct-tex-lexer.ll \
-  corefcn/oct-tex-parser.yy
+  libinterp/corefcn/oct-tex-lexer.ll \
+  libinterp/corefcn/oct-tex-parser.yy
 
 C_COREFCN_SRC = \
-  corefcn/cutils.c \
-  corefcn/matherr.c \
-  corefcn/siglist.c
+  libinterp/corefcn/cutils.c \
+  libinterp/corefcn/matherr.c \
+  libinterp/corefcn/siglist.c
 
 COREFCN_SRC = \
-  corefcn/Cell.cc \
-  corefcn/__contourc__.cc \
-  corefcn/__dispatch__.cc \
-  corefcn/__dsearchn__.cc \
-  corefcn/__ichol__.cc \
-  corefcn/__ilu__.cc \
-  corefcn/__lin_interpn__.cc \
-  corefcn/__pchip_deriv__.cc \
-  corefcn/__qp__.cc \
-  corefcn/balance.cc \
-  corefcn/besselj.cc \
-  corefcn/betainc.cc \
-  corefcn/bitfcns.cc \
-  corefcn/bsxfun.cc \
-  corefcn/c-file-ptr-stream.cc \
-  corefcn/cdisplay.c \
-  corefcn/cellfun.cc \
-  corefcn/colloc.cc \
-  corefcn/comment-list.cc \
-  corefcn/conv2.cc \
-  corefcn/daspk.cc \
-  corefcn/dasrt.cc \
-  corefcn/dassl.cc \
-  corefcn/data.cc \
-  corefcn/debug.cc \
-  corefcn/defaults.cc \
-  corefcn/defun.cc \
-  corefcn/det.cc \
-  corefcn/dirfns.cc \
-  corefcn/display.cc \
-  corefcn/dlmread.cc \
-  corefcn/dot.cc \
-  corefcn/dynamic-ld.cc \
-  corefcn/eig.cc \
-  corefcn/ellipj.cc \
-  corefcn/error.cc \
-  corefcn/fft.cc \
-  corefcn/fft2.cc \
-  corefcn/fftn.cc \
-  corefcn/file-io.cc \
-  corefcn/filter.cc \
-  corefcn/find.cc \
-  corefcn/gammainc.cc \
-  corefcn/gcd.cc \
-  corefcn/getgrent.cc \
-  corefcn/getpwent.cc \
-  corefcn/getrusage.cc \
-  corefcn/givens.cc \
-  corefcn/gl-render.cc \
-  corefcn/gl2ps-renderer.cc \
-  corefcn/graphics.cc \
-  corefcn/gripes.cc \
-  corefcn/help.cc \
-  corefcn/hess.cc \
-  corefcn/hex2num.cc \
-  corefcn/hook-fcn.cc \
-  corefcn/input.cc \
-  corefcn/inv.cc \
-  corefcn/kron.cc \
-  corefcn/load-path.cc \
-  corefcn/load-save.cc \
-  corefcn/lookup.cc \
-  corefcn/ls-ascii-helper.cc \
-  corefcn/ls-hdf5.cc \
-  corefcn/ls-mat-ascii.cc \
-  corefcn/ls-mat4.cc \
-  corefcn/ls-mat5.cc \
-  corefcn/ls-oct-ascii.cc \
-  corefcn/ls-oct-binary.cc \
-  corefcn/ls-utils.cc \
-  corefcn/lsode.cc \
-  corefcn/lu.cc \
-  corefcn/luinc.cc \
-  corefcn/mappers.cc \
-  corefcn/matrix_type.cc \
-  corefcn/max.cc \
-  corefcn/md5sum.cc \
-  corefcn/mex.cc \
-  corefcn/mgorth.cc \
-  corefcn/nproc.cc \
-  corefcn/oct-fstrm.cc \
-  corefcn/oct-hdf5-id.cc \
-  corefcn/oct-hist.cc \
-  corefcn/oct-iostrm.cc \
-  corefcn/oct-lvalue.cc \
-  corefcn/oct-map.cc \
-  corefcn/oct-obj.cc \
-  corefcn/oct-prcstrm.cc \
-  corefcn/oct-procbuf.cc \
-  corefcn/oct-stream.cc \
-  corefcn/oct-strstrm.cc \
-  corefcn/octave-link.cc \
-  corefcn/ordschur.cc \
-  corefcn/pager.cc \
-  corefcn/pinv.cc \
-  corefcn/pr-output.cc \
-  corefcn/procstream.cc \
-  corefcn/profiler.cc \
-  corefcn/quad.cc \
-  corefcn/quadcc.cc \
-  corefcn/qz.cc \
-  corefcn/rand.cc \
-  corefcn/rcond.cc \
-  corefcn/regexp.cc \
-  corefcn/schur.cc \
-  corefcn/sighandlers.cc \
-  corefcn/sparse-xdiv.cc \
-  corefcn/sparse-xpow.cc \
-  corefcn/sparse.cc \
-  corefcn/spparms.cc \
-  corefcn/sqrtm.cc \
-  corefcn/str2double.cc \
-  corefcn/strfind.cc \
-  corefcn/strfns.cc \
-  corefcn/sub2ind.cc \
-  corefcn/svd.cc \
-  corefcn/sylvester.cc \
-  corefcn/symtab.cc \
-  corefcn/syscalls.cc \
-  corefcn/sysdep.cc \
-  corefcn/time.cc \
-  corefcn/toplev.cc \
-  corefcn/tril.cc \
-  corefcn/tsearch.cc \
-  corefcn/txt-eng-ft.cc \
-  corefcn/txt-eng.cc \
-  corefcn/typecast.cc \
-  corefcn/urlwrite.cc \
-  corefcn/utils.cc \
-  corefcn/variables.cc \
-  corefcn/xdiv.cc \
-  corefcn/xnorm.cc \
-  corefcn/xpow.cc \
-  corefcn/zfstream.cc \
+  libinterp/corefcn/Cell.cc \
+  libinterp/corefcn/__contourc__.cc \
+  libinterp/corefcn/__dispatch__.cc \
+  libinterp/corefcn/__dsearchn__.cc \
+  libinterp/corefcn/__ichol__.cc \
+  libinterp/corefcn/__ilu__.cc \
+  libinterp/corefcn/__lin_interpn__.cc \
+  libinterp/corefcn/__pchip_deriv__.cc \
+  libinterp/corefcn/__qp__.cc \
+  libinterp/corefcn/balance.cc \
+  libinterp/corefcn/besselj.cc \
+  libinterp/corefcn/betainc.cc \
+  libinterp/corefcn/bitfcns.cc \
+  libinterp/corefcn/bsxfun.cc \
+  libinterp/corefcn/c-file-ptr-stream.cc \
+  libinterp/corefcn/cdisplay.c \
+  libinterp/corefcn/cellfun.cc \
+  libinterp/corefcn/colloc.cc \
+  libinterp/corefcn/comment-list.cc \
+  libinterp/corefcn/conv2.cc \
+  libinterp/corefcn/daspk.cc \
+  libinterp/corefcn/dasrt.cc \
+  libinterp/corefcn/dassl.cc \
+  libinterp/corefcn/data.cc \
+  libinterp/corefcn/debug.cc \
+  libinterp/corefcn/defaults.cc \
+  libinterp/corefcn/defun.cc \
+  libinterp/corefcn/det.cc \
+  libinterp/corefcn/dirfns.cc \
+  libinterp/corefcn/display.cc \
+  libinterp/corefcn/dlmread.cc \
+  libinterp/corefcn/dot.cc \
+  libinterp/corefcn/dynamic-ld.cc \
+  libinterp/corefcn/eig.cc \
+  libinterp/corefcn/ellipj.cc \
+  libinterp/corefcn/error.cc \
+  libinterp/corefcn/fft.cc \
+  libinterp/corefcn/fft2.cc \
+  libinterp/corefcn/fftn.cc \
+  libinterp/corefcn/file-io.cc \
+  libinterp/corefcn/filter.cc \
+  libinterp/corefcn/find.cc \
+  libinterp/corefcn/gammainc.cc \
+  libinterp/corefcn/gcd.cc \
+  libinterp/corefcn/getgrent.cc \
+  libinterp/corefcn/getpwent.cc \
+  libinterp/corefcn/getrusage.cc \
+  libinterp/corefcn/givens.cc \
+  libinterp/corefcn/gl-render.cc \
+  libinterp/corefcn/gl2ps-renderer.cc \
+  libinterp/corefcn/graphics.cc \
+  libinterp/corefcn/gripes.cc \
+  libinterp/corefcn/help.cc \
+  libinterp/corefcn/hess.cc \
+  libinterp/corefcn/hex2num.cc \
+  libinterp/corefcn/hook-fcn.cc \
+  libinterp/corefcn/input.cc \
+  libinterp/corefcn/inv.cc \
+  libinterp/corefcn/kron.cc \
+  libinterp/corefcn/load-path.cc \
+  libinterp/corefcn/load-save.cc \
+  libinterp/corefcn/lookup.cc \
+  libinterp/corefcn/ls-ascii-helper.cc \
+  libinterp/corefcn/ls-hdf5.cc \
+  libinterp/corefcn/ls-mat-ascii.cc \
+  libinterp/corefcn/ls-mat4.cc \
+  libinterp/corefcn/ls-mat5.cc \
+  libinterp/corefcn/ls-oct-text.cc \
+  libinterp/corefcn/ls-oct-binary.cc \
+  libinterp/corefcn/ls-utils.cc \
+  libinterp/corefcn/lsode.cc \
+  libinterp/corefcn/lu.cc \
+  libinterp/corefcn/luinc.cc \
+  libinterp/corefcn/mappers.cc \
+  libinterp/corefcn/matrix_type.cc \
+  libinterp/corefcn/max.cc \
+  libinterp/corefcn/md5sum.cc \
+  libinterp/corefcn/mex.cc \
+  libinterp/corefcn/mgorth.cc \
+  libinterp/corefcn/nproc.cc \
+  libinterp/corefcn/oct-fstrm.cc \
+  libinterp/corefcn/oct-hdf5-types.cc \
+  libinterp/corefcn/oct-hist.cc \
+  libinterp/corefcn/oct-iostrm.cc \
+  libinterp/corefcn/oct-lvalue.cc \
+  libinterp/corefcn/oct-map.cc \
+  libinterp/corefcn/oct-obj.cc \
+  libinterp/corefcn/oct-prcstrm.cc \
+  libinterp/corefcn/oct-procbuf.cc \
+  libinterp/corefcn/oct-stream.cc \
+  libinterp/corefcn/oct-strstrm.cc \
+  libinterp/corefcn/octave-link.cc \
+  libinterp/corefcn/ordschur.cc \
+  libinterp/corefcn/pager.cc \
+  libinterp/corefcn/pinv.cc \
+  libinterp/corefcn/pr-output.cc \
+  libinterp/corefcn/procstream.cc \
+  libinterp/corefcn/profiler.cc \
+  libinterp/corefcn/psi.cc \
+  libinterp/corefcn/quad.cc \
+  libinterp/corefcn/quadcc.cc \
+  libinterp/corefcn/qz.cc \
+  libinterp/corefcn/rand.cc \
+  libinterp/corefcn/rcond.cc \
+  libinterp/corefcn/regexp.cc \
+  libinterp/corefcn/schur.cc \
+  libinterp/corefcn/sighandlers.cc \
+  libinterp/corefcn/sparse-xdiv.cc \
+  libinterp/corefcn/sparse-xpow.cc \
+  libinterp/corefcn/sparse.cc \
+  libinterp/corefcn/spparms.cc \
+  libinterp/corefcn/sqrtm.cc \
+  libinterp/corefcn/str2double.cc \
+  libinterp/corefcn/strfind.cc \
+  libinterp/corefcn/strfns.cc \
+  libinterp/corefcn/sub2ind.cc \
+  libinterp/corefcn/svd.cc \
+  libinterp/corefcn/sylvester.cc \
+  libinterp/corefcn/symtab.cc \
+  libinterp/corefcn/syscalls.cc \
+  libinterp/corefcn/sysdep.cc \
+  libinterp/corefcn/time.cc \
+  libinterp/corefcn/toplev.cc \
+  libinterp/corefcn/tril.cc \
+  libinterp/corefcn/tsearch.cc \
+  libinterp/corefcn/txt-eng-ft.cc \
+  libinterp/corefcn/txt-eng.cc \
+  libinterp/corefcn/typecast.cc \
+  libinterp/corefcn/urlwrite.cc \
+  libinterp/corefcn/utils.cc \
+  libinterp/corefcn/variables.cc \
+  libinterp/corefcn/xdiv.cc \
+  libinterp/corefcn/xnorm.cc \
+  libinterp/corefcn/xpow.cc \
+  libinterp/corefcn/zfstream.cc \
   $(JIT_SRC) \
   $(C_COREFCN_SRC)
 
 COREFCN_FT2_DF = \
-  corefcn/graphics.df \
-  corefcn/gl-render.df \
-  corefcn/toplev.df \
-  corefcn/txt-eng-ft.df
+  libinterp/corefcn/graphics.df \
+  libinterp/corefcn/gl-render.df \
+  libinterp/corefcn/toplev.df \
+  libinterp/corefcn/txt-eng-ft.df
 
 ## FIXME: Automake does not support per-object rules.
 ##        These rules could be emulated by creating a new convenience
@@ -286,85 +267,101 @@
 
 ## Special rules for FreeType .df files so that not all .df files are built
 ## with FT2_CPPFLAGS, FONTCONFIG_CPPFLAGS
-$(COREFCN_FT2_DF) : corefcn/%.df : corefcn/%.cc $(GENERATED_MAKE_BUILTINS_INCS)
-	$(AM_V_GEN)rm -f $@-t $@ && \
+$(COREFCN_FT2_DF) : libinterp/corefcn/%.df : libinterp/corefcn/%.cc $(GENERATED_MAKE_BUILTINS_INCS)
+	$(AM_V_GEN)rm -f $@-t $@-t1 $@ && \
 	$(CXXCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	  $(AM_CPPFLAGS) $(FONTCONFIG_CPPFLAGS) $(FT2_CPPFLAGS) $(CPPFLAGS) \
-	  $(AM_CXXFLAGS) $(CXXFLAGS) \
-	  -DMAKE_BUILTINS $< > $@-t && \
-	$(srcdir)/mkdefs $(srcdir) $< < $@-t > $@ && \
-	rm $@-t
+	  $(libinterp_corefcn_libcorefcn_la_CPPFLAGS) $(CPPFLAGS) \
+	  $(libinterp_corefcn_libcorefcn_la_CXXFLAGS) $(CXXFLAGS) \
+	  -DMAKE_BUILTINS $< > $@-t1 && \
+	$(srcdir)/libinterp/mkdefs $(srcdir)/libinterp $< < $@-t1 > $@-t && \
+	rm -f $@-t1 && \
+	mv $@-t $@
 
 ## Special rules for sources which must be built before rest of compilation.
 
 ## defaults.h and graphics.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.
-corefcn/defaults.h: corefcn/defaults.in.h Makefile
+libinterp/corefcn/defaults.h: libinterp/corefcn/defaults.in.h Makefile
 	$(AM_V_GEN)$(do_subst_default_vals)
 
-corefcn/graphics.h: corefcn/graphics.in.h genprops.awk Makefile
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(AWK) -f $(srcdir)/genprops.awk $< > $@-t && \
-	mv $@-t $@
+libinterp/corefcn/graphics.h: libinterp/corefcn/graphics.in.h libinterp/genprops.awk Makefile
+	$(AM_V_GEN)rm -f $@-t && \
+	$(AWK) -f $(srcdir)/libinterp/genprops.awk $< > $@-t && \
+	$(simple_move_if_change_rule)
 
-corefcn/graphics-props.cc: corefcn/graphics.in.h genprops.awk Makefile
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(AWK) -v emit_graphics_props=1 -f $(srcdir)/genprops.awk $< > $@-t && \
-	mv $@-t $@
+libinterp/corefcn/graphics-props.cc: libinterp/corefcn/graphics.in.h libinterp/genprops.awk Makefile
+	$(AM_V_GEN)rm -f $@-t && \
+	$(AWK) -v emit_graphics_props=1 -f $(srcdir)/libinterp/genprops.awk $< > $@-t && \
+	$(simple_move_if_change_rule)
 
-corefcn/oct-errno.cc: corefcn/oct-errno.in.cc Makefile
-	$(AM_V_GEN)rm -f $@-t $@ && \
+libinterp/corefcn/oct-errno.cc: libinterp/corefcn/oct-errno.in.cc Makefile
+	$(AM_V_GEN)rm -f $@-t && \
 	if test -n "$(PERL)"; then \
-	  $(srcdir)/mk-errno-list --perl "$(PERL)" < $< > $@-t; \
+	  $(srcdir)/libinterp/mk-errno-list --perl "$(PERL)" < $< > $@-t; \
 	elif test -n "$(PYTHON)"; then \
-	  $(srcdir)/mk-errno-list --python "$(PYTHON)" < $< > $@-t; \
+	  $(srcdir)/libinterp/mk-errno-list --python "$(PYTHON)" < $< > $@-t; \
 	else \
 	  $(SED) '/@SYSDEP_ERRNO_LIST@/D' $< > $@-t; \
 	fi && \
-	mv $@-t $@
+	$(simple_move_if_change_rule)
 
-corefcn/mxarray.h: corefcn/mxarray.in.h Makefile
-	$(AM_V_GEN)rm -f $@-t $@ && \
+libinterp/corefcn/mxarray.h: libinterp/corefcn/mxarray.in.h Makefile
+	$(AM_V_GEN)rm -f $@-t && \
 	$(SED) < $< \
 	  -e "s|%NO_EDIT_WARNING%|DO NOT EDIT!  Generated automatically from $(<F) by Make.|" \
 	  -e "s|%OCTAVE_IDX_TYPE%|${OCTAVE_IDX_TYPE}|" > $@-t && \
-	mv $@-t $@
+	$(simple_move_if_change_rule)
 
-corefcn/oct-tex-lexer.ll: corefcn/oct-tex-lexer.in.ll corefcn/oct-tex-symbols.in Makefile.am
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(AWK) 'BEGIN { print "/* DO NOT EDIT. AUTOMATICALLY GENERATED FROM oct-tex-lexer.in.ll and oct-tex-symbols.in. */"; } /^@SYMBOL_RULES@$$/ { count = 0; while (getline < "$(srcdir)/corefcn/oct-tex-symbols.in") { if ($$0 !~ /^#.*/ && NF == 3) { printf("\"\\\\%s\" { yylval->sym = %d; return SYM; }\n", $$1, count); count++; } } getline } ! /^@SYMBOL_RULES@$$/ { print }' $< > $@-t && \
-	mv $@-t $@
+libinterp/corefcn/oct-tex-lexer.ll: libinterp/corefcn/oct-tex-lexer.in.ll libinterp/corefcn/oct-tex-symbols.in Makefile.am
+	$(AM_V_GEN)rm -f $@-t && \
+	$(AWK) 'BEGIN { print "/* DO NOT EDIT. AUTOMATICALLY GENERATED FROM oct-tex-lexer.in.ll and oct-tex-symbols.in. */"; } /^@SYMBOL_RULES@$$/ { count = 0; while (getline < "$(srcdir)/libinterp/corefcn/oct-tex-symbols.in") { if ($$0 !~ /^#.*/ && NF == 3) { printf("\"\\\\%s\" { yylval->sym = %d; return SYM; }\n", $$1, count); count++; } } getline } ! /^@SYMBOL_RULES@$$/ { print }' $< > $@-t && \
+	$(simple_move_if_change_rule)
 
-corefcn/oct-tex-symbols.cc: corefcn/oct-tex-symbols.in Makefile.am
-	$(AM_V_GEN)rm -f $@-t $@ && \
+libinterp/corefcn/oct-tex-symbols.cc: libinterp/corefcn/oct-tex-symbols.in Makefile.am
+	$(AM_V_GEN)rm -f $@-t && \
 	$(AWK) 'BEGIN { print "// DO NOT EDIT. AUTOMATICALLY GENERATED FROM oct-tex-symbols.in."; print "static uint32_t symbol_codes[][2] = {"; count = 0; } END { print "};"; printf("static int num_symbol_codes = %d;\n", count); } !/^#/ && (NF == 3) { printf("  { %s, %s },\n", $$2, $$3); count++; }' $< > $@-t && \
-	mv $@-t $@
+	$(simple_move_if_change_rule)
 
-corefcn/txt-eng.cc: corefcn/oct-tex-symbols.cc
-corefcn/oct-tex-lexer.cc: LEX_OUTPUT_ROOT := lex.octave_tex_
-corefcn/oct-tex-parser.h: corefcn/oct-tex-parser.yy
+libinterp/corefcn/txt-eng.cc: libinterp/corefcn/oct-tex-symbols.cc
+libinterp/corefcn/oct-tex-lexer.cc: LEX_OUTPUT_ROOT := lex.octave_tex_
+libinterp/corefcn/oct-tex-parser.h: libinterp/corefcn/oct-tex-parser.yy
 
-corefcn/oct-tex-parser.yy: corefcn/oct-tex-parser.in.yy
+libinterp/corefcn/oct-tex-parser.yy: libinterp/corefcn/oct-tex-parser.in.yy
 	$(AM_V_GEN)$(call subst-bison-api-decls,octave_tex_)
 
 noinst_LTLIBRARIES += \
-  corefcn/libcorefcn.la \
-  corefcn/libtex_parser.la
+  libinterp/corefcn/libcorefcn.la \
+  libinterp/corefcn/libtex_parser.la
+
+libinterp_corefcn_libcorefcn_la_SOURCES = $(COREFCN_SRC)
+
+libinterp_corefcn_libcorefcn_la_CPPFLAGS = \
+  $(libinterp_liboctinterp_la_CPPFLAGS) \
+  $(FFTW_XCPPFLAGS) \
+  $(FONTCONFIG_CPPFLAGS) \
+  $(FT2_CPPFLAGS) \
+  $(HDF5_CPPFLAGS) \
+  $(LLVM_CPPFLAGS) \
+  $(Z_CPPFLAGS)
+
+libinterp_corefcn_libcorefcn_la_CFLAGS = $(AM_CFLAGS) $(WARN_CFLAGS)
 
-corefcn_libcorefcn_la_SOURCES = $(COREFCN_SRC)
-corefcn_libcorefcn_la_CPPFLAGS = $(liboctinterp_la_CPPFLAGS) \
-                                 $(FFTW_XCPPFLAGS) \
-                                 $(FONTCONFIG_CPPFLAGS) \
-                                 $(FT2_CPPFLAGS) \
-                                 $(HDF5_CPPFLAGS) \
-                                 $(LLVM_CPPFLAGS) \
-                                 $(Z_CPPFLAGS)
+libinterp_corefcn_libcorefcn_la_CXXFLAGS = $(AM_CXXFLAGS) $(WARN_CXXFLAGS) $(LLVM_CXXFLAGS)
+
+libinterp_corefcn_libtex_parser_la_SOURCES = $(TEX_PARSER_SRC)
+
+libinterp_corefcn_libtex_parser_la_CPPFLAGS = $(libinterp_liboctinterp_la_CPPFLAGS)
+
+libinterp_corefcn_libtex_parser_la_CXXFLAGS = \
+  $(filter-out -Wold-style-cast, $(libinterp_corefcn_libcorefcn_la_CXXFLAGS))
 
-corefcn_libcorefcn_la_CXXFLAGS = $(AM_CXXFLAGS) $(LLVM_CXXFLAGS)
+libinterp_EXTRA_DIST += \
+  libinterp/corefcn/defaults.in.h \
+  libinterp/corefcn/graphics.in.h \
+  libinterp/corefcn/mxarray.in.h \
+  libinterp/corefcn/oct-errno.in.cc \
+  libinterp/corefcn/oct-tex-lexer.in.ll \
+  libinterp/corefcn/oct-tex-parser.in.yy \
+  libinterp/corefcn/oct-tex-symbols.in
 
-corefcn_libtex_parser_la_SOURCES = $(TEX_PARSER_SRC)
-corefcn_libtex_parser_la_CPPFLAGS = $(liboctinterp_la_CPPFLAGS)
-corefcn_libtex_parser_la_CXXFLAGS = \
-  $(filter-out -Wold-style-cast, $(AM_CXXFLAGS))
-
--- a/libinterp/corefcn/nproc.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/nproc.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -54,10 +54,7 @@
   int nargin = args.length ();
 
   if ((nargin != 0 && nargin != 1) || (nargout != 0 && nargout != 1))
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   nproc_query query = NPROC_CURRENT;
   if (nargin == 1)
@@ -73,10 +70,7 @@
       else if (arg == "overridable")
         query = NPROC_CURRENT_OVERRIDABLE;
       else
-        {
-          error ("nproc: invalid value for QUERY");
-          return retval;
-        }
+        error ("nproc: invalid value for QUERY");
     }
 
   retval = num_processors (query);
--- a/libinterp/corefcn/oct-errno.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-errno.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_oct_errno_h)
+#if ! defined (octave_oct_errno_h)
 #define octave_oct_errno_h 1
 
 #include <cerrno>
--- a/libinterp/corefcn/oct-errno.in.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-errno.in.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -303,7 +303,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create errno object!");
+      error ("unable to create errno object!");
 
       retval = false;
     }
--- a/libinterp/corefcn/oct-fstrm.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-fstrm.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_fstrm_h)
+#if ! defined (octave_oct_fstrm_h)
 #define octave_oct_fstrm_h 1
 
 #include <fstream>
--- a/libinterp/corefcn/oct-handle.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-handle.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_handle_h)
+#if ! defined (octave_oct_handle_h)
 #define octave_oct_handle_h 1
 
 #include "dMatrix.h"
@@ -42,12 +42,14 @@
       /* do nothing */;
     else
       {
-        double tval = a.double_value ();
-
-        if (! error_state)
-          val = tval;
-        else
-          error ("invalid handle");
+        try
+          {
+            val = a.double_value ();
+          }
+        catch (octave_execution_exception& e)
+          {
+            error (e, "invalid handle");
+          }
       }
   }
 
--- a/libinterp/corefcn/oct-hdf5-id.cc	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
-
-Copyright (C) 2015 John W. Eaton
-
-This file is part of Octave.
-
-Octave is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-Octave is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<http://www.gnu.org/licenses/>.
-
-*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "error.h"
-#include "oct-hdf5.h"
-#include "oct-hdf5-id.h"
-
-bool
-check_hdf5_id_type (bool warn)
-{
-  static bool checked = false;
-  static bool ok = false;
-
-  if (! checked)
-    {
-#if defined (HAVE_HDF5)
-      ok = sizeof (octave_hdf5_id) >= sizeof (hid_t);
-
-      if (warn && ! ok)
-        warning_with_id
-          ("Octave:internal",
-           "the size of octave_hdf5_id is smaller than the size of HDF5 hid_t");
-#else
-      warning_with_id
-        ("Octave:internal",
-         "check_hdf5_id_type called but Octave was not compiled with support for HDF5");
-#endif
-
-      checked = true;
-    }
-
-  return ok;
-}
--- a/libinterp/corefcn/oct-hdf5-id.h	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
-
-Copyright (C) 2015 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_oct_hdf5_id_h)
-#define octave_oct_hdf5_id_h 1
-
-typedef int octave_hdf5_id;
-
-extern bool check_hdf5_id_type (bool warn = true);
-
-#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/corefcn/oct-hdf5-types.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,63 @@
+/*
+
+Copyright (C) 2015 John W. Eaton
+
+This file is part of Octave.
+
+Octave is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+Octave is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Octave; see the file COPYING.  If not, see
+<http://www.gnu.org/licenses/>.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "error.h"
+#include "oct-hdf5.h"
+#include "oct-hdf5-types.h"
+
+bool
+check_hdf5_types (bool warn)
+{
+  static bool checked = false;
+  static bool ok = false;
+
+  if (! checked)
+    {
+#if defined (HAVE_HDF5)
+      ok = sizeof (octave_hdf5_id) >= sizeof (hid_t);
+
+      if (warn && ! ok)
+        warning_with_id
+          ("Octave:internal",
+           "the size of octave_hdf5_id is smaller than the size of HDF5 hid_t");
+
+      ok = sizeof (octave_hdf5_err) >= sizeof (herr_t);
+
+      if (warn && ! ok)
+        warning_with_id
+          ("Octave:internal",
+           "the size of octave_hdf5_err is smaller than the size of HDF5 herr_t");
+#else
+      warning_with_id
+        ("Octave:internal",
+         "check_hdf5_id_type called but Octave was not compiled with support for HDF5");
+#endif
+
+      checked = true;
+    }
+
+  return ok;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/corefcn/oct-hdf5-types.h	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,31 @@
+/*
+
+Copyright (C) 2015 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_oct_hdf5_types_h)
+#define octave_oct_hdf5_types_h 1
+
+typedef int octave_hdf5_id;
+typedef int octave_hdf5_err;
+
+extern bool check_hdf5_types (bool warn = true);
+
+#endif
--- a/libinterp/corefcn/oct-hdf5.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-hdf5.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,13 +20,21 @@
 
 */
 
-#if !defined (octave_oct_hdf5_h)
+#if ! defined (octave_oct_hdf5_h)
 #define octave_hdf5_h 1
 
 #if defined (HAVE_HDF5_H)
 
 #include <hdf5.h>
 
+#include "oct-hdf5-types.h"
+
+
+#ifdef USE_64_BIT_IDX_T
+#define H5T_NATIVE_IDX H5T_NATIVE_INT64
+#else
+#define H5T_NATIVE_IDX H5T_NATIVE_INT
+#endif
 #endif
 
 #endif
--- a/libinterp/corefcn/oct-hist.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-hist.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -171,14 +171,11 @@
         {
           if (i < nargin - 1)
             {
-              if (args(i+1).is_string ())
-                command_history::set_file (args(++i).string_value ());
-              else
-                {
-                  error ("history: expecting file name for %s option",
-                         option.c_str ());
-                  return hlist;
-                }
+              std::string fname
+                = args(++i).xstring_value ("history: filename must be a string for %s option",
+                                           option.c_str ());
+
+              command_history::set_file (fname);
             }
           else
             command_history::set_file (default_history_file ());
@@ -250,7 +247,7 @@
 
   hlist = command_history::list (limit, numbered_output);
 
-  int len = hlist.length ();
+  int len = hlist.numel ();
 
   if (nargout == 0)
     {
@@ -360,7 +357,7 @@
 
   string_vector hlist = command_history::list ();
 
-  int hist_count = hlist.length () - 1;  // switch to zero-based indexing
+  int hist_count = hlist.numel () - 1;  // switch to zero-based indexing
 
   // The current command line is already part of the history list by
   // the time we get to this point.  Delete the cmd from the list when
@@ -423,10 +420,7 @@
     }
 
   if (hist_beg > hist_count || hist_end > hist_count)
-    {
-      error ("%s: history specification out of range", warn_for);
-      return retval;
-    }
+    error ("%s: history specification out of range", warn_for);
 
   if (hist_end < hist_beg)
     {
@@ -439,11 +433,8 @@
   std::fstream file (name.c_str (), std::ios::out);
 
   if (! file)
-    {
-      error ("%s: couldn't open temporary file '%s'", warn_for,
-             name.c_str ());
-      return retval;
-    }
+    error ("%s: couldn't open temporary file '%s'", warn_for,
+           name.c_str ());
 
   if (reverse)
     {
@@ -493,10 +484,7 @@
   // Check if text edition was successfull.  Abort the operation
   // in case of failure.
   if (status != EXIT_SUCCESS)
-    {
-      error ("edit_history: text editor command failed");
-      return;
-    }
+    error ("edit_history: text editor command failed");
 
   // Write the commands to the history file since source_file
   // disables command line history while it executes.
--- a/libinterp/corefcn/oct-hist.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-hist.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_hist_h)
+#if ! defined (octave_oct_hist_h)
 #define octave_oct_hist_h 1
 
 #include <string>
--- a/libinterp/corefcn/oct-iostrm.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-iostrm.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_iostrm_h)
+#if ! defined (octave_oct_iostrm_h)
 #define octave_oct_iostrm_h 1
 
 #include <iosfwd>
--- a/libinterp/corefcn/oct-lvalue.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-lvalue.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -54,6 +54,21 @@
     error ("invalid index expression in assignment");
 }
 
+bool
+octave_lvalue::index_is_empty (void) const
+{
+  bool retval = false;
+
+  if (idx.size () == 1)
+    {
+      octave_value_list tmp = idx.front ();
+
+      retval = (tmp.length () == 1 && tmp(0).is_empty ());
+    }
+
+  return retval;
+}
+
 void
 octave_lvalue::do_unary_op (octave_value::unary_op op)
 {
--- a/libinterp/corefcn/oct-lvalue.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-lvalue.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_lvalue_h)
+#if ! defined (octave_oct_lvalue_h)
 #define octave_oct_lvalue_h 1
 
 class octave_value;
@@ -90,6 +90,10 @@
 
   void clear_index (void) { type = std::string (); idx.clear (); }
 
+  std::string index_type (void) const { return type; }
+
+  bool index_is_empty (void) const;
+
   void do_unary_op (octave_value::unary_op op);
 
   octave_value value (void) const;
--- a/libinterp/corefcn/oct-map.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-map.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -142,7 +142,7 @@
                                   Array<octave_idx_type>& perm) const
 {
   octave_idx_type n = nfields ();
-  if (perm.length () != n)
+  if (perm.numel () != n)
     perm.clear (1, n);
 
   return equal_up_to_order (other, perm.fortran_vec ());
@@ -639,22 +639,21 @@
 
   Array<octave_idx_type> perm (dim_vector (1, nf));
 
-  for (octave_idx_type i = 0; i < n; i++)
+  try
     {
-      if (i == idx)
-        continue;
-
-      permute_to_correct_order1 (map_list[idx], map_list[i], new_map_list[i],
-                                 perm);
+      for (octave_idx_type i = 0; i < n; i++)
+        {
+          if (i == idx)
+            continue;
 
-      if (error_state)
-        {
-          // Use liboctave exception to be consistent.
-          (*current_liboctave_error_handler)
-            ("cat: field names mismatch in concatenating structs");
-          break;
+          permute_to_correct_order1 (map_list[idx], map_list[i],
+                                     new_map_list[i], perm);
         }
     }
+  catch (octave_execution_exception& e)
+    {
+      error (e, "cat: field names mismatch in concatenating structs");
+    }
 }
 
 
@@ -667,8 +666,7 @@
   if (dim == -1 || dim == -2)
     dim = -dim - 1;
   else if (dim < 0)
-    (*current_liboctave_error_handler)
-      ("cat: invalid dimension");
+    error ("cat: invalid dimension");
 
   if (n == 1)
     retval = map_list[0];
@@ -732,8 +730,7 @@
   if (dim == -1 || dim == -2)
     dim = -dim - 1;
   else if (dim < 0)
-    (*current_liboctave_error_handler)
-      ("cat: invalid dimension");
+    error ("cat: invalid dimension");
 
   if (n == 1)
     retval = map_list[0];
@@ -785,10 +782,7 @@
               for (octave_idx_type i = 1; i < n; i++)
                 {
                   if (! dv.concat (map_list[i].dimensions, dim))
-                    {
-                      error ("dimension mismatch in struct concatenation");
-                      return retval;
-                    }
+                    error ("dimension mismatch in struct concatenation");
                 }
 
               retval.dimensions = dv;
@@ -900,46 +894,52 @@
   octave_idx_type n_idx = idx.length ();
   octave_map retval;
 
-  switch (n_idx)
-    {
-    case 1:
-      {
-        idx_vector i = idx(0).index_vector ();
+  // If we catch an indexing error in index_vector, we flag an error in
+  // index k.  Ensure it is the right value befor each idx_vector call.
+  // Same variable as used in the for loop in the default case.
+
+  octave_idx_type k = 0;
 
-        if (! error_state)
-          retval = index (i, resize_ok);
-      }
-      break;
+  try
+    {
+      switch (n_idx)
+        {
+        case 1:
+          {
+            idx_vector i = idx(0).index_vector ();
 
-    case 2:
-      {
-        idx_vector i = idx(0).index_vector ();
+            retval = index (i, resize_ok);
+          }
+          break;
 
-        if (! error_state)
+        case 2:
           {
+            idx_vector i = idx(0).index_vector ();
+
+            k = 1;
             idx_vector j = idx(1).index_vector ();
 
             retval = index (i, j, resize_ok);
           }
-      }
-      break;
+          break;
 
-    default:
-      {
-        Array<idx_vector> ia (dim_vector (n_idx, 1));
-
-        for (octave_idx_type i = 0; i < n_idx; i++)
+        default:
           {
-            ia(i) = idx(i).index_vector ();
+            Array<idx_vector> ia (dim_vector (n_idx, 1));
 
-            if (error_state)
-              break;
+            for (k = 0; k < n_idx; k++)
+              ia(k) = idx(k).index_vector ();
+
+            retval = index (ia, resize_ok);
           }
-
-        if (! error_state)
-          retval = index (ia, resize_ok);
-      }
-      break;
+          break;
+        }
+    }
+  catch (index_exception& e)
+    {
+      // Rethrow to allow more info to be reported later.
+      e.set_pos_if_unset (n_idx, k+1);
+      throw;
     }
 
   return retval;
@@ -992,14 +992,19 @@
   else
     {
       Array<octave_idx_type> perm;
-      octave_map rhs1 = rhs.orderfields (*this, perm);
-      if (! error_state)
+      octave_map rhs1;
+
+      try
         {
-          assert (rhs1.xkeys.is_same (xkeys));
-          assign (i, rhs1);
+          rhs1 = rhs.orderfields (*this, perm);
         }
-      else
-        error ("incompatible fields in struct assignment");
+      catch (octave_execution_exception& e)
+        {
+          error (e, "incompatible fields in struct assignment");
+        }
+
+      assert (rhs1.xkeys.is_same (xkeys));
+      assign (i, rhs1);
     }
 }
 
@@ -1035,14 +1040,19 @@
   else
     {
       Array<octave_idx_type> perm;
-      octave_map rhs1 = rhs.orderfields (*this, perm);
-      if (! error_state)
+      octave_map rhs1;
+
+      try
         {
-          assert (rhs1.xkeys.is_same (xkeys));
-          assign (i, j, rhs1);
+          rhs1 = rhs.orderfields (*this, perm);
         }
-      else
-        error ("incompatible fields in struct assignment");
+      catch (octave_execution_exception& e)
+        {
+          error (e, "incompatible fields in struct assignment");
+        }
+
+      assert (rhs1.xkeys.is_same (xkeys));
+      assign (i, j, rhs1);
     }
 }
 
@@ -1078,14 +1088,19 @@
   else
     {
       Array<octave_idx_type> perm;
-      octave_map rhs1 = rhs.orderfields (*this, perm);
-      if (! error_state)
+      octave_map rhs1;
+
+      try
         {
-          assert (rhs1.xkeys.is_same (xkeys));
-          assign (ia, rhs1);
+          rhs1 = rhs.orderfields (*this, perm);
         }
-      else
-        error ("incompatible fields in struct assignment");
+      catch (octave_execution_exception& e)
+        {
+          error (e, "incompatible fields in struct assignment");
+        }
+
+      assert (rhs1.xkeys.is_same (xkeys));
+      assign (ia, rhs1);
     }
 }
 
@@ -1094,46 +1109,52 @@
 {
   octave_idx_type n_idx = idx.length ();
 
-  switch (n_idx)
-    {
-    case 1:
-      {
-        idx_vector i = idx(0).index_vector ();
+  // If we catch an indexing error in index_vector, we flag an error in
+  // index k.  Ensure it is the right value befor each idx_vector call.
+  // Same variable as used in the for loop in the default case.
+
+  octave_idx_type k = 0;
 
-        if (! error_state)
-          assign (i, rhs);
-      }
-      break;
+  try
+    {
+      switch (n_idx)
+        {
+        case 1:
+          {
+            idx_vector i = idx(0).index_vector ();
 
-    case 2:
-      {
-        idx_vector i = idx(0).index_vector ();
+            assign (i, rhs);
+          }
+          break;
 
-        if (! error_state)
+        case 2:
           {
+            idx_vector i = idx(0).index_vector ();
+
+            k = 1;
             idx_vector j = idx(1).index_vector ();
 
             assign (i, j, rhs);
           }
-      }
-      break;
+          break;
 
-    default:
-      {
-        Array<idx_vector> ia (dim_vector (n_idx, 1));
-
-        for (octave_idx_type i = 0; i < n_idx; i++)
+        default:
           {
-            ia(i) = idx(i).index_vector ();
+            Array<idx_vector> ia (dim_vector (n_idx, 1));
 
-            if (error_state)
-              break;
+            for (k = 0; k < n_idx; k++)
+              ia(k) = idx(k).index_vector ();
+
+            assign (ia, rhs);
           }
-
-        if (! error_state)
-          assign (ia, rhs);
-      }
-      break;
+          break;
+        }
+    }
+  catch (index_exception& e)
+    {
+      // Rethrow to allow more info to be reported later.
+      e.set_pos_if_unset (n_idx, k+1);
+      throw;
     }
 }
 
@@ -1150,7 +1171,7 @@
 
   ref.assign (idx, rhs);
 
-  if (! error_state && ref.dims () != dimensions)
+  if (ref.dims () != dimensions)
     {
       dimensions = ref.dims ();
 
@@ -1164,7 +1185,7 @@
       optimize_dimensions ();
     }
 
-  if (! error_state && &ref == &tmp)
+  if (&ref == &tmp)
     setfield (k, tmp);
 }
 
@@ -1244,14 +1265,19 @@
 
   for (octave_idx_type i = 0; i < n_idx; i++)
     {
-      ia(i) = idx(i).index_vector ();
-
-      if (error_state)
-        break;
+      try
+        {
+          ia(i) = idx(i).index_vector ();
+        }
+      catch (index_exception& e)
+        {
+          // Rethrow to allow more info to be reported later.
+          e.set_pos_if_unset (n_idx, i+1);
+          throw;
+        }
     }
 
-  if (! error_state)
-    delete_elements (ia);
+  delete_elements (ia);
 }
 
 /*
@@ -1271,10 +1297,7 @@
           const_iterator pb = rb.seek (key(pa));
 
           if (pb == rb.end ())
-            {
-              error ("field name mismatch in structure concatenation");
-              break;
-            }
+            error ("field name mismatch in structure concatenation");
 
           contents(pa).insert (rb.contents (pb), ra_idx);
         }
@@ -1300,10 +1323,7 @@
   for (octave_idx_type i = 0; i < nf; i++)
     {
       if (! xvals[i].optimize_dimensions (dimensions))
-        {
-          error ("internal error: dimension mismatch across fields in struct");
-          break;
-        }
+        error ("internal error: dimension mismatch across fields in struct");
     }
 
 }
--- a/libinterp/corefcn/oct-map.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-map.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_oct_map_h)
+#if ! defined (octave_oct_map_h)
 #define octave_oct_map_h 1
 
 #include <algorithm>
@@ -161,7 +161,7 @@
   octave_scalar_map (void) : xkeys (), xvals () { }
 
   octave_scalar_map (const string_vector& k)
-    : xkeys (k), xvals (k.length ()) { }
+    : xkeys (k), xvals (k.numel ()) { }
 
   octave_scalar_map (const octave_scalar_map& m)
     : xkeys (m.xkeys), xvals(m.xvals) { }
@@ -277,10 +277,10 @@
   octave_map (const dim_vector& dv) : xkeys (), xvals (), dimensions (dv) { }
 
   octave_map (const string_vector& k)
-    : xkeys (k), xvals (k.length (), Cell (1, 1)), dimensions (1, 1) { }
+    : xkeys (k), xvals (k.numel (), Cell (1, 1)), dimensions (1, 1) { }
 
   octave_map (const dim_vector& dv, const string_vector& k)
-    : xkeys (k), xvals (k.length (), Cell (dv)), dimensions (dv) { }
+    : xkeys (k), xvals (k.numel (), Cell (dv)), dimensions (dv) { }
 
   octave_map (const octave_map& m)
     : xkeys (m.xkeys), xvals (m.xvals), dimensions (m.dimensions) { }
--- a/libinterp/corefcn/oct-obj.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-obj.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -133,17 +133,11 @@
   if (offset < 0 || offset >= len)
     {
       if (! (rep_length == 0 && offset == len))
-        {
-          error ("octave_value_list::splice: invalid OFFSET");
-          return retval;
-        }
+        error ("octave_value_list::splice: invalid OFFSET");
     }
 
   if (rep_length < 0 || rep_length + offset > len)
-    {
-      error ("octave_value_list::splice: invalid LENGTH");
-      return retval;
-    }
+    error ("octave_value_list::splice: invalid LENGTH");
 
   octave_idx_type lst_len = lst.length ();
 
@@ -263,7 +257,7 @@
         }
     }
   else
-    error ("%s: expecting all arguments to be strings", fcn_name.c_str ());
+    error ("%s: all arguments must be strings", fcn_name.c_str ());
 
   return argv;
 }
--- a/libinterp/corefcn/oct-obj.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-obj.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_oct_obj_h)
+#if ! defined (octave_oct_obj_h)
 #define octave_oct_obj_h 1
 
 #include <string>
@@ -86,7 +86,7 @@
 
   const octave_value& operator () (octave_idx_type n) const { return elem (n); }
 
-  octave_idx_type length (void) const { return data.length (); }
+  octave_idx_type length (void) const { return data.numel (); }
 
   bool empty (void) const { return length () == 0; }
 
@@ -113,9 +113,9 @@
     octave_value_list retval
       = data.linear_slice (offset, std::min (offset + len, length ()));
 
-    if (tags && len > 0 && names.length () > 0)
+    if (tags && len > 0 && names.numel () > 0)
       retval.names = names.linear_slice (offset, std::min (offset + len,
-                                                           names.length ()));
+                                                           names.numel ()));
 
     return retval;
   }
@@ -177,7 +177,7 @@
 inline octave_value_list
 ovl (const octave_value& a0)
 {
-  octave_value_list retval;
+  octave_value_list retval (1);
   retval(0) = a0;
   return retval;
 }
@@ -185,7 +185,7 @@
 inline octave_value_list
 ovl (const octave_value& a0, const octave_value& a1)
 {
-  octave_value_list retval;
+  octave_value_list retval (2);
   retval(1) = a1;
   retval(0) = a0;
   return retval;
@@ -195,7 +195,7 @@
 ovl (const octave_value& a0, const octave_value& a1,
      const octave_value& a2)
 {
-  octave_value_list retval;
+  octave_value_list retval (3);
   retval(2) = a2;
   retval(1) = a1;
   retval(0) = a0;
@@ -206,7 +206,7 @@
 ovl (const octave_value& a0, const octave_value& a1,
      const octave_value& a2, const octave_value& a3)
 {
-  octave_value_list retval;
+  octave_value_list retval (4);
   retval(3) = a3;
   retval(2) = a2;
   retval(1) = a1;
@@ -219,7 +219,7 @@
      const octave_value& a2, const octave_value& a3,
      const octave_value& a4)
 {
-  octave_value_list retval;
+  octave_value_list retval (5);
   retval(4) = a4;
   retval(3) = a3;
   retval(2) = a2;
@@ -233,7 +233,7 @@
      const octave_value& a2, const octave_value& a3,
      const octave_value& a4, const octave_value& a5)
 {
-  octave_value_list retval;
+  octave_value_list retval (6);
   retval(5) = a5;
   retval(4) = a4;
   retval(3) = a3;
@@ -249,7 +249,7 @@
      const octave_value& a4, const octave_value& a5,
      const octave_value& a6)
 {
-  octave_value_list retval;
+  octave_value_list retval (7);
   retval(6) = a6;
   retval(5) = a5;
   retval(4) = a4;
@@ -266,7 +266,7 @@
      const octave_value& a4, const octave_value& a5,
      const octave_value& a6, const octave_value& a7)
 {
-  octave_value_list retval;
+  octave_value_list retval (8);
   retval(7) = a7;
   retval(6) = a6;
   retval(5) = a5;
@@ -285,7 +285,7 @@
      const octave_value& a6, const octave_value& a7,
      const octave_value& a8)
 {
-  octave_value_list retval;
+  octave_value_list retval (9);
   retval(8) = a8;
   retval(7) = a7;
   retval(6) = a6;
@@ -305,7 +305,7 @@
      const octave_value& a6, const octave_value& a7,
      const octave_value& a8, const octave_value& a9)
 {
-  octave_value_list retval;
+  octave_value_list retval (10);
   retval(9) = a9;
   retval(8) = a8;
   retval(7) = a7;
--- a/libinterp/corefcn/oct-prcstrm.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-prcstrm.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_prcstrm_h)
+#if ! defined (octave_oct_prcstrm_h)
 #define octave_oct_prcstrm_h 1
 
 #include "oct-stdstrm.h"
--- a/libinterp/corefcn/oct-procbuf.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-procbuf.h	Thu Dec 10 12:50:06 2015 -0800
@@ -23,7 +23,7 @@
 // This class is based on the procbuf class from libg++, written by
 // Per Bothner, Copyright (C) 1993 Free Software Foundation.
 
-#if !defined (octave_oct_procbuf_h)
+#if ! defined (octave_oct_procbuf_h)
 #define octave_oct_procbuf_h 1
 
 #include <sys/types.h>
--- a/libinterp/corefcn/oct-stdstrm.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-stdstrm.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_stdstrm_h)
+#if ! defined (octave_oct_stdstrm_h)
 #define octave_oct_stdstrm_h 1
 
 #include "oct-stream.h"
--- a/libinterp/corefcn/oct-stream.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-stream.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -50,6 +50,7 @@
 #include "oct-stdstrm.h"
 #include "oct-stream.h"
 #include "oct-obj.h"
+#include "toplev.h"
 #include "utils.h"
 
 // Possible values for conv_err:
@@ -61,13 +62,24 @@
 static int
 convert_to_valid_int (const octave_value& tc, int& conv_err)
 {
+  conv_err = 0;
+
   int retval = 0;
 
-  conv_err = 0;
-
-  double dval = tc.double_value ();
-
-  if (! error_state)
+  double dval = 0.0;
+
+  try
+    {
+      dval = tc.double_value ();
+    }
+  catch (const octave_execution_exception&)
+    {
+      recover_from_exception ();
+
+      conv_err = 1;
+    }
+
+  if (! conv_err)
     {
       if (! lo_ieee_isnan (dval))
         {
@@ -81,8 +93,6 @@
       else
         conv_err = 2;
     }
-  else
-    conv_err = 1;
 
   return retval;
 }
@@ -123,7 +133,7 @@
   double dnr = -1.0;
   double dnc = -1.0;
 
-  octave_idx_type sz_len = size.length ();
+  octave_idx_type sz_len = size.numel ();
 
   if (sz_len == 1)
     {
@@ -145,13 +155,10 @@
   else
     ::error ("%s: invalid size specification", who.c_str ());
 
-  if (! error_state)
-    {
-      nr = get_size (dnr, who);
-
-      if (! error_state && dnc >= 0.0)
-        nc = get_size (dnc, who);
-    }
+  nr = get_size (dnr, who);
+
+  if (dnc >= 0.0)
+    nc = get_size (dnc, who);
 }
 
 scanf_format_list::scanf_format_list (const std::string& s)
@@ -235,7 +242,7 @@
 
 scanf_format_list::~scanf_format_list (void)
 {
-  octave_idx_type n = list.length ();
+  octave_idx_type n = list.numel ();
 
   for (octave_idx_type i = 0; i < n; i++)
     {
@@ -259,7 +266,7 @@
             = new scanf_format_elt (text.c_str (), width, discard, type,
                                     modifier, char_class);
 
-          if (num_elts == list.length ())
+          if (num_elts == list.numel ())
             list.resize (dim_vector (2 * num_elts, 1));
 
           list(num_elts++) = elt;
@@ -342,13 +349,13 @@
           else
             {
               char c = s[i++];
-              width = width * 10 + c - '0';
+              width = 10 * width + c - '0';
               have_width = true;
               *buf << c;
               while (i < n && isdigit (s[i]))
                 {
                   c = s[i++];
-                  width = width * 10 + c - '0';
+                  width = 10 * width + c - '0';
                   *buf << c;
                 }
             }
@@ -489,7 +496,7 @@
 void
 scanf_format_list::printme (void) const
 {
-  octave_idx_type n = list.length ();
+  octave_idx_type n = list.numel ();
 
   for (octave_idx_type i = 0; i < n; i++)
     {
@@ -517,7 +524,7 @@
 bool
 scanf_format_list::all_character_conversions (void)
 {
-  octave_idx_type n = list.length ();
+  octave_idx_type n = list.numel ();
 
   if (n > 0)
     {
@@ -547,7 +554,7 @@
 bool
 scanf_format_list::all_numeric_conversions (void)
 {
-  octave_idx_type n = list.length ();
+  octave_idx_type n = list.numel ();
 
   if (n > 0)
     {
@@ -664,7 +671,7 @@
 
 printf_format_list::~printf_format_list (void)
 {
-  octave_idx_type n = list.length ();
+  octave_idx_type n = list.numel ();
 
   for (octave_idx_type i = 0; i < n; i++)
     {
@@ -688,7 +695,7 @@
             = new printf_format_elt (text.c_str (), args, fw, prec, flags,
                                      type, modifier);
 
-          if (num_elts == list.length ())
+          if (num_elts == list.numel ())
             list.resize (dim_vector (2 * num_elts, 1));
 
           list(num_elts++) = elt;
@@ -871,7 +878,7 @@
 void
 printf_format_list::printme (void) const
 {
-  int n = list.length ();
+  int n = list.numel ();
 
   for (int i = 0; i < n; i++)
     {
@@ -932,12 +939,8 @@
   std::string retval;
 
   if (interactive && file_number () == 0)
-    {
-      ::error ("%s: unable to read from stdin while running interactively",
-               who.c_str ());
-
-      return retval;
-    }
+    ::error ("%s: unable to read from stdin while running interactively",
+             who.c_str ());
 
   err = false;
 
@@ -1603,11 +1606,19 @@
 
           if (elt)
             {
-              if (! (elt->type == scanf_format_elt::whitespace_conversion
-                     || elt->type == scanf_format_elt::literal_conversion
-                     || elt->type == '%')
-                  && max_conv > 0 && conversion_count == max_conv)
+              if (elt->type == scanf_format_elt::null
+                  || (! (elt->type == scanf_format_elt::whitespace_conversion
+                        || elt->type == scanf_format_elt::literal_conversion
+                        || elt->type == '%')
+                      && max_conv > 0 && conversion_count == max_conv))
                 {
+                  // We are done, either because we have reached the end
+                  // of the format string and are not cycling through
+                  // the format again or because we've converted all the
+                  // values that have been requested and the next format
+                  // element is a conversion.  Determine final array
+                  // size and exit.
+
                   if (all_char_conv && one_elt_size_spec)
                     {
                       final_nr = 1;
@@ -1859,7 +1870,16 @@
               break;
             }
           else
-            elt = fmt_list.next (nconv > 0);
+            {
+              // Cycle through the format list more than once if we have
+              // some conversions to make and we haven't reached the
+              // limit on the number of values to convert (possibly
+              // because there is no specified limit).
+
+              elt = fmt_list.next (nconv > 0
+                                   && (max_conv == 0
+                                       || conversion_count < max_conv));
+            }
         }
     }
 
@@ -1902,9 +1922,8 @@
 
           get_size (size, nr, nc, one_elt_size_spec, who);
 
-          if (! error_state)
-            retval = do_scanf (fmt_list, nr, nc, one_elt_size_spec,
-                               conversion_count, who);
+          retval = do_scanf (fmt_list, nr, nc, one_elt_size_spec,
+                             conversion_count, who);
         }
     }
   else
@@ -2233,19 +2252,9 @@
         {
           curr_val = values (val_idx);
 
-          // Force string conversion here for compatibility.
-
-          if (! error_state)
-            {
-              elt_idx = 0;
-              n_elts = curr_val.numel ();
-              have_data = true;
-            }
-          else
-            {
-              curr_state = conversion_error;
-              break;
-            }
+          elt_idx = 0;
+          n_elts = curr_val.numel ();
+          have_data = true;
         }
 
       if (elt_idx < n_elts)
@@ -2344,18 +2353,12 @@
 
   octave_value val = get_next_value ();
 
-  if (! error_state)
-    {
-      double dval = val.double_value (true);
-
-      if (! error_state)
-        {
-          if (D_NINT (dval) == dval)
-            retval = NINT (dval);
-          else
-            curr_state = conversion_error;
-        }
-    }
+  double dval = val.double_value (true);
+
+  if (D_NINT (dval) == dval)
+    retval = NINT (dval);
+  else
+    curr_state = conversion_error;
 
   return retval;
 }
@@ -2399,10 +2402,7 @@
   size_t retval = 0;
 
   if (nsa > 2)
-    {
-      ::error ("%s: internal error handling format", who.c_str ());
-      return retval;
-    }
+    ::error ("%s: internal error handling format", who.c_str ());
 
   std::string flags = elt->flags;
 
@@ -2570,9 +2570,8 @@
 
               double dval = val.double_value (true);
 
-              if (! error_state)
-                retval += do_printf_conv (os, tfmt.c_str (), nsa,
-                                          sa_1, sa_2, dval, who);
+              retval += do_printf_conv (os, tfmt.c_str (), nsa,
+                                        sa_1, sa_2, dval, who);
             }
           break;
 
@@ -2594,9 +2593,8 @@
 
               double dval = val.double_value (true);
 
-              if (! error_state)
-                retval += do_printf_conv (os, tfmt.c_str (), nsa,
-                                          sa_1, sa_2, dval, who);
+              retval += do_printf_conv (os, tfmt.c_str (), nsa,
+                                        sa_1, sa_2, dval, who);
             }
           break;
 
@@ -2605,14 +2603,12 @@
           {
             double dval = val.double_value (true);
 
-            if (! error_state)
-              retval += do_printf_conv (os, fmt, nsa, sa_1, sa_2, dval, who);
+            retval += do_printf_conv (os, fmt, nsa, sa_1, sa_2, dval, who);
           }
           break;
 
         default:
-          error ("%s: invalid format specifier",
-                 who.c_str ());
+          error ("%s: invalid format specifier", who.c_str ());
           return -1;
           break;
         }
@@ -2640,9 +2636,6 @@
 
       printf_value_cache val_cache (args, who);
 
-      if (error_state)
-        return retval;
-
       for (;;)
         {
           octave_quit ();
@@ -2900,8 +2893,7 @@
         }
     }
 
-  if (! error_state)
-    retval = getl (max_len, err, who);
+  retval = getl (max_len, err, who);
 
   return retval;
 }
@@ -2940,8 +2932,7 @@
         }
     }
 
-  if (! error_state)
-    retval = gets (max_len, err, who);
+  retval = gets (max_len, err, who);
 
   return retval;
 }
@@ -2985,8 +2976,7 @@
         }
     }
 
-  if (! error_state)
-    retval = skipl (count, err, who);
+  retval = skipl (count, err, who);
 
   return retval;
 }
@@ -3067,57 +3057,52 @@
   int retval = -1;
 
   // FIXME: should we have octave_value methods that handle off_t explicitly?
-  octave_int64 val = tc_offset.int64_scalar_value ();
+  octave_int64 val = tc_offset.xint64_scalar_value ("fseek: invalid value for offset");
   off_t xoffset = val.value ();
 
-  if (! error_state)
+  int conv_err = 0;
+
+  int origin = SEEK_SET;
+
+  if (tc_origin.is_string ())
     {
-      int conv_err = 0;
-
-      int origin = SEEK_SET;
-
-      if (tc_origin.is_string ())
+      std::string xorigin = tc_origin.string_value ("fseek: invalid value for origin");
+
+      if (xorigin == "bof")
+        origin = SEEK_SET;
+      else if (xorigin == "cof")
+        origin = SEEK_CUR;
+      else if (xorigin == "eof")
+        origin = SEEK_END;
+      else
+        conv_err = -1;
+    }
+  else
+    {
+      int xorigin = convert_to_valid_int (tc_origin, conv_err);
+
+      if (! conv_err)
         {
-          std::string xorigin = tc_origin.string_value ();
-
-          if (xorigin == "bof")
+          if (xorigin == -1)
             origin = SEEK_SET;
-          else if (xorigin == "cof")
+          else if (xorigin == 0)
             origin = SEEK_CUR;
-          else if (xorigin == "eof")
+          else if (xorigin == 1)
             origin = SEEK_END;
           else
             conv_err = -1;
         }
-      else
-        {
-          int xorigin = convert_to_valid_int (tc_origin, conv_err);
-
-          if (! conv_err)
-            {
-              if (xorigin == -1)
-                origin = SEEK_SET;
-              else if (xorigin == 0)
-                origin = SEEK_CUR;
-              else if (xorigin == 1)
-                origin = SEEK_END;
-              else
-                conv_err = -1;
-            }
-        }
-
-      if (! conv_err)
-        {
-          retval = seek (xoffset, origin);
-
-          if (retval != 0)
-            error ("fseek: failed to seek to requested position");
-        }
-      else
-        error ("fseek: invalid value for origin");
+    }
+
+  if (! conv_err)
+    {
+      retval = seek (xoffset, origin);
+
+      if (retval != 0)
+        error ("fseek: failed to seek to requested position");
     }
   else
-    error ("fseek: invalid value for offset");
+    error ("fseek: invalid value for origin");
 
   return retval;
 }
@@ -3189,7 +3174,7 @@
               else if (do_float_fmt_conv)
                 do_float_format_conversion (&data[i], sizeof (SRC_T),
                                             1, from_flt_fmt,
-                                            oct_mach_info::float_format ());
+                                            oct_mach_info::native_float_format ());
 
               dst_elt_type tmp (data[i]);
 
@@ -3341,8 +3326,7 @@
 
     default:
       retval = false;
-      (*current_liboctave_error_handler)
-        ("read: invalid type specification");
+      error ("read: invalid type specification");
       break;
     }
 
@@ -3377,166 +3361,167 @@
 
       count = 0;
 
-      get_size (size, nr, nc, one_elt_size_spec, "fread");
-
-      if (! error_state)
+      try
+        {
+          get_size (size, nr, nc, one_elt_size_spec, "fread");
+        }
+      catch (const octave_execution_exception&)
         {
-
-          octave_idx_type elts_to_read;
-
-          if (one_elt_size_spec)
-            {
-              // If NR == 0, Matlab returns [](0x0).
-
-              // If NR > 0, the result will be a column vector with the given
-              // number of rows.
-
-              // If NR < 0, then we have Inf and the result will be a column
-              // vector but we have to wait to see how big NR will be.
-
-              if (nr == 0)
-                nr = nc = 0;
-              else
-                nc = 1;
-            }
-          else
-            {
-              // Matlab returns [] even if there are two elements in the size
-              // specification and one is nonzero.
-
-              // If NC < 0 we have [NR, Inf] and we'll wait to decide how big NC
-              // should be.
-
-              if (nr == 0 || nc == 0)
-                nr = nc = 0;
-            }
-
-          // FIXME: Ensure that this does not overflow.
-          //        Maybe try comparing nr * nc computed in double with
-          //        std::numeric_limits<octave_idx_type>::max ();
-
-          elts_to_read = nr * nc;
-
-          bool read_to_eof = elts_to_read < 0;
-
-          octave_idx_type input_buf_elts = -1;
-
-          if (skip == 0)
-            {
-              if (read_to_eof)
-                input_buf_elts = 1024 * 1024;
-              else
-                input_buf_elts = elts_to_read;
-            }
+          invalid_operation ("fread", "reading");
+        }
+
+      octave_idx_type elts_to_read;
+
+      if (one_elt_size_spec)
+        {
+          // If NR == 0, Matlab returns [](0x0).
+
+          // If NR > 0, the result will be a column vector with the given
+          // number of rows.
+
+          // If NR < 0, then we have Inf and the result will be a column
+          // vector but we have to wait to see how big NR will be.
+
+          if (nr == 0)
+            nr = nc = 0;
           else
-            input_buf_elts = block_size;
-
-          octave_idx_type input_elt_size
-            = oct_data_conv::data_type_size (input_type);
-
-          octave_idx_type input_buf_size = input_buf_elts * input_elt_size;
-
-          assert (input_buf_size >= 0);
-
-          // Must also work and return correct type object
-          // for 0 elements to read.
-
-          std::istream *isp = input_stream ();
-
-          if (isp)
-            {
-              std::istream& is = *isp;
-
-              std::list <void *> input_buf_list;
-
-              while (is && ! is.eof ()
-                     && (read_to_eof || count < elts_to_read))
-                {
-                  if (! read_to_eof)
-                    {
-                      octave_idx_type remaining_elts = elts_to_read - count;
-
-                      if (remaining_elts < input_buf_elts)
-                        input_buf_size = remaining_elts * input_elt_size;
-                    }
-
-                  char *input_buf = new char [input_buf_size];
-
-                  is.read (input_buf, input_buf_size);
-
-                  size_t gcount = is.gcount ();
-
-                  char_count += gcount;
-
-                  octave_idx_type nel = gcount / input_elt_size;
-
-                  count += nel;
-
-                  input_buf_list.push_back (input_buf);
-
-                  if (is && skip != 0 && nel == block_size)
-                    {
-                      // Seek to skip.  If skip would move past EOF,
-                      // position at EOF.
-
-                      off_t orig_pos = tell ();
-
-                      seek (0, SEEK_END);
-
-                      off_t eof_pos = tell ();
-
-                      // Is it possible for this to fail to return us to
-                      // the original position?
-                      seek (orig_pos, SEEK_SET);
-
-                      off_t remaining = eof_pos - orig_pos;
-
-                      if (remaining < skip)
-                        seek (0, SEEK_END);
-                      else
-                        seek (skip, SEEK_CUR);
-
-                      if (! is)
-                        break;
-                    }
-                }
-
-              if (read_to_eof)
-                {
-                  if (nc < 0)
-                    {
-                      nc = count / nr;
-
-                      if (count % nr != 0)
-                        nc ++;
-                    }
-                  else
-                    nr = count;
-                }
-              else if (count == 0)
-                {
-                  nr = 0;
-                  nc = 0;
-                }
-              else if (count != nr * nc)
-                {
-                  if (count % nr != 0)
-                    nc = count / nr + 1;
-                  else
-                    nc = count / nr;
-
-                  if (count < nr)
-                    nr = count;
-                }
-
-              retval = finalize_read (input_buf_list, input_buf_elts, count,
-                                      nr, nc, input_type, output_type, ffmt);
-            }
+            nc = 1;
+        }
+      else
+        {
+          // Matlab returns [] even if there are two elements in the size
+          // specification and one is nonzero.
+
+          // If NC < 0 we have [NR, Inf] and we'll wait to decide how big NC
+          // should be.
+
+          if (nr == 0 || nc == 0)
+            nr = nc = 0;
+        }
+
+      // FIXME: Ensure that this does not overflow.
+      //        Maybe try comparing nr * nc computed in double with
+      //        std::numeric_limits<octave_idx_type>::max ();
+
+      elts_to_read = nr * nc;
+
+      bool read_to_eof = elts_to_read < 0;
+
+      octave_idx_type input_buf_elts = -1;
+
+      if (skip == 0)
+        {
+          if (read_to_eof)
+            input_buf_elts = 1024 * 1024;
           else
-            error ("fread: invalid input stream");
+            input_buf_elts = elts_to_read;
         }
       else
-        invalid_operation ("fread", "reading");
+        input_buf_elts = block_size;
+
+      octave_idx_type input_elt_size
+                                        = oct_data_conv::data_type_size (input_type);
+
+      octave_idx_type input_buf_size = input_buf_elts * input_elt_size;
+
+      assert (input_buf_size >= 0);
+
+      // Must also work and return correct type object
+      // for 0 elements to read.
+
+      std::istream *isp = input_stream ();
+
+      if (isp)
+        {
+          std::istream& is = *isp;
+
+          std::list <void *> input_buf_list;
+
+          while (is && ! is.eof ()
+                 && (read_to_eof || count < elts_to_read))
+            {
+              if (! read_to_eof)
+                {
+                  octave_idx_type remaining_elts = elts_to_read - count;
+
+                  if (remaining_elts < input_buf_elts)
+                    input_buf_size = remaining_elts * input_elt_size;
+                }
+
+              char *input_buf = new char [input_buf_size];
+
+              is.read (input_buf, input_buf_size);
+
+              size_t gcount = is.gcount ();
+
+              char_count += gcount;
+
+              octave_idx_type nel = gcount / input_elt_size;
+
+              count += nel;
+
+              input_buf_list.push_back (input_buf);
+
+              if (is && skip != 0 && nel == block_size)
+                {
+                  // Seek to skip.  If skip would move past EOF,
+                  // position at EOF.
+
+                  off_t orig_pos = tell ();
+
+                  seek (0, SEEK_END);
+
+                  off_t eof_pos = tell ();
+
+                  // Is it possible for this to fail to return us to
+                  // the original position?
+                  seek (orig_pos, SEEK_SET);
+
+                  off_t remaining = eof_pos - orig_pos;
+
+                  if (remaining < skip)
+                    seek (0, SEEK_END);
+                  else
+                    seek (skip, SEEK_CUR);
+
+                  if (! is)
+                    break;
+                }
+            }
+
+          if (read_to_eof)
+            {
+              if (nc < 0)
+                {
+                  nc = count / nr;
+
+                  if (count % nr != 0)
+                    nc++;
+                }
+              else
+                nr = count;
+            }
+          else if (count == 0)
+            {
+              nr = 0;
+              nc = 0;
+            }
+          else if (count != nr * nc)
+            {
+              if (count % nr != 0)
+                nc = count / nr + 1;
+              else
+                nc = count / nr;
+
+              if (count < nr)
+                nr = count;
+            }
+
+          retval = finalize_read (input_buf_list, input_buf_elts, count,
+                                  nr, nc, input_type, output_type, ffmt);
+        }
+      else
+        error ("fread: invalid input stream");
     }
 
   return retval;
@@ -3551,22 +3536,19 @@
 
   if (stream_ok ())
     {
-      if (! error_state)
-        {
-          if (flt_fmt == oct_mach_info::flt_fmt_unknown)
-            flt_fmt = float_format ();
-
-          octave_idx_type status = data.write (*this, block_size, output_type,
-                                               skip, flt_fmt);
-
-          if (status < 0)
-            error ("fwrite: write error");
-          else
-            retval = status;
-        }
+      if (flt_fmt == oct_mach_info::flt_fmt_unknown)
+        flt_fmt = float_format ();
+
+      octave_idx_type status = data.write (*this, block_size, output_type,
+                                           skip, flt_fmt);
+
+      if (status < 0)
+        error ("fwrite: write error");
       else
-        invalid_operation ("fwrite", "writing");
+        retval = status;
     }
+  else
+    invalid_operation ("fwrite", "writing");
 
   return retval;
 }
@@ -3713,8 +3695,7 @@
 
     default:
       retval = false;
-      (*current_liboctave_error_handler)
-        ("write: invalid type specification");
+      error ("write: invalid type specification");
       break;
     }
 
@@ -4139,11 +4120,7 @@
     }
 
   if (! instance)
-    {
-      ::error ("unable to create stream list object!");
-
-      retval = false;
-    }
+    ::error ("unable to create stream list object!");
 
   return retval;
 }
@@ -4296,8 +4273,7 @@
 
   int i = get_file_number (fid);
 
-  if (! error_state)
-    retval = do_lookup (i, who);
+  retval = do_lookup (i, who);
 
   return retval;
 }
@@ -4307,9 +4283,7 @@
 {
   int retval = -1;
 
-  // Can't remove stdin (std::cin), stdout (std::cout), or stderr
-  // (std::cerr).
-
+  // Can't remove stdin (std::cin), stdout (std::cout), or stderr (std::cerr).
   if (fid > 2)
     {
       ostrl_map::iterator iter = list.find (fid);
@@ -4353,8 +4327,7 @@
     {
       int i = get_file_number (fid);
 
-      if (! error_state)
-        retval = do_remove (i, who);
+      retval = do_remove (i, who);
     }
 
   return retval;
@@ -4365,25 +4338,40 @@
 {
   if (flush)
     {
-      // Do flush stdout and stderr.
-
-      list[0].flush ();
+      // Flush stdout and stderr.
       list[1].flush ();
+      list[2].flush ();
     }
 
-  octave_stream saved_os[3];
-  // But don't delete them or stdin.
-  for (ostrl_map::iterator iter = list.begin (); iter != list.end (); iter++)
+  for (ostrl_map::iterator iter = list.begin (); iter != list.end (); )
     {
       int fid = iter->first;
+      if (fid < 3)  // Don't delete stdin, stdout, stderr
+        {
+          iter++;
+          continue;
+        }
+
       octave_stream os = iter->second;
-      if (fid < 3)
-        saved_os[fid] = os;
-      else if (os.is_valid ())
+
+      std::string name = os.name ();
+      std::transform (name.begin (), name.end (), name.begin (), tolower);
+
+      // FIXME: This test for gnuplot is hardly foolproof.
+      if (name.find ("gnuplot") != std::string::npos)
+        {
+          // Don't close down pipes to gnuplot
+          iter++;
+          continue;
+        }
+
+      // Normal file handle.  Close and delete from list.
+      if (os.is_valid ())
         os.close ();
+
+      list.erase (iter++);
     }
-  list.clear ();
-  for (int fid = 0; fid < 3; fid++) list[fid] = saved_os[fid];
+
   lookup_cache = list.end ();
 }
 
--- a/libinterp/corefcn/oct-stream.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-stream.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_stream_h)
+#if ! defined (octave_oct_stream_h)
 #define octave_oct_stream_h 1
 
 class Matrix;
@@ -49,7 +49,8 @@
   enum special_conversion
   {
     whitespace_conversion = 1,
-    literal_conversion = 2
+    literal_conversion = 2,
+    null = 3
   };
 
   scanf_format_elt (const char *txt = 0, int w = 0, bool d = false,
@@ -116,7 +117,7 @@
   // the list is 3 because of the characters that appear after the
   // last conversion.
 
-  octave_idx_type length (void) { return list.length (); }
+  octave_idx_type length (void) { return list.numel (); }
 
   const scanf_format_elt *first (void)
   {
@@ -125,19 +126,23 @@
   }
 
   const scanf_format_elt *current (void) const
-  { return list.length () > 0 ? list.elem (curr_idx) : 0; }
+  { return list.numel () > 0 ? list.elem (curr_idx) : 0; }
 
   const scanf_format_elt *next (bool cycle = true)
   {
+    static scanf_format_elt dummy
+      (0, 0, false, scanf_format_elt::null, '\0', "");
+
     curr_idx++;
 
-    if (curr_idx >= list.length ())
+    if (curr_idx >= list.numel ())
       {
         if (cycle)
           curr_idx = 0;
         else
-          return 0;
+          return &dummy;
       }
+
     return current ();
   }
 
@@ -260,13 +265,13 @@
   }
 
   const printf_format_elt *current (void) const
-  { return list.length () > 0 ? list.elem (curr_idx) : 0; }
+  { return list.numel () > 0 ? list.elem (curr_idx) : 0; }
 
   const printf_format_elt *next (bool cycle = true)
   {
     curr_idx++;
 
-    if (curr_idx >= list.length ())
+    if (curr_idx >= list.numel ())
       {
         if (cycle)
           curr_idx = 0;
@@ -277,7 +282,7 @@
     return current ();
   }
 
-  bool last_elt_p (void) { return (curr_idx + 1 == list.length ()); }
+  bool last_elt_p (void) { return (curr_idx + 1 == list.numel ()); }
 
   void printme (void) const;
 
--- a/libinterp/corefcn/oct-strstrm.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-strstrm.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_strstrm_h)
+#if ! defined (octave_oct_strstrm_h)
 #define octave_oct_strstrm_h 1
 
 #include <string>
--- a/libinterp/corefcn/oct-tex-lexer.in.ll	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-tex-lexer.in.ll	Thu Dec 10 12:50:06 2015 -0800
@@ -36,8 +36,8 @@
 
 }
 
-%x	NUM_MODE
-%x	MAYBE_NUM_MODE
+%x NUM_MODE
+%x MAYBE_NUM_MODE
 
 %{
 
@@ -53,19 +53,19 @@
 
 // FIXME: with bison 3.x, OCTAVE_TEX_STYPE appears in the generated
 // oct-parse.h file, but there is no definition for YYSTYPE, which is
-// needed by the code that is generated by flex.  I can't seem to find a
-// way to tell flex to use OCTAVE_TEX_STYPE instead of YYSTYPE in the code
-// it generates, or to tell bison to provide the definition of YYSTYPE
-// in the generated oct-parse.h file.
+// needed by the code that is generated by flex.  I can't seem to find
+// a way to tell flex to use OCTAVE_TEX_STYPE instead of YYSTYPE in
+// the code it generates, or to tell bison to provide the definition
+// of YYSTYPE in the generated oct-parse.h file.
 
 #if defined (OCTAVE_TEX_STYPE_IS_DECLARED) && ! defined YYSTYPE
 #define YYSTYPE OCTAVE_TEX_STYPE
 #endif
 
 #if defined (GNULIB_NAMESPACE)
-// Calls to the following functions appear in the generated output from
-// flex without the namespace tag.  Redefine them so we will use them
-// via the gnulib namespace.
+// Calls to the following functions appear in the generated output
+// from flex without the namespace tag.  Redefine them so we will use
+// them via the gnulib namespace.
 #define fprintf GNULIB_NAMESPACE::fprintf
 #define fread GNULIB_NAMESPACE::fread
 #define fwrite GNULIB_NAMESPACE::fwrite
@@ -77,73 +77,99 @@
 
 %}
 
-D       [0-9]
-NUM	(({D}+\.?{D}*)|(\.{D}+))
+D   [0-9]
+NUM (({D}+\.?{D}*)|(\.{D}+))
 
 %%
 
 %{
-// Numeric values
+// Numeric values.
 %}
 
-<NUM_MODE>{NUM}		{
-    int nread;
+<NUM_MODE>{NUM} {
+    int nread = sscanf (yytext, "%lf", &(yylval->num));
 
-    nread = sscanf (yytext, "%lf", &(yylval->num));
     if (nread == 1)
       return NUM;
   }
-<NUM_MODE>[ \t]+	{ }
-<NUM_MODE>"\n"|.	{ yyless (0); BEGIN (INITIAL); }
+
+<NUM_MODE>[ \t]+ { }
+
+<NUM_MODE>"\n"|. {
+    yyless (0);
+    BEGIN (INITIAL);
+  }
 
-<MAYBE_NUM_MODE>"{"	{ BEGIN (NUM_MODE); return START; }
-<MAYBE_NUM_MODE>"\n"|.	{ yyless (0); BEGIN (INITIAL); }
+<MAYBE_NUM_MODE>"{" {
+    BEGIN (NUM_MODE);
+    return START;
+  }
+
+<MAYBE_NUM_MODE>"\n"|. {
+    yyless (0);
+    BEGIN (INITIAL);
+  }
 
 %{
-// Simple commands
+// Simple commands.
 %}
 
-"\\bf"		{ return BF; }
-"\\it"		{ return IT; }
-"\\sl"		{ return SL; }
-"\\rm"		{ return RM; }
+"\\bf" { return BF; }
+"\\it" { return IT; }
+"\\sl" { return SL; }
+"\\rm" { return RM; }
 
 %{
-// Generic font commands
+// Generic font commands.
 %}
 
-"\\fontname"	{ return FONTNAME; }
-"\\fontsize"	{ BEGIN (MAYBE_NUM_MODE); return FONTSIZE; }
-"\\color[rgb]"	{ BEGIN (MAYBE_NUM_MODE); return COLOR_RGB; }
-"\\color"	{ return COLOR; }
+"\\fontname" { return FONTNAME; }
+
+"\\fontsize" {
+    BEGIN (MAYBE_NUM_MODE);
+    return FONTSIZE;
+  }
+
+"\\color[rgb]" {
+    BEGIN (MAYBE_NUM_MODE);
+    return COLOR_RGB;
+  }
+
+"\\color" { return COLOR; }
 
 %{
-// Special characters
+// Special characters.
 %}
 
-"{"	{ return START; }
-"}"	{ return END; }
-"^"	{ return SUPER; }
-"_"	{ return SUB; }
+"{" { return START; }
+"}" { return END; }
+"^" { return SUPER; }
+"_" { return SUB; }
 
-"\\{"	|
-"\\}"	|
-"\\^"	|
-"\\_"	|
-"\\\\"	{ yylval->ch = yytext[1]; return CH; }
+"\\{"  |
+"\\}"  |
+"\\^"  |
+"\\_"  |
+"\\\\" {
+    yylval->ch = yytext[1];
+    return CH;
+  }
 
 %{
-// Symbols
+// Symbols.
 %}
 
 @SYMBOL_RULES@
 
 %{
-// Generic character
+// Generic character.
 %}
 
-"\n"	|
-.	{ yylval->ch = yytext[0]; return CH; }
+"\n" |
+.    {
+    yylval->ch = yytext[0];
+    return CH;
+  }
 
 %%
 
--- a/libinterp/corefcn/oct-tex-parser.in.yy	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct-tex-parser.in.yy	Thu Dec 10 12:50:06 2015 -0800
@@ -21,6 +21,7 @@
 */
 
 %{
+
 #define YYDEBUG 1
 
 #ifdef HAVE_CONFIG_H
@@ -34,15 +35,16 @@
 static void yyerror (text_parser_tex& parser, const char *s);
 
 #if defined (GNULIB_NAMESPACE)
-// Calls to the following functions appear in the generated output from
-// Bison without the namespace tag.  Redefine them so we will use them
-// via the gnulib namespace.
+// Calls to the following functions appear in the generated output
+// from Bison without the namespace tag.  Redefine them so we will use
+// them via the gnulib namespace.
 #define fclose GNULIB_NAMESPACE::fclose
 #define fprintf GNULIB_NAMESPACE::fprintf
 #define malloc GNULIB_NAMESPACE::malloc
 #endif
 
 #define scanner parser.get_scanner ()
+
 %}
 
 %API_PREFIX_DECL%
@@ -53,16 +55,17 @@
 
 %code requires {#include <string>}
 
-%union {
-  /* Leaf symbols produced by the scanner */
+%union
+{
+  // Leaf symbols produced by the scanner.
   char                       ch;
   double                     num;
   int                        sym;
 
-  /* Used for string buffering */
+  // Used for string buffering.
   std::string*               str;
 
-  /* Objects produced by the parser */
+  // Objects produced by the parser.
   text_element*              e_base;
   text_element_list*         e_list;
 }
@@ -78,10 +81,11 @@
 %type<str> simple_string
 %type<e_base> string_element symbol_element
 %type<e_base> superscript_element subscript_element combined_script_element
-%type<e_base> font_modifier_element fontname_element fontsize_element color_element
+%type<e_base> font_modifier_element fontname_element fontsize_element
+%type<e_base> color_element
 %type<e_list> string_element_list scoped_string_element_list
 
-/* Make sure there's no memory leak on parse error. */
+// Make sure there's no memory leak on parse error.
 %destructor { } <ch> <num> <sym>
 %destructor { delete $$; } <*>
 
@@ -95,105 +99,104 @@
 
 %%
 
-simple_string			: CH
-				  { $$ = new std::string (1, $1); }
-				| simple_string CH
-				  { $1->append (1, $2); $$ = $1; }
-				;
+simple_string                   : CH
+                                  { $$ = new std::string (1, $1); }
+                                | simple_string CH
+                                  { $1->append (1, $2); $$ = $1; }
+                                ;
 
-symbol_element			: SYM
-				  { $$ = new text_element_symbol ($1); }
-				;
+symbol_element                  : SYM
+                                  { $$ = new text_element_symbol ($1); }
+                                ;
 
-font_modifier_element		: BF
-				  { $$ = new text_element_fontstyle (text_element_fontstyle::bold); }
-				| IT
-				  { $$ = new text_element_fontstyle (text_element_fontstyle::italic); }
-				| SL
-				  { $$ = new text_element_fontstyle (text_element_fontstyle::oblique); }
-				| RM
-				  { $$ = new text_element_fontstyle (text_element_fontstyle::normal); }
-				;
+font_modifier_element           : BF
+                                  { $$ = new text_element_fontstyle (text_element_fontstyle::bold); }
+                                | IT
+                                  { $$ = new text_element_fontstyle (text_element_fontstyle::italic); }
+                                | SL
+                                  { $$ = new text_element_fontstyle (text_element_fontstyle::oblique); }
+                                | RM
+                                  { $$ = new text_element_fontstyle (text_element_fontstyle::normal); }
+                                ;
 
-fontsize_element		: FONTSIZE START NUM END
-				  { $$ = new text_element_fontsize ($3); }
-				;
+fontsize_element                : FONTSIZE START NUM END
+                                  { $$ = new text_element_fontsize ($3); }
+                                ;
 
-fontname_element		: FONTNAME START simple_string END
-				  {
-				    $$ = new text_element_fontname (*$3);
-				    delete $3;
-				  }
-				;
+fontname_element                : FONTNAME START simple_string END
+                                  {
+                                    $$ = new text_element_fontname (*$3);
+                                    delete $3;
+                                  }
+                                ;
 
-color_element			: COLOR START simple_string END
-				  {
-				    $$ = new text_element_color (*$3);
-				    delete $3;
-				  }
-				| COLOR_RGB START NUM NUM NUM END
-				  {
-				    $$ = new text_element_color ($3, $4, $5);
-				  }
-				;
+color_element                   : COLOR START simple_string END
+                                  {
+                                    $$ = new text_element_color (*$3);
+                                    delete $3;
+                                  }
+                                | COLOR_RGB START NUM NUM NUM END
+                                  {
+                                    $$ = new text_element_color ($3, $4, $5);
+                                  }
+                                ;
 
-string_element			: simple_string %prec STR
-				  {
-				    $$ = new text_element_string (*$1);
-				    delete $1;
-				  }
-				| scoped_string_element_list
-				  /* This is just to avoid a warning in bison. */
-				  { $$ = $1; }
-				| symbol_element
-				| font_modifier_element
-				| fontsize_element
-				| fontname_element
-				| color_element
-				| superscript_element %prec SCRIPT
-				| subscript_element %prec SCRIPT
-				| combined_script_element
-				;
+string_element                  : simple_string %prec STR
+                                  {
+                                    $$ = new text_element_string (*$1);
+                                    delete $1;
+                                  }
+                                | scoped_string_element_list
+                                  { $$ = $1; }
+                                | symbol_element
+                                | font_modifier_element
+                                | fontsize_element
+                                | fontname_element
+                                | color_element
+                                | superscript_element %prec SCRIPT
+                                | subscript_element %prec SCRIPT
+                                | combined_script_element
+                                ;
 
-superscript_element		: SUPER CH
-				  { $$ = new text_element_superscript ($2); }
-				| SUPER scoped_string_element_list
-				  { $$ = new text_element_superscript ($2); }
-				| SUPER symbol_element
-				  { $$ = new text_element_superscript ($2); }
-				;
+superscript_element             : SUPER CH
+                                  { $$ = new text_element_superscript ($2); }
+                                | SUPER scoped_string_element_list
+                                  { $$ = new text_element_superscript ($2); }
+                                | SUPER symbol_element
+                                  { $$ = new text_element_superscript ($2); }
+                                ;
 
-subscript_element		: SUB CH
-				  { $$ = new text_element_subscript ($2); }
-				| SUB scoped_string_element_list
-				  { $$ = new text_element_subscript ($2); }
-				| SUB symbol_element
-				  { $$ = new text_element_subscript ($2); }
-				;
+subscript_element               : SUB CH
+                                  { $$ = new text_element_subscript ($2); }
+                                | SUB scoped_string_element_list
+                                  { $$ = new text_element_subscript ($2); }
+                                | SUB symbol_element
+                                  { $$ = new text_element_subscript ($2); }
+                                ;
 
-combined_script_element		: subscript_element superscript_element
-				  { $$ = new text_element_combined ($1, $2); }
-				| superscript_element subscript_element
-				  { $$ = new text_element_combined ($1, $2); }
-				;
+combined_script_element         : subscript_element superscript_element
+                                  { $$ = new text_element_combined ($1, $2); }
+                                | superscript_element subscript_element
+                                  { $$ = new text_element_combined ($1, $2); }
+                                ;
 
-string_element_list		: string_element
-				  { $$ = new text_element_list ($1); }
-				| string_element_list string_element
-				  { $1->push_back ($2); $$ = $1; }
-				;
+string_element_list             : string_element
+                                  { $$ = new text_element_list ($1); }
+                                | string_element_list string_element
+                                  { $1->push_back ($2); $$ = $1; }
+                                ;
 
-scoped_string_element_list	: START string_element_list END
-				  { $$ = $2; }
-				| START END
-				  { $$ = new text_element_list (); }
-				;
+scoped_string_element_list      : START string_element_list END
+                                  { $$ = $2; }
+                                | START END
+                                  { $$ = new text_element_list (); }
+                                ;
 
-string				: /* empty */
-				  { parser.set_parse_result (new text_element_string ("")); }
-				| string_element_list
-				  { parser.set_parse_result ($1); }
-				;
+string                          : // empty
+                                  { parser.set_parse_result (new text_element_string ("")); }
+                                | string_element_list
+                                  { parser.set_parse_result ($1); }
+                                ;
 
 %%
 
--- a/libinterp/corefcn/oct.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/oct.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_h)
+#if ! defined (octave_oct_h)
 #define octave_oct_h 1
 
 // Things that are often included to create .oct files.
--- a/libinterp/corefcn/octave-link.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/octave-link.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -73,7 +73,7 @@
 octave_link::connect_link (octave_link* obj)
 {
   if (obj && instance)
-    ::error ("octave_link is already linked!");
+    error ("octave_link is already linked!");
   else
     instance = obj;
 }
@@ -122,29 +122,19 @@
 
   if (args.length () == 1)
     {
-      std::string file = args(0).string_value ();
+      std::string file = args(0).xstring_value ("first argument must be filename");
 
-      if (! error_state)
-        {
-          flush_octave_stdout ();
+      flush_octave_stdout ();
 
-          retval = octave_link::edit_file (file);
-        }
-      else
-        error ("expecting file name as argument");
+      retval = octave_link::edit_file (file);
     }
   else if (args.length () == 2)
     {
-      std::string file = args(0).string_value ();
+      std::string file = args(0).xstring_value ("first argument must be filename");
 
-      if (! error_state)
-        {
-          flush_octave_stdout ();
+      flush_octave_stdout ();
 
-          retval = octave_link::prompt_new_edit_file (file);
-        }
-      else
-        error ("expecting file name as first argument");
+      retval = octave_link::prompt_new_edit_file (file);
     }
 
   return retval;
@@ -160,18 +150,13 @@
 
   if (args.length () == 3)
     {
-      std::string dlg   = args(0).string_value ();
-      std::string msg   = args(1).string_value ();
-      std::string title = args(2).string_value ();
+      std::string dlg = args(0).xstring_value ("invalid arguments");
+      std::string msg = args(1).xstring_value ("invalid arguments");
+      std::string title = args(2).xstring_value ("invalid arguments");
 
-      if (! error_state)
-        {
-          flush_octave_stdout ();
+      flush_octave_stdout ();
 
-          retval = octave_link::message_dialog (dlg, msg, title);
-        }
-      else
-        error ("invalid arguments");
+      retval = octave_link::message_dialog (dlg, msg, title);
     }
 
   return retval;
@@ -187,22 +172,17 @@
 
   if (args.length () == 6)
     {
-      std::string msg    = args(0).string_value ();
-      std::string title  = args(1).string_value ();
-      std::string btn1   = args(2).string_value ();
-      std::string btn2   = args(3).string_value ();
-      std::string btn3   = args(4).string_value ();
-      std::string btndef = args(5).string_value ();
+      std::string msg = args(0).xstring_value ("invalid arguments");
+      std::string title = args(1).xstring_value ("invalid arguments");
+      std::string btn1 = args(2).xstring_value ("invalid arguments");
+      std::string btn2 = args(3).xstring_value ("invalid arguments");
+      std::string btn3 = args(4).xstring_value ("invalid arguments");
+      std::string btndef = args(5).xstring_value ("invalid arguments");
 
-      if (! error_state)
-        {
-          flush_octave_stdout ();
+      flush_octave_stdout ();
 
-          retval = octave_link::question_dialog (msg, title, btn1, btn2, btn3,
-                                                 btndef);
-        }
-      else
-        error ("invalid arguments");
+      retval = octave_link::question_dialog (msg, title, btn1, btn2, btn3,
+                                             btndef);
     }
 
   return retval;
@@ -234,55 +214,50 @@
                                               (flist.columns () > 1
                                                ? flist(i,1) : "")));
 
-      if (! error_state)
-        {
-          flush_octave_stdout ();
-
-          std::list<std::string> items_lst
-            = octave_link::file_dialog (filter_lst, title, filename, pathname,
-                                        multi_on);
-
-          nel = items_lst.size ();
+      flush_octave_stdout ();
 
-          retval.resize (3);
+      std::list<std::string> items_lst
+        = octave_link::file_dialog (filter_lst, title, filename, pathname,
+                                    multi_on);
 
-          // If 3, then retval is filename, directory, and selected index.
-          if (nel <= 3)
-            {
-              int idx = 0;
-              for (std::list<std::string>::iterator it = items_lst.begin ();
-                   it != items_lst.end (); it++)
-                {
-                  retval(idx++) = *it;
+      nel = items_lst.size ();
+
+      retval.resize (3);
 
-                  if (idx == 1 && retval(0).string_value ().length () == 0)
-                    retval(0) = 0;
-
-                  if (idx == 3)
-                    retval(2) = atoi (retval(2).string_value ().c_str ());
-                }
-            }
-          else
+      // If 3, then retval is filename, directory, and selected index.
+      if (nel <= 3)
+        {
+          int idx = 0;
+          for (std::list<std::string>::iterator it = items_lst.begin ();
+               it != items_lst.end (); it++)
             {
-              // Multiple files.
-              nel = items_lst.size () - 2;
-              Cell items (dim_vector (1, nel));
-
-              std::list<std::string>::iterator it = items_lst.begin ();
+              retval(idx++) = *it;
 
-              for (int idx = 0; idx < nel; idx++)
-                {
-                  items.xelem (idx) = *it;
-                  it++;
-                }
+              if (idx == 1 && retval(0).string_value ().length () == 0)
+                retval(0) = 0;
 
-              retval(0) = items;
-              retval(1) = *it++;
-              retval(2) = atoi (it->c_str ());
+              if (idx == 3)
+                retval(2) = atoi (retval(2).string_value ().c_str ());
             }
         }
       else
-        error ("invalid arguments");
+        {
+          // Multiple files.
+          nel = items_lst.size () - 2;
+          Cell items (dim_vector (1, nel));
+
+          std::list<std::string>::iterator it = items_lst.begin ();
+
+          for (int idx = 0; idx < nel; idx++)
+            {
+              items.xelem (idx) = *it;
+              it++;
+            }
+
+          retval(0) = items;
+          retval(1) = *it++;
+          retval(2) = atoi (it->c_str ());
+        }
     }
 
   return retval;
@@ -327,30 +302,25 @@
       std::string ok_string = args(6).string_value ();
       std::string cancel_string = args(7).string_value ();
 
-      if (! error_state)
-        {
-          flush_octave_stdout ();
+      flush_octave_stdout ();
 
-          std::pair<std::list<int>, int> result
-            = octave_link::list_dialog (list_lst, mode, width, height,
-                                        initial_lst, name, prompt_lst,
-                                        ok_string, cancel_string);
+      std::pair<std::list<int>, int> result
+        = octave_link::list_dialog (list_lst, mode, width, height,
+                                    initial_lst, name, prompt_lst,
+                                    ok_string, cancel_string);
 
-          std::list<int> items_lst = result.first;
-          nel = items_lst.size ();
-          Matrix items (dim_vector (1, nel));
-          octave_idx_type i = 0;
-          for (std::list<int>::iterator it = items_lst.begin ();
-               it != items_lst.end (); it++)
-            {
-              items.xelem(i++) = *it;
-            }
+      std::list<int> items_lst = result.first;
+      nel = items_lst.size ();
+      Matrix items (dim_vector (1, nel));
+      octave_idx_type i = 0;
+      for (std::list<int>::iterator it = items_lst.begin ();
+           it != items_lst.end (); it++)
+        {
+          items.xelem(i++) = *it;
+        }
 
-          retval(1) = result.second;
-          retval(0) = items;
-        }
-      else
-        error ("invalid arguments");
+      retval(1) = result.second;
+      retval(0) = items;
     }
 
   return retval;
@@ -392,27 +362,22 @@
       for (octave_idx_type i = 0; i < nel; i++)
         defaults_lst.push_back (tmp(i));
 
-      if (! error_state)
-        {
-          flush_octave_stdout ();
+      flush_octave_stdout ();
 
-          std::list<std::string> items_lst
-            = octave_link::input_dialog (prompt_lst, title, nr, nc,
-                                         defaults_lst);
+      std::list<std::string> items_lst
+        = octave_link::input_dialog (prompt_lst, title, nr, nc,
+                                     defaults_lst);
 
-          nel = items_lst.size ();
-          Cell items (dim_vector (nel, 1));
-          octave_idx_type i = 0;
-          for (std::list<std::string>::iterator it = items_lst.begin ();
-               it != items_lst.end (); it++)
-            {
-              items.xelem(i++) = *it;
-            }
+      nel = items_lst.size ();
+      Cell items (dim_vector (nel, 1));
+      octave_idx_type i = 0;
+      for (std::list<std::string>::iterator it = items_lst.begin ();
+           it != items_lst.end (); it++)
+        {
+          items.xelem(i++) = *it;
+        }
 
-          retval = items;
-        }
-      else
-        error ("invalid arguments");
+      retval = items;
     }
 
   return retval;
--- a/libinterp/corefcn/octave-link.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/octave-link.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 */
 
-#if !defined (octave_octave_link_h)
+#if ! defined (octave_octave_link_h)
 #define octave_octave_link_h 1
 
 #include <string>
--- a/libinterp/corefcn/ordschur.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/ordschur.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -107,35 +107,21 @@
 @seealso{schur}\n\
 @end deftypefn")
 {
-  const octave_idx_type nargin = args.length ();
   octave_value_list retval;
 
-  if (nargin != 3)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 3)
+    print_usage ();
 
-  const Array<octave_idx_type> sel = args(2).octave_idx_type_vector_value ();
-  if (error_state)
-    {
-      error ("ordschur: SELECT must be an array of integers");
-      return retval;
-    }
+  const Array<octave_idx_type> sel = args(2).octave_idx_type_vector_value ("ordschur: SELECT must be an array of integers");
+
   const octave_idx_type n = sel.numel ();
 
   const dim_vector dimU = args(0).dims ();
   const dim_vector dimS = args(1).dims ();
   if (n != dimU(0))
-    {
-      error ("ordschur: SELECT must have same length as the sides of U and S");
-      return retval;
-    }
+    error ("ordschur: SELECT must have same length as the sides of U and S");
   else if (n != dimU(0) || n != dimS(0) || n != dimU(1) || n != dimS(1))
-    {
-      error ("ordschur: U and S must be square and of equal sizes");
-      return retval;
-    }
+    error ("ordschur: U and S must be square and of equal sizes");
 
   const bool double_type  = args(0).is_double_type ()
                             || args(1).is_double_type ();
@@ -143,13 +129,8 @@
                             || args(1).is_complex_type ();
 
 #define PREPARE_ARGS(TYPE, TYPE_M, TYPE_COND) \
-          TYPE ## Matrix U = args(0).TYPE_M ## _value (); \
-          TYPE ## Matrix S = args(1).TYPE_M ## _value (); \
-          if (error_state) \
-            { \
-              error ("ordschur: U and S must be real or complex floating point matrices"); \
-              return retval; \
-            } \
+          TYPE ## Matrix U = args(0).x ## TYPE_M ## _value ("ordschur: U and S must be real or complex floating point matrices"); \
+          TYPE ## Matrix S = args(1).x ## TYPE_M ## _value ("ordschur: U and S must be real or complex floating point matrices"); \
           TYPE ## Matrix w (dim_vector (n, 1)); \
           TYPE ## Matrix work (dim_vector (n, 1)); \
           octave_idx_type m; \
@@ -158,10 +139,8 @@
 
 #define PREPARE_OUTPUT()\
           if (info != 0) \
-            { \
-              error ("ordschur: trsen failed"); \
-              return retval; \
-            } \
+            error ("ordschur: trsen failed"); \
+ \
           retval(0) = U; \
           retval(1) = S;
 
--- a/libinterp/corefcn/pager.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/pager.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -381,7 +381,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create pager_stream object!");
+      error ("unable to create pager_stream object!");
 
       retval = false;
     }
@@ -446,7 +446,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create diary_stream object!");
+      error ("unable to create diary_stream object!");
 
       retval = false;
     }
@@ -539,54 +539,42 @@
 @seealso{history}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
-  int argc = args.length () + 1;
+  int nargin = args.length ();
 
-  string_vector argv = args.make_argv ("diary");
-
-  if (error_state)
-    return retval;
+  if (nargin > 1)
+    print_usage ();
 
   if (diary_file.empty ())
     diary_file = "diary";
 
-  switch (argc)
+  if (nargin == 0)
     {
-    case 1:
       write_to_diary_file = ! write_to_diary_file;
       open_diary_file ();
-      break;
-
-    case 2:
-      {
-        std::string arg = argv[1];
+    }
+  else
+    {
+      std::string arg = args(0).xstring_value ("diary: argument must be a string");
 
-        if (arg == "on")
-          {
-            write_to_diary_file = true;
-            open_diary_file ();
-          }
-        else if (arg == "off")
-          {
-            close_diary_file ();
-            write_to_diary_file = false;
-          }
-        else
-          {
-            diary_file = arg;
-            write_to_diary_file = true;
-            open_diary_file ();
-          }
-      }
-      break;
-
-    default:
-      print_usage ();
-      break;
+      if (arg == "on")
+        {
+          write_to_diary_file = true;
+          open_diary_file ();
+        }
+      else if (arg == "off")
+        {
+          close_diary_file ();
+          write_to_diary_file = false;
+        }
+      else
+        {
+          diary_file = arg;
+          write_to_diary_file = true;
+          open_diary_file ();
+        }
     }
 
-  return retval;
+  return octave_value ();
 }
 
 DEFUN (__diaryfile__, , ,
@@ -624,10 +612,10 @@
 
   int argc = args.length () + 1;
 
-  string_vector argv = args.make_argv ("more");
+  if (argc < 1 || argc > 2)
+    print_usage ();
 
-  if (error_state)
-    return retval;
+  string_vector argv = args.make_argv ("more");
 
   if (argc == 2)
     {
@@ -640,10 +628,8 @@
       else
         error ("more: unrecognized argument '%s'", arg.c_str ());
     }
-  else if (argc == 1)
+  else
     Vpage_screen_output = ! Vpage_screen_output;
-  else
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/corefcn/pager.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/pager.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pager_h)
+#if ! defined (octave_pager_h)
 #define octave_pager_h 1
 
 #include <iosfwd>
--- a/libinterp/corefcn/pinv.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/pinv.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -59,10 +59,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
 
@@ -83,14 +80,8 @@
           if (nargin == 2)
             tol = args(1).float_value ();
 
-          if (error_state)
-            return retval;
-
           if (tol < 0.0)
-            {
-              error ("pinv: TOL must be greater than zero");
-              return retval;
-            }
+            error ("pinv: TOL must be greater than zero");
 
           if (arg.is_real_type ())
             retval = arg.float_diag_matrix_value ().pseudo_inverse (tol);
@@ -103,14 +94,8 @@
           if (nargin == 2)
             tol = args(1).double_value ();
 
-          if (error_state)
-            return retval;
-
           if (tol < 0.0)
-            {
-              error ("pinv: TOL must be greater than zero");
-              return retval;
-            }
+            error ("pinv: TOL must be greater than zero");
 
           if (arg.is_real_type ())
             retval = arg.diag_matrix_value ().pseudo_inverse (tol);
@@ -128,33 +113,23 @@
       if (nargin == 2)
         tol = args(1).float_value ();
 
-      if (error_state)
-        return retval;
-
       if (tol < 0.0)
-        {
-          error ("pinv: TOL must be greater than zero");
-          return retval;
-        }
+        error ("pinv: TOL must be greater than zero");
 
       if (arg.is_real_type ())
         {
           FloatMatrix m = arg.float_matrix_value ();
 
-          if (! error_state)
-            retval = m.pseudo_inverse (tol);
+          retval = m.pseudo_inverse (tol);
         }
       else if (arg.is_complex_type ())
         {
           FloatComplexMatrix m = arg.float_complex_matrix_value ();
 
-          if (! error_state)
-            retval = m.pseudo_inverse (tol);
+          retval = m.pseudo_inverse (tol);
         }
       else
-        {
-          gripe_wrong_type_arg ("pinv", arg);
-        }
+        gripe_wrong_type_arg ("pinv", arg);
     }
   else
     {
@@ -162,33 +137,23 @@
       if (nargin == 2)
         tol = args(1).double_value ();
 
-      if (error_state)
-        return retval;
-
       if (tol < 0.0)
-        {
-          error ("pinv: TOL must be greater than zero");
-          return retval;
-        }
+        error ("pinv: TOL must be greater than zero");
 
       if (arg.is_real_type ())
         {
           Matrix m = arg.matrix_value ();
 
-          if (! error_state)
-            retval = m.pseudo_inverse (tol);
+          retval = m.pseudo_inverse (tol);
         }
       else if (arg.is_complex_type ())
         {
           ComplexMatrix m = arg.complex_matrix_value ();
 
-          if (! error_state)
-            retval = m.pseudo_inverse (tol);
+          retval = m.pseudo_inverse (tol);
         }
       else
-        {
-          gripe_wrong_type_arg ("pinv", arg);
-        }
+        gripe_wrong_type_arg ("pinv", arg);
     }
 
   return retval;
--- a/libinterp/corefcn/pr-output.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/pr-output.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -393,8 +393,8 @@
             }
 
           frac = flip - step;
-          n = n * step + lastn;
-          d = d * step + lastd;
+          n = step * n + lastn;
+          d = step * d + lastd;
           lastn = nextn;
           lastd = nextd;
 
@@ -2664,7 +2664,7 @@
   double base = r.base ();
   double increment = r.inc ();
   double limit = r.limit ();
-  octave_idx_type num_elem = r.nelem ();
+  octave_idx_type num_elem = r.numel ();
 
   if (plus_format && ! pr_as_read_syntax)
     {
@@ -2886,7 +2886,7 @@
 
   if (nda.is_empty ())
     print_empty_nd_array (os, nda.dims (), pr_as_read_syntax);
-  else if (nda.length () == 1)
+  else if (nda.numel () == 1)
     {
       os << nda(0);
     }
@@ -3155,7 +3155,7 @@
 
   if (nda.is_empty ())
     print_empty_nd_array (os, nda.dims (), pr_as_read_syntax);
-  else if (nda.length () == 1)
+  else if (nda.numel () == 1)
     octave_print_internal_template (os, nda(0), pr_as_read_syntax);
   else if (plus_format && ! pr_as_read_syntax)
     {
@@ -3431,58 +3431,53 @@
 
   if (nargin < 1 || nargin > 2 || nargout > 1)
     print_usage ();
-  else
+
+  unwind_protect frame;
+
+  frame.protect_var (rat_string_len);
+
+  rat_string_len = 9;
+
+  if (nargin == 2)
+    rat_string_len = args(1).nint_value ();
+
+  octave_value arg = args(0);
+
+  if (arg.is_numeric_type ())
     {
-      unwind_protect frame;
-
-      frame.protect_var (rat_string_len);
-
-      rat_string_len = 9;
-
-      if (nargin == 2)
-        rat_string_len = args(1).nint_value ();
-
-      if (! error_state)
+      frame.protect_var (rat_format);
+
+      rat_format = true;
+
+      std::ostringstream buf;
+      arg.print (buf);
+      std::string s = buf.str ();
+
+      std::list<std::string> lst;
+
+      size_t n = 0;
+      size_t s_len = s.length ();
+
+      while (n < s_len)
         {
-          octave_value arg = args(0);
-
-          if (arg.is_numeric_type ())
+          size_t m = s.find ('\n',  n);
+
+          if (m == std::string::npos)
             {
-              frame.protect_var (rat_format);
-
-              rat_format = true;
-
-              std::ostringstream buf;
-              arg.print (buf);
-              std::string s = buf.str ();
-
-              std::list<std::string> lst;
-
-              size_t n = 0;
-              size_t s_len = s.length ();
-
-              while (n < s_len)
-                {
-                  size_t m = s.find ('\n',  n);
-
-                  if (m == std::string::npos)
-                    {
-                      lst.push_back (s.substr (n));
-                      break;
-                    }
-                  else
-                    {
-                      lst.push_back (s.substr (n, m - n));
-                      n = m + 1;
-                    }
-                }
-
-              retval = string_vector (lst);
+              lst.push_back (s.substr (n));
+              break;
             }
           else
-            error ("rats: X must be numeric");
+            {
+              lst.push_back (s.substr (n, m - n));
+              n = m + 1;
+            }
         }
+
+      retval = string_vector (lst);
     }
+  else
+    error ("rats: X must be numeric");
 
   return retval;
 }
@@ -3513,23 +3508,19 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 1 && nargout < 2)
+  if (args.length () != 1 || nargout > 1)
+    print_usage ();
+
+  octave_value arg = args(0);
+
+  if (nargout == 0)
+    arg.print (octave_stdout);
+  else
     {
-      octave_value arg = args(0);
-
-      if (nargout == 0)
-        arg.print (octave_stdout);
-      else
-        {
-          std::ostringstream buf;
-          arg.print (buf);
-          retval = octave_value (buf.str (), arg.is_dq_string () ? '"' : '\'');
-        }
+      std::ostringstream buf;
+      arg.print (buf);
+      retval = octave_value (buf.str (), arg.is_dq_string () ? '"' : '\'');
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -3557,28 +3548,21 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 2)
-    {
-      int fid = octave_stream_list::get_file_number (args(0));
-
-      octave_stream os = octave_stream_list::lookup (fid, "fdisp");
-
-      if (! error_state)
-        {
-          std::ostream *osp = os.output_stream ();
-
-          octave_value arg = args(1);
-
-          if (osp)
-            arg.print (*osp);
-          else
-            error ("fdisp: stream FID not open for writing");
-        }
-    }
+  if (args.length () != 2)
+    print_usage ();
+
+  int fid = octave_stream_list::get_file_number (args(0));
+
+  octave_stream os = octave_stream_list::lookup (fid, "fdisp");
+
+  std::ostream *osp = os.output_stream ();
+
+  octave_value arg = args(1);
+
+  if (osp)
+    arg.print (*osp);
   else
-    print_usage ();
+    error ("fdisp: stream FID not open for writing");
 
   return retval;
 }
@@ -3681,11 +3665,7 @@
                   print_eng = true;
                 }
               else
-                {
-                  error ("format: unrecognized option 'short %s'",
-                         arg.c_str ());
-                  return;
-                }
+                error ("format: unrecognized option 'short %s'", arg.c_str ());
             }
           else
             init_format_state ();
@@ -3759,11 +3739,7 @@
                   print_eng = true;
                 }
               else
-                {
-                  error ("format: unrecognized option 'long %s'",
-                         arg.c_str ());
-                  return;
-                }
+                error ("format: unrecognized option 'long %s'", arg.c_str ());
             }
           else
             init_format_state ();
@@ -3832,10 +3808,7 @@
               if (arg.length () == 3)
                 plus_format_chars = arg;
               else
-                {
-                  error ("format: invalid option for plus format");
-                  return;
-                }
+                error ("format: invalid option for plus format");
             }
           else
             plus_format_chars = "+- ";
@@ -3874,10 +3847,7 @@
           return;
         }
       else
-        {
-          error ("format: unrecognized format state '%s'", arg.c_str ());
-          return;
-        }
+        error ("format: unrecognized format state '%s'", arg.c_str ());
     }
   else
     {
@@ -4069,9 +4039,6 @@
 
   string_vector argv = args.make_argv ("format");
 
-  if (error_state)
-    return retval;
-
   set_format_style (argc, argv);
 
   return retval;
--- a/libinterp/corefcn/pr-output.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/pr-output.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pr_output_h)
+#if ! defined (octave_pr_output_h)
 #define octave_pr_output_h 1
 
 #include <iosfwd>
--- a/libinterp/corefcn/procstream.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/procstream.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_procstream_h)
+#if ! defined (octave_procstream_h)
 #define octave_procstream_h 1
 
 #include <istream>
--- a/libinterp/corefcn/profiler.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/profiler.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -265,10 +265,7 @@
 profile_data_accumulator::reset (void)
 {
   if (is_active ())
-    {
-      error ("Can't reset active profiler.");
-      return;
-    }
+    error ("Can't reset active profiler.");
 
   known_functions.clear ();
   fcn_index.clear ();
@@ -401,23 +398,15 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
+  int nargin = args.length ();
 
-  const int nargin = args.length ();
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin > 0)
-    {
-      if (nargin > 1)
-        {
-          print_usage ();
-          return retval;
-        }
+    profiler.set_active (args(0).bool_value ());
 
-      profiler.set_active (args(0).bool_value ());
-    }
-
-  retval(0) = profiler.is_active ();
-
-  return retval;
+  return octave_value (profiler.is_active ());
 }
 
 // Clear all collected profiling data.
@@ -428,9 +417,8 @@
 @end deftypefn")
 {
   octave_value_list retval;
-  const int nargin = args.length ();
 
-  if (nargin > 0)
+  if (args.length () > 0)
     warning ("profiler_reset: ignoring extra arguments");
 
   profiler.reset ();
@@ -446,9 +434,8 @@
 @end deftypefn")
 {
   octave_value_list retval;
-  const int nargin = args.length ();
 
-  if (nargin > 0)
+  if (args.length () > 0)
     warning ("profiler_data: ignoring extra arguments");
 
   if (nargout > 1)
--- a/libinterp/corefcn/profiler.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/profiler.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_profiler_h)
+#if ! defined (octave_profiler_h)
 #define octave_profiler_h 1
 
 #include <cstddef>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/corefcn/psi.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,224 @@
+/*
+
+Copyright (C) 2015 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/>.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "ov.h"
+#include "defun.h"
+#include "error.h"
+#include "dNDArray.h"
+#include "fNDArray.h"
+
+#include "lo-specfun.h"
+
+DEFUN (psi, args, ,
+"-*- texinfo -*-\n\
+@deftypefn  {Function File} {} psi (@var{z})\n\
+@deftypefnx {Function File} {} psi (@var{k}, @var{z})\n\
+Compute the psi (polygamma) function.\n\
+\n\
+The polygamma functions are the @var{k}th derivative of the logarithm\n\
+of the gamma function.  If unspecified, @var{k} defaults to zero.  A value\n\
+of zero computes the digamma function, a value of 1, the trigamma function,\n\
+and so on.\n\
+\n\
+The digamma function is defined:\n\
+\n\
+@tex\n\
+$$\n\
+\\Psi (z) = {d (log (\\Gamma (z))) \\over dx}\n\
+$$\n\
+@end tex\n\
+@ifnottex\n\
+@example\n\
+@group\n\
+psi (z) = d (log (gamma (z))) / dx\n\
+@end group\n\
+@end example\n\
+@end ifnottex\n\
+\n\
+When computing the digamma function (when @var{k} equals zero), @var{z}\n\
+can have any value real or complex value.  However, for polygamma functions\n\
+(@var{k} higher than 0), @var{z} must be real and non-negative.\n\
+\n\
+@seealso{gamma, gammainc, gammaln}\n\
+@end deftypefn")
+{
+  octave_value retval;
+
+  const octave_idx_type nargin = args.length ();
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  const octave_value oct_z = (nargin == 1) ? args(0) : args(1);
+  const octave_idx_type k = (nargin == 1) ? 0 : args(0).idx_type_value ("psi: K must be an integer");
+  if (k < 0)
+    error ("psi: K must be non-negative");
+  else if (k == 0)
+    {
+#define FLOAT_BRANCH(T, A, M, E) \
+      if (oct_z.is_ ## T ##_type ()) \
+        { \
+          const A ## NDArray z = oct_z.M ## array_value (); \
+          A ## NDArray psi_z (z.dims ()); \
+ \
+          const E* zv = z.data (); \
+          E* psi_zv = psi_z.fortran_vec (); \
+          const octave_idx_type n = z.numel (); \
+          for (octave_idx_type i = 0; i < n; i++) \
+            *psi_zv++ = psi (*zv++); \
+ \
+          retval = psi_z; \
+        }
+
+      if (oct_z.is_complex_type ())
+        {
+          FLOAT_BRANCH(double, Complex, complex_, Complex)
+          else FLOAT_BRANCH(single, FloatComplex, float_complex_, FloatComplex)
+          else
+            error ("psi: Z must be a floating point");
+        }
+      else
+        {
+          FLOAT_BRANCH(double, , , double)
+          else FLOAT_BRANCH(single, Float, float_, float)
+          else
+            error ("psi: Z must be a floating point");
+        }
+
+#undef FLOAT_BRANCH
+    }
+  else
+    {
+      if (! oct_z.is_real_type ())
+        error ("psi: Z must be real value for polygamma (K > 0)");
+
+#define FLOAT_BRANCH(T, A, M, E) \
+      if (oct_z.is_ ## T ##_type ()) \
+        { \
+          const A ## NDArray z = oct_z.M ## array_value (); \
+          A ## NDArray psi_z (z.dims ()); \
+ \
+          const E* zv = z.data (); \
+          E* psi_zv = psi_z.fortran_vec (); \
+          const octave_idx_type n = z.numel (); \
+          for (octave_idx_type i = 0; i < n; i++) \
+            { \
+              if (*zv < 0) \
+                error ("psi: Z must be non-negative for polygamma (K > 0)"); \
+ \
+              *psi_zv++ = psi (k, *zv++); \
+            } \
+          retval = psi_z; \
+        }
+
+      FLOAT_BRANCH(double, , , double)
+      else FLOAT_BRANCH(single, Float, float_, float)
+      else
+        error ("psi: Z must be a floating point for polygamma (K > 0)");
+
+#undef FLOAT_BRANCH
+    }
+
+  return retval;
+}
+
+/*
+%!shared em
+%! em = 0.577215664901532860606512090082402431042; # Euler-Mascheroni Constant
+
+%!assert (psi (ones (7, 3, 5)), repmat (-em, [7 3 5]))
+%!assert (psi ([0 1]), [-Inf -em])
+%!assert (psi ([-20:1]), [repmat(-Inf, [1 21]) -em])
+%!assert (psi (single ([0 1])), single ([-Inf -em]))
+
+## Abramowitz and Stegun, page 258, eq 6.3.5
+%!test
+%! z = [-100:-1 1:200] ./ 10; # drop the 0
+%! assert (psi (z + 1), psi (z) + 1 ./ z, eps*1000)
+
+## Abramowitz and Stegun, page 258, eq 6.3.2
+%!assert (psi (1), -em)
+
+## Abramowitz and Stegun, page 258, eq 6.3.3
+%!assert (psi (1/2), -em - 2 * log (2))
+
+## The following tests are from Pascal Sebah and Xavier Gourdon (2002)
+## "Introduction to the Gamma Function"
+
+## Interesting identities of the digamma function, in section of 5.1.3
+%!assert (psi (1/3), - em - (3/2) * log(3) - ((sqrt (3) / 6) * pi), eps*10)
+%!assert (psi (1/4), - em -3 * log (2) - pi/2, eps*10)
+%!assert (psi (1/6), - em -2 * log (2) - (3/2) * log (3) - ((sqrt (3) / 2) * pi), eps*10)
+
+## First 6 zeros of the digamma function, in section of 5.1.5 (and also on
+## Abramowitz and Stegun, page 258, eq 6.3.19)
+%!assert (psi ( 1.46163214496836234126265954232572132846819620400644), 0, eps)
+%!assert (psi (-0.504083008264455409258269304533302498955385182368579), 0, eps)
+%!assert (psi (-1.573498473162390458778286043690434612655040859116846), 0, eps)
+%!assert (psi (-2.610720868444144650001537715718724207951074010873480), 0, eps*10)
+%!assert (psi (-3.635293366436901097839181566946017713948423861193530), 0, eps*10)
+%!assert (psi (-4.653237761743142441714598151148207363719069416133868), 0, eps*100)
+
+## Tests for complex values
+%!shared z
+%! z = [-100:-1 1:200] ./ 10; # drop the 0
+
+## Abramowitz and Stegun, page 259 eq 6.3.10
+%!assert (real (psi (i*z)), real (psi (1 - i*z)))
+
+## Abramowitz and Stegun, page 259 eq 6.3.11
+%!assert (imag (psi (i*z)), 1/2 .* 1./z + 1/2 * pi * coth (pi * z), eps *10)
+
+## Abramowitz and Stegun, page 259 eq 6.3.12
+%!assert (imag (psi (1/2 + i*z)), 1/2 * pi * tanh (pi * z), eps*10)
+
+## Abramowitz and Stegun, page 259 eq 6.3.13
+%!assert (imag (psi (1 + i*z)), - 1./(2*z) + 1/2 * pi * coth (pi * z), eps*10)
+
+## Abramowitz and Stegun, page 260 eq 6.4.5
+%!test
+%! for z = 0:20
+%!   assert (psi (1, z + 0.5), 0.5 * (pi^2) - 4 * sum ((2*(1:z) -1) .^(-2)), eps*10)
+%! endfor
+
+## Abramowitz and Stegun, page 260 eq 6.4.6
+%!test
+%! z = 0.1:0.1:20;
+%! for n = 0:8
+%!   ## our precision goes down really quick when computing n is too high,
+%!   assert (psi (n, z+1), psi (n, z) + ((-1)^n) * factorial (n) * (z.^(-n-1)), 0.1)
+%! endfor
+
+## Test input validation
+%!error psi ()
+%!error psi (1, 2, 3)
+%!error <Z must be> psi ("non numeric")
+%!error <conversion of 5.3 to int value failed> psi (5.3, 1)
+%!error <K must be non-negative> psi (-5, 1)
+%!error <Z must be non-negative for polygamma> psi (5, -1)
+%!error <Z must be a floating point> psi (5, uint8 (-1))
+%!error <Z must be real value for polygamma> psi (5, 5i)
+
+*/
--- a/libinterp/corefcn/pt-jit.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/pt-jit.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -2170,7 +2170,7 @@
   if (bounds.is_range ())
     {
       Range rng = bounds.range_value ();
-      return rng.nelem ();
+      return rng.numel ();
     }
 
   // unsupported type
--- a/libinterp/corefcn/pt-jit.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/pt-jit.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 // Author: Max Brister <max@2bass.com>
 
-#if !defined (octave_pt_jit_h)
+#if ! defined (octave_pt_jit_h)
 #define octave_pt_jit_h 1
 
 #ifdef HAVE_LLVM
--- a/libinterp/corefcn/quad.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/quad.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -67,13 +67,15 @@
 
   if (quad_fcn)
     {
-      octave_value_list tmp = quad_fcn->do_multi_index_op (1, args);
+      octave_value_list tmp;
 
-      if (error_state)
+      try
         {
-          quad_integration_error = 1;  // FIXME
-          gripe_user_supplied_eval ("quad");
-          return retval;
+          tmp = quad_fcn->do_multi_index_op (1, args);
+        }
+      catch (octave_execution_exception& e)
+        {
+          gripe_user_supplied_eval (e, "quad");
         }
 
       if (tmp.length () && tmp(0).is_defined ())
@@ -84,19 +86,10 @@
               warned_imaginary = true;
             }
 
-          retval = tmp(0).double_value ();
-
-          if (error_state)
-            {
-              quad_integration_error = 1;  // FIXME
-              gripe_user_supplied_eval ("quad");
-            }
+          retval = tmp(0).xdouble_value ("quad: expecting user supplied function to return numeric value");
         }
       else
-        {
-          quad_integration_error = 1;  // FIXME
-          gripe_user_supplied_eval ("quad");
-        }
+        gripe_user_supplied_eval ("quad");
     }
 
   return retval;
@@ -112,13 +105,15 @@
 
   if (quad_fcn)
     {
-      octave_value_list tmp = quad_fcn->do_multi_index_op (1, args);
+      octave_value_list tmp;
 
-      if (error_state)
+      try
         {
-          quad_integration_error = 1;  // FIXME
-          gripe_user_supplied_eval ("quad");
-          return retval;
+          tmp = quad_fcn->do_multi_index_op (1, args);
+        }
+      catch (octave_execution_exception& e)
+        {
+          gripe_user_supplied_eval (e, "quad");
         }
 
       if (tmp.length () && tmp(0).is_defined ())
@@ -129,49 +124,16 @@
               warned_imaginary = true;
             }
 
-          retval = tmp(0).float_value ();
+          retval = tmp(0).xfloat_value ("quad: expecting user supplied function to return numeric value");
 
-          if (error_state)
-            {
-              quad_integration_error = 1;  // FIXME
-              gripe_user_supplied_eval ("quad");
-            }
         }
       else
-        {
-          quad_integration_error = 1;  // FIXME
-          gripe_user_supplied_eval ("quad");
-        }
+        gripe_user_supplied_eval ("quad");
     }
 
   return retval;
 }
 
-#define QUAD_ABORT() \
-  do \
-    { \
-      if (fcn_name.length ()) \
-        clear_function (fcn_name); \
-      return retval; \
-    } \
-  while (0)
-
-#define QUAD_ABORT1(msg) \
-  do \
-    { \
-      ::error ("quad: " msg); \
-      QUAD_ABORT (); \
-    } \
-  while (0)
-
-#define QUAD_ABORT2(fmt, arg) \
-  do \
-    { \
-      ::error ("quad: " fmt, arg); \
-      QUAD_ABORT (); \
-    } \
-  while (0)
-
 DEFUN (quad, args, nargout,
        "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {@var{q} =} quad (@var{f}, @var{a}, @var{b})\n\
@@ -230,250 +192,223 @@
   call_depth++;
 
   if (call_depth > 1)
-    QUAD_ABORT1 ("invalid recursive call");
+    error ("quad: invalid recursive call");
 
   int nargin = args.length ();
 
-  if (nargin > 2 && nargin < 6 && nargout < 5)
+  if (nargin < 3 || nargin > 5 || nargout > 4)
+    print_usage ();
+
+  if (args(0).is_function_handle () || args(0).is_inline_function ())
+    quad_fcn = args(0).function_value ();
+  else
     {
-      if (args(0).is_function_handle () || args(0).is_inline_function ())
-        quad_fcn = args(0).function_value ();
-      else
+      fcn_name = unique_symbol_name ("__quad_fcn__");
+      std::string fname = "function y = ";
+      fname.append (fcn_name);
+      fname.append ("(x) y = ");
+      quad_fcn = extract_function (args(0), "quad", fcn_name, fname,
+                                   "; endfunction");
+      frame.add_fcn (clear_function, fcn_name);
+    }
+
+  if (! quad_fcn)
+    error ("quad: FCN argument is not a valid function name or handle");
+
+  if (args(1).is_single_type () || args(2).is_single_type ())
+    {
+      float a = args(1).xfloat_value ("quad: lower limit of integration A must be a scalar");
+      float b = args(2).xfloat_value ("quad: upper limit of integration B must be a scalar");
+
+      int indefinite = 0;
+      FloatIndefQuad::IntegralType indef_type
+        = FloatIndefQuad::doubly_infinite;
+      float bound = 0.0;
+      if (xisinf (a) && xisinf (b))
         {
-          fcn_name = unique_symbol_name ("__quad_fcn__");
-          std::string fname = "function y = ";
-          fname.append (fcn_name);
-          fname.append ("(x) y = ");
-          quad_fcn = extract_function (args(0), "quad", fcn_name, fname,
-                                       "; endfunction");
+          indefinite = 1;
+          indef_type = FloatIndefQuad::doubly_infinite;
+        }
+      else if (xisinf (a))
+        {
+          indefinite = 1;
+          bound = b;
+          indef_type = FloatIndefQuad::neg_inf_to_bound;
+        }
+      else if (xisinf (b))
+        {
+          indefinite = 1;
+          bound = a;
+          indef_type = FloatIndefQuad::bound_to_inf;
         }
 
-      if (! quad_fcn)
-        QUAD_ABORT ();
-
-      if (args(1).is_single_type () || args(2).is_single_type ())
-        {
-          float a = args(1).float_value ();
-
-          if (error_state)
-            QUAD_ABORT1 ("expecting second argument to be a scalar");
-
-          float b = args(2).float_value ();
-
-          if (error_state)
-            QUAD_ABORT1 ("expecting third argument to be a scalar");
+      octave_idx_type ier = 0;
+      octave_idx_type nfun = 0;
+      float abserr = 0.0;
+      float val = 0.0;
+      bool have_sing = false;
+      FloatColumnVector sing;
+      FloatColumnVector tol;
 
-          int indefinite = 0;
-          FloatIndefQuad::IntegralType indef_type
-            = FloatIndefQuad::doubly_infinite;
-          float bound = 0.0;
-          if (xisinf (a) && xisinf (b))
-            {
-              indefinite = 1;
-              indef_type = FloatIndefQuad::doubly_infinite;
-            }
-          else if (xisinf (a))
-            {
-              indefinite = 1;
-              bound = b;
-              indef_type = FloatIndefQuad::neg_inf_to_bound;
-            }
-          else if (xisinf (b))
-            {
-              indefinite = 1;
-              bound = a;
-              indef_type = FloatIndefQuad::bound_to_inf;
-            }
+      switch (nargin)
+        {
+        case 5:
+          if (indefinite)
+            error ("quad: singularities not allowed on infinite intervals");
 
-          octave_idx_type ier = 0;
-          octave_idx_type nfun = 0;
-          float abserr = 0.0;
-          float val = 0.0;
-          bool have_sing = false;
-          FloatColumnVector sing;
-          FloatColumnVector tol;
+          have_sing = true;
+
+          sing = args(4).xfloat_vector_value ("quad: fifth argument SING must be a vector vector of singularities");
 
-          switch (nargin)
+        case 4:
+          tol = args(3).xfloat_vector_value ("quad: TOL must be a 1 or 2-element vector");
+
+          switch (tol.numel ())
             {
-            case 5:
-              if (indefinite)
-                QUAD_ABORT1 ("singularities not allowed on infinite intervals");
-
-              have_sing = true;
-
-              sing = FloatColumnVector (args(4).float_vector_value ());
-
-              if (error_state)
-                QUAD_ABORT1 ("expecting vector of singularities as fourth argument");
-
-            case 4:
-              tol = FloatColumnVector (args(3).float_vector_value ());
-
-              if (error_state)
-                QUAD_ABORT1 ("expecting vector of tolerances as fifth argument");
-
-              switch (tol.capacity ())
-                {
-                case 2:
-                  quad_opts.set_single_precision_relative_tolerance (tol (1));
-
-                case 1:
-                  quad_opts.set_single_precision_absolute_tolerance (tol (0));
-                  break;
+            case 2:
+              quad_opts.set_single_precision_relative_tolerance (tol (1));
 
-                default:
-                  QUAD_ABORT1 ("expecting tol to contain no more than two values");
-                }
-
-            case 3:
-              if (indefinite)
-                {
-                  FloatIndefQuad iq (quad_float_user_function, bound,
-                                     indef_type);
-                  iq.set_options (quad_opts);
-                  val = iq.float_integrate (ier, nfun, abserr);
-                }
-              else
-                {
-                  if (have_sing)
-                    {
-                      FloatDefQuad dq (quad_float_user_function, a, b, sing);
-                      dq.set_options (quad_opts);
-                      val = dq.float_integrate (ier, nfun, abserr);
-                    }
-                  else
-                    {
-                      FloatDefQuad dq (quad_float_user_function, a, b);
-                      dq.set_options (quad_opts);
-                      val = dq.float_integrate (ier, nfun, abserr);
-                    }
-                }
+            case 1:
+              quad_opts.set_single_precision_absolute_tolerance (tol (0));
               break;
 
             default:
-              panic_impossible ();
-              break;
-            }
-
-          retval(3) = abserr;
-          retval(2) = nfun;
-          retval(1) = ier;
-          retval(0) = val;
-
-        }
-      else
-        {
-          double a = args(1).double_value ();
-
-          if (error_state)
-            QUAD_ABORT1 ("expecting second argument to be a scalar");
-
-          double b = args(2).double_value ();
-
-          if (error_state)
-            QUAD_ABORT1 ("expecting third argument to be a scalar");
-
-          int indefinite = 0;
-          IndefQuad::IntegralType indef_type = IndefQuad::doubly_infinite;
-          double bound = 0.0;
-          if (xisinf (a) && xisinf (b))
-            {
-              indefinite = 1;
-              indef_type = IndefQuad::doubly_infinite;
-            }
-          else if (xisinf (a))
-            {
-              indefinite = 1;
-              bound = b;
-              indef_type = IndefQuad::neg_inf_to_bound;
-            }
-          else if (xisinf (b))
-            {
-              indefinite = 1;
-              bound = a;
-              indef_type = IndefQuad::bound_to_inf;
+              error ("quad: TOL must be a 1 or 2-element vector");
             }
 
-          octave_idx_type ier = 0;
-          octave_idx_type nfun = 0;
-          double abserr = 0.0;
-          double val = 0.0;
-          bool have_sing = false;
-          ColumnVector sing;
-          ColumnVector tol;
-
-          switch (nargin)
+        case 3:
+          if (indefinite)
             {
-            case 5:
-              if (indefinite)
-                QUAD_ABORT1 ("singularities not allowed on infinite intervals");
-
-              have_sing = true;
-
-              sing = ColumnVector (args(4).vector_value ());
-
-              if (error_state)
-                QUAD_ABORT1 ("expecting vector of singularities as fourth argument");
-
-            case 4:
-              tol = ColumnVector (args(3).vector_value ());
-
-              if (error_state)
-                QUAD_ABORT1 ("expecting vector of tolerances as fifth argument");
-
-              switch (tol.capacity ())
+              FloatIndefQuad iq (quad_float_user_function, bound,
+                                 indef_type);
+              iq.set_options (quad_opts);
+              val = iq.float_integrate (ier, nfun, abserr);
+            }
+          else
+            {
+              if (have_sing)
                 {
-                case 2:
-                  quad_opts.set_relative_tolerance (tol (1));
-
-                case 1:
-                  quad_opts.set_absolute_tolerance (tol (0));
-                  break;
-
-                default:
-                  QUAD_ABORT1 ("expecting tol to contain no more than two values");
-                }
-
-            case 3:
-              if (indefinite)
-                {
-                  IndefQuad iq (quad_user_function, bound, indef_type);
-                  iq.set_options (quad_opts);
-                  val = iq.integrate (ier, nfun, abserr);
+                  FloatDefQuad dq (quad_float_user_function, a, b, sing);
+                  dq.set_options (quad_opts);
+                  val = dq.float_integrate (ier, nfun, abserr);
                 }
               else
                 {
-                  if (have_sing)
-                    {
-                      DefQuad dq (quad_user_function, a, b, sing);
-                      dq.set_options (quad_opts);
-                      val = dq.integrate (ier, nfun, abserr);
-                    }
-                  else
-                    {
-                      DefQuad dq (quad_user_function, a, b);
-                      dq.set_options (quad_opts);
-                      val = dq.integrate (ier, nfun, abserr);
-                    }
+                  FloatDefQuad dq (quad_float_user_function, a, b);
+                  dq.set_options (quad_opts);
+                  val = dq.float_integrate (ier, nfun, abserr);
                 }
+            }
+          break;
+
+        default:
+          panic_impossible ();
+          break;
+        }
+
+      retval(3) = abserr;
+      retval(2) = nfun;
+      retval(1) = ier;
+      retval(0) = val;
+
+    }
+  else
+    {
+      double a = args(1).xdouble_value ("quad: lower limit of integration A must be a scalar");
+      double b = args(2).xdouble_value ("quad: upper limit of integration B must be a scalar");
+
+      int indefinite = 0;
+      IndefQuad::IntegralType indef_type = IndefQuad::doubly_infinite;
+      double bound = 0.0;
+      if (xisinf (a) && xisinf (b))
+        {
+          indefinite = 1;
+          indef_type = IndefQuad::doubly_infinite;
+        }
+      else if (xisinf (a))
+        {
+          indefinite = 1;
+          bound = b;
+          indef_type = IndefQuad::neg_inf_to_bound;
+        }
+      else if (xisinf (b))
+        {
+          indefinite = 1;
+          bound = a;
+          indef_type = IndefQuad::bound_to_inf;
+        }
+
+      octave_idx_type ier = 0;
+      octave_idx_type nfun = 0;
+      double abserr = 0.0;
+      double val = 0.0;
+      bool have_sing = false;
+      ColumnVector sing;
+      ColumnVector tol;
+
+      switch (nargin)
+        {
+        case 5:
+          if (indefinite)
+            error ("quad: singularities not allowed on infinite intervals");
+
+          have_sing = true;
+
+          sing = args(4).vector_value ("quad: fifth argument SING must be a vector vector of singularities");
+
+        case 4:
+          tol = args(3).xvector_value ("quad: TOL must be a 1 or 2-element vector");
+
+          switch (tol.numel ())
+            {
+            case 2:
+              quad_opts.set_relative_tolerance (tol (1));
+
+            case 1:
+              quad_opts.set_absolute_tolerance (tol (0));
               break;
 
             default:
-              panic_impossible ();
-              break;
+              error ("quad: TOL must be a 1 or 2-element vector");
             }
 
-          retval(3) = abserr;
-          retval(2) = nfun;
-          retval(1) = ier;
-          retval(0) = val;
+        case 3:
+          if (indefinite)
+            {
+              IndefQuad iq (quad_user_function, bound, indef_type);
+              iq.set_options (quad_opts);
+              val = iq.integrate (ier, nfun, abserr);
+            }
+          else
+            {
+              if (have_sing)
+                {
+                  DefQuad dq (quad_user_function, a, b, sing);
+                  dq.set_options (quad_opts);
+                  val = dq.integrate (ier, nfun, abserr);
+                }
+              else
+                {
+                  DefQuad dq (quad_user_function, a, b);
+                  dq.set_options (quad_opts);
+                  val = dq.integrate (ier, nfun, abserr);
+                }
+            }
+          break;
+
+        default:
+          panic_impossible ();
+          break;
         }
 
-      if (fcn_name.length ())
-        clear_function (fcn_name);
+      retval(3) = abserr;
+      retval(2) = nfun;
+      retval(1) = ier;
+      retval(0) = val;
     }
-  else
-    print_usage ();
+
+  if (fcn_name.length ())
+    clear_function (fcn_name);
 
   return retval;
 }
--- a/libinterp/corefcn/quadcc.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/quadcc.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -1588,10 +1588,7 @@
 
   /* Parse the input arguments. */
   if (nargin < 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   if (args(0).is_function_handle () || args(0).is_inline_function ())
     fcn = args(0).function_value ();
@@ -1606,28 +1603,19 @@
     }
 
   if (! args(1).is_real_scalar ())
-    {
-      error ("quadcc: lower limit of integration (A) must be a single real scalar");
-      return retval;
-    }
+    error ("quadcc: lower limit of integration (A) must be a single real scalar");
   else
     a = args(1).double_value ();
 
   if (! args(2).is_real_scalar ())
-    {
-      error ("quadcc: upper limit of integration (B) must be a single real scalar");
-      return retval;
-    }
+    error ("quadcc: upper limit of integration (B) must be a single real scalar");
   else
     b = args(2).double_value ();
 
   if (nargin < 4 || args(3).is_empty ())
     tol = 1.0e-6;
   else if (! args(3).is_real_scalar () || args(3).double_value () <= 0)
-    {
-      error ("quadcc: tolerance (TOL) must be a single real scalar > 0");
-      return retval;
-    }
+    error ("quadcc: tolerance (TOL) must be a single real scalar > 0");
   else
     tol = args(3).double_value ();
 
@@ -1636,10 +1624,7 @@
       nivals = 1;
     }
   else if (!(args(4).is_real_scalar () || args(4).is_real_matrix ()))
-    {
-      error ("quadcc: list of singularities (SING) must be a vector of real values");
-      return retval;
-    }
+    error ("quadcc: list of singularities (SING) must be a vector of real values");
   else
     {
       nivals = 1 + args(4).numel ();
@@ -1708,16 +1693,12 @@
       fargs(0) = ex;
       fvals = feval (fcn, fargs, 1);
       if (fvals.length () != 1 || ! fvals(0).is_real_matrix ())
-        {
-          error ("quadcc: integrand F must return a single, real-valued vector");
-          return retval;
-        }
+        error ("quadcc: integrand F must return a single, real-valued vector");
+
       Matrix effex = fvals(0).matrix_value ();
-      if (effex.length () != ex.length ())
-        {
-          error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input");
-          return retval;
-        }
+      if (effex.numel () != ex.numel ())
+        error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input");
+
       for (i = 0; i <= n[3]; i++)
         {
           iv->fx[i] = effex(i);
@@ -1827,17 +1808,13 @@
             fargs(0) = ex;
             fvals = feval (fcn, fargs, 1);
             if (fvals.length () != 1 || ! fvals(0).is_real_matrix ())
-              {
-                error ("quadcc: integrand F must return a single, real-valued vector");
-                return retval;
-              }
+              error ("quadcc: integrand F must return a single, real-valued vector");
+
             Matrix effex = fvals(0).matrix_value ();
-            if (effex.length () != ex.length ())
-              {
-                error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input");
-                return retval;
-              }
-            neval += effex.length ();
+            if (effex.numel () != ex.numel ())
+              error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input");
+
+            neval += effex.numel ();
             for (i = 0; i < n[d] / 2; i++)
               {
                 j = (2 * i + 1) * skip[d];
@@ -1975,17 +1952,13 @@
             fargs(0) = ex;
             fvals = feval (fcn, fargs, 1);
             if (fvals.length () != 1 || ! fvals(0).is_real_matrix ())
-              {
-                error ("quadcc: integrand F must return a single, real-valued vector");
-                return retval;
-              }
+              error ("quadcc: integrand F must return a single, real-valued vector");
+
             Matrix effex = fvals(0).matrix_value ();
-            if (effex.length () != ex.length ())
-              {
-                error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input");
-                return retval;
-              }
-            neval += effex.length ();
+            if (effex.numel () != ex.numel ())
+              error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input");
+
+            neval += effex.numel ();
             for (i = 0; i < n[0] - 1; i++)
               {
                 j = (i + 1) * skip[0];
@@ -2071,17 +2044,13 @@
             fargs(0) = ex;
             fvals = feval (fcn, fargs, 1);
             if (fvals.length () != 1 || ! fvals(0).is_real_matrix ())
-              {
-                error ("quadcc: integrand F must return a single, real-valued vector");
-                return retval;
-              }
+              error ("quadcc: integrand F must return a single, real-valued vector");
+
             Matrix effex = fvals(0).matrix_value ();
-            if (effex.length () != ex.length ())
-              {
-                error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input");
-                return retval;
-              }
-            neval += effex.length ();
+            if (effex.numel () != ex.numel ())
+              error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input");
+
+            neval += effex.numel ();
             for (i = 0; i < n[0] - 1; i++)
               {
                 j = (i + 1) * skip[0];
--- a/libinterp/corefcn/qz.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/qz.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -383,15 +383,10 @@
 #endif
 
   if (nargin < 2 || nargin > 3 || nargout > 7)
-    {
-      print_usage ();
-      return retval;
-    }
-  else if (nargin == 3 && (nargout < 3 || nargout > 4))
-    {
-      error ("qz: invalid number of output arguments for form [3] call");
-      return retval;
-    }
+    print_usage ();
+
+  if (nargin == 3 && (nargout < 3 || nargout > 4))
+    error ("qz: invalid number of output arguments for form [3] call");
 
 #ifdef DEBUG
   std::cout << "qz: determine ordering option" << std::endl;
@@ -403,14 +398,9 @@
 
   if (nargin == 2)
     ord_job = 'N';
-  else if (! args(2).is_string ())
-    {
-      error ("qz: OPT must be a string");
-      return retval;
-    }
   else
     {
-      std::string tmp = args(2).string_value ();
+      std::string tmp = args(2).xstring_value ("qz: OPT must be a string");
 
       if (! tmp.empty ())
         ord_job = tmp[0];
@@ -419,10 +409,7 @@
              || ord_job == 'S' || ord_job == 's'
              || ord_job == 'B' || ord_job == 'b'
              || ord_job == '+' || ord_job == '-'))
-        {
-          error ("qz: invalid order option");
-          return retval;
-        }
+        error ("qz: invalid order option");
 
       // overflow constant required by dlag2
       F77_FUNC (xdlamch, XDLAMCH) (F77_CONST_CHAR_ARG2 ("S", 1),
@@ -495,9 +482,6 @@
   else
     aa = args(0).matrix_value ();
 
-  if (error_state)
-    return retval;
-
 #ifdef DEBUG
   std::cout << "qz: check argument 2" << std::endl;
 #endif
@@ -517,9 +501,6 @@
   else
     bb = args(1).matrix_value ();
 
-  if (error_state)
-    return retval;
-
   // Both matrices loaded, now let's check what kind of arithmetic:
   // declared volatile to avoid compiler warnings about long jumps,
   // vforks.
@@ -528,10 +509,7 @@
     = (args(0).is_complex_type () || args(1).is_complex_type ());
 
   if (nargin == 3 && complex_case)
-    {
-      error ("qz: cannot re-order complex qz decomposition");
-      return retval;
-    }
+    error ("qz: cannot re-order complex qz decomposition");
 
   // First, declare variables used in both the real and complex case.
   Matrix QQ(nn,nn), ZZ(nn,nn), VR(nn,nn), VL(nn,nn);
@@ -810,216 +788,211 @@
   if (! (ord_job == 'N' || ord_job == 'n'))
     {
       if (complex_case)
-        {
-          // Probably not needed, but better be safe.
-          error ("qz: cannot re-order complex qz decomposition");
-          return retval;
-        }
-      else
-        {
+        // Probably not needed, but better be safe.
+        error ("qz: cannot re-order complex qz decomposition");
+
 #ifdef DEBUG_SORT
-          std::cout << "qz: ordering eigenvalues: ord_job = "
-                    << ord_job << std::endl;
+      std::cout << "qz: ordering eigenvalues: ord_job = "
+                << ord_job << std::endl;
 #endif
 
-          // Declared static to avoid vfork/long jump compiler complaints.
-          static sort_function sort_test;
-          sort_test = 0;
+      // Declared static to avoid vfork/long jump compiler complaints.
+      static sort_function sort_test;
+      sort_test = 0;
 
-          switch (ord_job)
-            {
-            case 'S':
-            case 's':
-              sort_test = &fin;
-              break;
+      switch (ord_job)
+        {
+        case 'S':
+        case 's':
+          sort_test = &fin;
+          break;
 
-            case 'B':
-            case 'b':
-              sort_test = &fout;
-              break;
+        case 'B':
+        case 'b':
+          sort_test = &fout;
+          break;
 
-            case '+':
-              sort_test = &fcrhp;
-              break;
+        case '+':
+          sort_test = &fcrhp;
+          break;
 
-            case '-':
-              sort_test = &folhp;
-              break;
+        case '-':
+          sort_test = &folhp;
+          break;
 
-            default:
-              // Invalid order option (should never happen, since we
-              // checked the options at the top).
-              panic_impossible ();
-              break;
-            }
+        default:
+          // Invalid order option (should never happen, since we
+          // checked the options at the top).
+          panic_impossible ();
+          break;
+        }
 
-          octave_idx_type ndim, fail;
-          double inf_norm;
+      octave_idx_type ndim, fail;
+      double inf_norm;
 
-          F77_XFCN (xdlange, XDLANGE,
-                    (F77_CONST_CHAR_ARG2 ("I", 1),
-                     nn, nn, aa.data (), nn, work.fortran_vec (), inf_norm
-                     F77_CHAR_ARG_LEN (1)));
+      F77_XFCN (xdlange, XDLANGE,
+                (F77_CONST_CHAR_ARG2 ("I", 1),
+                 nn, nn, aa.data (), nn, work.fortran_vec (), inf_norm
+                 F77_CHAR_ARG_LEN (1)));
 
-          double eps = std::numeric_limits<double>::epsilon () * inf_norm * nn;
+      double eps = std::numeric_limits<double>::epsilon () * inf_norm * nn;
 
 #ifdef DEBUG_SORT
-          std::cout << "qz: calling dsubsp: aa=" << std::endl;
-          octave_print_internal (std::cout, aa, 0);
-          std::cout << std::endl << "bb="  << std::endl;
-          octave_print_internal (std::cout, bb, 0);
-          if (compz == 'V')
-            {
-              std::cout << std::endl << "ZZ="  << std::endl;
-              octave_print_internal (std::cout, ZZ, 0);
-            }
-          std::cout << std::endl;
-          std::cout << "alphar = " << std::endl;
-          octave_print_internal (std::cout, (Matrix) alphar, 0);
-          std::cout << std::endl << "alphai = " << std::endl;
-          octave_print_internal (std::cout, (Matrix) alphai, 0);
-          std::cout << std::endl << "beta = " << std::endl;
-          octave_print_internal (std::cout, (Matrix) betar, 0);
-          std::cout << std::endl;
+      std::cout << "qz: calling dsubsp: aa=" << std::endl;
+      octave_print_internal (std::cout, aa, 0);
+      std::cout << std::endl << "bb="  << std::endl;
+      octave_print_internal (std::cout, bb, 0);
+      if (compz == 'V')
+        {
+          std::cout << std::endl << "ZZ="  << std::endl;
+          octave_print_internal (std::cout, ZZ, 0);
+        }
+      std::cout << std::endl;
+      std::cout << "alphar = " << std::endl;
+      octave_print_internal (std::cout, (Matrix) alphar, 0);
+      std::cout << std::endl << "alphai = " << std::endl;
+      octave_print_internal (std::cout, (Matrix) alphai, 0);
+      std::cout << std::endl << "beta = " << std::endl;
+      octave_print_internal (std::cout, (Matrix) betar, 0);
+      std::cout << std::endl;
 #endif
 
-          Array<octave_idx_type> ind (dim_vector (nn, 1));
+      Array<octave_idx_type> ind (dim_vector (nn, 1));
 
-          F77_XFCN (dsubsp, DSUBSP,
-                    (nn, nn, aa.fortran_vec (), bb.fortran_vec (),
-                     ZZ.fortran_vec (), sort_test, eps, ndim, fail,
-                     ind.fortran_vec ()));
+      F77_XFCN (dsubsp, DSUBSP,
+                (nn, nn, aa.fortran_vec (), bb.fortran_vec (),
+                 ZZ.fortran_vec (), sort_test, eps, ndim, fail,
+                 ind.fortran_vec ()));
 
 #ifdef DEBUG
-          std::cout << "qz: back from dsubsp: aa=" << std::endl;
-          octave_print_internal (std::cout, aa, 0);
-          std::cout << std::endl << "bb="  << std::endl;
-          octave_print_internal (std::cout, bb, 0);
-          if (compz == 'V')
-            {
-              std::cout << std::endl << "ZZ="  << std::endl;
-              octave_print_internal (std::cout, ZZ, 0);
-            }
-          std::cout << std::endl;
+      std::cout << "qz: back from dsubsp: aa=" << std::endl;
+      octave_print_internal (std::cout, aa, 0);
+      std::cout << std::endl << "bb="  << std::endl;
+      octave_print_internal (std::cout, bb, 0);
+      if (compz == 'V')
+        {
+          std::cout << std::endl << "ZZ="  << std::endl;
+          octave_print_internal (std::cout, ZZ, 0);
+        }
+      std::cout << std::endl;
 #endif
 
-          // Manually update alphar, alphai, betar.
-          static int jj;
+      // Manually update alphar, alphai, betar.
+      static int jj;
+
+      jj = 0;
+      while (jj < nn)
+        {
+#ifdef DEBUG_EIG
+          std::cout << "computing gen eig #" << jj << std::endl;
+#endif
+
+          // Number of zeros in this block.
+          static int zcnt;
 
-          jj = 0;
-          while (jj < nn)
+          if (jj == (nn-1))
+            zcnt = 1;
+          else if (aa(jj+1,jj) == 0)
+            zcnt = 1;
+          else zcnt = 2;
+
+          if (zcnt == 1)
             {
+              // Real zero.
 #ifdef DEBUG_EIG
-              std::cout << "computing gen eig #" << jj << std::endl;
+              std::cout << "  single gen eig:" << std::endl;
+              std::cout << "  alphar(" << jj << ") = " << aa(jj,jj)
+                        << std::endl;
+              std::cout << "  betar(" << jj << ") = " << bb(jj,jj)
+                        << std::endl;
+              std::cout << "  alphai(" << jj << ") = 0" << std::endl;
 #endif
 
-              // Number of zeros in this block.
-              static int zcnt;
-
-              if (jj == (nn-1))
-                zcnt = 1;
-              else if (aa(jj+1,jj) == 0)
-                zcnt = 1;
-              else zcnt = 2;
+              alphar(jj) = aa(jj,jj);
+              alphai(jj) = 0;
+              betar(jj) = bb(jj,jj);
+            }
+          else
+            {
+              // Complex conjugate pair.
+#ifdef DEBUG_EIG
+              std::cout << "qz: calling dlag2:" << std::endl;
+              std::cout << "safmin="
+                        << setiosflags (std::ios::scientific)
+                        << safmin << std::endl;
 
-              if (zcnt == 1)
+              for (int idr = jj; idr <= jj+1; idr++)
                 {
-                  // Real zero.
-#ifdef DEBUG_EIG
-                  std::cout << "  single gen eig:" << std::endl;
-                  std::cout << "  alphar(" << jj << ") = " << aa(jj,jj)
-                            << std::endl;
-                  std::cout << "  betar(" << jj << ") = " << bb(jj,jj)
-                            << std::endl;
-                  std::cout << "  alphai(" << jj << ") = 0" << std::endl;
+                  for (int idc = jj; idc <= jj+1; idc++)
+                    {
+                      std::cout << "aa(" << idr << "," << idc << ")="
+                                << aa(idr,idc) << std::endl;
+                      std::cout << "bb(" << idr << "," << idc << ")="
+                                << bb(idr,idc) << std::endl;
+                    }
+                }
 #endif
 
-                  alphar(jj) = aa(jj,jj);
+              // FIXME: probably should be using
+              // fortran_vec instead of &aa(jj,jj) here.
+
+              double scale1, scale2, wr1, wr2, wi;
+              const double *aa_ptr = aa.data () + jj * nn + jj;
+              const double *bb_ptr = bb.data () + jj * nn + jj;
+              F77_XFCN (dlag2, DLAG2,
+                        (aa_ptr, nn, bb_ptr, nn, safmin,
+                         scale1, scale2, wr1, wr2, wi));
+
+#ifdef DEBUG_EIG
+              std::cout << "dlag2 returns: scale1=" << scale1
+                        << "\tscale2=" << scale2 << std::endl
+                        << "\twr1=" << wr1 << "\twr2=" << wr2
+                        << "\twi=" << wi << std::endl;
+#endif
+
+              // Just to be safe, check if it's a real pair.
+              if (wi == 0)
+                {
+                  alphar(jj) = wr1;
                   alphai(jj) = 0;
-                  betar(jj) = bb(jj,jj);
+                  betar(jj) = scale1;
+                  alphar(jj+1) = wr2;
+                  alphai(jj+1) = 0;
+                  betar(jj+1) = scale2;
                 }
               else
                 {
-                  // Complex conjugate pair.
-#ifdef DEBUG_EIG
-                  std::cout << "qz: calling dlag2:" << std::endl;
-                  std::cout << "safmin="
-                            << setiosflags (std::ios::scientific)
-                            << safmin << std::endl;
-
-                  for (int idr = jj; idr <= jj+1; idr++)
-                    {
-                      for (int idc = jj; idc <= jj+1; idc++)
-                        {
-                          std::cout << "aa(" << idr << "," << idc << ")="
-                                    << aa(idr,idc) << std::endl;
-                          std::cout << "bb(" << idr << "," << idc << ")="
-                                    << bb(idr,idc) << std::endl;
-                        }
-                    }
-#endif
-
-                  // FIXME: probably should be using
-                  // fortran_vec instead of &aa(jj,jj) here.
-
-                  double scale1, scale2, wr1, wr2, wi;
-                  const double *aa_ptr = aa.data () + jj * nn + jj;
-                  const double *bb_ptr = bb.data () + jj * nn + jj;
-                  F77_XFCN (dlag2, DLAG2,
-                            (aa_ptr, nn, bb_ptr, nn, safmin,
-                             scale1, scale2, wr1, wr2, wi));
-
-#ifdef DEBUG_EIG
-                  std::cout << "dlag2 returns: scale1=" << scale1
-                            << "\tscale2=" << scale2 << std::endl
-                            << "\twr1=" << wr1 << "\twr2=" << wr2
-                            << "\twi=" << wi << std::endl;
-#endif
-
-                  // Just to be safe, check if it's a real pair.
-                  if (wi == 0)
-                    {
-                      alphar(jj) = wr1;
-                      alphai(jj) = 0;
-                      betar(jj) = scale1;
-                      alphar(jj+1) = wr2;
-                      alphai(jj+1) = 0;
-                      betar(jj+1) = scale2;
-                    }
-                  else
-                    {
-                      alphar(jj) = alphar(jj+1) = wr1;
-                      alphai(jj) = -(alphai(jj+1) = wi);
-                      betar(jj)  = betar(jj+1) = scale1;
-                    }
+                  alphar(jj) = alphar(jj+1) = wr1;
+                  alphai(jj) = -(alphai(jj+1) = wi);
+                  betar(jj)  = betar(jj+1) = scale1;
                 }
-
-              // Advance past this block.
-              jj += zcnt;
             }
 
+          // Advance past this block.
+          jj += zcnt;
+        }
+
 #ifdef DEBUG_SORT
-          std::cout << "qz: back from dsubsp: aa=" << std::endl;
-          octave_print_internal (std::cout, aa, 0);
-          std::cout << std::endl << "bb="  << std::endl;
-          octave_print_internal (std::cout, bb, 0);
+      std::cout << "qz: back from dsubsp: aa=" << std::endl;
+      octave_print_internal (std::cout, aa, 0);
+      std::cout << std::endl << "bb="  << std::endl;
+      octave_print_internal (std::cout, bb, 0);
 
-          if (compz == 'V')
-            {
-              std::cout << std::endl << "ZZ="  << std::endl;
-              octave_print_internal (std::cout, ZZ, 0);
-            }
-          std::cout << std::endl << "qz: ndim=" << ndim << std::endl
-                    << "fail=" << fail << std::endl;
-          std::cout << "alphar = " << std::endl;
-          octave_print_internal (std::cout, (Matrix) alphar, 0);
-          std::cout << std::endl << "alphai = " << std::endl;
-          octave_print_internal (std::cout, (Matrix) alphai, 0);
-          std::cout << std::endl << "beta = " << std::endl;
-          octave_print_internal (std::cout, (Matrix) betar, 0);
-          std::cout << std::endl;
+      if (compz == 'V')
+        {
+          std::cout << std::endl << "ZZ="  << std::endl;
+          octave_print_internal (std::cout, ZZ, 0);
+        }
+      std::cout << std::endl << "qz: ndim=" << ndim << std::endl
+                << "fail=" << fail << std::endl;
+      std::cout << "alphar = " << std::endl;
+      octave_print_internal (std::cout, (Matrix) alphar, 0);
+      std::cout << std::endl << "alphai = " << std::endl;
+      octave_print_internal (std::cout, (Matrix) alphai, 0);
+      std::cout << std::endl << "beta = " << std::endl;
+      octave_print_internal (std::cout, (Matrix) betar, 0);
+      std::cout << std::endl;
 #endif
-        }
     }
 
   // Compute generalized eigenvalues?
--- a/libinterp/corefcn/rand.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/rand.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -86,20 +86,13 @@
   if (additional_arg)
     {
       if (nargin == 0)
-        {
-          error ("%s: expecting at least one argument", fcn);
-          goto done;
-        }
+        error ("%s: at least one argument is required", fcn);
       else if (args(0).is_string ())
         additional_arg = false;
       else
         {
-          a = args(0).array_value ();
-          if (error_state)
-            {
-              error ("%s: expecting scalar or matrix arguments", fcn);
-              goto done;
-            }
+          a = args(0).xarray_value ("%s: dimension must be a scalar integer", fcn);
+
           idx++;
           nargin--;
         }
@@ -170,9 +163,7 @@
             double dval = tmp.double_value ();
 
             if (xisnan (dval))
-              {
-                error ("%s: NaN is invalid matrix dimension", fcn);
-              }
+              error ("%s: NaN is invalid matrix dimension", fcn);
             else
               {
                 dims.resize (2);
@@ -180,8 +171,7 @@
                 dims(0) = NINTbig (tmp.double_value ());
                 dims(1) = NINTbig (tmp.double_value ());
 
-                if (! error_state)
-                  goto gen_matrix;
+                goto gen_matrix;
               }
           }
         else if (tmp.is_range ())
@@ -190,7 +180,7 @@
 
             if (r.all_elements_are_ints ())
               {
-                octave_idx_type n = r.nelem ();
+                octave_idx_type n = r.numel ();
 
                 dims.resize (n);
 
@@ -199,8 +189,8 @@
 
                 for (octave_idx_type i = 0; i < n; i++)
                   {
-                    //Negative dimensions are treated as zero for Matlab
-                    //compatibility
+                    // Negative dimensions are treated as zero for Matlab
+                    // compatibility
                     dims(i) = base >= 0 ? base : 0;
                     base += incr;
                   }
@@ -209,31 +199,34 @@
 
               }
             else
-              error ("%s: all elements of range must be integers",
-                     fcn);
+              error ("%s: all elements of range must be integers", fcn);
           }
         else if (tmp.is_matrix_type ())
           {
-            Array<int> iv = tmp.int_vector_value (true);
+            Array<int> iv;
 
-            if (! error_state)
+            try
               {
-                octave_idx_type len = iv.length ();
-
-                dims.resize (len);
+                iv = tmp.int_vector_value (true);
+              }
+            catch (octave_execution_exception& e)
+              {
+                error (e, "%s: dimensions must be a scalar or array of integers", fcn);
+              }
 
-                for (octave_idx_type i = 0; i < len; i++)
-                  {
-                    //Negative dimensions are treated as zero for Matlab
-                    //compatibility
-                    octave_idx_type elt = iv(i);
-                    dims(i) = elt >=0 ? elt : 0;
-                  }
+            octave_idx_type len = iv.numel ();
+
+            dims.resize (len);
 
-                goto gen_matrix;
+            for (octave_idx_type i = 0; i < len; i++)
+              {
+                // Negative dimensions are treated as zero for Matlab
+                // compatibility
+                octave_idx_type elt = iv(i);
+                dims(i) = elt >=0 ? elt : 0;
               }
-            else
-              error ("%s: expecting integer vector", fcn);
+
+            goto gen_matrix;
           }
         else
           {
@@ -257,8 +250,7 @@
                   {
                     double d = args(idx+1).double_value ();
 
-                    if (! error_state)
-                      octave_rand::seed (d);
+                    octave_rand::seed (d);
                   }
                 else if (args(idx+1).is_string ()
                          && args(idx+1).string_value () == "reset")
@@ -276,8 +268,7 @@
                     ColumnVector s =
                       ColumnVector (args(idx+1).vector_value(false, true));
 
-                    if (! error_state)
-                      octave_rand::state (s, fcn);
+                    octave_rand::state (s, fcn);
                   }
               }
             else
@@ -289,13 +280,9 @@
 
             for (int i = 0; i < nargin; i++)
               {
-                octave_idx_type elt = args(idx+i).int_value ();
-                if (error_state)
-                  {
-                    error ("%s: expecting integer arguments", fcn);
-                    goto done;
-                  }
-                //Negative is zero for Matlab compatibility
+                octave_idx_type elt = args(idx+i).xint_value ("%s: dimension must be a scalar or array of integers", fcn);
+
+                // Negative is zero for Matlab compatibility
                 dims(i) = elt >= 0 ? elt : 0;
               }
 
@@ -317,16 +304,14 @@
     {
       if (additional_arg)
         {
-          if (a.length () == 1)
+          if (a.numel () == 1)
             return octave_rand::float_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 ();
+                error ("%s: mismatch in argument size", fcn);
+
+              octave_idx_type len = a.numel ();
               FloatNDArray m (dims);
               float *v = m.fortran_vec ();
               for (octave_idx_type i = 0; i < len; i++)
@@ -341,16 +326,14 @@
     {
       if (additional_arg)
         {
-          if (a.length () == 1)
+          if (a.numel () == 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 ();
+                error ("%s: mismatch in argument size", fcn);
+
+              octave_idx_type len = a.numel ();
               NDArray m (dims);
               double *v = m.fortran_vec ();
               for (octave_idx_type i = 0; i < len; i++)
@@ -1138,6 +1121,7 @@
 @seealso{perms}\n\
 @end deftypefn")
 {
+  octave_value retval;
 
 #ifdef USE_UNORDERED_MAP_WITH_TR1
 using std::tr1::unordered_map;
@@ -1146,108 +1130,94 @@
 #endif
 
   int nargin = args.length ();
-  octave_value retval;
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      octave_idx_type n, m;
+  octave_idx_type n = args(0).idx_type_value (true);
+  octave_idx_type m = (nargin == 2) ? args(1).idx_type_value (true) : n;
 
-      n = args(0).idx_type_value (true);
+  if (m < 0 || n < 0)
+    error ("randperm: M and N must be non-negative");
 
-      if (nargin == 2)
-        m = args(1).idx_type_value (true);
-      else
-        m = n;
+  if (m > n)
+    error ("randperm: M must be less than or equal to N");
 
-      if (m < 0 || n < 0)
-        error ("randperm: M and N must be non-negative");
+  // Quick and dirty heuristic to decide if we allocate or not the
+  // whole vector for tracking the truncated shuffle.
+  bool short_shuffle = m < n/5;
+
+  // Generate random numbers.
+  NDArray r = octave_rand::nd_array (dim_vector (1, m));
+  double *rvec = r.fortran_vec ();
 
-      if (m > n)
-        error ("randperm: M must be less than or equal to N");
+  octave_idx_type idx_len = short_shuffle ? m : n;
+  Array<octave_idx_type> idx;
+  try
+    {
+      idx = Array<octave_idx_type> (dim_vector (1, idx_len));
+    }
+  catch (const std::bad_alloc&)
+    {
+      // Looks like n is too big and short_shuffle is false.
+      // Let's try again, but this time with the alternative.
+      idx_len = m;
+      short_shuffle = true;
+      idx = Array<octave_idx_type> (dim_vector (1, idx_len));
+    }
 
-      // Quick and dirty heuristic to decide if we allocate or not the
-      // whole vector for tracking the truncated shuffle.
-      bool short_shuffle = m < n/5;
+  octave_idx_type *ivec = idx.fortran_vec ();
+
+  for (octave_idx_type i = 0; i < idx_len; i++)
+    ivec[i] = i;
 
-      if (! error_state)
+  if (short_shuffle)
+    {
+      unordered_map<octave_idx_type, octave_idx_type> map (m);
+
+      // Perform the Knuth shuffle only keeping track of moved
+      // entries in the map
+      for (octave_idx_type i = 0; i < m; i++)
         {
-          // Generate random numbers.
-          NDArray r = octave_rand::nd_array (dim_vector (1, m));
-          double *rvec = r.fortran_vec ();
+          octave_idx_type k = i +
+            gnulib::floor (rvec[i] * (n - i));
 
-          octave_idx_type idx_len = short_shuffle ? m : n;
-          Array<octave_idx_type> idx;
-          try
-            {
-              idx = Array<octave_idx_type> (dim_vector (1, idx_len));
-            }
-          catch (std::bad_alloc)
+          // For shuffling first m entries, no need to use extra
+          // storage
+          if (k < m)
             {
-              // Looks like n is too big and short_shuffle is false.
-              // Let's try again, but this time with the alternative.
-              idx_len = m;
-              short_shuffle = true;
-              idx = Array<octave_idx_type> (dim_vector (1, idx_len));
-            }
-
-          octave_idx_type *ivec = idx.fortran_vec ();
-
-          for (octave_idx_type i = 0; i < idx_len; i++)
-            ivec[i] = i;
-
-          if (short_shuffle)
-            {
-              unordered_map<octave_idx_type, octave_idx_type> map (m);
-
-              // Perform the Knuth shuffle only keeping track of moved
-              // entries in the map
-              for (octave_idx_type i = 0; i < m; i++)
-                {
-                  octave_idx_type k = i +
-                                      gnulib::floor (rvec[i] * (n - i));
-
-                  //For shuffling first m entries, no need to use extra
-                  //storage
-                  if (k < m)
-                    {
-                      std::swap (ivec[i], ivec[k]);
-                    }
-                  else
-                    {
-                      if (map.find (k) == map.end ())
-                        map[k] = k;
-
-                      std::swap (ivec[i], map[k]);
-                    }
-                }
+              std::swap (ivec[i], ivec[k]);
             }
           else
             {
-
-              // Perform the Knuth shuffle of the first m entries
-              for (octave_idx_type i = 0; i < m; i++)
-                {
-                  octave_idx_type k = i +
-                                      gnulib::floor (rvec[i] * (n - i));
-                  std::swap (ivec[i], ivec[k]);
-                }
-            }
+              if (map.find (k) == map.end ())
+                map[k] = k;
 
-          // Convert to doubles, reusing r.
-          for (octave_idx_type i = 0; i < m; i++)
-            rvec[i] = ivec[i] + 1;
-
-          if (m < n)
-            idx.resize (dim_vector (1, m));
-
-          // Now create an array object with a cached idx_vector.
-          retval = new octave_matrix (r, idx_vector (idx));
+              std::swap (ivec[i], map[k]);
+            }
         }
     }
   else
-    print_usage ();
+    {
 
-  return retval;
+      // Perform the Knuth shuffle of the first m entries
+      for (octave_idx_type i = 0; i < m; i++)
+        {
+          octave_idx_type k = i +
+            gnulib::floor (rvec[i] * (n - i));
+          std::swap (ivec[i], ivec[k]);
+        }
+    }
+
+  // Convert to doubles, reusing r.
+  for (octave_idx_type i = 0; i < m; i++)
+    rvec[i] = ivec[i] + 1;
+
+  if (m < n)
+    idx.resize (dim_vector (1, m));
+
+  // Now create an array object with a cached idx_vector.
+  return octave_value (new octave_matrix (r, idx_vector (idx)));
 }
 
 /*
--- a/libinterp/corefcn/rcond.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/rcond.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -47,11 +47,10 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin != 1)
-    print_usage ();
-  else if (args(0).is_sparse_type ())
+  if (args(0).is_sparse_type ())
     error ("rcond: for sparse matrices use 'rcond (full (a))' or 'condest (a)' instead");
   else if (args(0).is_single_type ())
     {
--- a/libinterp/corefcn/regexp.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/regexp.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -77,13 +77,38 @@
               retval[++i] = 'b';
               break;
 
-#if 0
-// FIXME: To be complete, we need to handle \oN, \o{N}.
-//        The PCRE library already handles \N where N
-//        is an octal number.  New code needs to merely
-//        replace \oN or \o{N} with \N.
-            case 'o': // octal number
-#endif
+            case 'o': // octal input
+            {
+              bool bad_esc_seq = (j+1 >= len);
+
+              bool brace = false;
+              if (! bad_esc_seq && s[++j] == '{')
+                {
+                  brace = true;
+                  j++;
+                }
+
+              int tmpi = 0;
+              size_t k;
+              for (k = j; k < std::min (j+3+brace, len); k++)
+                {
+                  int digit = s[k] - '0';
+                  if (digit < 0 || digit > 7)
+                    break;
+                  tmpi <<= 3;
+                  tmpi += digit;
+                }
+              if (bad_esc_seq || (brace && s[k++] != '}'))
+                {
+                  bad_esc_seq = true;
+                  tmpi = 0;
+                  warning ("malformed octal escape sequence '\\o' --\
+ converting to '\\0'");
+                }
+              retval[i] = tmpi;
+              j = k - 1;
+              break;
+            }
 
             default:  // pass escape sequence through
               retval[i] = '\\';
@@ -150,18 +175,90 @@
               retval[i] = '\v';
               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 input
+            {
+              bool bad_esc_seq = (j+1 >= len);
+
+              bool brace = false;
+              if (! bad_esc_seq && s[++j] == '{')
+                {
+                  brace = true;
+                  j++;
+                }
+
+              int tmpi = 0;
+              size_t k;
+              for (k = j; k < std::min (j+3+brace, len); k++)
+                {
+                  int digit = s[k] - '0';
+                  if (digit < 0 || digit > 7)
+                    break;
+                  tmpi <<= 3;
+                  tmpi += digit;
+                }
+              if (bad_esc_seq || (brace && s[k++] != '}'))
+                {
+                  warning ("malformed octal escape sequence '\\o' --\
+ converting to '\\0'");
+                  tmpi = 0;
+                }
+              retval[i] = tmpi;
+              j = k - 1;
+              break;
+            }
+
+            case 'x': // hex input
+            {
+              bool bad_esc_seq = (j+1 >= len);
 
-            case 'o': // octal number
-            case 'x': // hex number
-#endif
+              bool brace = false;
+              if (! bad_esc_seq && s[++j] == '{')
+                {
+                  brace = true;
+                  j++;
+                }
+
+              int tmpi = 0;
+              size_t k;
+              for (k = j; k < std::min (j+2+brace, len); k++)
+                {
+                  if (! isxdigit (s[k]))
+                    break;
 
-            default:  // pass escape sequence through
-              retval[i] = '\\';
-              retval[++i] = s[j];
+                  tmpi <<= 4;
+                  int digit = s[k];
+                  if (digit >= 'a')
+                    tmpi += digit - 'a' + 10;
+                  else if (digit >= 'A')
+                    tmpi += digit - 'A' + 10;
+                  else
+                    tmpi += digit - '0';
+                }
+              if (bad_esc_seq || (brace && s[k++] != '}'))
+                {
+                  warning ("malformed hex escape sequence '\\x' --\
+ converting to '\\0'");
+                  tmpi = 0;
+                }
+              retval[i] = tmpi;
+              j = k - 1;
+              break;
+            }
+
+            // Both dollar sign (for capture buffer) and backslash are
+            // passed through with their escape backslash.  The processing
+            // for these must occur during the actual replacement operation
+            // in lo-regexp.cc.
+            case '$':  // pass dollar sign through with escape
+              retval[i] = '\\'; retval[++i] = '$';
+              break;
+
+            case '\\': // pass backslash through with escape
+              retval[i] = '\\'; retval[++i] = '\\';
+              break;
+
+            default:   // convert escaped character to unescaped char
+              retval[i] = s[j];
               break;
             }
         }
@@ -183,21 +280,13 @@
 parse_options (regexp::opts& options, const octave_value_list& args,
                const std::string& who, int skip, bool& extra_args)
 {
-  int nargin = args.length ();
-
   extra_args = false;
 
-  for (int i = skip; i < nargin; i++)
+  for (int i = skip; i < args.length (); i++)
     {
       std::string str;
 
-      if (args(i).is_string ())
-        str = args(i).string_value ();
-      else
-        {
-          error ("%s: optional arguments must be strings", who.c_str ());
-          break;
-        }
+      str = args(i).xstring_value ("%s: optional arguments must be strings", who.c_str ());
 
       std::transform (str.begin (), str.end (), str.begin (), tolower);
 
@@ -246,12 +335,9 @@
 
   // Make sure we have string, pattern
   const std::string buffer = args(0).string_value ();
-  if (error_state)
-    return retval;
 
   std::string pattern = args(1).string_value ();
-  if (error_state)
-    return retval;
+
   // Matlab compatibility.
   if (args(1).is_sq_string ())
     pattern = do_regexp_ptn_string_escapes (pattern);
@@ -260,8 +346,6 @@
   options.case_insensitive (case_insensitive);
   bool extra_options = false;
   parse_options (options, args, who, 2, extra_options);
-  if (error_state)
-    return retval;
 
   regexp::match_data rx_lst = regexp_match (pattern, buffer, options, who);
 
@@ -269,175 +353,172 @@
 
   size_t sz = rx_lst.size ();
 
-  if (! error_state)
-    {
-      // Converted the linked list in the correct form for the return values
-
-      octave_idx_type i = 0;
-      octave_scalar_map nmap;
+  // Converted the linked list in the correct form for the return values
 
-      retval.resize (7);
-
-      if (sz == 1)
-        {
-          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));
+  octave_idx_type i = 0;
+  octave_scalar_map nmap;
 
-          retval(5) = nmap;
-        }
-      else
-        {
-          for (int j = 0; j < named_pats.length (); j++)
-            {
-              Cell tmp (dim_vector (1, sz));
+  retval.resize (7);
 
-              i = 0;
-              for (regexp::match_data::const_iterator p = rx_lst.begin ();
-                   p != rx_lst.end (); p++)
-                {
-                  string_vector named_tokens = p->named_tokens ();
-
-                  tmp(i++) = named_tokens(j);
-                }
-
-              nmap.assign (named_pats(j), octave_value (tmp));
-            }
+  if (sz == 1)
+    {
+      string_vector named_tokens = rx_lst.begin ()->named_tokens ();
 
-          retval(5) = nmap;
-        }
-
-      if (options.once ())
-        {
-          regexp::match_data::const_iterator p = rx_lst.begin ();
-
-          retval(4) = sz ? p->tokens () : Cell ();
-          retval(3) = sz ? p->match_string () : std::string ();
-          retval(2) = sz ? p->token_extents () : Matrix ();
-
-          if (sz)
-            {
-              double start = p->start ();
-              double end = p->end ();
-
-              Cell split (dim_vector (1, 2));
-              split(0) = buffer.substr (0, start-1);
-              split(1) = buffer.substr (end);
+      for (int j = 0; j < named_pats.numel (); j++)
+        nmap.assign (named_pats(j), named_tokens(j));
 
-              retval(6) = split;
-              retval(1) = end;
-              retval(0) = start;
-            }
-          else
-            {
-              retval(6) = buffer;
-              retval(1) = Matrix ();
-              retval(0) = Matrix ();
-            }
-        }
-      else
+      retval(5) = nmap;
+    }
+  else
+    {
+      for (int j = 0; j < named_pats.numel (); j++)
         {
-          Cell tokens (dim_vector (1, sz));
-          Cell match_string (dim_vector (1, sz));
-          Cell token_extents (dim_vector (1, sz));
-          NDArray end (dim_vector (1, sz));
-          NDArray start (dim_vector (1, sz));
-          Cell split (dim_vector (1, sz+1));
-          size_t sp_start = 0;
+          Cell tmp (dim_vector (1, sz));
 
           i = 0;
           for (regexp::match_data::const_iterator p = rx_lst.begin ();
                p != rx_lst.end (); p++)
             {
-              double s = p->start ();
-              double e = p->end ();
+              string_vector named_tokens = p->named_tokens ();
 
-              string_vector tmp = p->tokens ();
-              tokens(i) = Cell (dim_vector (1, tmp.length ()), tmp);
-              match_string(i) = p->match_string ();
-              token_extents(i) = p->token_extents ();
-              end(i) = e;
-              start(i) = s;
-              split(i) = buffer.substr (sp_start, s-sp_start-1);
-              sp_start = e;
-              i++;
+              tmp(i++) = named_tokens(j);
             }
 
-          split(i) = buffer.substr (sp_start);
+          nmap.assign (named_pats(j), octave_value (tmp));
+        }
+
+      retval(5) = nmap;
+    }
+
+  if (options.once ())
+    {
+      regexp::match_data::const_iterator p = rx_lst.begin ();
+
+      retval(4) = sz ? p->tokens () : Cell ();
+      retval(3) = sz ? p->match_string () : std::string ();
+      retval(2) = sz ? p->token_extents () : Matrix ();
+
+      if (sz)
+        {
+          double start = p->start ();
+          double end = p->end ();
+
+          Cell split (dim_vector (1, 2));
+          split(0) = buffer.substr (0, start-1);
+          split(1) = buffer.substr (end);
 
           retval(6) = split;
-          retval(4) = tokens;
-          retval(3) = match_string;
-          retval(2) = token_extents;
           retval(1) = end;
           retval(0) = start;
         }
-
-      // Alter the order of the output arguments
+      else
+        {
+          retval(6) = buffer;
+          retval(1) = Matrix ();
+          retval(0) = Matrix ();
+        }
+    }
+  else
+    {
+      Cell tokens (dim_vector (1, sz));
+      Cell match_string (dim_vector (1, sz));
+      Cell token_extents (dim_vector (1, sz));
+      NDArray end (dim_vector (1, sz));
+      NDArray start (dim_vector (1, sz));
+      Cell split (dim_vector (1, sz+1));
+      size_t sp_start = 0;
 
-      if (extra_options)
+      i = 0;
+      for (regexp::match_data::const_iterator p = rx_lst.begin ();
+           p != rx_lst.end (); p++)
         {
-          int n = 0;
-          octave_value_list new_retval;
-          new_retval.resize (nargout);
+          double s = p->start ();
+          double e = p->end ();
 
-          OCTAVE_LOCAL_BUFFER (int, arg_used, 6);
-          for (int j = 0; j < 6; j++)
-            arg_used[j] = false;
+          string_vector tmp = p->tokens ();
+          tokens(i) = Cell (dim_vector (1, tmp.numel ()), tmp);
+          match_string(i) = p->match_string ();
+          token_extents(i) = p->token_extents ();
+          end(i) = e;
+          start(i) = s;
+          split(i) = buffer.substr (sp_start, s-sp_start-1);
+          sp_start = e;
+          i++;
+        }
+
+      split(i) = buffer.substr (sp_start);
 
-          for (int j = 2; j < nargin; j++)
-            {
-              int k = 0;
-              std::string str = args(j).string_value ();
-              std::transform (str.begin (), str.end (), str.begin (), tolower);
+      retval(6) = split;
+      retval(4) = tokens;
+      retval(3) = match_string;
+      retval(2) = token_extents;
+      retval(1) = end;
+      retval(0) = start;
+    }
+
+  // Alter the order of the output arguments
+
+  if (extra_options)
+    {
+      int n = 0;
+      octave_value_list new_retval;
+      new_retval.resize (nargout);
 
-              if (str.find ("once", 0) == 0
-                  || str.find ("stringanchors", 0) == 0
-                  || str.find ("lineanchors", 0) == 0
-                  || str.find ("matchcase", 0) == 0
-                  || str.find ("ignorecase", 0) == 0
-                  || str.find ("dotall", 0) == 0
-                  || str.find ("dotexceptnewline", 0) == 0
-                  || str.find ("literalspacing", 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;
-              else if (str.find ("end", 0) == 0)
-                k = 1;
-              else if (str.find ("tokenextents", 0) == 0)
-                k = 2;
-              else if (str.find ("match", 0) == 0)
-                k = 3;
-              else if (str.find ("tokens", 0) == 0)
-                k = 4;
-              else if (str.find ("names", 0) == 0)
-                k = 5;
-              else if (str.find ("split", 0) == 0)
-                k = 6;
+      OCTAVE_LOCAL_BUFFER (int, arg_used, 6);
+      for (int j = 0; j < 6; j++)
+        arg_used[j] = false;
+
+      for (int j = 2; j < nargin; j++)
+        {
+          int k = 0;
+          std::string str = args(j).string_value ();
+          std::transform (str.begin (), str.end (), str.begin (), tolower);
 
-              new_retval(n++) = retval(k);
-              arg_used[k] = true;
+          if (str.find ("once", 0) == 0
+              || str.find ("stringanchors", 0) == 0
+              || str.find ("lineanchors", 0) == 0
+              || str.find ("matchcase", 0) == 0
+              || str.find ("ignorecase", 0) == 0
+              || str.find ("dotall", 0) == 0
+              || str.find ("dotexceptnewline", 0) == 0
+              || str.find ("literalspacing", 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;
+          else if (str.find ("end", 0) == 0)
+            k = 1;
+          else if (str.find ("tokenextents", 0) == 0)
+            k = 2;
+          else if (str.find ("match", 0) == 0)
+            k = 3;
+          else if (str.find ("tokens", 0) == 0)
+            k = 4;
+          else if (str.find ("names", 0) == 0)
+            k = 5;
+          else if (str.find ("split", 0) == 0)
+            k = 6;
 
-              if (n == nargout)
-                break;
-            }
+          new_retval(n++) = retval(k);
+          arg_used[k] = true;
 
-          // Fill in the rest of the arguments
-          if (n < nargout)
+          if (n == nargout)
+            break;
+        }
+
+      // Fill in the rest of the arguments
+      if (n < nargout)
+        {
+          for (int j = 0; j < 6; j++)
             {
-              for (int j = 0; j < 6; j++)
-                {
-                  if (! arg_used[j])
-                    new_retval(n++) = retval(j);
-                }
+              if (! arg_used[j])
+                new_retval(n++) = retval(j);
             }
+        }
 
-          retval = new_retval;
-        }
+      retval = new_retval;
     }
 
   return retval;
@@ -471,9 +552,6 @@
                   octave_value_list tmp = octregexp (new_args, nargout, who,
                                                      case_insensitive);
 
-                  if (error_state)
-                    break;
-
                   for (int j = 0; j < nargout; j++)
                     newretval[j](i) = tmp(j);
                 }
@@ -491,9 +569,6 @@
                   octave_value_list tmp = octregexp (new_args, nargout, who,
                                                      case_insensitive);
 
-                  if (error_state)
-                    break;
-
                   for (int j = 0; j < nargout; j++)
                     newretval[j](i) = tmp(j);
                 }
@@ -516,9 +591,6 @@
                       octave_value_list tmp = octregexp (new_args, nargout, who,
                                                          case_insensitive);
 
-                      if (error_state)
-                        break;
-
                       for (int j = 0; j < nargout; j++)
                         newretval[j](i) = tmp(j);
                     }
@@ -538,17 +610,13 @@
               octave_value_list tmp = octregexp (new_args, nargout, who,
                                                  case_insensitive);
 
-              if (error_state)
-                break;
-
               for (int j = 0; j < nargout; j++)
                 newretval[j](i) = tmp(j);
             }
         }
 
-      if (!error_state)
-        for (int j = 0; j < nargout; j++)
-          retval(j) = octave_value (newretval[j]);
+      for (int j = 0; j < nargout; j++)
+        retval(j) = octave_value (newretval[j]);
     }
   else if (args(1).is_cell ())
     {
@@ -565,18 +633,12 @@
           octave_value_list tmp = octregexp (new_args, nargout, who,
                                              case_insensitive);
 
-          if (error_state)
-            break;
-
           for (int j = 0; j < nargout; j++)
             newretval[j](i) = tmp(j);
         }
 
-      if (!error_state)
-        {
-          for (int j = 0; j < nargout; j++)
-            retval(j) = octave_value (newretval[j]);
-        }
+      for (int j = 0; j < nargout; j++)
+        retval(j) = octave_value (newretval[j]);
     }
   else
     retval = octregexp (args, nargout, who, case_insensitive);
@@ -791,13 +853,12 @@
 @seealso{regexpi, strfind, regexprep}\n\
 @end deftypefn")
 {
+  if (args.length () < 2)
+    print_usage ();
+
   octave_value_list retval;
 
-  int nargin = args.length ();
-
-  if (nargin < 2)
-    print_usage ();
-  else if (args(0).is_cell () || args(1).is_cell ())
+  if (args(0).is_cell () || args(1).is_cell ())
     retval = octcellregexp (args, (nargout > 0 ? nargout : 1), "regexp");
   else
     retval = octregexp (args, nargout, "regexp");
@@ -1065,6 +1126,12 @@
 
 %!assert (regexp ("\n", '\n'), 1);
 %!assert (regexp ("\n", "\n"), 1);
+
+%!test  # Bug #45407, escape sequences are silently converted
+%! assert (regexprep ('s', 's', 'x\.y'), 'x.y');
+%! assert (regexprep ('s', '(s)', 'x\$1y'), 'x$1y');
+%! assert (regexprep ('s', '(s)', 'x\\$1y'), 'x\sy');
+
 */
 
 DEFUN (regexpi, args, nargout,
@@ -1080,13 +1147,12 @@
 @seealso{regexp}\n\
 @end deftypefn")
 {
+  if (args.length () < 2)
+    print_usage ();
+
   octave_value_list retval;
 
-  int nargin = args.length ();
-
-  if (nargin < 2)
-    print_usage ();
-  else if (args(0).is_cell () || args(1).is_cell ())
+  if (args(0).is_cell () || args(1).is_cell ())
     retval = octcellregexp (args, (nargout > 0 ? nargout : 1), "regexpi", true);
   else
     retval = octregexp (args, nargout, "regexpi", true);
@@ -1237,19 +1303,15 @@
 
   // Make sure we have string, pattern, replacement
   const std::string buffer = args(0).string_value ();
-  if (error_state)
-    return retval;
 
   std::string pattern = args(1).string_value ();
-  if (error_state)
-    return retval;
+
   // Matlab compatibility.
   if (args(1).is_sq_string ())
     pattern = do_regexp_ptn_string_escapes (pattern);
 
   std::string replacement = args(2).string_value ();
-  if (error_state)
-    return retval;
+
   // Matlab compatibility.
   if (args(2).is_sq_string ())
     replacement = do_regexp_rep_string_escapes (replacement);
@@ -1274,8 +1336,6 @@
   regexp::opts options;
   bool extra_args = false;
   parse_options (options, regexpargs, who, 0, extra_args);
-  if (error_state)
-    return retval;
 
   return regexp_replace (pattern, buffer, replacement, options, who);
 }
@@ -1320,20 +1380,14 @@
 @seealso{regexp, regexpi, strrep}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-  int nargin = args.length ();
+  if (args.length () < 3)
+    print_usage ();
 
-  if (nargin < 3)
-    {
-      print_usage ();
-      return retval;
-    }
+  octave_value_list retval;
 
   if (args(0).is_cell () || args(1).is_cell () || args(2).is_cell ())
     {
-      Cell str;
-      Cell pat;
-      Cell rep;
+      Cell str, pat, rep;
       dim_vector dv0;
       dim_vector dv1 (1, 1);
 
@@ -1362,41 +1416,31 @@
       else if (rep.numel () != 1)
         dv1 = rep.dims ();
 
-      if (!error_state)
-        {
-          Cell ret (dv0);
-          octave_value_list new_args = args;
-
-          for (octave_idx_type i = 0; i < dv0.numel (); i++)
-            {
-              new_args(0) = str(i);
-              if (pat.numel () == 1)
-                new_args(1) = pat(0);
-              if (rep.numel () == 1)
-                new_args(2) = rep(0);
+      Cell ret (dv0);
+      octave_value_list new_args = args;
 
-              for (octave_idx_type j = 0; j < dv1.numel (); j++)
-                {
-                  if (pat.numel () != 1)
-                    new_args(1) = pat(j);
-                  if (rep.numel () != 1)
-                    new_args(2) = rep(j);
-                  new_args(0) = octregexprep (new_args, "regexprep");
+      for (octave_idx_type i = 0; i < dv0.numel (); i++)
+        {
+          new_args(0) = str(i);
+          if (pat.numel () == 1)
+            new_args(1) = pat(0);
+          if (rep.numel () == 1)
+            new_args(2) = rep(0);
 
-                  if (error_state)
-                    break;
-                }
-
-              if (error_state)
-                break;
-
-              ret(i) = new_args(0);
+          for (octave_idx_type j = 0; j < dv1.numel (); j++)
+            {
+              if (pat.numel () != 1)
+                new_args(1) = pat(j);
+              if (rep.numel () != 1)
+                new_args(2) = rep(j);
+              new_args(0) = octregexprep (new_args, "regexprep");
             }
 
-          if (!error_state)
-            retval = args(0).is_cell () ? octave_value (ret)
-                                        : octave_value (ret(0));
+          ret(i) = new_args(0);
         }
+
+      retval = args(0).is_cell () ? octave_value (ret)
+                                  : octave_value (ret(0));
     }
   else
     retval = octregexprep (args, "regexprep");
--- a/libinterp/corefcn/schur.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/schur.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -133,25 +133,14 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2 || nargout > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
 
   std::string ord;
 
   if (nargin == 2)
-    {
-      if (args(1).is_string ())
-        ord = args(1).string_value ();
-      else
-        {
-          error ("schur: second argument must be a string");
-          return retval;
-        }
-    }
+    ord = args(1).xstring_value ("schur: second argument must be a string");
 
   bool force_complex = false;
 
@@ -194,39 +183,32 @@
         {
           FloatMatrix tmp = arg.float_matrix_value ();
 
-          if (! error_state)
+          if (nargout == 0 || nargout == 1)
             {
-              if (nargout == 0 || nargout == 1)
-                {
-                  FloatSCHUR result (tmp, ord, false);
-                  retval(0) = result.schur_matrix ();
-                }
-              else
-                {
-                  FloatSCHUR result (tmp, ord, true);
-                  retval(1) = result.schur_matrix ();
-                  retval(0) = result.unitary_matrix ();
-                }
+              FloatSCHUR result (tmp, ord, false);
+              retval(0) = result.schur_matrix ();
+            }
+          else
+            {
+              FloatSCHUR result (tmp, ord, true);
+              retval(1) = result.schur_matrix ();
+              retval(0) = result.unitary_matrix ();
             }
         }
       else
         {
           FloatComplexMatrix ctmp = arg.float_complex_matrix_value ();
 
-          if (! error_state)
+          if (nargout == 0 || nargout == 1)
             {
-
-              if (nargout == 0 || nargout == 1)
-                {
-                  FloatComplexSCHUR result (ctmp, ord, false);
-                  retval(0) = mark_upper_triangular (result.schur_matrix ());
-                }
-              else
-                {
-                  FloatComplexSCHUR result (ctmp, ord, true);
-                  retval(1) = mark_upper_triangular (result.schur_matrix ());
-                  retval(0) = result.unitary_matrix ();
-                }
+              FloatComplexSCHUR result (ctmp, ord, false);
+              retval(0) = mark_upper_triangular (result.schur_matrix ());
+            }
+          else
+            {
+              FloatComplexSCHUR result (ctmp, ord, true);
+              retval(1) = mark_upper_triangular (result.schur_matrix ());
+              retval(0) = result.unitary_matrix ();
             }
         }
     }
@@ -236,39 +218,32 @@
         {
           Matrix tmp = arg.matrix_value ();
 
-          if (! error_state)
+          if (nargout == 0 || nargout == 1)
             {
-              if (nargout == 0 || nargout == 1)
-                {
-                  SCHUR result (tmp, ord, false);
-                  retval(0) = result.schur_matrix ();
-                }
-              else
-                {
-                  SCHUR result (tmp, ord, true);
-                  retval(1) = result.schur_matrix ();
-                  retval(0) = result.unitary_matrix ();
-                }
+              SCHUR result (tmp, ord, false);
+              retval(0) = result.schur_matrix ();
+            }
+          else
+            {
+              SCHUR result (tmp, ord, true);
+              retval(1) = result.schur_matrix ();
+              retval(0) = result.unitary_matrix ();
             }
         }
       else
         {
           ComplexMatrix ctmp = arg.complex_matrix_value ();
 
-          if (! error_state)
+          if (nargout == 0 || nargout == 1)
             {
-
-              if (nargout == 0 || nargout == 1)
-                {
-                  ComplexSCHUR result (ctmp, ord, false);
-                  retval(0) = mark_upper_triangular (result.schur_matrix ());
-                }
-              else
-                {
-                  ComplexSCHUR result (ctmp, ord, true);
-                  retval(1) = mark_upper_triangular (result.schur_matrix ());
-                  retval(0) = result.unitary_matrix ();
-                }
+              ComplexSCHUR result (ctmp, ord, false);
+              retval(0) = mark_upper_triangular (result.schur_matrix ());
+            }
+          else
+            {
+              ComplexSCHUR result (ctmp, ord, true);
+              retval(1) = mark_upper_triangular (result.schur_matrix ());
+              retval(0) = result.unitary_matrix ();
             }
         }
     }
@@ -319,45 +294,39 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 2 && nargout <= 2)
+  if (args.length () != 2 || nargout > 2)
+    print_usage ();
+
+  if (! args(0).is_numeric_type ())
+    gripe_wrong_type_arg ("rsf2csf", args(0));
+  else if (! args(1).is_numeric_type ())
+    gripe_wrong_type_arg ("rsf2csf", args(1));
+  else if (args(0).is_complex_type () || args(1).is_complex_type ())
+    error ("rsf2csf: UR and TR must be real matrices");
+  else
     {
-      if (! args(0).is_numeric_type ())
-        gripe_wrong_type_arg ("rsf2csf", args(0));
-      else if (! args(1).is_numeric_type ())
-        gripe_wrong_type_arg ("rsf2csf", args(1));
-      else if (args(0).is_complex_type () || args(1).is_complex_type ())
-        error ("rsf2csf: UR and TR must be real matrices");
+
+      if (args(0).is_single_type () || args(1).is_single_type ())
+        {
+          FloatMatrix u = args(0).float_matrix_value ();
+          FloatMatrix t = args(1).float_matrix_value ();
+
+          FloatComplexSCHUR cs (FloatSCHUR (t, u));
+
+          retval(1) = cs.schur_matrix ();
+          retval(0) = cs.unitary_matrix ();
+        }
       else
         {
-
-          if (args(0).is_single_type () || args(1).is_single_type ())
-            {
-              FloatMatrix u = args(0).float_matrix_value ();
-              FloatMatrix t = args(1).float_matrix_value ();
-              if (! error_state)
-                {
-                  FloatComplexSCHUR cs (FloatSCHUR (t, u));
+          Matrix u = args(0).matrix_value ();
+          Matrix t = args(1).matrix_value ();
 
-                  retval(1) = cs.schur_matrix ();
-                  retval(0) = cs.unitary_matrix ();
-                }
-            }
-          else
-            {
-              Matrix u = args(0).matrix_value ();
-              Matrix t = args(1).matrix_value ();
-              if (! error_state)
-                {
-                  ComplexSCHUR cs (SCHUR (t, u));
+          ComplexSCHUR cs (SCHUR (t, u));
 
-                  retval(1) = cs.schur_matrix ();
-                  retval(0) = cs.unitary_matrix ();
-                }
-            }
+          retval(1) = cs.schur_matrix ();
+          retval(0) = cs.unitary_matrix ();
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/corefcn/sighandlers.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/sighandlers.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -199,7 +199,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create w32_interrupt_manager");
+        error ("unable to create w32_interrupt_manager");
 
         retval = false;
       }
@@ -255,7 +255,7 @@
     } \
   while (0)
 
-#if !defined (SIGCHLD) && defined (SIGCLD)
+#if ! defined (SIGCHLD) && defined (SIGCLD)
 #define SIGCHLD SIGCLD
 #endif
 
@@ -929,7 +929,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create child list object!");
+      error ("unable to create child list object!");
 
       retval = false;
     }
@@ -1052,18 +1052,12 @@
 Return a structure containing Unix signal names and their defined values.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 0)
-    {
-      static octave_scalar_map m = make_sig_struct ();
-
-      retval = m;
-    }
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  static octave_scalar_map m = make_sig_struct ();
+
+  return octave_value (m);
 }
 
 /*
--- a/libinterp/corefcn/sighandlers.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/sighandlers.h	Thu Dec 10 12:50:06 2015 -0800
@@ -30,7 +30,7 @@
 
 // This file should always be included after config.h!
 
-#if !defined (octave_sighandlers_h)
+#if ! defined (octave_sighandlers_h)
 #define octave_sighandlers_h 1
 
 // Include signal.h, not csignal since the latter might only define
--- a/libinterp/corefcn/siglist.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/siglist.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_siglist_h)
+#if ! defined (octave_siglist_h)
 #define octave_siglist_h 1
 
 #ifdef __cplusplus
--- a/libinterp/corefcn/sparse-xdiv.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/sparse-xdiv.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_sparse_xdiv_h)
+#if ! defined (octave_sparse_xdiv_h)
 #define octave_sparse_xdiv_h 1
 
 #include "oct-cmplx.h"
--- a/libinterp/corefcn/sparse-xpow.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/sparse-xpow.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_sparse_xpow_h)
+#if ! defined (octave_sparse_xpow_h)
 #define octave_sparse_xpow_h 1
 
 #include "oct-cmplx.h"
--- a/libinterp/corefcn/sparse.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/sparse.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -49,12 +49,9 @@
 @end deftypefn")
 {
   if (args.length () != 1)
-    {
-      print_usage ();
-      return octave_value ();
-    }
-  else
-    return octave_value (args(0).is_sparse_type ());
+    print_usage ();
+
+  return octave_value (args(0).is_sparse_type ());
 }
 
 DEFUN (sparse, args, ,
@@ -128,6 +125,9 @@
   octave_value retval;
   int nargin = args.length ();
 
+  if (nargin == 0 || nargin > 6)
+    print_usage ();
+
   // Temporarily disable sparse_auto_mutate if set (it's obsolete anyway).
   unwind_protect frame;
   frame.protect_var (Vsparse_auto_mutate);
@@ -152,13 +152,10 @@
 
       get_dimensions (args(0), args(1), "sparse", m, n);
 
-      if (! error_state)
-        {
-          if (m >= 0 && n >= 0)
-            retval = SparseMatrix (m, n);
-          else
-            error ("sparse: dimensions must be non-negative");
-        }
+      if (m >= 0 && n >= 0)
+        retval = SparseMatrix (m, n);
+      else
+        error ("sparse: dimensions must be non-negative");
     }
   else if (nargin >= 3)
     {
@@ -176,44 +173,46 @@
           nargin -= 1;
         }
 
-      if (! error_state)
+      octave_idx_type m, n, nzmax;
+      m = n = nzmax = -1;
+      if (nargin == 6)
         {
-          octave_idx_type m, n, nzmax;
-          m = n = nzmax = -1;
-          if (nargin == 6)
-            {
-              nzmax = args(5).idx_type_value ();
-              nargin --;
-            }
+          nzmax = args(5).idx_type_value ();
+          nargin --;
+        }
 
-          if (nargin == 5)
-            {
-              get_dimensions (args(3), args(4), "sparse", m, n);
+      if (nargin == 5)
+        {
+          get_dimensions (args(3), args(4), "sparse", m, n);
+
+          if (m < 0 || n < 0)
+            error ("sparse: dimensions must be non-negative");
+        }
 
-              if (! error_state && (m < 0 || n < 0))
-                error ("sparse: dimensions must be non-negative");
-            }
-          else if (nargin != 3)
-            print_usage ();
-
-          if (! error_state)
-            {
-              idx_vector i = args(0).index_vector ();
-              idx_vector j = args(1).index_vector ();
+      int k = 0;    // index we're checking when index_vector throws
+      try
+        {
+          idx_vector i = args(0).index_vector ();
+          k = 1;
+          idx_vector j = args(1).index_vector ();
 
-              if (args(2).is_bool_type ())
-                retval = SparseBoolMatrix (args(2).bool_array_value (), i, j,
-                                           m, n, summation, nzmax);
-              else if (args(2).is_complex_type ())
-                retval = SparseComplexMatrix (args(2).complex_array_value (),
-                                              i, j, m, n, summation, nzmax);
-              else if (args(2).is_numeric_type ())
-                retval = SparseMatrix (args(2).array_value (), i, j,
+          if (args(2).is_bool_type ())
+            retval = SparseBoolMatrix (args(2).bool_array_value (), i,j,
                                        m, n, summation, nzmax);
-              else
-                gripe_wrong_type_arg ("sparse", args(2));
-            }
-
+          else if (args(2).is_complex_type ())
+            retval = SparseComplexMatrix (args(2).complex_array_value(),
+                                          i, j, m, n, summation, nzmax);
+          else if (args(2).is_numeric_type ())
+            retval = SparseMatrix (args(2).array_value (), i, j,
+                                   m, n, summation, nzmax);
+          else
+            gripe_wrong_type_arg ("sparse", args(2));
+        }
+      catch (index_exception& e)
+        {
+          // Rethrow to allow more info to be reported later.
+          e.set_pos_if_unset (2, k+1);
+          throw;
         }
     }
 
@@ -259,24 +258,23 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
-    {
-      octave_idx_type m = args(0).idx_type_value ();
-      octave_idx_type n = args(1).idx_type_value ();
-      octave_idx_type nz = 0;
-      if (nargin == 3)
-        nz = args(2).idx_type_value ();
-      if (error_state)
-        ;
-      else if (m >= 0 && n >= 0 && nz >= 0)
-        retval = SparseMatrix (dim_vector (m, n), nz);
-      else
-        error ("spalloc: M,N,NZ must be non-negative");
-    }
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  octave_idx_type m = args(0).idx_type_value ();
+  octave_idx_type n = args(1).idx_type_value ();
+  octave_idx_type nz = 0;
+
+  if (nargin == 3)
+    nz = args(2).idx_type_value ();
+
+  if (m >= 0 && n >= 0 && nz >= 0)
+    retval = SparseMatrix (dim_vector (m, n), nz);
   else
-    print_usage ();
+    error ("spalloc: M,N,NZ must be non-negative");
 
   return retval;
 }
--- a/libinterp/corefcn/spparms.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/spparms.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -155,11 +155,9 @@
         }
       else
         {
-          NDArray vals = args(0).array_value ();
+          NDArray vals = args(0).xarray_value ("spparms: input must be a string or a vector");
 
-          if (error_state)
-            error ("spparms: input must be a string or a vector");
-          else if (vals.numel () > OCTAVE_SPARSE_CONTROLS_SIZE)
+          if (vals.numel () > OCTAVE_SPARSE_CONTROLS_SIZE)
             error ("spparms: too many elements in vector VALS");
           else
             octave_sparse_params::set_vals (vals);
@@ -167,21 +165,14 @@
     }
   else if (nargin == 2)
     {
-      if (args(0).is_string ())
-        {
-          std::string str = args(0).string_value ();
+      std::string str = args(0).xstring_value ("spparms: first argument must be a string");
 
-          double val = args(1).double_value ();
+      double val = args(1).xdouble_value ("spparms: second argument must be a real scalar");
 
-          if (error_state)
-            error ("spparms: second argument must be a real scalar");
-          else if (str == "umfpack")
-            warning ("spparms: request to disable umfpack solvers ignored");
-          else if (!octave_sparse_params::set_key (str, val))
-            error ("spparms: KEY not found");
-        }
-      else
-        error ("spparms: first argument must be a string");
+      if (str == "umfpack")
+        warning ("spparms: request to disable umfpack solvers ignored");
+      else if (!octave_sparse_params::set_key (str, val))
+        error ("spparms: KEY not found");
     }
   else
     error ("spparms: too many input arguments");
--- a/libinterp/corefcn/sqrtm.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/sqrtm.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -214,13 +214,8 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 1)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 1)
+    print_usage ();
 
   octave_value arg = args(0);
 
@@ -228,10 +223,7 @@
   octave_idx_type nc = arg.columns ();
 
   if (n != nc || arg.ndims () > 2)
-    {
-      gripe_square_matrix_required ("sqrtm");
-      return retval;
-    }
+    gripe_square_matrix_required ("sqrtm");
 
   if (nargout > 1)
     {
@@ -248,7 +240,7 @@
   else if (arg.is_numeric_type ())
     retval(0) = do_sqrtm<Matrix, ComplexMatrix, ComplexSCHUR> (arg);
 
-  if (nargout > 1 && ! error_state)
+  if (nargout > 1)
     {
       // This corresponds to generic code
       //
--- a/libinterp/corefcn/str2double.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/str2double.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -345,7 +345,8 @@
 
   if (args.length () != 1)
     print_usage ();
-  else if (args(0).is_string ())
+
+  if (args(0).is_string ())
     {
       if (args(0).rows () == 0 || args(0).columns () == 0)
         {
@@ -358,29 +359,25 @@
       else
         {
           const string_vector sv = args(0).all_strings ();
-          if (! error_state)
-            retval = sv.map<Complex> (str2double1);
+
+          retval = sv.map<Complex> (str2double1);
         }
     }
   else if (args(0).is_cell ())
     {
       const Cell cell = args(0).cell_value ();
 
-      if (! error_state)
+      ComplexNDArray output (cell.dims (), octave_NaN);
+      for (octave_idx_type i = 0; i < cell.numel (); i++)
         {
-          ComplexNDArray output (cell.dims (), octave_NaN);
-          for (octave_idx_type i = 0; i < cell.numel (); i++)
-            {
-              if (cell(i).is_string ())
-                output(i) = str2double1 (cell(i).string_value ());
-            }
-          retval = output;
+          if (cell(i).is_string ())
+            output(i) = str2double1 (cell(i).string_value ());
         }
+      retval = output;
     }
   else
     retval = Matrix (1, 1, octave_NaN);
 
-
   return retval;
 }
 
--- a/libinterp/corefcn/strfind.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/strfind.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -193,81 +193,79 @@
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
+
+  if (nargin != 4 && nargin != 2)
+    print_usage ();
+
   bool overlaps = true;
 
-  if (nargin == 4 && args(2).is_string () && args(3).is_scalar_type ())
+  if (nargin == 4)
     {
-      std::string opt = args(2).string_value ();
-      if (opt == "overlaps")
+      if (args(2).is_string () && args(3).is_scalar_type ())
         {
-          overlaps = args(3).bool_value ();
-          nargin = 2;
+          std::string opt = args(2).string_value ();
+
+          if (opt == "overlaps")
+            overlaps = args(3).bool_value ();
+          else
+            error ("strfind: unknown option: %s", opt.c_str ());
         }
       else
-        {
-          error ("strfind: unknown option: %s", opt.c_str ());
-          return retval;
-        }
+        error ("strfind: invalid optional arguments");
     }
 
-  if (nargin == 2)
+  octave_value argstr = args(0);
+  octave_value argpat = args(1);
+
+  if (argpat.is_string ())
     {
-      octave_value argstr = args(0);
-      octave_value argpat = args(1);
-      if (argpat.is_string ())
-        {
-          Array<char> needle = argpat.char_array_value ();
-          OCTAVE_LOCAL_BUFFER (octave_idx_type, table, TABSIZE);
-          qs_preprocess (needle, table);
+      Array<char> needle = argpat.char_array_value ();
+      OCTAVE_LOCAL_BUFFER (octave_idx_type, table, TABSIZE);
+      qs_preprocess (needle, table);
 
-          if (argstr.is_string ())
-            if (argpat.is_empty ())
-              // Return a null matrix for null pattern for MW compatibility
-              retval = Matrix ();
-            else
-              retval = octave_value (qs_search (needle,
-                                                argstr.char_array_value (),
-                                                table, overlaps),
-                                     true, true);
-          else if (argstr.is_cell ())
+      if (argstr.is_string ())
+        if (argpat.is_empty ())
+          // Return a null matrix for null pattern for MW compatibility
+          retval = Matrix ();
+        else
+          retval = octave_value (qs_search (needle,
+                                            argstr.char_array_value (),
+                                            table, overlaps),
+                                 true, true);
+      else if (argstr.is_cell ())
+        {
+          const Cell argsc = argstr.cell_value ();
+          Cell retc (argsc.dims ());
+          octave_idx_type ns = argsc.numel ();
+
+          for (octave_idx_type i = 0; i < ns; i++)
             {
-              const Cell argsc = argstr.cell_value ();
-              Cell retc (argsc.dims ());
-              octave_idx_type ns = argsc.numel ();
-
-              for (octave_idx_type i = 0; i < ns; i++)
+              octave_value argse = argsc(i);
+              if (argse.is_string ())
                 {
-                  octave_value argse = argsc(i);
-                  if (argse.is_string ())
-                    {
-                      if (argpat.is_empty ())
-                        retc(i) = Matrix ();
-                      else
-                        retc(i) = octave_value (qs_search (needle,
-                                                     argse.char_array_value (),
-                                                     table, overlaps),
-                                                true, true);
-                    }
+                  if (argpat.is_empty ())
+                    retc(i) = Matrix ();
                   else
-                    {
-                      error ("strfind: each element of CELLSTR must be a string");
-                      break;
-                    }
+                    retc(i) = octave_value (qs_search (needle,
+                                                       argse.char_array_value (),
+                                                       table, overlaps),
+                                            true, true);
                 }
-
-              retval = retc;
+              else
+                error ("strfind: each element of CELLSTR must be a string");
             }
-          else
-            error ("strfind: first argument must be a string or cell array of strings");
+
+          retval = retc;
         }
-      else if (argpat.is_cell ())
-        retval = do_simple_cellfun (Fstrfind, "strfind", args);
       else
-        error ("strfind: PATTERN must be a string or cell array of strings");
+        error ("strfind: first argument must be a string or cell array of strings");
     }
+  else if (argpat.is_cell ())
+    retval = do_simple_cellfun (Fstrfind, "strfind", args);
   else
-    print_usage ();
+    error ("strfind: PATTERN must be a string or cell array of strings");
 
   return retval;
 }
@@ -386,71 +384,68 @@
 @end deftypefn")
 {
   octave_value retval;
-  int nargin = args.length ();
+
   bool overlaps = true;
 
-  if (nargin == 5 && args(3).is_string () && args(4).is_scalar_type ())
+  int nargin = args.length ();
+
+  if (nargin != 3 && nargin != 5)
+    print_usage ();
+
+  if (nargin == 5)
     {
-      std::string opt = args(3).string_value ();
-      if (opt == "overlaps")
+      if (args(3).is_string () && args(4).is_scalar_type ())
         {
-          overlaps = args(4).bool_value ();
-          nargin = 3;
+          std::string opt = args(3).string_value ();
+          if (opt == "overlaps")
+            overlaps = args(4).bool_value ();
+          else
+            error ("strrep: unknown option: %s", opt.c_str ());
         }
       else
-        {
-          error ("strrep: unknown option: %s", opt.c_str ());
-          return retval;
-        }
+        error ("strrep: invalid optional arguments");
     }
 
-  if (nargin == 3)
-    {
-      octave_value argstr = args(0);
-      octave_value argpat = args(1);
-      octave_value argrep = args(2);
-      if (argpat.is_string () && argrep.is_string ())
-        {
-          const Array<char> pat = argpat.char_array_value ();
-          const Array<char> rep = argrep.char_array_value ();
+  octave_value argstr = args(0);
+  octave_value argpat = args(1);
+  octave_value argrep = args(2);
 
-          OCTAVE_LOCAL_BUFFER (octave_idx_type, table, TABSIZE);
-          qs_preprocess (pat, table);
+  if (argpat.is_string () && argrep.is_string ())
+    {
+      const Array<char> pat = argpat.char_array_value ();
+      const Array<char> rep = argrep.char_array_value ();
 
-          if (argstr.is_string ())
-            retval = qs_replace (argstr.char_array_value (), pat, rep,
-                                 table, overlaps);
-          else if (argstr.is_cell ())
-            {
-              const Cell argsc = argstr.cell_value ();
-              Cell retc (argsc.dims ());
-              octave_idx_type ns = argsc.numel ();
+      OCTAVE_LOCAL_BUFFER (octave_idx_type, table, TABSIZE);
+      qs_preprocess (pat, table);
 
-              for (octave_idx_type i = 0; i < ns; i++)
-                {
-                  octave_value argse = argsc(i);
-                  if (argse.is_string ())
-                    retc(i) = qs_replace (argse.char_array_value (), pat, rep,
-                                          table, overlaps);
-                  else
-                    {
-                      error ("strrep: each element of S must be a string");
-                      break;
-                    }
-                }
+      if (argstr.is_string ())
+        retval = qs_replace (argstr.char_array_value (), pat, rep,
+                             table, overlaps);
+      else if (argstr.is_cell ())
+        {
+          const Cell argsc = argstr.cell_value ();
+          Cell retc (argsc.dims ());
+          octave_idx_type ns = argsc.numel ();
 
-              retval = retc;
+          for (octave_idx_type i = 0; i < ns; i++)
+            {
+              octave_value argse = argsc(i);
+              if (argse.is_string ())
+                retc(i) = qs_replace (argse.char_array_value (), pat, rep,
+                                      table, overlaps);
+              else
+                error ("strrep: each element of S must be a string");
             }
-          else
-            error ("strrep: S must be a string or cell array of strings");
+
+          retval = retc;
         }
-      else if (argpat.is_cell () || argrep.is_cell ())
-        retval = do_simple_cellfun (Fstrrep, "strrep", args);
       else
-        error ("strrep: PTN and REP arguments must be strings or cell arrays of strings");
+        error ("strrep: S must be a string or cell array of strings");
     }
+  else if (argpat.is_cell () || argrep.is_cell ())
+    retval = do_simple_cellfun (Fstrrep, "strrep", args);
   else
-    print_usage ();
+    error ("strrep: PTN and REP arguments must be strings or cell arrays of strings");
 
   return retval;
 }
--- a/libinterp/corefcn/strfns.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/strfns.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -95,16 +95,10 @@
 
       for (int i = 0; i < nargin; i++)
         {
-          string_vector s = args(i).all_strings ();
+          string_vector s = args(i).xall_strings ("char: unable to convert some args to strings");
 
-          if (error_state)
-            {
-              error ("char: unable to convert some args to strings");
-              return retval;
-            }
-
-          if (s.length () > 0)
-            n_elts += s.length ();
+          if (s.numel () > 0)
+            n_elts += s.numel ();
           else
             n_elts += 1;
 
@@ -125,7 +119,7 @@
           string_vector s = args_as_strings.front ();
           args_as_strings.pop ();
 
-          int n = s.length ();
+          int n = s.numel ();
 
           if (n > 0)
             {
@@ -210,78 +204,64 @@
   octave_value retval;
 
   int nargin = args.length ();
-
-  if (nargin > 0)
-    {
-      int n_elts = 0;
-
-      size_t max_len = 0;
-
-      std::queue<string_vector> args_as_strings;
+  int n_elts = 0;
+  size_t max_len = 0;
+  std::queue<string_vector> args_as_strings;
 
-      for (int i = 0; i < nargin; i++)
-        {
-          string_vector s = args(i).all_strings ();
-
-          if (error_state)
-            {
-              error ("strvcat: unable to convert some args to strings");
-              return retval;
-            }
+  for (int i = 0; i < nargin; i++)
+    {
+      string_vector s = args(i).xall_strings ("strvcat: unable to convert some args to strings");
 
-          size_t n = s.length ();
+      size_t n = s.numel ();
 
-          // do not count empty strings in calculation of number of elements
-          if (n > 0)
+      // do not count empty strings in calculation of number of elements
+      if (n > 0)
+        {
+          for (size_t j = 0; j < n; j++)
             {
-              for (size_t j = 0; j < n; j++)
-                {
-                  if (s[j].length () > 0)
-                    n_elts++;
-                }
+              if (s[j].length () > 0)
+                n_elts++;
             }
-
-          size_t s_max_len = s.max_length ();
-
-          if (s_max_len > max_len)
-            max_len = s_max_len;
-
-          args_as_strings.push (s);
         }
 
-      string_vector result (n_elts);
+      size_t s_max_len = s.max_length ();
+
+      if (s_max_len > max_len)
+        max_len = s_max_len;
+
+      args_as_strings.push (s);
+    }
+
+  string_vector result (n_elts);
 
-      octave_idx_type k = 0;
+  octave_idx_type k = 0;
 
-      for (int i = 0; i < nargin; i++)
+  for (int i = 0; i < nargin; i++)
+    {
+      string_vector s = args_as_strings.front ();
+      args_as_strings.pop ();
+
+      size_t n = s.numel ();
+
+      if (n > 0)
         {
-          string_vector s = args_as_strings.front ();
-          args_as_strings.pop ();
-
-          size_t n = s.length ();
-
-          if (n > 0)
+          for (size_t j = 0; j < n; j++)
             {
-              for (size_t j = 0; j < n; j++)
+              std::string t = s[j];
+              if (t.length () > 0)
                 {
-                  std::string t = s[j];
-                  if (t.length () > 0)
-                    {
-                      size_t t_len = t.length ();
+                  size_t t_len = t.length ();
 
-                      if (max_len > t_len)
-                        t += std::string (max_len - t_len, ' ');
+                  if (max_len > t_len)
+                    t += std::string (max_len - t_len, ' ');
 
-                      result[k++] = t;
-                    }
+                  result[k++] = t;
                 }
             }
         }
+    }
 
-      retval = octave_value (result, '\'');
-    }
-  else
-    print_usage ();
+  retval = octave_value (result, '\'');
 
   return retval;
 }
@@ -298,8 +278,7 @@
 %!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 ()
+%!assert (strvcat (), "")
 */
 
 
@@ -310,16 +289,10 @@
 @seealso{isfloat, isinteger, islogical, isnumeric, iscellstr, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1 && args(0).is_defined ())
-    retval = args(0).is_string ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_string ());
 }
 
 /*
@@ -374,7 +347,7 @@
 
       const Cell cell = cell_val.cell_value ();
       const string_vector str = str_val.all_strings ();
-      octave_idx_type r = str.length ();
+      octave_idx_type r = str.numel ();
 
       if (r == 0 || r == 1)
         {
@@ -387,13 +360,13 @@
           if (cell_val.is_cellstr ())
             {
               const Array<std::string> cellstr = cell_val.cellstr_value ();
-              for (octave_idx_type i = 0; i < cellstr.length (); i++)
+              for (octave_idx_type i = 0; i < cellstr.numel (); i++)
                 output(i) = str_op (cellstr(i), s, n);
             }
           else
             {
               // FIXME: should we warn here?
-              for (octave_idx_type i = 0; i < cell.length (); i++)
+              for (octave_idx_type i = 0; i < cell.numel (); i++)
                 {
                   if (cell(i).is_string ())
                     output(i) = str_op (cell(i).string_value (), s, n);
@@ -404,7 +377,7 @@
         }
       else if (r > 1)
         {
-          if (cell.length () == 1)
+          if (cell.numel () == 1)
             {
               // Broadcast the cell.
 
@@ -427,13 +400,13 @@
 
               boolNDArray output (cell.dims (), false);
 
-              if (cell.length () == r)
+              if (cell.numel () == r)
                 {
                   if (cell_val.is_cellstr ())
                     {
                       const Array<std::string> cellstr
                         = cell_val.cellstr_value ();
-                      for (octave_idx_type i = 0; i < cellstr.length (); i++)
+                      for (octave_idx_type i = 0; i < cellstr.numel (); i++)
                         output(i) = str_op (str[i], cellstr(i), n);
                     }
                   else
@@ -493,7 +466,7 @@
               if (cell1_val.is_cellstr ())
                 {
                   const Array<std::string> cellstr = cell1_val.cellstr_value ();
-                  for (octave_idx_type i = 0; i < cellstr.length (); i++)
+                  for (octave_idx_type i = 0; i < cellstr.numel (); i++)
                     output(i) = str_op (cellstr(i), str2, n);
                 }
               else
@@ -513,10 +486,7 @@
       else
         {
           if (size1 != size2)
-            {
-              error ("%s: nonconformant cell arrays", fcn_name);
-              return retval;
-            }
+            error ("%s: nonconformant cell arrays", fcn_name);
 
           if (cell1.is_cellstr () && cell2.is_cellstr ())
             {
@@ -582,17 +552,11 @@
 @seealso{strcmpi, strncmp, strncmpi}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 2)
-    {
-      retval = do_strcmp_fun (args(0), args(1), 0,
-                              "strcmp", strcmp_array_op, strcmp_str_op);
-    }
-  else
+  if (args.length () != 2)
     print_usage ();
 
-  return retval;
+  return octave_value (do_strcmp_fun (args(0), args(1), 0, "strcmp",
+                                      strcmp_array_op, strcmp_str_op));
 }
 
 /*
@@ -700,23 +664,16 @@
 {
   octave_value retval;
 
-  if (args.length () == 3)
-    {
-      octave_idx_type n = args(2).idx_type_value ();
+  if (args.length () != 3)
+    print_usage ();
+
+  octave_idx_type n = args(2).idx_type_value ();
 
-      if (! error_state)
-        {
-          if (n > 0)
-            {
-              retval = do_strcmp_fun (args(0), args(1), n, "strncmp",
-                                      strncmp_array_op, strncmp_str_op);
-            }
-          else
-            error ("strncmp: N must be greater than 0");
-        }
-    }
+  if (n > 0)
+    retval = do_strcmp_fun (args(0), args(1), n, "strncmp",
+                            strncmp_array_op, strncmp_str_op);
   else
-    print_usage ();
+    error ("strncmp: N must be greater than 0");
 
   return retval;
 }
@@ -738,7 +695,9 @@
 struct icmp_char_eq : public std::binary_function<char, char, bool>
 {
   bool operator () (char x, char y) const
-  { return std::toupper (x) == std::toupper (y); }
+  {
+    return std::toupper (x) == std::toupper (y);
+  }
 };
 
 // strcmpi is equivalent to strcmp in that it checks all dims.
@@ -782,15 +741,11 @@
 {
   octave_value retval;
 
-  if (args.length () == 2)
-    {
-      retval = do_strcmp_fun (args(0), args(1), 0,
-                              "strcmpi", strcmpi_array_op, strcmpi_str_op);
-    }
-  else
+  if (args.length () != 2)
     print_usage ();
 
-  return retval;
+  return octave_value (do_strcmp_fun (args(0), args(1), 0, "strcmpi",
+                                      strcmpi_array_op, strcmpi_str_op));
 }
 
 /*
@@ -843,23 +798,16 @@
 {
   octave_value retval;
 
-  if (args.length () == 3)
-    {
-      octave_idx_type n = args(2).idx_type_value ();
+  if (args.length () != 3)
+    print_usage ();
+
+  octave_idx_type n = args(2).idx_type_value ();
 
-      if (! error_state)
-        {
-          if (n > 0)
-            {
-              retval = do_strcmp_fun (args(0), args(1), n, "strncmpi",
-                                      strncmpi_array_op, strncmpi_str_op);
-            }
-          else
-            error ("strncmpi: N must be greater than 0");
-        }
-    }
+  if (n > 0)
+    retval = do_strcmp_fun (args(0), args(1), n, "strncmpi",
+                            strncmpi_array_op, strncmpi_str_op);
   else
-    print_usage ();
+    error ("strncmpi: N must be greater than 0");
 
   return retval;
 }
@@ -909,44 +857,19 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
-  string_vector s = args(0).all_strings ();
-
-  if (error_state)
-    {
-      error ("list_in_columns: ARG must be a cellstr or char array");
-      return retval;
-    }
+  string_vector s = args(0).xall_strings ("list_in_columns: ARG must be a cellstr or char array");
 
   int width = -1;
 
   if (nargin > 1 && ! args(1).is_empty ())
-    {
-      width = args(1).int_value ();
-
-      if (error_state)
-        {
-          error ("list_in_columns: WIDTH must be an integer");
-          return retval;
-        }
-    }
+    width = args(1).xint_value ("list_in_columns: WIDTH must be an integer");
 
   std::string prefix;
 
   if (nargin > 2)
-    {
-      if (args(2).is_string ())
-        prefix = args(2).string_value ();
-      else
-        {
-          error ("list_in_columns: PREFIX must be a string");
-          return retval;
-        }
-    }
+    prefix = args(2).xstring_value ("list_in_columns: PREFIX must be a string");
 
   std::ostringstream buf;
 
@@ -974,5 +897,5 @@
 %!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")
+%!error <list_in_columns: WIDTH must be an integer> list_in_columns (["abc", "def"], "a")
 */
--- a/libinterp/corefcn/sub2ind.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/sub2ind.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -39,7 +39,7 @@
 {
   RowVector dimsv = val.row_vector_value (false, true);
   dim_vector dv;
-  octave_idx_type n = dimsv.length ();
+  octave_idx_type n = dimsv.numel ();
 
   if (n < 1)
     error ("%s: dimension vector DIMS must not be empty", name);
@@ -83,44 +83,38 @@
 @end deftypefn")
 {
   int nargin = args.length ();
-  octave_value retval;
 
   if (nargin < 2)
     print_usage ();
-  else
-    {
-      dim_vector dv = get_dim_vector (args(0), "sub2ind");
-      Array<idx_vector> idxa (dim_vector (nargin-1, 1));
+
+  dim_vector dv = get_dim_vector (args(0), "sub2ind");
+  Array<idx_vector> idxa (dim_vector (nargin-1, 1));
 
-      if (! error_state)
+  dv = dv.redim (nargin - 1);
+  for (int j = 0; j < nargin - 1; j++)
+    {
+      if (args(j+1).is_numeric_type ())
         {
-          dv = dv.redim (nargin - 1);
-          for (int j = 0; j < nargin - 1; j++)
+          try
             {
-              if (args(j+1).is_numeric_type ())
-                {
-                  idxa(j) = args(j+1).index_vector ();
-                  if (error_state)
-                    break;
-                  else if (j > 0 && args(j+1).dims () != args(1).dims ())
-                    error ("sub2ind: all subscripts must be of the same size");
-                }
-              else
-                error ("sub2ind: subscripts must be numeric");
+              idxa(j) = args(j+1).index_vector ();
 
-              if (error_state)
-                break;
+              if (j > 0 && args(j+1).dims () != args(1).dims ())
+                error ("sub2ind: all subscripts must be of the same size");
+            }
+          catch (index_exception& e)
+            {
+              e.set_pos_if_unset (nargin-1, j+1);
+              e.set_var ();
+              std::string msg = e.message ();
+              error_with_id (e.err_id (), msg.c_str ());
             }
         }
-
-      if (! error_state)
-        {
-          idx_vector idx = sub2ind (dv, idxa);
-          retval = idx;
-        }
+      else
+        error ("sub2ind: subscripts must be numeric");
     }
 
-  return retval;
+  return octave_value (sub2ind (dv, idxa));
 }
 
 /*
@@ -134,23 +128,23 @@
 
 # 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)
+%!error <index \(0,_,_\)> sub2ind ([10 10 10], 0, 1, 1)
+%!error <index \(_,0,_\)> sub2ind ([10 10 10], 1, 0, 1)
+%!error <index \(_,_,0\)> sub2ind ([10 10 10], 1, 1, 0)
 
 # Test high index
 %!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)
+%!error <index \(11,_,_\): out of bound 10> sub2ind ([10 10 10], 11, 10, 10)
+%!error <index \(_,11,_\): out of bound 10> sub2ind ([10 10 10], 10, 11, 10)
+%!error <index \(_,_,11\): out of bound 10> sub2ind ([10 10 10], 10, 10, 11)
 
 # Test high index in the trailing dimensions
 %!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)
+%!error <index \(_,2,_\): out of bound 1> sub2ind ([10, 1], 1, 2, 1)
+%!error <index \(_,_,2\): out of bound 1> 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)
+%!error <index \(_,_,2\): out of bound 1> sub2ind ([10 10], 2, 1, 2)
+%!error <index \(_,_,2\): out of bound 1> sub2ind ([10 10], 1, 2, 2)
 
 # Test handling of empty arguments
 %!assert (sub2ind ([10 10], zeros (0,0), zeros (0,0)), zeros (0,0))
@@ -164,8 +158,8 @@
 
 ## 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)
+%!error <index \(1.5,_\)> sub2ind ([10 10], 1.5, 1)
+%!error <index \(_,1.5\)> sub2ind ([10 10], 1, 1.5)
 */
 
 DEFUN (ind2sub, args, nargout,
@@ -187,23 +181,27 @@
 @seealso{sub2ind}\n\
 @end deftypefn")
 {
-  int nargin = args.length ();
   octave_value_list retval;
 
-  if (nargin != 2)
+  if (args.length () != 2)
     print_usage ();
-  else
+
+  dim_vector dv = get_dim_vector (args(0), "ind2sub");
+
+  try
     {
-      dim_vector dv = get_dim_vector (args(0), "ind2sub");
       idx_vector idx = args(1).index_vector ();
-      if (! error_state)
-        {
-          if (nargout > dv.length ())
-            dv = dv.redim (nargout);
+
+      if (nargout > dv.length ())
+        dv = dv.redim (nargout);
 
-          Array<idx_vector> idxa = ind2sub (dv, idx);
-          retval = Array<octave_value> (idxa);
-        }
+      retval = Array<octave_value> (ind2sub (dv, idx));
+    }
+  catch (const index_exception& e)
+    {
+      std::string idx = e.idx ();
+      std::string msg = e.details ();
+      error ("ind2sub: Invalid index %s. %s", idx.c_str (), msg.c_str ());
     }
 
   return retval;
--- a/libinterp/corefcn/svd.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/svd.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -129,10 +129,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2 || nargout == 2 || nargout > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
 
@@ -140,10 +137,7 @@
   octave_idx_type nc = arg.columns ();
 
   if (arg.ndims () != 2)
-    {
-      error ("svd: A must be a 2-D matrix");
-      return retval;
-    }
+    error ("svd: A must be a 2-D matrix");
 
   bool isfloat = arg.is_single_type ();
 
@@ -164,12 +158,14 @@
               retval(1) = FloatMatrix (nr, nc);
               retval(0) = FloatDiagMatrix (nr, nr, 1.0f);
               break;
+
             case SVD::economy:
               retval(2) = FloatDiagMatrix (0, nc, 1.0f);
               retval(1) = FloatMatrix (0, 0);
               retval(0) = FloatDiagMatrix (nr, 0, 1.0f);
               break;
-          case SVD::sigma_only: default:
+
+            case SVD::sigma_only: default:
               retval(0) = FloatMatrix (0, 1);
               break;
             }
@@ -183,12 +179,14 @@
               retval(1) = Matrix (nr, nc);
               retval(0) = DiagMatrix (nr, nr, 1.0);
               break;
+
             case SVD::economy:
               retval(2) = DiagMatrix (0, nc, 1.0);
               retval(1) = Matrix (0, 0);
               retval(0) = DiagMatrix (nr, 0, 1.0);
               break;
-          case SVD::sigma_only: default:
+
+            case SVD::sigma_only: default:
               retval(0) = Matrix (0, 1);
               break;
             }
@@ -202,56 +200,40 @@
             {
               FloatMatrix tmp = arg.float_matrix_value ();
 
-              if (! error_state)
-                {
-                  if (tmp.any_element_is_inf_or_nan ())
-                    {
-                      error ("svd: cannot take SVD of matrix containing Inf or NaN values");
-                      return retval;
-                    }
+              if (tmp.any_element_is_inf_or_nan ())
+                error ("svd: cannot take SVD of matrix containing Inf or NaN values");
 
-                  FloatSVD result (tmp, type, driver);
+              FloatSVD result (tmp, type, driver);
+
+              FloatDiagMatrix sigma = result.singular_values ();
 
-                  FloatDiagMatrix sigma = result.singular_values ();
-
-                  if (nargout == 0 || nargout == 1)
-                    {
-                      retval(0) = sigma.extract_diag ();
-                    }
-                  else
-                    {
-                      retval(2) = result.right_singular_matrix ();
-                      retval(1) = sigma;
-                      retval(0) = result.left_singular_matrix ();
-                    }
+              if (nargout == 0 || nargout == 1)
+                retval(0) = sigma.extract_diag ();
+              else
+                {
+                  retval(2) = result.right_singular_matrix ();
+                  retval(1) = sigma;
+                  retval(0) = result.left_singular_matrix ();
                 }
             }
           else if (arg.is_complex_type ())
             {
               FloatComplexMatrix ctmp = arg.float_complex_matrix_value ();
 
-              if (! error_state)
-                {
-                  if (ctmp.any_element_is_inf_or_nan ())
-                    {
-                      error ("svd: cannot take SVD of matrix containing Inf or NaN values");
-                      return retval;
-                    }
+              if (ctmp.any_element_is_inf_or_nan ())
+                error ("svd: cannot take SVD of matrix containing Inf or NaN values");
 
-                  FloatComplexSVD result (ctmp, type, driver);
+              FloatComplexSVD result (ctmp, type, driver);
+
+              FloatDiagMatrix sigma = result.singular_values ();
 
-                  FloatDiagMatrix sigma = result.singular_values ();
-
-                  if (nargout == 0 || nargout == 1)
-                    {
-                      retval(0) = sigma.extract_diag ();
-                    }
-                  else
-                    {
-                      retval(2) = result.right_singular_matrix ();
-                      retval(1) = sigma;
-                      retval(0) = result.left_singular_matrix ();
-                    }
+              if (nargout == 0 || nargout == 1)
+                retval(0) = sigma.extract_diag ();
+              else
+                {
+                  retval(2) = result.right_singular_matrix ();
+                  retval(1) = sigma;
+                  retval(0) = result.left_singular_matrix ();
                 }
             }
         }
@@ -261,63 +243,44 @@
             {
               Matrix tmp = arg.matrix_value ();
 
-              if (! error_state)
-                {
-                  if (tmp.any_element_is_inf_or_nan ())
-                    {
-                      error ("svd: cannot take SVD of matrix containing Inf or NaN values");
-                      return retval;
-                    }
+              if (tmp.any_element_is_inf_or_nan ())
+                error ("svd: cannot take SVD of matrix containing Inf or NaN values");
 
-                  SVD result (tmp, type, driver);
+              SVD result (tmp, type, driver);
+
+              DiagMatrix sigma = result.singular_values ();
 
-                  DiagMatrix sigma = result.singular_values ();
-
-                  if (nargout == 0 || nargout == 1)
-                    {
-                      retval(0) = sigma.extract_diag ();
-                    }
-                  else
-                    {
-                      retval(2) = result.right_singular_matrix ();
-                      retval(1) = sigma;
-                      retval(0) = result.left_singular_matrix ();
-                    }
+              if (nargout == 0 || nargout == 1)
+                retval(0) = sigma.extract_diag ();
+              else
+                {
+                  retval(2) = result.right_singular_matrix ();
+                  retval(1) = sigma;
+                  retval(0) = result.left_singular_matrix ();
                 }
             }
           else if (arg.is_complex_type ())
             {
               ComplexMatrix ctmp = arg.complex_matrix_value ();
 
-              if (! error_state)
-                {
-                  if (ctmp.any_element_is_inf_or_nan ())
-                    {
-                      error ("svd: cannot take SVD of matrix containing Inf or NaN values");
-                      return retval;
-                    }
+              if (ctmp.any_element_is_inf_or_nan ())
+                error ("svd: cannot take SVD of matrix containing Inf or NaN values");
 
-                  ComplexSVD result (ctmp, type, driver);
+              ComplexSVD result (ctmp, type, driver);
+
+              DiagMatrix sigma = result.singular_values ();
 
-                  DiagMatrix sigma = result.singular_values ();
-
-                  if (nargout == 0 || nargout == 1)
-                    {
-                      retval(0) = sigma.extract_diag ();
-                    }
-                  else
-                    {
-                      retval(2) = result.right_singular_matrix ();
-                      retval(1) = sigma;
-                      retval(0) = result.left_singular_matrix ();
-                    }
+              if (nargout == 0 || nargout == 1)
+                retval(0) = sigma.extract_diag ();
+              else
+                {
+                  retval(2) = result.right_singular_matrix ();
+                  retval(1) = sigma;
+                  retval(0) = result.left_singular_matrix ();
                 }
             }
           else
-            {
-              gripe_wrong_type_arg ("svd", arg);
-              return retval;
-            }
+            gripe_wrong_type_arg ("svd", arg);
         }
     }
 
--- a/libinterp/corefcn/sylvester.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/sylvester.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -62,13 +62,8 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 3 || nargout > 1)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 3 || nargout > 1)
+    print_usage ();
 
   octave_value arg_a = args(0);
   octave_value arg_b = args(1);
@@ -126,20 +121,9 @@
           // Do everything in complex arithmetic;
 
           FloatComplexMatrix ca = arg_a.float_complex_matrix_value ();
-
-          if (error_state)
-            return retval;
-
           FloatComplexMatrix cb = arg_b.float_complex_matrix_value ();
-
-          if (error_state)
-            return retval;
-
           FloatComplexMatrix cc = arg_c.float_complex_matrix_value ();
 
-          if (error_state)
-            return retval;
-
           retval = Sylvester (ca, cb, cc);
         }
       else
@@ -147,20 +131,9 @@
           // Do everything in real arithmetic.
 
           FloatMatrix ca = arg_a.float_matrix_value ();
-
-          if (error_state)
-            return retval;
-
           FloatMatrix cb = arg_b.float_matrix_value ();
-
-          if (error_state)
-            return retval;
-
           FloatMatrix cc = arg_c.float_matrix_value ();
 
-          if (error_state)
-            return retval;
-
           retval = Sylvester (ca, cb, cc);
         }
     }
@@ -173,20 +146,9 @@
           // Do everything in complex arithmetic;
 
           ComplexMatrix ca = arg_a.complex_matrix_value ();
-
-          if (error_state)
-            return retval;
-
           ComplexMatrix cb = arg_b.complex_matrix_value ();
-
-          if (error_state)
-            return retval;
-
           ComplexMatrix cc = arg_c.complex_matrix_value ();
 
-          if (error_state)
-            return retval;
-
           retval = Sylvester (ca, cb, cc);
         }
       else
@@ -194,20 +156,9 @@
           // Do everything in real arithmetic.
 
           Matrix ca = arg_a.matrix_value ();
-
-          if (error_state)
-            return retval;
-
           Matrix cb = arg_b.matrix_value ();
-
-          if (error_state)
-            return retval;
-
           Matrix cc = arg_c.matrix_value ();
 
-          if (error_state)
-            return retval;
-
           retval = Sylvester (ca, cb, cc);
         }
     }
--- a/libinterp/corefcn/symtab.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/symtab.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -44,6 +44,7 @@
 #include "pager.h"
 #include "parse.h"
 #include "pt-arg-list.h"
+#include "pt-pr-code.h"
 #include "symtab.h"
 #include "unwind-prot.h"
 #include "utils.h"
@@ -695,7 +696,7 @@
 {
   octave_value retval = xfind (args, local_funcs);
 
-  if (! (error_state || retval.is_defined ()))
+  if (retval.is_undefined ())
     {
       // It is possible that the user created a file on the fly since
       // the last prompt or chdir, so try updating the load path and
@@ -1075,7 +1076,7 @@
   if (function_on_path.is_defined ())
     out_of_date_check (function_on_path);
 
-  if (! (error_state || function_on_path.is_defined ()))
+  if (function_on_path.is_undefined ())
     {
       std::string dir_name;
 
@@ -1102,7 +1103,7 @@
   //if (package.is_defined ())
   //  out_of_date_check (package);
 
-  if (! (error_state || package.is_defined ()))
+  if (package.is_undefined ())
     {
       octave_function * fcn =
         cdef_manager::find_package_symbol (full_name ());
@@ -1620,7 +1621,7 @@
               && 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");
+                error ("global and persistent may only be used in the topmost level in which a nested variable is used");
 
               if (! ours.is_formal ())
                 {
@@ -1667,6 +1668,9 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargout > 0 || nargin == 0)
     {
       switch (Vignore_function_time_stamp)
@@ -1687,23 +1691,17 @@
 
   if (nargin == 1)
     {
-      if (args(0).is_string ())
-        {
-          std::string sval = args(0).string_value ();
-          if (sval == "all")
-            Vignore_function_time_stamp = 2;
-          else if (sval == "system")
-            Vignore_function_time_stamp = 1;
-          else if (sval == "none")
-            Vignore_function_time_stamp = 0;
-          else
-            error ("ignore_function_time_stamp: argument must be \"all\", \"system\", or \"none\"");
-        }
+      std::string sval = args(0).xstring_value ("ignore_function_time_stamp: first argument must be a string");
+
+      if (sval == "all")
+        Vignore_function_time_stamp = 2;
+      else if (sval == "system")
+        Vignore_function_time_stamp = 1;
+      else if (sval == "none")
+        Vignore_function_time_stamp = 0;
       else
-        error ("ignore_function_time_stamp: expecting argument to be character string");
+        error ("ignore_function_time_stamp: argument must be one of \"all\", \"system\", or \"none\"");
     }
-  else if (nargin > 1)
-    print_usage ();
 
   return retval;
 }
@@ -1728,8 +1726,9 @@
 
 DEFUN (__current_scope__, , ,
        "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {[@var{scope}, @var{context}]} __dump_symtab_info__ ()\n\
-Undocumented internal function.\n\
+@deftypefn {Built-in Function} {[@var{scope}, @var{context}]} __current_scope__ ()\n\
+Return the current scope and context as integers.\n\
+@seealso{__dump_symtab_info__}\n\
 @end deftypefn")
 {
   octave_value_list retval;
@@ -1747,12 +1746,16 @@
 @deftypefnx {Built-in Function} {} __dump_symtab_info__ (\"scopes\")\n\
 @deftypefnx {Built-in Function} {} __dump_symtab_info__ (\"functions\")\n\
 Undocumented internal function.\n\
+@seealso{__current_scope__}\n\
 @end deftypefn")
 {
   octave_value retval;
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 0)
     {
       symbol_table::dump_functions (octave_stdout);
@@ -1765,7 +1768,7 @@
            p != lst.end (); p++)
         symbol_table::dump (octave_stdout, *p);
     }
-  else if (nargin == 1)
+  else
     {
       octave_value arg = args(0);
 
@@ -1792,21 +1795,47 @@
               symbol_table::dump_functions (octave_stdout);
             }
           else
-            error ("__dump_symtab_info__: expecting \"functions\" or \"scopes\"");
+            error ("__dump_symtab_info__: string argument must be \"functions\" or \"scopes\"");
         }
       else
         {
-          int s = arg.int_value ();
+          int s = arg.xint_value ("__dump_symtab_info__: first argument must be string or scope id");
 
-          if (! error_state)
-            symbol_table::dump (octave_stdout, s);
-          else
-            error ("__dump_symtab_info__: expecting string or scope id");
+          symbol_table::dump (octave_stdout, s);
         }
     }
-  else
+
+  return retval;
+}
+
+DEFUN (__get_cmdline_fcn_txt__, args, ,
+       "-*- texinfo -*-\n\
+@deftypefn {Built-in Function} {} __get_cmdline_fcn_txt__ (@var{name})\n\
+Undocumented internal function.\n\
+@end deftypefn")
+{
+  octave_value retval;
+
+  if (args.length () != 1)
     print_usage ();
 
+  std::string name = args(0).xstring_value ("__get_cmd_line_function_text__: first argument must be function name");
+
+  octave_value ov = symbol_table::find_cmdline_function (name);
+
+  octave_user_function *f = ov.user_function_value ();
+
+  if (f)
+    {
+      std::ostringstream buf;
+
+      tree_print_code tpc (buf);
+
+      f->accept (tpc);
+
+      retval = buf.str ();
+    }
+
   return retval;
 }
 
@@ -1818,17 +1847,12 @@
 {
   octave_value retval;
 
-  if (args.length () == 2)
-    {
-      std::string name = args(0).string_value ();
+  if (args.length () != 2)
+    print_usage ();
 
-      if (! error_state)
-        symbol_table::assign (name, args(1));
-      else
-        error ("set_variable: expecting variable name as first argument");
-    }
-  else
-    print_usage ();
+  std::string name = args(0).xstring_value ("set_variable: variable NAME must be a string");
+
+  symbol_table::assign (name, args(1));
 
   return retval;
 }
@@ -1837,23 +1861,16 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      std::string name = args(0).string_value ();
+  if (args.length () != 1)
+    print_usage ();
 
-      if (! error_state)
-        {
-          retval = symbol_table::varval (name);
+  std::string name = args(0).xstring_value ("variable_value: variable NAME must be a string");
 
-          if (retval.is_undefined ())
-            error ("variable_value: '%s' is not a variable in the current scope",
-                   name.c_str ());
-        }
-      else
-        error ("variable_value: expecting variable name as first argument");
-    }
-  else
-    print_usage ();
+  retval = symbol_table::varval (name);
+
+  if (retval.is_undefined ())
+    error ("variable_value: '%s' is not a variable in the current scope",
+           name.c_str ());
 
   return retval;
 }
--- a/libinterp/corefcn/symtab.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/symtab.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_symtab_h)
+#if ! defined (octave_symtab_h)
 #define octave_symtab_h 1
 
 #include <deque>
@@ -94,7 +94,7 @@
 
       if (! instance)
         {
-          ::error ("unable to create scope_id_cache object!");
+          error ("unable to create scope_id_cache object!");
 
           retval = false;
         }
@@ -881,6 +881,8 @@
       // "user defined"
       void clear_user_function (bool force = false)
       {
+        clear_autoload_function (force);
+
         if (force || ! function_on_path.islocked ())
           function_on_path = octave_value ();
 
@@ -1548,6 +1550,14 @@
            ? p->second.find_user_function () : octave_value ();
   }
 
+  static octave_value find_cmdline_function (const std::string& name)
+  {
+    fcn_table_iterator p = fcn_table.find (name);
+
+    return (p != fcn_table.end ())
+           ? p->second.find_cmdline_function () : octave_value ();
+  }
+
   static void install_cmdline_function (const std::string& name,
                                         const octave_value& fcn)
   {
@@ -2044,7 +2054,7 @@
   {
     std::list<symbol_record> retval;
 
-    size_t len = patterns.length ();
+    size_t len = patterns.numel ();
 
     for (size_t i = 0; i < len; i++)
       {
@@ -2061,7 +2071,7 @@
   {
     std::list<symbol_record> retval;
 
-    size_t len = patterns.length ();
+    size_t len = patterns.numel ();
 
     for (size_t i = 0; i < len; i++)
       {
@@ -2335,8 +2345,8 @@
   // 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);
+  // Name for this table
+  // (usually the filename of the function corresponding to the scope);
   std::string table_name;
 
   // Map from symbol names to symbol info.
--- a/libinterp/corefcn/syscalls.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/syscalls.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -125,39 +125,27 @@
   retval(1) = std::string ();
   retval(0) = -1;
 
-  int nargin = args.length ();
-
-  if (nargin == 2)
-    {
-      octave_stream old_stream
-        = octave_stream_list::lookup (args(0), "dup2");
+  if (args.length () != 2)
+    print_usage ();
 
-      if (! error_state)
-        {
-          octave_stream new_stream
-            = octave_stream_list::lookup (args(1), "dup2");
+  octave_stream old_stream
+    = octave_stream_list::lookup (args(0), "dup2");
 
-          if (! error_state)
-            {
-              int i_old = old_stream.file_number ();
-              int i_new = new_stream.file_number ();
+  octave_stream new_stream
+    = octave_stream_list::lookup (args(1), "dup2");
 
-              if (i_old >= 0 && i_new >= 0)
-                {
-                  std::string msg;
-
-                  int status = octave_syscalls::dup2 (i_old, i_new, msg);
+  int i_old = old_stream.file_number ();
+  int i_new = new_stream.file_number ();
 
-                  retval(1) = msg;
-                  retval(0) = status;
-                }
-            }
-        }
-      else
-        error ("dup2: invalid stream");
+  if (i_old >= 0 && i_new >= 0)
+    {
+      std::string msg;
+
+      int status = octave_syscalls::dup2 (i_old, i_new, msg);
+
+      retval(1) = msg;
+      retval(0) = status;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -190,59 +178,44 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      if (args(0).is_string ())
-        {
-          std::string exec_file = args(0).string_value ();
-
-          string_vector exec_args;
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-          if (nargin == 2)
-            {
-              string_vector tmp = args(1).all_strings ();
+  std::string exec_file = args(0).xstring_value ("exec: FILE must be a string");
 
-              if (! error_state)
-                {
-                  int len = tmp.length ();
-
-                  exec_args.resize (len + 1);
-
-                  exec_args[0] = exec_file;
+  string_vector exec_args;
 
-                  for (int i = 0; i < len; i++)
-                    exec_args[i+1] = tmp[i];
-                }
-              else
-                error ("exec: all arguments must be strings");
-            }
-          else
-            {
-              exec_args.resize (1);
+  if (nargin == 2)
+    {
+      string_vector tmp = args(1).xall_strings ("exec: all arguments must be strings");
 
-              exec_args[0] = exec_file;
-            }
+      int len = tmp.numel ();
 
-          if (! error_state)
-            {
-              octave_history_write_timestamp ();
-
-              if (! command_history::ignoring_entries ())
-                command_history::clean_up_and_save ();
-
-              std::string msg;
+      exec_args.resize (len + 1);
 
-              int status = octave_syscalls::execvp (exec_file, exec_args, msg);
+      exec_args[0] = exec_file;
 
-              retval(1) = msg;
-              retval(0) = status;
-            }
-        }
-      else
-        error ("exec: FILE must be a string");
+      for (int i = 0; i < len; i++)
+        exec_args[i+1] = tmp[i];
     }
   else
-    print_usage ();
+    {
+      exec_args.resize (1);
+
+      exec_args[0] = exec_file;
+    }
+
+  octave_history_write_timestamp ();
+
+  if (! command_history::ignoring_entries ())
+    command_history::clean_up_and_save ();
+
+  std::string msg;
+
+  int status = octave_syscalls::execvp (exec_file, exec_args, msg);
+
+  retval(1) = msg;
+  retval(0) = status;
 
   return retval;
 }
@@ -302,82 +275,64 @@
 
   int nargin = args.length ();
 
-  if (nargin >= 1 && nargin <= 3)
-    {
-      if (args(0).is_string ())
-        {
-          std::string exec_file = args(0).string_value ();
-
-          string_vector arg_list;
-
-          if (nargin >= 2)
-            {
-              string_vector tmp = args(1).all_strings ();
-
-              if (! error_state)
-                {
-                  int len = tmp.length ();
-
-                  arg_list.resize (len + 1);
+  if (nargin < 1 || nargin > 3)
+    print_usage ();
 
-                  arg_list[0] = exec_file;
+  std::string exec_file = args(0).xstring_value ("popen2: COMMAND argument must be a string");
 
-                  for (int i = 0; i < len; i++)
-                    arg_list[i+1] = tmp[i];
-                }
-              else
-                error ("popen2: all arguments must be strings");
-            }
-          else
-            {
-              arg_list.resize (1);
-
-              arg_list[0] = exec_file;
-            }
-
-          if (! error_state)
-            {
-              bool sync_mode = (nargin == 3 ? args(2).bool_value () : false);
+  string_vector arg_list;
 
-              if (! error_state)
-                {
-                  int fildes[2];
-                  std::string msg;
-                  pid_t pid;
+  if (nargin >= 2)
+    {
+      string_vector tmp = args(1).xall_strings ("popen2: all arguments must be strings");
 
-                  pid = octave_syscalls::popen2 (exec_file, arg_list, sync_mode,
-                                                 fildes, msg, interactive);
-                  if (pid >= 0)
-                    {
-                      FILE *ifile = fdopen (fildes[1], "r");
-                      FILE *ofile = fdopen (fildes[0], "w");
-
-                      std::string nm;
-
-                      octave_stream is = octave_stdiostream::create (nm, ifile,
-                                                                  std::ios::in);
+      int len = tmp.numel ();
 
-                      octave_stream os = octave_stdiostream::create (nm, ofile,
-                                                                 std::ios::out);
-
-                      Cell file_ids (1, 2);
+      arg_list.resize (len + 1);
 
-                      retval(2) = pid;
-                      retval(1) = octave_stream_list::insert (is);
-                      retval(0) = octave_stream_list::insert (os);
-                    }
-                  else
-                    error (msg.c_str ());
-                }
-            }
-          else
-            error ("popen2: all arguments must be strings");
-        }
-      else
-        error ("popen2: COMMAND argument must be a string");
+      arg_list[0] = exec_file;
+
+      for (int i = 0; i < len; i++)
+        arg_list[i+1] = tmp[i];
     }
   else
-    print_usage ();
+    {
+      arg_list.resize (1);
+
+      arg_list[0] = exec_file;
+    }
+
+  bool sync_mode = (nargin == 3 ? args(2).bool_value () : false);
+
+  int fildes[2];
+  std::string msg;
+  pid_t pid;
+
+  pid = octave_syscalls::popen2 (exec_file, arg_list, sync_mode,
+                                 fildes, msg, interactive);
+  if (pid >= 0)
+    {
+      FILE *ifile = fdopen (fildes[1], "r");
+      FILE *ofile = fdopen (fildes[0], "w");
+
+      std::string nm;
+
+      octave_stream is = octave_stdiostream::create (exec_file + "-in",
+                                                     ifile,
+                                                     std::ios::in);
+
+      octave_stream os = octave_stdiostream::create (exec_file + "-out",
+                                                     ofile,
+                                                     std::ios::out);
+
+      Cell file_ids (1, 2);
+
+      retval(2) = pid;
+      retval(1) = octave_stream_list::insert (is);
+      retval(0) = octave_stream_list::insert (os);
+    }
+  else
+    error (msg.c_str ());
 
   return retval;
 }
@@ -516,38 +471,28 @@
 
   int nargin = args.length ();
 
-  if (nargin == 3)
-    {
-      octave_stream strm = octave_stream_list::lookup (args(0), "fcntl");
+  if (nargin != 3)
+    print_usage ();
+
+  octave_stream strm = octave_stream_list::lookup (args(0), "fcntl");
 
-      if (! error_state)
-        {
-          int fid = strm.file_number ();
+  int fid = strm.file_number ();
 
-          int req = args(1).int_value (true);
-          int arg = args(2).int_value (true);
+  int req = args(1).int_value (true);
+  int arg = args(2).int_value (true);
 
-          if (! error_state)
-            {
-              // FIXME: Need better checking here?
-              if (fid < 0)
-                error ("fcntl: invalid file id");
-              else
-                {
-                  std::string msg;
-
-                  int status = octave_fcntl (fid, req, arg, msg);
+  // FIXME: Need better checking here?
+  if (fid < 0)
+    error ("fcntl: invalid file id");
+  else
+    {
+      std::string msg;
 
-                  retval(1) = msg;
-                  retval(0) = status;
-                }
-            }
-        }
-      else
-        error ("fcntl: FID, REQUEST, and ARG must be integers");
+      int status = octave_fcntl (fid, req, arg, msg);
+
+      retval(1) = msg;
+      retval(0) = status;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -582,17 +527,15 @@
 
   int nargin = args.length ();
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  if (nargin != 0)
+    print_usage ();
 
-      pid_t pid = octave_syscalls::fork (msg);
+  std::string msg;
 
-      retval(1) = msg;
-      retval(0) = pid;
-    }
-  else
-    print_usage ();
+  pid_t pid = octave_syscalls::fork (msg);
+
+  retval(1) = msg;
+  retval(0) = pid;
 
   return retval;
 }
@@ -610,15 +553,13 @@
 
   int nargin = args.length ();
 
-  if (nargin == 0)
-    {
-      std::string msg;
+  if (nargin != 0)
+    print_usage ();
 
-      retval(1) = msg;
-      retval(0) = octave_syscalls::getpgrp (msg);
-    }
-  else
-    print_usage ();
+  std::string msg;
+
+  retval(1) = msg;
+  retval(0) = octave_syscalls::getpgrp (msg);
 
   return retval;
 }
@@ -630,16 +571,12 @@
 @seealso{getppid}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   int nargin = args.length ();
 
-  if (nargin == 0)
-    retval = octave_syscalls::getpid ();
-  else
+  if (nargin != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_syscalls::getpid ());
 }
 
 DEFUNX ("getppid", Fgetppid, args, ,
@@ -649,16 +586,12 @@
 @seealso{getpid}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   int nargin = args.length ();
 
-  if (nargin == 0)
-    retval = octave_syscalls::getppid ();
-  else
+  if (nargin != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_syscalls::getppid ());
 }
 
 DEFUNX ("getegid", Fgetegid, args, ,
@@ -668,16 +601,12 @@
 @seealso{getgid}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   int nargin = args.length ();
 
-  if (nargin == 0)
-    retval = octave_syscalls::getegid ();
-  else
+  if (nargin != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_syscalls::getegid ());
 }
 
 DEFUNX ("getgid", Fgetgid, args, ,
@@ -687,16 +616,12 @@
 @seealso{getegid}\n\
 @end deftypefn")
 {
-  octave_value retval = -1;
-
   int nargin = args.length ();
 
-  if (nargin == 0)
-    retval = octave_syscalls::getgid ();
-  else
+  if (nargin != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_syscalls::getgid ());
 }
 
 DEFUNX ("geteuid", Fgeteuid, args, ,
@@ -768,20 +693,14 @@
     {
       pid_t pid = args(0).int_value (true);
 
-      if (! error_state)
-        {
-          int sig = args(1).int_value (true);
+      int sig = args(1).int_value (true);
+
+      std::string msg;
 
-          if (! error_state)
-            {
-              std::string msg;
+      int status = octave_syscalls::kill (pid, sig, msg);
 
-              int status = octave_syscalls::kill (pid, sig, msg);
-
-              retval(1) = msg;
-              retval(0) = status;
-            }
-        }
+      retval(1) = msg;
+      retval(0) = status;
     }
   else
     print_usage ();
@@ -804,14 +723,11 @@
 
   if (args.length () == 1)
     {
-      std::string fname = args(0).string_value ();
+      std::string fname = args(0).xstring_value ("lstat: NAME must be a string");
 
-      if (! error_state)
-        {
-          file_stat fs (fname, false);
+      file_stat fs (fname, false);
 
-          retval = mk_stat_result (fs);
-        }
+      retval = mk_stat_result (fs);
     }
   else
     print_usage ();
@@ -819,15 +735,45 @@
   return retval;
 }
 
+// FIXME: This routine also exists verbatim in file-io.cc.
+//        Maybe change to be a general utility routine.
+static int
+convert (int x, int ibase, int obase)
+{
+  int retval = 0;
+
+  int tmp = x % obase;
+
+  if (tmp > ibase - 1)
+    error ("mkfifo: invalid digit");
+  else
+    {
+      retval = tmp;
+      int mult = ibase;
+      while ((x = (x - tmp) / obase))
+        {
+          tmp = x % obase;
+          if (tmp > ibase - 1)
+            {
+              error ("mkfifo: invalid digit");
+              break;
+            }
+          retval += mult * tmp;
+          mult *= ibase;
+        }
+    }
+
+  return retval;
+}
+
 DEFUNX ("mkfifo", Fmkfifo, args, ,
         "-*- texinfo -*-\n\
 @deftypefn  {Built-in Function} {@var{err} =} mkfifo (@var{name}, @var{mode})\n\
 @deftypefnx {Built-in Function} {[@var{err}, @var{msg}] =} mkfifo (@var{name}, @var{mode})\n\
 Create a FIFO special file named @var{name} with file mode @var{mode}.\n\
 \n\
-@var{mode} is interpreted as a decimal number (@emph{not} octal) and is\n\
-subject to umask processing.  The final calculated mode is\n\
-@code{@var{mode} - @var{umask}}.\n\
+@var{mode} is interpreted as an octal number and is subject to umask\n\
+processing.  The final calculated mode is @code{@var{mode} - @var{umask}}.\n\
 \n\
 If successful, @var{err} is 0 and @var{msg} is an empty string.\n\
 Otherwise, @var{err} is nonzero and @var{msg} contains a system-dependent\n\
@@ -835,7 +781,7 @@
 @seealso{pipe, umask}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
+  octave_value_list retval (2);
 
   retval(1) = std::string ();
   retval(0) = -1;
@@ -844,33 +790,25 @@
 
   if (nargin == 2)
     {
-      if (args(0).is_string ())
-        {
-          std::string name = args(0).string_value ();
+      std::string name = args(0).xstring_value ("mkfifo: FILE must be a string");
+
+      int octal_mode = args(1).xint_value ("mkfifo: MODE must be an integer");
 
-          if (args(1).is_scalar_type ())
-            {
-              long mode = args(1).long_value ();
-
-              if (! error_state)
-                {
-                  std::string msg;
-
-                  int status = octave_mkfifo (name, mode, msg);
+      if (octal_mode < 0)
+        error ("mkfifo: MODE must be a positive integer value");
+      else
+        {
+          int mode = convert (octal_mode, 8, 10);
 
-                  retval(0) = status;
+          std::string msg;
+
+          int status = octave_mkfifo (name, mode, msg);
 
-                  if (status < 0)
-                    retval(1) = msg;
-                }
-              else
-                error ("mkfifo: invalid MODE");
-            }
-          else
-            error ("mkfifo: MODE must be an integer");
+          retval(0) = status;
+
+          if (status < 0)
+            retval(1) = msg;
         }
-      else
-        error ("mkfifo: FILE must be a string");
     }
   else
     print_usage ();
@@ -878,6 +816,19 @@
   return retval;
 }
 
+/*
+
+## Test input validation
+%!error mkfifo ()
+%!error mkfifo ("abc")
+%!error mkfifo ("abc", 777, 123)
+%!error <FILE must be a string> mkfifo (123, 456)
+## FIXME: These tests should work, but lasterr is not being set correctly.
+#%!error <MODE must be an integer> mkfifo ("abc", {456})
+#%!error <MODE must be a positive integer value> mkfifo ("abc", -1)
+
+*/
+
 DEFUNX ("pipe", Fpipe, args, ,
         "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {[@var{read_fd}, @var{write_fd}, @var{err}, @var{msg}] =} pipe ()\n\
@@ -914,12 +865,10 @@
           FILE *ifile = fdopen (fid[0], "r");
           FILE *ofile = fdopen (fid[1], "w");
 
-          std::string nm;
-
-          octave_stream is = octave_stdiostream::create (nm, ifile,
+          octave_stream is = octave_stdiostream::create ("pipe-in", ifile,
                                                          std::ios::in);
 
-          octave_stream os = octave_stdiostream::create (nm, ofile,
+          octave_stream os = octave_stdiostream::create ("pipe-out", ofile,
                                                          std::ios::out);
 
           retval(2) = status;
@@ -1037,23 +986,17 @@
         {
           int fid = octave_stream_list::get_file_number (args(0));
 
-          if (! error_state)
-            {
-              file_fstat fs (fid);
+          file_fstat fs (fid);
 
-              retval = mk_stat_result (fs);
-            }
+          retval = mk_stat_result (fs);
         }
       else
         {
-          std::string fname = args(0).string_value ();
+          std::string fname = args(0).xstring_value ("stat: NAME must be a string");
 
-          if (! error_state)
-            {
-              file_stat fs (fname);
+          file_stat fs (fname);
 
-              retval = mk_stat_result (fs);
-            }
+          retval = mk_stat_result (fs);
         }
     }
   else
@@ -1075,12 +1018,9 @@
 
   if (args.length () == 1)
     {
-      double mode = args(0).double_value ();
+      double mode = args(0).xdouble_value ("S_ISREG: invalid MODE value");
 
-      if (! error_state)
-        retval = file_stat::is_reg (static_cast<mode_t> (mode));
-      else
-        error ("S_ISREG: invalid MODE value");
+      retval = file_stat::is_reg (static_cast<mode_t> (mode));
     }
   else
     print_usage ();
@@ -1101,12 +1041,9 @@
 
   if (args.length () == 1)
     {
-      double mode = args(0).double_value ();
+      double mode = args(0).xdouble_value ("S_ISDIR: invalid MODE value");
 
-      if (! error_state)
-        retval = file_stat::is_dir (static_cast<mode_t> (mode));
-      else
-        error ("S_ISDIR: invalid MODE value");
+      retval = file_stat::is_dir (static_cast<mode_t> (mode));
     }
   else
     print_usage ();
@@ -1127,12 +1064,9 @@
 
   if (args.length () == 1)
     {
-      double mode = args(0).double_value ();
+      double mode = args(0).xdouble_value ("S_ISCHR: invalid MODE value");
 
-      if (! error_state)
-        retval = file_stat::is_chr (static_cast<mode_t> (mode));
-      else
-        error ("S_ISCHR: invalid MODE value");
+      retval = file_stat::is_chr (static_cast<mode_t> (mode));
     }
   else
     print_usage ();
@@ -1153,12 +1087,9 @@
 
   if (args.length () == 1)
     {
-      double mode = args(0).double_value ();
+      double mode = args(0).xdouble_value ("S_ISBLK: invalid MODE value");
 
-      if (! error_state)
-        retval = file_stat::is_blk (static_cast<mode_t> (mode));
-      else
-        error ("S_ISBLK: invalid MODE value");
+      retval = file_stat::is_blk (static_cast<mode_t> (mode));
     }
   else
     print_usage ();
@@ -1179,12 +1110,9 @@
 
   if (args.length () == 1)
     {
-      double mode = args(0).double_value ();
+      double mode = args(0).xdouble_value ("S_ISFIFO: invalid MODE value");
 
-      if (! error_state)
-        retval = file_stat::is_fifo (static_cast<mode_t> (mode));
-      else
-        error ("S_ISFIFO: invalid MODE value");
+      retval = file_stat::is_fifo (static_cast<mode_t> (mode));
     }
   else
     print_usage ();
@@ -1205,12 +1133,9 @@
 
   if (args.length () == 1)
     {
-      double mode = args(0).double_value ();
+      double mode = args(0).xdouble_value ("S_ISLNK: invalid MODE value");
 
-      if (! error_state)
-        retval = file_stat::is_lnk (static_cast<mode_t> (mode));
-      else
-        error ("S_ISLNK: invalid MODE value");
+      retval = file_stat::is_lnk (static_cast<mode_t> (mode));
     }
   else
     print_usage ();
@@ -1231,12 +1156,9 @@
 
   if (args.length () == 1)
     {
-      double mode = args(0).double_value ();
+      double mode = args(0).xdouble_value ("S_ISSOCK: invalid MODE value");
 
-      if (! error_state)
-        retval = file_stat::is_sock (static_cast<mode_t> (mode));
-      else
-        error ("S_ISSOCK: invalid MODE value");
+      retval = file_stat::is_sock (static_cast<mode_t> (mode));
     }
   else
     print_usage ();
@@ -1329,19 +1251,14 @@
 
   if (nargin == 1)
     {
-      if (args(0).is_string ())
-        {
-          std::string name = args(0).string_value ();
+      std::string name = args(0).xstring_value ("unlink: FILE must be a string");
 
-          std::string msg;
+      std::string msg;
 
-          int status = octave_unlink (name, msg);
+      int status = octave_unlink (name, msg);
 
-          retval(1) = msg;
-          retval(0) = status;
-        }
-      else
-        error ("unlink: FILE must be a string");
+      retval(1) = msg;
+      retval(0) = status;
     }
   else
     print_usage ();
@@ -1406,33 +1323,23 @@
 
   if (nargin == 1 || nargin == 2)
     {
-      pid_t pid = args(0).int_value (true);
+      pid_t pid = args(0).xint_value ("waitpid: OPTIONS must be an integer");
 
-      if (! error_state)
-        {
-          int options = 0;
+      int options = 0;
 
-          if (args.length () == 2)
-            options = args(1).int_value (true);
+      if (args.length () == 2)
+        options = args(1).xint_value ("waitpid: PID must be an integer value");
 
-          if (! error_state)
-            {
-              std::string msg;
+      std::string msg;
 
-              int status = 0;
-
-              pid_t result = octave_syscalls::waitpid (pid, &status,
-                                                       options, msg);
+      int status = 0;
 
-              retval(2) = msg;
-              retval(1) = status;
-              retval(0) = result;
-            }
-          else
-            error ("waitpid: OPTIONS must be an integer");
-        }
-      else
-        error ("waitpid: PID must be an integer value");
+      pid_t result = octave_syscalls::waitpid (pid, &status,
+                                               options, msg);
+
+      retval(2) = msg;
+      retval(1) = status;
+      retval(0) = result;
     }
   else
     print_usage ();
@@ -1452,13 +1359,12 @@
 
   if (args.length () == 1)
     {
-      int status = args(0).int_value ();
+      int status = args(0).xint_value ("WIFEXITED: STATUS must be an integer");
 
-      if (! error_state)
-        retval = octave_wait::ifexited (status);
-      else
-        error ("WIFEXITED: STATUS must be an integer");
+      retval = octave_wait::ifexited (status);
     }
+  else
+    print_usage ();
 
   return retval;
 }
@@ -1477,12 +1383,9 @@
 
   if (args.length () == 1)
     {
-      int status = args(0).int_value ();
+      int status = args(0).xint_value ("WEXITSTATUS: STATUS must be an integer");
 
-      if (! error_state)
-        retval = octave_wait::exitstatus (status);
-      else
-        error ("WEXITSTATUS: STATUS must be an integer");
+      retval = octave_wait::exitstatus (status);
     }
 
   return retval;
@@ -1500,13 +1403,12 @@
 
   if (args.length () == 1)
     {
-      int status = args(0).int_value ();
+      int status = args(0).xint_value ("WIFSIGNALED: STATUS must be an integer");
 
-      if (! error_state)
-        retval = octave_wait::ifsignaled (status);
-      else
-        error ("WIFSIGNALED: STATUS must be an integer");
+      retval = octave_wait::ifsignaled (status);
     }
+  else
+    print_usage ();
 
   return retval;
 }
@@ -1525,13 +1427,12 @@
 
   if (args.length () == 1)
     {
-      int status = args(0).int_value ();
+      int status = args(0).xint_value ("WTERMSIG: STATUS must be an integer");
 
-      if (! error_state)
-        retval = octave_wait::termsig (status);
-      else
-        error ("WTERMSIG: STATUS must be an integer");
+      retval = octave_wait::termsig (status);
     }
+  else
+    print_usage ();
 
   return retval;
 }
@@ -1552,13 +1453,12 @@
 
   if (args.length () == 1)
     {
-      int status = args(0).int_value ();
+      int status = args(0).xint_value ("WCOREDUMP: STATUS must be an integer");
 
-      if (! error_state)
-        retval = octave_wait::coredump (status);
-      else
-        error ("WCOREDUMP: STATUS must be an integer");
+      retval = octave_wait::coredump (status);
     }
+  else
+    print_usage ();
 
   return retval;
 }
@@ -1578,13 +1478,12 @@
 
   if (args.length () == 1)
     {
-      int status = args(0).int_value ();
+      int status = args(0).xint_value ("WIFSTOPPED: STATUS must be an integer");
 
-      if (! error_state)
-        retval = octave_wait::ifstopped (status);
-      else
-        error ("WIFSTOPPED: STATUS must be an integer");
+      retval = octave_wait::ifstopped (status);
     }
+  else
+    print_usage ();
 
   return retval;
 }
@@ -1603,13 +1502,12 @@
 
   if (args.length () == 1)
     {
-      int status = args(0).int_value ();
+      int status = args(0).xint_value ("WSTOPSIG: STATUS must be an integer");
 
-      if (! error_state)
         retval = octave_wait::stopsig (status);
-      else
-        error ("WSTOPSIG: STATUS must be an integer");
     }
+  else
+    print_usage ();
 
   return retval;
 }
@@ -1626,13 +1524,12 @@
 
   if (args.length () == 1)
     {
-      int status = args(0).int_value ();
+      int status = args(0).xint_value ("WIFCONTINUED: STATUS must be an integer");
 
-      if (! error_state)
-        retval = octave_wait::ifcontinued (status);
-      else
-        error ("WIFCONTINUED: STATUS must be an integer");
+      retval = octave_wait::ifcontinued (status);
     }
+  else
+    print_usage ();
 
   return retval;
 }
@@ -1650,19 +1547,14 @@
 
   if (args.length () == 1)
     {
-      if (args(0).is_string ())
-        {
-          std::string name = args(0).string_value ();
-          std::string msg;
-
-          std::string result = octave_canonicalize_file_name (name, msg);
+      std::string name = args(0).xstring_value ("canonicalize_file_name: NAME must be a string");
+      std::string msg;
 
-          retval(2) = msg;
-          retval(1) = msg.empty () ? 0 : -1;
-          retval(0) = result;
-        }
-      else
-        error ("canonicalize_file_name: NAME must be a string");
+      std::string result = octave_canonicalize_file_name (name, msg);
+
+      retval(2) = msg;
+      retval(1) = msg.empty () ? 0 : -1;
+      retval(0) = result;
     }
   else
     print_usage ();
@@ -1685,7 +1577,7 @@
   return retval;
 }
 
-#if !defined (O_NONBLOCK) && defined (O_NDELAY)
+#if ! defined (O_NONBLOCK) && defined (O_NDELAY)
 #define O_NONBLOCK O_NDELAY
 #endif
 
@@ -1934,7 +1826,7 @@
 #endif
 }
 
-#if !defined (WNOHANG)
+#if ! defined (WNOHANG)
 #define WNOHANG 0
 #endif
 
@@ -1950,7 +1842,7 @@
   return const_value (args, WNOHANG);
 }
 
-#if !defined (WUNTRACED)
+#if ! defined (WUNTRACED)
 #define WUNTRACED 0
 #endif
 
@@ -1966,7 +1858,7 @@
   return const_value (args, WUNTRACED);
 }
 
-#if !defined (WCONTINUE)
+#if ! defined (WCONTINUE)
 #define WCONTINUE 0
 #endif
 
--- a/libinterp/corefcn/sysdep.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/sysdep.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -193,32 +193,25 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      std::string file = args(0).string_value ();
+  if (args.length () != 1)
+    print_usage ();
+
+  std::string file = args(0).xstring_value ("__open_with_system_app__: argument must be a filename");
 
-      if (! error_state)
-        {
 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
-          HINSTANCE status = ShellExecute (0, 0, file.c_str (), 0, 0,
-                                           SW_SHOWNORMAL);
+  HINSTANCE status = ShellExecute (0, 0, file.c_str (), 0, 0,
+                                   SW_SHOWNORMAL);
 
-          // ShellExecute returns a value greater than 32 if successful.
-          retval = (reinterpret_cast<ptrdiff_t> (status) > 32);
+  // ShellExecute returns a value greater than 32 if successful.
+  retval = (reinterpret_cast<ptrdiff_t> (status) > 32);
 #else
-          octave_value_list tmp
-            = Fsystem (ovl ("xdg-open " + file + " 2> /dev/null",
-                            false, "async"),
-                       1);
+  octave_value_list tmp
+    = Fsystem (ovl ("xdg-open " + file + " 2> /dev/null",
+                    false, "async"),
+               1);
 
-          retval = (tmp(0).double_value () == 0);
+  retval = (tmp(0).double_value () == 0);
 #endif
-        }
-      else
-        error ("__open_with_system_app__: argument must be a file name");
-    }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -345,7 +338,6 @@
     {
       if (interactive && ! forced_interactive)
         error ("stdin is not a tty!");
-      return;
     }
 
   if (on == curr_on)
@@ -619,21 +611,12 @@
 @seealso{setenv, unsetenv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      std::string name = args(0).string_value ();
-
-      if (! error_state)
-        retval = octave_env::getenv (name);
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  std::string name = args(0).string_value ();
+
+  return octave_value (octave_env::getenv (name));
 }
 
 /*
@@ -656,25 +639,16 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 1)
-    {
-      if (args(0).is_string ())
-        {
-          std::string var = args(0).string_value ();
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-          std::string val = (nargin == 2
-                             ? args(1).string_value () : std::string ());
+  std::string var = args(0).xstring_value ("setenv: VAR must be a string");
 
-          if (! error_state)
-            octave_env::putenv (var, val);
-          else
-            error ("setenv: VALUE must be a string");
-        }
-      else
-        error ("setenv: VAR must be a string");
-    }
-  else
-    print_usage ();
+  std::string val = (nargin == 2
+                     ? args(1).xstring_value ("setenv: VALUE must be a string")
+                     : std::string ());
+
+  octave_env::putenv (var, val);
 
   return retval;
 }
@@ -699,24 +673,12 @@
 @seealso{setenv, getenv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      std::string tmp = args(0).string_value ();
-
-      if (! error_state)
-        {
-          int status = gnulib::unsetenv (tmp.c_str ());
-          retval = status;
-        }
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  std::string tmp = args(0).string_value ();
+
+  return octave_value (gnulib::unsetenv (tmp.c_str ()));
 }
 
 /*
@@ -802,33 +764,27 @@
 
   int nargin = args.length ();
 
-  if (! (nargin == 0 || nargin == 1))
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin > 1)
+    print_usage ();
 
   if (nargin == 1)
     {
       double dval = args(0).double_value ();
 
-      if (! error_state)
+      if (! xisnan (dval))
         {
-          if (! xisnan (dval))
-            {
-              Fdrawnow ();
+          Fdrawnow ();
 
-              if (xisinf (dval))
-                {
-                  flush_octave_stdout ();
-                  octave_kbhit ();
-                }
-              else
-                octave_sleep (dval);
+          if (xisinf (dval))
+            {
+              flush_octave_stdout ();
+              octave_kbhit ();
             }
           else
-            warning ("pause: NaN is an invalid delay");
+            octave_sleep (dval);
         }
+      else
+        warning ("pause: NaN is an invalid delay");
     }
   else
     {
@@ -856,23 +812,18 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 1)
-    {
-      double dval = args(0).double_value ();
+  if (args.length () != 1)
+    print_usage ();
+
+  double dval = args(0).double_value ();
 
-      if (! error_state)
-        {
-          if (xisnan (dval))
-            warning ("sleep: NaN is an invalid delay");
-          else
-            {
-              Fdrawnow ();
-              octave_sleep (dval);
-            }
-        }
+  if (xisnan (dval))
+    warning ("sleep: NaN is an invalid delay");
+  else
+    {
+      Fdrawnow ();
+      octave_sleep (dval);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -899,27 +850,22 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 1)
-    {
-      double dval = args(0).double_value ();
+  if (args.length () != 1)
+    print_usage ();
+
+  double dval = args(0).double_value ();
 
-      if (! error_state)
-        {
-          if (xisnan (dval))
-            warning ("usleep: NaN is an invalid delay");
-          else
-            {
-              Fdrawnow ();
+  if (xisnan (dval))
+    warning ("usleep: NaN is an invalid delay");
+  else
+    {
+      Fdrawnow ();
 
-              int delay = NINT (dval);
+      int delay = NINT (dval);
 
-              if (delay > 0)
-                octave_usleep (delay);
-            }
-        }
+      if (delay > 0)
+        octave_usleep (delay);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -971,7 +917,8 @@
 
 DEFUN (tilde_expand, args, ,
        "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} tilde_expand (@var{string})\n\
+@deftypefn  {Built-in Function} {} tilde_expand (@var{string})\n\
+@deftypefnx {Built-in Function} {} tilde_expand (@var{cellstr})\n\
 Perform tilde expansion on @var{string}.\n\
 \n\
 If @var{string} begins with a tilde character, (@samp{~}), all of the\n\
@@ -981,7 +928,10 @@
 user.  If the tilde is followed immediately by a slash, the tilde is\n\
 replaced by the home directory of the user running Octave.\n\
 \n\
-For example:\n\
+If the input is a cell array of strings @var{cellstr} then tilde expansion\n\
+is performed on each string element.\n\
+\n\
+Examples:\n\
 \n\
 @example\n\
 @group\n\
@@ -995,28 +945,19 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin == 1)
-    {
-      octave_value arg = args(0);
+  octave_value arg = args(0);
 
-      string_vector sv = arg.all_strings ();
+  string_vector sv = arg.xall_strings ("tilde_expand: argument must be char or cellstr object");
 
-      if (! error_state)
-        {
-          sv = file_ops::tilde_expand (sv);
+  sv = file_ops::tilde_expand (sv);
 
-          if (arg.is_cellstr ())
-            retval = Cell (arg.dims (), sv);
-          else
-            retval = sv;
-        }
-      else
-        error ("tilde_expand: expecting argument to be char or cellstr object");
-    }
+  if (arg.is_cellstr ())
+    retval = Cell (arg.dims (), sv);
   else
-    print_usage ();
+    retval = sv;
 
   return retval;
 }
--- a/libinterp/corefcn/sysdep.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/sysdep.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_sysdep_h)
+#if ! defined (octave_sysdep_h)
 #define octave_sysdep_h 1
 
 #include <cstdio>
--- a/libinterp/corefcn/time.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/time.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -50,53 +50,55 @@
   m.assign ("wday", static_cast<double> (t.wday ()));
   m.assign ("yday", static_cast<double> (t.yday ()));
   m.assign ("isdst", static_cast<double> (t.isdst ()));
+  m.assign ("gmtoff", static_cast<double> (t.gmtoff ()));
   m.assign ("zone", t.zone ());
 
   return m;
 }
 
 static inline int
-intfield (const octave_scalar_map& m, const std::string& k)
+intfield (const octave_scalar_map& m, const std::string& k, const char *who)
 {
   int retval = 0;
 
   octave_value v = m.getfield (k);
 
   if (! v.is_empty ())
-    retval = v.int_value ();
+    retval = v.xint_value ("%s: invalid TM_STRUCT argument", who);
 
   return retval;
 }
 
 static inline std::string
-stringfield (const octave_scalar_map& m, const std::string& k)
+stringfield (const octave_scalar_map& m, const std::string& k, const char *who)
 {
   std::string retval;
 
   octave_value v = m.getfield (k);
 
   if (! v.is_empty ())
-    retval = v.string_value ();
+    retval = v.xstring_value ("%s: invalid TM_STRUCT argument", who);
 
   return retval;
 }
 
 static octave_base_tm
-extract_tm (const octave_scalar_map& m)
+extract_tm (const octave_scalar_map& m, const char *who)
 {
   octave_base_tm tm;
 
-  tm.usec (intfield (m, "usec"));
-  tm.sec (intfield (m, "sec"));
-  tm.min (intfield (m, "min"));
-  tm.hour (intfield (m, "hour"));
-  tm.mday (intfield (m, "mday"));
-  tm.mon (intfield (m, "mon"));
-  tm.year (intfield (m, "year"));
-  tm.wday (intfield (m, "wday"));
-  tm.yday (intfield (m, "yday"));
-  tm.isdst (intfield (m, "isdst"));
-  tm.zone (stringfield (m, "zone"));
+  tm.usec (intfield (m, "usec", who));
+  tm.sec (intfield (m, "sec", who));
+  tm.min (intfield (m, "min", who));
+  tm.hour (intfield (m, "hour", who));
+  tm.mday (intfield (m, "mday", who));
+  tm.mon (intfield (m, "mon", who));
+  tm.year (intfield (m, "year", who));
+  tm.wday (intfield (m, "wday", who));
+  tm.yday (intfield (m, "yday", who));
+  tm.isdst (intfield (m, "isdst", who));
+  tm.gmtoff (intfield (m, "gmtoff", who));
+  tm.zone (stringfield (m, "zone", who));
 
   return tm;
 }
@@ -112,14 +114,10 @@
 @seealso{strftime, strptime, localtime, gmtime, mktime, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 0)
-    retval = octave_time ();
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_time ());
 }
 
 /*
@@ -150,26 +148,20 @@
            wday = 1\n\
            yday = 47\n\
            isdst = 0\n\
-           zone = CST\n\
+           gmtoff = 0\n\
+           zone = GMT\n\
         @}\n\
 @end group\n\
 @end example\n\
 @seealso{strftime, strptime, localtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      double tmp = args(0).double_value ();
-
-      if (! error_state)
-        retval = octave_value (mk_tm_map (octave_gmtime (tmp)));
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  double tmp = args(0).double_value ();
+
+  return octave_value (mk_tm_map (octave_gmtime (tmp)));
 }
 
 /*
@@ -211,6 +203,7 @@
            wday = 1\n\
            yday = 47\n\
            isdst = 0\n\
+           gmtoff = -21600\n\
            zone = CST\n\
         @}\n\
 @end group\n\
@@ -218,19 +211,12 @@
 @seealso{strftime, strptime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      double tmp = args(0).double_value ();
-
-      if (! error_state)
-        retval = octave_value (mk_tm_map (octave_localtime (tmp)));
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  double tmp = args(0).double_value ();
+
+  return octave_value (mk_tm_map (octave_localtime (tmp)));
 }
 
 /*
@@ -269,28 +255,14 @@
 @seealso{strftime, strptime, localtime, gmtime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      octave_scalar_map map = args(0).scalar_map_value ();
-
-      if (! error_state)
-        {
-          octave_base_tm tm = extract_tm (map);
-
-          if (! error_state)
-            retval = octave_time (tm);
-          else
-            error ("mktime: invalid TM_STRUCT argument");
-        }
-      else
-        error ("mktime: TM_STRUCT argument must be a structure");
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  octave_scalar_map map = args(0).xscalar_map_value ("mktime: TM_STRUCT argument must be a structure");
+
+  octave_base_tm tm = extract_tm (map, "mktime");
+
+  return octave_value (octave_time (tm));
 }
 
 /*
@@ -399,6 +371,10 @@
 @item %X\n\
 Locale's time representation (%H:%M:%S).\n\
 \n\
+@item %z\n\
+Offset from UTC (±@nospell{hhmm}), or nothing if no time zone is\n\
+determinable.\n\
+\n\
 @item %Z\n\
 Time zone (EDT), or nothing if no time zone is determinable.\n\
 @end table\n\
@@ -466,33 +442,16 @@
 {
   octave_value retval;
 
-  if (args.length () == 2)
-    {
-      if (args(0).is_string ())
-        {
-          std::string fmt = args(0).string_value ();
-
-          octave_scalar_map map = args(1).scalar_map_value ();
-
-          if (! error_state)
-            {
-              octave_base_tm tm = extract_tm (map);
-
-              if (! error_state)
-                retval = tm.strftime (fmt);
-              else
-                error ("strftime: invalid TM_STRUCT argument");
-            }
-          else
-            error ("strftime: TM_STRUCT must be a structure");
-        }
-      else
-        error ("strftime: FMT must be a string");
-    }
-  else
+  if (args.length () != 2)
     print_usage ();
 
-  return retval;
+  std::string fmt = args(0).xstring_value ("strftime: FMT must be a string");
+
+  octave_scalar_map map = args(1).xscalar_map_value ("strftime: TM_STRUCT must be a structure");
+
+  octave_base_tm tm = extract_tm (map, "strftime");
+
+  return octave_value (tm.strftime (fmt));
 }
 
 /*
@@ -522,29 +481,17 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 2)
-    {
-      if (args(0).is_string ())
-        {
-          std::string str = args(0).string_value ();
+  if (args.length () != 2)
+    print_usage ();
 
-          if (args(1).is_string ())
-            {
-              std::string fmt = args(1).string_value ();
-
-              octave_strptime t (str, fmt);
+  std::string str = args(0).xstring_value ("strptime: argument STR must be a string");
 
-              retval(1) = t.characters_converted ();
-              retval(0) = octave_value (mk_tm_map (t));
-            }
-          else
-            error ("strptime: FMT must be a string");
-        }
-      else
-        error ("strptime: argument STR must be a string");
-    }
-  else
-    print_usage ();
+  std::string fmt = args(1).xstring_value ("strptime: FMT must be a string");
+
+  octave_strptime t (str, fmt);
+
+  retval(1) = t.characters_converted ();
+  retval(0) = octave_value (mk_tm_map (t));
 
   return retval;
 }
--- a/libinterp/corefcn/toplev.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/toplev.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -130,6 +130,21 @@
   return retval;
 }
 
+bool
+octave_call_stack::stack_frame::operator== (const octave_call_stack::stack_frame &rhs) const
+{
+  if (this->line () != rhs.line ())
+    return false;
+  else if (this->column () != rhs.column ())
+    return false;
+  else if (this->fcn_file_name () != rhs.fcn_file_name ())
+    return false;
+  else if (this->fcn_name () != rhs.fcn_name ())
+    return false;
+  else
+    return true;
+}
+
 void
 octave_call_stack::create_instance (void)
 {
@@ -615,43 +630,52 @@
                         break;
                     }
 
-                  if (error_state)
-                    {
-                      if (! interactive)
-                        {
-                          // We should exit with a nonzero status.
-                          retval = 1;
-                          break;
-                        }
-                    }
+                  if (octave_completion_matches_called)
+                    octave_completion_matches_called = false;
                   else
-                    {
-                      if (octave_completion_matches_called)
-                        octave_completion_matches_called = false;
-                      else
-                        command_editor::increment_current_command_number ();
-                    }
+                    command_editor::increment_current_command_number ();
                 }
               else if (parser.lexer.end_of_input)
                 break;
             }
         }
-      catch (octave_interrupt_exception)
+      catch (const octave_interrupt_exception&)
         {
           recover_from_exception ();
+
           octave_stdout << "\n";
+
           if (quitting_gracefully)
             return exit_status;
         }
-      catch (octave_execution_exception)
+      catch (const index_exception& e)
         {
           recover_from_exception ();
-          std::cerr << "error: unhandled execution exception -- trying to return to prompt"
+
+          std::cerr << "error: unhandled index exception: "
+                    << e.message () << " -- trying to return to prompt"
                     << std::endl;
         }
-      catch (std::bad_alloc)
+      catch (const octave_execution_exception& e)
+        {
+          std::string stack_trace = e.info ();
+
+          if (! stack_trace.empty ())
+            std::cerr << stack_trace;
+
+          if (interactive)
+            recover_from_exception ();
+          else
+            {
+              // We should exit with a nonzero status.
+              retval = 1;
+              break;
+            }
+        }
+      catch (const std::bad_alloc&)
         {
           recover_from_exception ();
+
           std::cerr << "error: out of memory -- trying to return to prompt"
                     << std::endl;
         }
@@ -820,24 +844,20 @@
         {
           int tmp = args(0).nint_value ();
 
-          if (! error_state)
-            exit_status = tmp;
+          exit_status = tmp;
         }
 
-      if (! error_state)
-        {
-          // Instead of simply calling exit, we simulate an interrupt
-          // with a request to exit cleanly so that no matter where the
-          // call to quit occurs, we will run the unwind_protect stack,
-          // clear the OCTAVE_LOCAL_BUFFER allocations, etc. before
-          // exiting.
+      // Instead of simply calling exit, we simulate an interrupt
+      // with a request to exit cleanly so that no matter where the
+      // call to quit occurs, we will run the unwind_protect stack,
+      // clear the OCTAVE_LOCAL_BUFFER allocations, etc. before
+      // exiting.
 
-          quitting_gracefully = true;
+      quitting_gracefully = true;
 
-          octave_interrupt_state = -1;
+      octave_interrupt_state = -1;
 
-          octave_throw_interrupt_exception ();
-        }
+      octave_throw_interrupt_exception ();
     }
 
   return retval;
@@ -944,7 +964,7 @@
       retval(0) = cmd_status;
     }
   else
-    error ("unable to start subprocess for '%s'", cmd_str.c_str ());
+    error ("system: unable to start subprocess for '%s'", cmd_str.c_str ());
 
   return retval;
 }
@@ -1009,124 +1029,104 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0 && nargin < 4)
-    {
-      bool return_output = (nargin == 1 && nargout > 1);
+  if (nargin == 0 || nargin > 3)
+    print_usage ();
 
-      system_exec_type type = et_sync;
+  bool return_output = (nargin == 1 && nargout > 1);
 
-      if (nargin == 3)
-        {
-          if (args(2).is_string ())
-            {
-              std::string type_str = args(2).string_value ();
+  system_exec_type type = et_sync;
+
+  if (nargin == 3)
+    {
+      std::string type_str = args(2).xstring_value ("system: TYPE must be a string");
 
-              if (type_str == "sync")
-                type = et_sync;
-              else if (type_str == "async")
-                type = et_async;
-              else
-                {
-                  error ("system: TYPE must be \"sync\" or \"async\"");
-                  return retval;
-                }
-            }
-          else
-            {
-              error ("system: TYPE must be a string");
-              return retval;
-            }
-        }
+      if (type_str == "sync")
+        type = et_sync;
+      else if (type_str == "async")
+        type = et_async;
+      else
+        error ("system: TYPE must be \"sync\" or \"async\"");
+    }
 
-      if (nargin > 1)
+  if (nargin > 1)
+    {
+      try
         {
           return_output = args(1).is_true ();
-
-          if (error_state)
-            {
-              error ("system: RETURN_OUTPUT must be boolean value true or false");
-              return retval;
-            }
         }
-
-      if (return_output && type == et_async)
+      catch (octave_execution_exception& e)
         {
-          error ("system: can't return output from commands run asynchronously");
-          return retval;
+          error (e, "system: RETURN_OUTPUT must be boolean value true or false");
         }
+    }
 
-      std::string cmd_str = args(0).string_value ();
+  if (return_output && type == et_async)
+    error ("system: can't return output from commands run asynchronously");
 
-      if (! error_state)
-        {
+  std::string cmd_str = args(0).xstring_value ("system: first argument must be a string");
+
 #if defined (__WIN32__) && ! defined (__CYGWIN__)
-          // Work around weird double-quote handling on Windows systems.
-          if (type == et_sync)
-            cmd_str = "\"" + cmd_str + "\"";
+  // Work around weird double-quote handling on Windows systems.
+  if (type == et_sync)
+    cmd_str = "\"" + cmd_str + "\"";
 #endif
 
-          if (type == et_async)
-            {
-              // FIXME: maybe this should go in sysdep.cc?
+  if (type == et_async)
+    {
+      // FIXME: maybe this should go in sysdep.cc?
 #ifdef HAVE_FORK
-              pid_t pid = fork ();
-
-              if (pid < 0)
-                error ("system: fork failed -- can't create child process");
-              else if (pid == 0)
-                {
-                  // FIXME: should probably replace this
-                  // call with something portable.
-
-                  execl (SHELL_PATH, "sh", "-c", cmd_str.c_str (),
-                         static_cast<void *> (0));
-
-                  panic_impossible ();
-                }
-              else
-                retval(0) = pid;
-#elif defined (__WIN32__)
-              STARTUPINFO si;
-              PROCESS_INFORMATION pi;
-              ZeroMemory (&si, sizeof (si));
-              ZeroMemory (&pi, sizeof (pi));
-              OCTAVE_LOCAL_BUFFER (char, xcmd_str, cmd_str.length ()+1);
-              strcpy (xcmd_str, cmd_str.c_str ());
+      pid_t pid = fork ();
 
-              if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi))
-                error ("system: CreateProcess failed -- can't create child process");
-              else
-                {
-                  retval(0) = pi.dwProcessId;
-                  CloseHandle (pi.hProcess);
-                  CloseHandle (pi.hThread);
-                }
-#else
-              error ("asynchronous system calls are not supported");
-#endif
-            }
-          else if (return_output)
-            retval = run_command_and_return_output (cmd_str);
-          else
-            {
-              int status = system (cmd_str.c_str ());
+      if (pid < 0)
+        error ("system: fork failed -- can't create child process");
+      else if (pid == 0)
+        {
+          // FIXME: should probably replace this
+          // call with something portable.
 
-              // The value in status is as returned by waitpid.  If
-              // the process exited normally, extract the actual exit
-              // status of the command.  Otherwise, return 127 as a
-              // failure code.
+          execl (SHELL_PATH, "sh", "-c", cmd_str.c_str (),
+                 static_cast<void *> (0));
 
-              if (octave_wait::ifexited (status))
-                status = octave_wait::exitstatus (status);
-
-              retval(0) = status;
-            }
+          panic_impossible ();
         }
       else
-        error ("system: expecting string as first argument");
+        retval(0) = pid;
+#elif defined (__WIN32__)
+      STARTUPINFO si;
+      PROCESS_INFORMATION pi;
+      ZeroMemory (&si, sizeof (si));
+      ZeroMemory (&pi, sizeof (pi));
+      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))
+        error ("system: CreateProcess failed -- can't create child process");
+      else
+        {
+          retval(0) = pi.dwProcessId;
+          CloseHandle (pi.hProcess);
+          CloseHandle (pi.hThread);
+        }
+#else
+      error ("system: asynchronous system calls are not supported");
+#endif
     }
+  else if (return_output)
+    retval = run_command_and_return_output (cmd_str);
   else
-    print_usage ();
+    {
+      int status = system (cmd_str.c_str ());
+
+      // The value in status is as returned by waitpid.  If
+      // the process exited normally, extract the actual exit
+      // status of the command.  Otherwise, return 127 as a
+      // failure code.
+
+      if (octave_wait::ifexited (status))
+        status = octave_wait::exitstatus (status);
+
+      retval(0) = status;
+    }
 
   return retval;
 }
@@ -1213,40 +1213,24 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      if (args(0).is_string ())
-        {
-          std::string arg = args(0).string_value ();
-
-          bool add_mode = true;
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
-          if (nargin == 2)
-            {
-              add_mode = args(1).bool_value ();
+  std::string arg = args(0).xstring_value ("atexit: FCN argument must be a string");
 
-              if (error_state)
-                error ("atexit: FLAG argument must be a logical value");
-            }
+  bool add_mode = (nargin == 2)
+    ? args(1).xbool_value ("atexit: FLAG argument must be a logical value")
+    : true;
 
-          if (! error_state)
-            {
-              if (add_mode)
-                octave_add_atexit_function (arg);
-              else
-                {
-                  bool found = octave_remove_atexit_function (arg);
+  if (add_mode)
+    octave_add_atexit_function (arg);
+  else
+    {
+      bool found = octave_remove_atexit_function (arg);
 
-                  if (nargout > 0)
-                    retval(0) = found;
-                }
-            }
-        }
-      else
-        error ("atexit: FCN argument must be a string");
+      if (nargout > 0)
+        retval(0) = found;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1508,7 +1492,7 @@
 
 #if defined (WIN32)
       windows_system = true;
-#if !defined (__CYGWIN__)
+#if ! defined (__CYGWIN__)
       unix_system = false;
 #endif
 #endif
@@ -1526,29 +1510,27 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 1)
     {
       std::string arg = args(0).string_value ();
 
-      if (! error_state)
+      if (m.isfield (arg))
         {
-          if (m.isfield (arg))
-            {
-              Cell c = m.contents (arg);
+          Cell c = m.contents (arg);
 
-              if (c.is_empty ())
-                error ("octave_config_info: no info for '%s'", arg.c_str ());
-              else
-                retval = c(0);
-            }
+          if (c.is_empty ())
+            error ("octave_config_info: no info for '%s'", arg.c_str ());
           else
-            error ("octave_config_info: invalid parameter '%s'", arg.c_str ());
+            retval = c(0);
         }
+      else
+        error ("octave_config_info: invalid parameter '%s'", arg.c_str ());
     }
-  else if (nargin == 0)
+  else
     retval = m;
-  else
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/corefcn/toplev.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/toplev.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_toplev_h)
+#if ! defined (octave_toplev_h)
 #define octave_toplev_h 1
 
 #include <cstdio>
@@ -107,6 +107,8 @@
 
     std::string fcn_name (bool print_subfn = true) const;
 
+    bool operator== (const stack_frame &rhs) const;
+
   private:
 
     octave_function *m_fcn;
@@ -134,7 +136,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create call stack object!");
+        error ("unable to create call stack object!");
 
         retval = false;
       }
@@ -515,12 +517,9 @@
  \
           F ARGS; \
         } \
-      OCTAVE_IGNORE_EXCEPTION (octave_interrupt_exception) \
-      OCTAVE_IGNORE_EXCEPTION (octave_execution_exception) \
-      OCTAVE_IGNORE_EXCEPTION (std::bad_alloc) \
- \
-      if (error_state) \
-        error_state = 0; \
+      OCTAVE_IGNORE_EXCEPTION (const octave_interrupt_exception&) \
+      OCTAVE_IGNORE_EXCEPTION (const octave_execution_exception&) \
+      OCTAVE_IGNORE_EXCEPTION (const std::bad_alloc&) \
     } \
   while (0)
 
--- a/libinterp/corefcn/tril.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/tril.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -131,10 +131,7 @@
 do_tril (const Sparse<T>& a, octave_idx_type k, bool pack)
 {
   if (pack) // FIXME
-    {
-      error ("tril: \"pack\" not implemented for sparse matrices");
-      return Sparse<T> ();
-    }
+    error ("tril: \"pack\" not implemented for sparse matrices");
 
   Sparse<T> m = a;
   octave_idx_type nc = m.cols ();
@@ -145,6 +142,7 @@
         m.data(i) = 0.;
 
   m.maybe_compress (true);
+
   return m;
 }
 
@@ -153,10 +151,7 @@
 do_triu (const Sparse<T>& a, octave_idx_type k, bool pack)
 {
   if (pack) // FIXME
-    {
-      error ("triu: \"pack\" not implemented for sparse matrices");
-      return Sparse<T> ();
-    }
+    error ("triu: \"pack\" not implemented for sparse matrices");
 
   Sparse<T> m = a;
   octave_idx_type nc = m.cols ();
@@ -189,156 +184,147 @@
 do_trilu (const std::string& name,
           const octave_value_list& args)
 {
-  bool lower = name == "tril";
+  bool lower = (name == "tril");
 
   octave_value retval;
   int nargin = args.length ();
   octave_idx_type k = 0;
   bool pack = false;
+
   if (nargin >= 2 && args(nargin-1).is_string ())
     {
       pack = args(nargin-1).string_value () == "pack";
       nargin--;
     }
 
-  if (nargin == 2)
-    {
-      k = args(1).int_value (true);
-
-      if (error_state)
-        return retval;
-    }
-
   if (nargin < 1 || nargin > 2)
     print_usage ();
+
+  if (nargin == 2)
+    k = args(1).int_value (true);
+
+  octave_value arg = args(0);
+
+  dim_vector dims = arg.dims ();
+  if (dims.length () != 2)
+    error ("%s: need a 2-D matrix", name.c_str ());
+  else if (k < -dims(0) || k > dims(1))
+    error ("%s: requested diagonal out of range", name.c_str ());
   else
     {
-      octave_value arg = args(0);
-
-      dim_vector dims = arg.dims ();
-      if (dims.length () != 2)
-        error ("%s: need a 2-D matrix", name.c_str ());
-      else if (k < -dims (0) || k > dims(1))
-        error ("%s: requested diagonal out of range", name.c_str ());
-      else
+      switch (arg.builtin_type ())
         {
-          switch (arg.builtin_type ())
-            {
-            case btyp_double:
-              if (arg.is_sparse_type ())
-                retval = do_trilu (arg.sparse_matrix_value (), k, lower, pack);
-              else
-                retval = do_trilu (arg.array_value (), k, lower, pack);
-              break;
-            case btyp_complex:
-              if (arg.is_sparse_type ())
-                retval = do_trilu (arg.sparse_complex_matrix_value (), k, lower,
-                                   pack);
-              else
-                retval = do_trilu (arg.complex_array_value (), k, lower, pack);
-              break;
-            case btyp_bool:
-              if (arg.is_sparse_type ())
-                retval = do_trilu (arg.sparse_bool_matrix_value (), k, lower,
-                                   pack);
-              else
-                retval = do_trilu (arg.bool_array_value (), k, lower, pack);
-              break;
-#define ARRAYCASE(TYP) \
-            case btyp_ ## TYP: \
-              retval = do_trilu (arg.TYP ## _array_value (), k, lower, pack); \
-              break
-            ARRAYCASE (float);
-            ARRAYCASE (float_complex);
-            ARRAYCASE (int8);
-            ARRAYCASE (int16);
-            ARRAYCASE (int32);
-            ARRAYCASE (int64);
-            ARRAYCASE (uint8);
-            ARRAYCASE (uint16);
-            ARRAYCASE (uint32);
-            ARRAYCASE (uint64);
-            ARRAYCASE (char);
+        case btyp_double:
+          if (arg.is_sparse_type ())
+            retval = do_trilu (arg.sparse_matrix_value (), k, lower, pack);
+          else
+            retval = do_trilu (arg.array_value (), k, lower, pack);
+          break;
+
+        case btyp_complex:
+          if (arg.is_sparse_type ())
+            retval = do_trilu (arg.sparse_complex_matrix_value (), k, lower,
+                               pack);
+          else
+            retval = do_trilu (arg.complex_array_value (), k, lower, pack);
+          break;
+
+        case btyp_bool:
+          if (arg.is_sparse_type ())
+            retval = do_trilu (arg.sparse_bool_matrix_value (), k, lower,
+                               pack);
+          else
+            retval = do_trilu (arg.bool_array_value (), k, lower, pack);
+          break;
+
+#define ARRAYCASE(TYP)       \
+          case btyp_ ## TYP: \
+            retval = do_trilu (arg.TYP ## _array_value (), k, lower, pack); \
+            break
+
+          ARRAYCASE (float);
+          ARRAYCASE (float_complex);
+          ARRAYCASE (int8);
+          ARRAYCASE (int16);
+          ARRAYCASE (int32);
+          ARRAYCASE (int64);
+          ARRAYCASE (uint8);
+          ARRAYCASE (uint16);
+          ARRAYCASE (uint32);
+          ARRAYCASE (uint64);
+          ARRAYCASE (char);
+
 #undef ARRAYCASE
-            default:
-              {
-                // Generic code that works on octave-values, that is slow
-                // but will also work on arbitrary user types
+
+        default:
+          {
+            // Generic code that works on octave-values, that is slow
+            // but will also work on arbitrary user types
 
-                if (pack) // FIXME
-                  {
-                    error ("%s: \"pack\" not implemented for class %s",
-                           name.c_str (), arg.class_name ().c_str ());
-                    return octave_value ();
-                  }
+            if (pack) // FIXME
+              error ("%s: \"pack\" not implemented for class %s",
+                     name.c_str (), arg.class_name ().c_str ());
 
-                octave_value tmp = arg;
-                if (arg.numel () == 0)
-                  return arg;
+            octave_value tmp = arg;
+            if (arg.numel () == 0)
+              return arg;
 
-                octave_idx_type nr = dims(0);
-                octave_idx_type nc = dims(1);
+            octave_idx_type nr = dims(0);
+            octave_idx_type nc = dims(1);
 
-                // The sole purpose of the below is to force the correct
-                // matrix size. This would not be necessary if the
-                // octave_value resize function allowed a fill_value.
-                // It also allows odd attributes in some user types
-                // to be handled. With a fill_value ot should be replaced
-                // with
-                //
-                // octave_value_list ov_idx;
-                // tmp = tmp.resize(dim_vector (0,0)).resize (dims, fill_value);
+            // The sole purpose of the below is to force the correct
+            // matrix size. This would not be necessary if the
+            // octave_value resize function allowed a fill_value.
+            // It also allows odd attributes in some user types
+            // to be handled. With a fill_value ot should be replaced
+            // with
+            //
+            // octave_value_list ov_idx;
+            // tmp = tmp.resize(dim_vector (0,0)).resize (dims, fill_value);
 
-                octave_value_list ov_idx;
-                std::list<octave_value_list> idx_tmp;
-                ov_idx(1) = static_cast<double> (nc+1);
-                ov_idx(0) = Range (1, nr);
-                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);
+            octave_value_list ov_idx;
+            std::list<octave_value_list> idx_tmp;
+            ov_idx(1) = static_cast<double> (nc+1);
+            ov_idx(0) = Range (1, nr);
+            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);
 
-                if (lower)
-                  {
-                    octave_idx_type st = nc < nr + k ? nc : nr + k;
+            if (lower)
+              {
+                octave_idx_type st = nc < nr + k ? nc : nr + k;
 
-                    for (octave_idx_type j = 1; j <= st; j++)
-                      {
-                        octave_idx_type nr_limit = 1 > j - k ? 1 : j - k;
-                        ov_idx(1) = static_cast<double> (j);
-                        ov_idx(0) = Range (nr_limit, nr);
-                        std::list<octave_value_list> idx;
-                        idx.push_back (ov_idx);
+                for (octave_idx_type j = 1; j <= st; j++)
+                  {
+                    octave_idx_type nr_limit = 1 > j - k ? 1 : j - k;
+                    ov_idx(1) = static_cast<double> (j);
+                    ov_idx(0) = Range (nr_limit, nr);
+                    std::list<octave_value_list> idx;
+                    idx.push_back (ov_idx);
 
-                        tmp = tmp.subsasgn ("(", idx, arg.do_index_op (ov_idx));
-
-                        if (error_state)
-                          return retval;
-                      }
+                    tmp = tmp.subsasgn ("(", idx, arg.do_index_op (ov_idx));
                   }
-                else
-                  {
-                    octave_idx_type st = k + 1 > 1 ? k + 1 : 1;
+              }
+            else
+              {
+                octave_idx_type st = k + 1 > 1 ? k + 1 : 1;
 
-                    for (octave_idx_type j = st; j <= nc; j++)
-                      {
-                        octave_idx_type nr_limit = nr < j - k ? nr : j - k;
-                        ov_idx(1) = static_cast<double> (j);
-                        ov_idx(0) = Range (1, nr_limit);
-                        std::list<octave_value_list> idx;
-                        idx.push_back (ov_idx);
+                for (octave_idx_type j = st; j <= nc; j++)
+                  {
+                    octave_idx_type nr_limit = nr < j - k ? nr : j - k;
+                    ov_idx(1) = static_cast<double> (j);
+                    ov_idx(0) = Range (1, nr_limit);
+                    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;
-                      }
-                  }
-
-                retval = tmp;
-              }
-            }
+            retval = tmp;
+          }
         }
     }
 
--- a/libinterp/corefcn/tsearch.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/tsearch.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -70,15 +70,12 @@
 @seealso{delaunay, delaunayn}\n\
 @end deftypefn")
 {
-  const double eps=1.0e-12;
+  octave_value_list retval;
 
-  octave_value_list retval;
-  const int nargin = args.length ();
-  if (nargin != 5)
-    {
-      print_usage ();
-      return retval;
-    }
+  const double eps = 1.0e-12;
+
+  if (args.length () != 5)
+    print_usage ();
 
   const ColumnVector x (args(0).vector_value ());
   const ColumnVector y (args(1).vector_value ());
@@ -86,9 +83,6 @@
   const ColumnVector xi (args(3).vector_value ());
   const ColumnVector yi (args(4).vector_value ());
 
-  if (error_state)
-    return retval;
-
   const octave_idx_type nelem = elem.rows ();
 
   ColumnVector minx (nelem);
@@ -103,7 +97,7 @@
       maxy(k) = max (REF (y, k, 0), REF (y, k, 1), REF (y, k, 2)) + eps;
     }
 
-  const octave_idx_type np = xi.length ();
+  const octave_idx_type np = xi.numel ();
   ColumnVector values (np);
 
   double x0, y0, a11, a12, a21, a22, det;
--- a/libinterp/corefcn/txt-eng-ft.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/txt-eng-ft.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -90,7 +90,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create ft_manager!");
+        error ("unable to create ft_manager!");
 
         retval = false;
       }
@@ -138,13 +138,13 @@
     : library (), freetype_initialized (false), fontconfig_initialized (false)
   {
     if (FT_Init_FreeType (&library))
-      ::error ("unable to initialize FreeType library");
+      error ("unable to initialize FreeType library");
     else
       freetype_initialized = true;
 
 #if defined (HAVE_FONTCONFIG)
     if (! FcInit ())
-      ::error ("unable to initialize fontconfig library");
+      error ("unable to initialize fontconfig library");
     else
       fontconfig_initialized = true;
 #endif
@@ -366,7 +366,7 @@
         line_bbox.pop_front ();
         Matrix new_bbox = line_bbox.front ();
 
-        xoffset = compute_line_xoffset (new_bbox);
+        xoffset = line_xoffset = compute_line_xoffset (new_bbox);
         line_yoffset += (old_bbox(1) - (new_bbox(1) + new_bbox(3)));
         yoffset = 0;
       }
@@ -438,7 +438,7 @@
       int asc = font.get_face ()->size->metrics.ascender >> 6;
       int desc = font.get_face ()->size->metrics.descender >> 6;
 
-      Matrix& bb = line_bbox.front ();
+      Matrix& bb = line_bbox.back ();
 
       if ((yoffset + desc) < bb(1))
         {
@@ -492,7 +492,7 @@
         }
       break;
     default:
-      ::error ("ft_render: invalid mode '%d'", mode);
+      error ("ft_render: invalid mode '%d'", mode);
       break;
     }
 }
@@ -560,8 +560,8 @@
                   if (x0 < 0)
                     x0 = 0;
 
-                  for (int r = 0; r < bitmap.rows; r++)
-                    for (int c = 0; c < bitmap.width; c++)
+                  for (int r = 0; static_cast<unsigned int> (r) < bitmap.rows; r++)
+                    for (int c = 0; static_cast<unsigned int> (c) < bitmap.width; c++)
                       {
                         unsigned char pix = bitmap.buffer[r*bitmap.width+c];
                         if (x0+c < 0 || x0+c >= pixels.dim2 ()
@@ -637,10 +637,14 @@
       std::string str = e.string_value ();
       size_t n = str.length ();
       size_t curr = 0;
+      size_t idx = 0;
       mbstate_t ps;
       memset (&ps, 0, sizeof (ps));  // Initialize state to 0.
       wchar_t wc;
 
+      ft_string fs (str, font.get_angle (), font.get_weight (),
+                    font.get_name (), font.get_size (), xoffset, yoffset);
+
       while (n > 0)
         {
           size_t r = gnulib::mbrtowc (&wc, str.data () + curr, n, &ps);
@@ -652,10 +656,32 @@
               n -= r;
               curr += r;
 
+              if (wc == L'\n')
+                {
+                  // Finish previous string in srtlist before processing
+                  // the newline character
+                  fs.set_y (line_yoffset + yoffset);
+                  fs.set_color (color);
+                  std::string s = str.substr (idx, curr - idx - 1);
+                  if (! s.empty ())
+                    {
+                      fs.set_string (s);
+                      strlist.push_back (fs);
+                    }
+                }
+
               glyph_index = process_character (wc, previous);
 
               if (wc == L'\n')
-                previous = 0;
+                {
+                  previous = 0;
+                  // Start a new string in strlist
+                  idx = curr;
+                  fs = ft_string (str.substr (idx), font.get_angle (),
+                                  font.get_weight (), font.get_name (),
+                                  font.get_size (), line_xoffset, yoffset);
+
+                }
               else
                 previous = glyph_index;
             }
@@ -668,6 +694,12 @@
               break;
             }
         }
+      if (! fs.get_string ().empty ())
+        {
+          fs.set_y (line_yoffset + yoffset);
+          fs.set_color (color);
+          strlist.push_back (fs);
+        }
     }
 }
 
@@ -806,10 +838,23 @@
 {
   uint32_t code = e.get_symbol_code ();
 
+  ft_string fs (std::string ("-"), font.get_angle (), font.get_weight (),
+                font.get_name (), font.get_size (), xoffset, yoffset);
+
   if (code != text_element_symbol::invalid_code && font.is_valid ())
-    process_character (code);
+    {
+      process_character (code);
+      fs.set_code (code);
+    }
   else if (font.is_valid ())
     ::warning ("ignoring unknown symbol: %d", e.get_symbol ());
+
+  if (fs.get_code ())
+    {
+      fs.set_y (line_yoffset + yoffset);
+      fs.set_color (color);
+      strlist.push_back (fs);
+   }
 }
 
 void
@@ -857,6 +902,9 @@
   box = bbox;
 
   set_mode (MODE_RENDER);
+  // Clear the list of parsed strings
+  strlist.clear ();
+
   if (pixels.numel () > 0)
     {
       elt->accept (*this);
@@ -976,7 +1024,8 @@
 ft_render::text_to_pixels (const std::string& txt,
                            uint8NDArray& pixels_, Matrix& box,
                            int _halign, int valign, double rotation,
-                           const caseless_str& interpreter)
+                           const caseless_str& interpreter,
+                           bool handle_rotation)
 {
   int rot_mode = rotation_to_mode (rotation);
 
@@ -1007,23 +1056,24 @@
     case 4: box(1) = -box(3)-box(1); break;
     }
 
-  switch (rot_mode)
-    {
-    case ROTATION_90:
-      std::swap (box(0), box(1));
-      std::swap (box(2), box(3));
-      box(0) = -box(0)-box(2);
-      break;
-    case ROTATION_180:
-      box(0) = -box(0)-box(2);
-      box(1) = -box(1)-box(3);
-      break;
-    case ROTATION_270:
-      std::swap (box(0), box(1));
-      std::swap (box(2), box(3));
-      box(1) = -box(1)-box(3);
-      break;
-    }
+  if (handle_rotation)
+    switch (rot_mode)
+      {
+      case ROTATION_90:
+        std::swap (box(0), box(1));
+        std::swap (box(2), box(3));
+        box(0) = -box(0)-box(2);
+        break;
+      case ROTATION_180:
+        box(0) = -box(0)-box(2);
+        box(1) = -box(1)-box(3);
+        break;
+      case ROTATION_270:
+        std::swap (box(0), box(1));
+        std::swap (box(2), box(3));
+        box(1) = -box(1)-box(3);
+        break;
+      }
 }
 
 ft_render::ft_font::ft_font (const ft_font& ft)
--- a/libinterp/corefcn/txt-eng-ft.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/txt-eng-ft.h	Thu Dec 10 12:50:06 2015 -0800
@@ -55,6 +55,7 @@
   };
 
 public:
+
   ft_render (void);
 
   ~ft_render (void);
@@ -102,7 +103,8 @@
   void text_to_pixels (const std::string& txt,
                        uint8NDArray& pixels_, Matrix& bbox,
                        int halign, int valign, double rotation,
-                       const caseless_str& interpreter = "tex");
+                       const caseless_str& interpreter = "tex",
+                       bool handle_rotation = true);
 
 private:
   int rotation_to_mode (double rotation) const;
@@ -165,6 +167,66 @@
 
   FT_UInt process_character (FT_ULong code, FT_UInt previous = 0);
 
+public:
+  // A class to store informations on substrings after parsing.
+  class ft_string : public ft_font
+  {
+  public:
+    ft_string (const std::string s, const std::string fontang,
+              const std::string fontwgt, const std::string nm,
+              const double fontsz, const double x0, const double y0)
+      : ft_font (nm, fontwgt, fontang, fontsz),
+        string(s), x(x0), y(y0), z(0.0), code(0),
+        color(Matrix (1,3,0.0)){ }
+
+    void set_string (const std::string str) { string = str; }
+
+    std::string get_string (void) const { return string; }
+
+    void set_x (const double x0) { x = x0; }
+
+    double get_x (void) const { return x; }
+
+    void set_y (const double y0) { y = y0; }
+
+    double get_y (void) const { return y; }
+
+    void set_z (const double z0) { z = z0; }
+
+    double get_z (void) const { return z; }
+
+    void set_code (const uint32_t c) { code = c; }
+
+    uint32_t get_code (void) const { return code; }
+
+    void set_color (const uint8NDArray c)
+    {
+      color(0) = static_cast<double> (c(0)) / 255;
+      color(1) = static_cast<double> (c(1)) / 255;
+      color(2) = static_cast<double> (c(2)) / 255;
+    }
+
+    Matrix get_color (void) const { return color; }
+
+  private:
+    std::string  string;
+    double x, y, z;
+    uint32_t code;
+    Matrix color;
+  };
+
+ void text_to_strlist (const std::string& txt,
+                        std::list<ft_string>& lst, Matrix& box,
+                        int ha, int va, double rot,
+                        const caseless_str& interp = "tex")
+  {
+    uint8NDArray pixels_;
+    // First run text_to_pixels which will also build the string list
+    text_to_pixels (txt, pixels_, box, ha, va, rot, interp, false);
+
+    lst = strlist;
+  }
+
 private:
   // The current font used by the renderer.
   ft_font font;
@@ -203,6 +265,13 @@
 
   // The base color of the rendered text.
   uint8NDArray color;
+
+  // A list of parsed strings to be used for printing.
+  std::list<ft_string> strlist;
+
+  // The X offset of the baseline for the current line.
+  int line_xoffset;
+
 };
 
 #endif // HAVE_FREETYPE
--- a/libinterp/corefcn/typecast.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/typecast.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -40,7 +40,7 @@
 {
   if (old_dims.length () == 2 && old_dims(0) == 1)
     return dim_vector (1, n);
-  else if (old_dims.length () == 2 && old_dims (0) == 0 && old_dims (1) == 0)
+  else if (old_dims.length () == 2 && old_dims(0) == 0 && old_dims(1) == 0)
     return dim_vector ();
   else
     return dim_vector (n, 1);
@@ -81,10 +81,9 @@
       return retval;
     }
   else
-    {
-      error ("typecast: incorrect number of input values to make output value");
-      return ArrayType ();
-    }
+    error ("typecast: incorrect number of input values to make output value");
+
+  return ArrayType ();
 }
 
 
@@ -145,119 +144,117 @@
 {
   octave_value retval;
 
-  if (args.length () == 2)
-    {
-      unwind_protect frame;
-      const void *data = 0;
-      octave_idx_type byte_size = 0;
-      dim_vector old_dims;
+  if (args.length () != 2)
+    print_usage ();
+
+  unwind_protect frame;
+  const void *data = 0;
+  octave_idx_type byte_size = 0;
+  dim_vector old_dims;
+
+  octave_value array = args(0);
 
-      octave_value array = args(0);
-
-      if (array.is_bool_type ())
-        get_data_and_bytesize (array.bool_array_value (), data, byte_size,
+  if (array.is_bool_type ())
+    get_data_and_bytesize (array.bool_array_value (), data, byte_size,
+                           old_dims, frame);
+  else if (array.is_string ())
+    get_data_and_bytesize (array.char_array_value (), data, byte_size,
+                           old_dims, frame);
+  else if (array.is_integer_type ())
+    {
+      if (array.is_int8_type ())
+        get_data_and_bytesize (array.int8_array_value (), data, byte_size,
+                               old_dims, frame);
+      else if (array.is_int16_type ())
+        get_data_and_bytesize (array.int16_array_value (), data, byte_size,
                                old_dims, frame);
-      else if (array.is_string ())
-        get_data_and_bytesize (array.char_array_value (), data, byte_size,
+      else if (array.is_int32_type ())
+        get_data_and_bytesize (array.int32_array_value (), data, byte_size,
+                               old_dims, frame);
+      else if (array.is_int64_type ())
+        get_data_and_bytesize (array.int64_array_value (), data, byte_size,
+                               old_dims, frame);
+      else if (array.is_uint8_type ())
+        get_data_and_bytesize (array.uint8_array_value (), data, byte_size,
+                               old_dims, frame);
+      else if (array.is_uint16_type ())
+        get_data_and_bytesize (array.uint16_array_value (), data, byte_size,
+                               old_dims, frame);
+      else if (array.is_uint32_type ())
+        get_data_and_bytesize (array.uint32_array_value (), data, byte_size,
+                               old_dims, frame);
+      else if (array.is_uint64_type ())
+        get_data_and_bytesize (array.uint64_array_value (), data, byte_size,
                                old_dims, frame);
-      else if (array.is_integer_type ())
-        {
-          if (array.is_int8_type ())
-            get_data_and_bytesize (array.int8_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_int16_type ())
-            get_data_and_bytesize (array.int16_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_int32_type ())
-            get_data_and_bytesize (array.int32_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_int64_type ())
-            get_data_and_bytesize (array.int64_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_uint8_type ())
-            get_data_and_bytesize (array.uint8_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_uint16_type ())
-            get_data_and_bytesize (array.uint16_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_uint32_type ())
-            get_data_and_bytesize (array.uint32_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else if (array.is_uint64_type ())
-            get_data_and_bytesize (array.uint64_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else
-            assert (0);
-        }
-      else if (array.is_complex_type ())
-        {
-          if (array.is_single_type ())
-            get_data_and_bytesize (array.float_complex_array_value (), data,
-                                   byte_size, old_dims, frame);
-          else
-            get_data_and_bytesize (array.complex_array_value (), data,
-                                   byte_size, old_dims, frame);
-        }
-      else if (array.is_real_type ())
-        {
-          if (array.is_single_type ())
-            get_data_and_bytesize (array.float_array_value (), data, byte_size,
-                                   old_dims, frame);
-          else
-            get_data_and_bytesize (array.array_value (), data, byte_size,
-                                   old_dims, frame); }
+      else
+        assert (0);
+    }
+  else if (array.is_complex_type ())
+    {
+      if (array.is_single_type ())
+        get_data_and_bytesize (array.float_complex_array_value (), data,
+                               byte_size, old_dims, frame);
+      else
+        get_data_and_bytesize (array.complex_array_value (), data,
+                               byte_size, old_dims, frame);
+    }
+  else if (array.is_real_type ())
+    {
+      if (array.is_single_type ())
+        get_data_and_bytesize (array.float_array_value (), data, byte_size,
+                               old_dims, frame);
       else
-        error ("typecast: invalid input class: %s",
-                                                array.class_name ().c_str ());
+        get_data_and_bytesize (array.array_value (), data, byte_size,
+                               old_dims, frame); }
+  else
+    error ("typecast: invalid input class: %s",
+           array.class_name ().c_str ());
 
-      std::string numclass = args(1).string_value ();
+  std::string numclass = args(1).string_value ();
 
-      if (error_state || numclass.size () == 0)
-        ;
-      else if (numclass == "char")
-        retval = octave_value (reinterpret_copy<charNDArray>
-                   (data, byte_size, old_dims), array.is_dq_string () ? '"'
-                                                                      : '\'');
-      else if (numclass[0] == 'i')
-        {
-          if (numclass == "int8")
-            retval = reinterpret_copy<int8NDArray> (data, byte_size, old_dims);
-          else if (numclass == "int16")
-            retval = reinterpret_copy<int16NDArray> (data, byte_size, old_dims);
-          else if (numclass == "int32")
-            retval = reinterpret_copy<int32NDArray> (data, byte_size, old_dims);
-          else if (numclass == "int64")
-            retval = reinterpret_copy<int64NDArray> (data, byte_size, old_dims);
-        }
-      else if (numclass[0] == 'u')
-        {
-          if (numclass == "uint8")
-            retval = reinterpret_copy<uint8NDArray> (data, byte_size, old_dims);
-          else if (numclass == "uint16")
-            retval = reinterpret_copy<uint16NDArray> (data, byte_size,
-                                                      old_dims);
-          else if (numclass == "uint32")
-            retval = reinterpret_copy<uint32NDArray> (data, byte_size,
-                                                      old_dims);
-          else if (numclass == "uint64")
-            retval = reinterpret_copy<uint64NDArray> (data, byte_size,
-                                                      old_dims);
-        }
-      else if (numclass == "single")
-        retval = reinterpret_copy<FloatNDArray> (data, byte_size, old_dims);
-      else if (numclass == "double")
-        retval = reinterpret_copy<NDArray> (data, byte_size, old_dims);
-      else if (numclass == "single complex")
-        retval = reinterpret_copy<FloatComplexNDArray> (data, byte_size,
-                                                        old_dims);
-      else if (numclass == "double complex")
-        retval = reinterpret_copy<ComplexNDArray> (data, byte_size, old_dims);
+  if (numclass.size () == 0)
+    ;
+  else if (numclass == "char")
+    retval = octave_value (reinterpret_copy<charNDArray>
+                           (data, byte_size, old_dims), array.is_dq_string () ? '"'
+                           : '\'');
+  else if (numclass[0] == 'i')
+    {
+      if (numclass == "int8")
+        retval = reinterpret_copy<int8NDArray> (data, byte_size, old_dims);
+      else if (numclass == "int16")
+        retval = reinterpret_copy<int16NDArray> (data, byte_size, old_dims);
+      else if (numclass == "int32")
+        retval = reinterpret_copy<int32NDArray> (data, byte_size, old_dims);
+      else if (numclass == "int64")
+        retval = reinterpret_copy<int64NDArray> (data, byte_size, old_dims);
+    }
+  else if (numclass[0] == 'u')
+    {
+      if (numclass == "uint8")
+        retval = reinterpret_copy<uint8NDArray> (data, byte_size, old_dims);
+      else if (numclass == "uint16")
+        retval = reinterpret_copy<uint16NDArray> (data, byte_size,
+                                                  old_dims);
+      else if (numclass == "uint32")
+        retval = reinterpret_copy<uint32NDArray> (data, byte_size,
+                                                  old_dims);
+      else if (numclass == "uint64")
+        retval = reinterpret_copy<uint64NDArray> (data, byte_size,
+                                                  old_dims);
+    }
+  else if (numclass == "single")
+    retval = reinterpret_copy<FloatNDArray> (data, byte_size, old_dims);
+  else if (numclass == "double")
+    retval = reinterpret_copy<NDArray> (data, byte_size, old_dims);
+  else if (numclass == "single complex")
+    retval = reinterpret_copy<FloatComplexNDArray> (data, byte_size,
+                                                    old_dims);
+  else if (numclass == "double complex")
+    retval = reinterpret_copy<ComplexNDArray> (data, byte_size, old_dims);
 
-      if (! error_state && retval.is_undefined ())
-        error ("typecast: cannot convert to %s class", numclass.c_str ());
-    }
-  else
-    print_usage ();
+  if (retval.is_undefined ())
+    error ("typecast: cannot convert to %s class", numclass.c_str ());
 
   return retval;
 }
@@ -293,10 +290,9 @@
       return retval;
     }
   else
-    {
-      error ("bitpack: incorrect number of bits to make up output value");
-      return ArrayType ();
-    }
+    error ("bitpack: incorrect number of bits to make up output value");
+
+  return ArrayType ();
 }
 
 DEFUN (bitpack, args, ,
@@ -339,52 +335,51 @@
 
   if (args.length () != 2)
     print_usage ();
-  else if (! args(0).is_bool_type ())
+
+  if (! args(0).is_bool_type ())
     error ("bitpack: X must be a logical array");
-  else
-    {
-      boolNDArray bitp = args(0).bool_array_value ();
 
-      std::string numclass = args(1).string_value ();
+  boolNDArray bitp = args(0).bool_array_value ();
+
+  std::string numclass = args(1).string_value ();
 
-      if (error_state || numclass.size () == 0)
-        ;
-      else if (numclass == "char")
-        retval = octave_value (do_bitpack<charNDArray> (bitp), '\'');
-      else if (numclass[0] == 'i')
-        {
-          if (numclass == "int8")
-            retval = do_bitpack<int8NDArray> (bitp);
-          else if (numclass == "int16")
-            retval = do_bitpack<int16NDArray> (bitp);
-          else if (numclass == "int32")
-            retval = do_bitpack<int32NDArray> (bitp);
-          else if (numclass == "int64")
-            retval = do_bitpack<int64NDArray> (bitp);
-        }
-      else if (numclass[0] == 'u')
-        {
-          if (numclass == "uint8")
-            retval = do_bitpack<uint8NDArray> (bitp);
-          else if (numclass == "uint16")
-            retval = do_bitpack<uint16NDArray> (bitp);
-          else if (numclass == "uint32")
-            retval = do_bitpack<uint32NDArray> (bitp);
-          else if (numclass == "uint64")
-            retval = do_bitpack<uint64NDArray> (bitp);
-        }
-      else if (numclass == "single")
-        retval = do_bitpack<FloatNDArray> (bitp);
-      else if (numclass == "double")
-        retval = do_bitpack<NDArray> (bitp);
-      else if (numclass == "single complex")
-        retval = do_bitpack<FloatComplexNDArray> (bitp);
-      else if (numclass == "double complex")
-        retval = do_bitpack<ComplexNDArray> (bitp);
+  if (numclass.size () == 0)
+    ;
+  else if (numclass == "char")
+    retval = octave_value (do_bitpack<charNDArray> (bitp), '\'');
+  else if (numclass[0] == 'i')
+    {
+      if (numclass == "int8")
+        retval = do_bitpack<int8NDArray> (bitp);
+      else if (numclass == "int16")
+        retval = do_bitpack<int16NDArray> (bitp);
+      else if (numclass == "int32")
+        retval = do_bitpack<int32NDArray> (bitp);
+      else if (numclass == "int64")
+        retval = do_bitpack<int64NDArray> (bitp);
+    }
+  else if (numclass[0] == 'u')
+    {
+      if (numclass == "uint8")
+        retval = do_bitpack<uint8NDArray> (bitp);
+      else if (numclass == "uint16")
+        retval = do_bitpack<uint16NDArray> (bitp);
+      else if (numclass == "uint32")
+        retval = do_bitpack<uint32NDArray> (bitp);
+      else if (numclass == "uint64")
+        retval = do_bitpack<uint64NDArray> (bitp);
+    }
+  else if (numclass == "single")
+    retval = do_bitpack<FloatNDArray> (bitp);
+  else if (numclass == "double")
+    retval = do_bitpack<NDArray> (bitp);
+  else if (numclass == "single complex")
+    retval = do_bitpack<FloatComplexNDArray> (bitp);
+  else if (numclass == "double complex")
+    retval = do_bitpack<ComplexNDArray> (bitp);
 
-      if (! error_state && retval.is_undefined ())
-        error ("bitpack: cannot pack to %s class", numclass.c_str ());
-    }
+  if (retval.is_undefined ())
+    error ("bitpack: cannot pack to %s class", numclass.c_str ());
 
   return retval;
 }
@@ -447,54 +442,54 @@
 {
   octave_value retval;
 
-  if (args.length () == 1
-      && (args(0).is_numeric_type () || args(0).is_string ()))
-    {
-      octave_value array = args(0);
+  if (args.length () != 1)
+    print_usage ();
+  
+  if (! (args(0).is_numeric_type () || args(0).is_string ()))
+    error ("bitunpack: argument must be a number or a string");
+
+  octave_value array = args(0);
 
-      if (array.is_string ())
-        retval = do_bitunpack (array.char_array_value ());
-      else if (array.is_integer_type ())
-        {
-          if (array.is_int8_type ())
-            retval = do_bitunpack (array.int8_array_value ());
-          else if (array.is_int16_type ())
-            retval = do_bitunpack (array.int16_array_value ());
-          else if (array.is_int32_type ())
-            retval = do_bitunpack (array.int32_array_value ());
-          else if (array.is_int64_type ())
-            retval = do_bitunpack (array.int64_array_value ());
-          else if (array.is_uint8_type ())
-            retval = do_bitunpack (array.uint8_array_value ());
-          else if (array.is_uint16_type ())
-            retval = do_bitunpack (array.uint16_array_value ());
-          else if (array.is_uint32_type ())
-            retval = do_bitunpack (array.uint32_array_value ());
-          else if (array.is_uint64_type ())
-            retval = do_bitunpack (array.uint64_array_value ());
-          else
-            assert (0);
-        }
-      else if (array.is_complex_type ())
-        {
-          if (array.is_single_type ())
-            retval = do_bitunpack (array.float_complex_array_value ());
-          else
-            retval = do_bitunpack (array.complex_array_value ());
-        }
-      else if (array.is_real_type ())
-        {
-          if (array.is_single_type ())
-            retval = do_bitunpack (array.float_array_value ());
-          else
-            retval = do_bitunpack (array.array_value ());
-        }
+  if (array.is_string ())
+    retval = do_bitunpack (array.char_array_value ());
+  else if (array.is_integer_type ())
+    {
+      if (array.is_int8_type ())
+        retval = do_bitunpack (array.int8_array_value ());
+      else if (array.is_int16_type ())
+        retval = do_bitunpack (array.int16_array_value ());
+      else if (array.is_int32_type ())
+        retval = do_bitunpack (array.int32_array_value ());
+      else if (array.is_int64_type ())
+        retval = do_bitunpack (array.int64_array_value ());
+      else if (array.is_uint8_type ())
+        retval = do_bitunpack (array.uint8_array_value ());
+      else if (array.is_uint16_type ())
+        retval = do_bitunpack (array.uint16_array_value ());
+      else if (array.is_uint32_type ())
+        retval = do_bitunpack (array.uint32_array_value ());
+      else if (array.is_uint64_type ())
+        retval = do_bitunpack (array.uint64_array_value ());
       else
-        error ("bitunpack: invalid input class: %s",
-                                                 array.class_name ().c_str ());
+        assert (0);
+    }
+  else if (array.is_complex_type ())
+    {
+      if (array.is_single_type ())
+        retval = do_bitunpack (array.float_complex_array_value ());
+      else
+        retval = do_bitunpack (array.complex_array_value ());
+    }
+  else if (array.is_real_type ())
+    {
+      if (array.is_single_type ())
+        retval = do_bitunpack (array.float_array_value ());
+      else
+        retval = do_bitunpack (array.array_value ());
     }
   else
-    print_usage ();
+    error ("bitunpack: invalid input class: %s",
+           array.class_name ().c_str ());
 
   return retval;
 }
--- a/libinterp/corefcn/urlwrite.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/urlwrite.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -80,11 +80,7 @@
       create_instance ();
 
     if (! instance)
-      {
-        ::error ("unable to create ch_manager!");
-
-        retval = false;
-      }
+      error ("unable to create ch_manager!");
 
     return retval;
   }
@@ -190,14 +186,9 @@
     url_transfer obj (host, user, passwd, os);
 
     if (obj.is_valid ())
-      {
-        if (! error_state)
-          handle_map[h] = obj;
-        else
-          h = curl_handle ();
-      }
+      handle_map[h] = obj;
     else
-      error ("support for url transfers was disabled when Octave was built");
+      error ("support for URL transfers was disabled when Octave was built");
 
     return h;
   }
@@ -345,60 +336,27 @@
 
   // verify arguments
   if (nargin != 2 && nargin != 4)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
-  if (! args(0).is_string ())
-    {
-      error ("urlwrite: URL must be a string");
-      return retval;
-    }
-
-  std::string url = args(0).string_value ();
-
-  if (! args(1).is_string ())
-    {
-      error ("urlwrite: LOCALFILE must be a string");
-      return retval;
-    }
+  std::string url = args(0).xstring_value ("urlwrite: URL must be a string");
 
   // name to store the file if download is succesful
-  std::string filename = args(1).string_value ();
+  std::string filename = args(1).xstring_value ("urlwrite: LOCALFILE must be a string");
 
   std::string method;
   Array<std::string> param;
 
   if (nargin == 4)
     {
-      if (! args(2).is_string ())
-        {
-          error ("urlwrite: METHOD must be a string");
-          return retval;
-        }
-
-      method = args(2).string_value ();
+      method = args(2).xstring_value ("urlwrite: METHOD must be a string");
 
       if (method != "get" && method != "post")
-        {
-          error ("urlwrite: METHOD must be \"get\" or \"post\"");
-          return retval;
-        }
+        error ("urlwrite: METHOD must be \"get\" or \"post\"");
 
-      param = args(3).cellstr_value ();
-
-      if (error_state)
-        {
-          error ("urlwrite: parameters (PARAM) for get and post requests must be given as a cell array of strings");
-          return retval;
-        }
+      param = args(3).xcellstr_value ("urlwrite: parameters (PARAM) for get and post requests must be given as a cell array of strings");
 
       if (param.numel () % 2 == 1)
-        {
-          error ("urlwrite: number of elements in PARAM must be even");
-          return retval;
-        }
+        error ("urlwrite: number of elements in PARAM must be even");
     }
 
   // The file should only be deleted if it doesn't initially exist, we
@@ -410,10 +368,7 @@
   std::ofstream ofile (filename.c_str (), std::ios::out | std::ios::binary);
 
   if (! ofile.is_open ())
-    {
-      error ("urlwrite: unable to open file");
-      return retval;
-    }
+    error ("urlwrite: unable to open file");
 
   unwind_protect_safe frame;
 
@@ -450,7 +405,7 @@
         error ("urlwrite: %s", curl.lasterror ().c_str ());
     }
   else
-    error ("support for url transfers was disabled when Octave was built");
+    error ("support for URL transfers was disabled when Octave was built");
 
   return retval;
 }
@@ -506,51 +461,24 @@
 
   // verify arguments
   if (nargin != 1 && nargin != 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
-  if (! args(0).is_string ())
-    {
-      error ("urlread: URL must be a string");
-      return retval;
-    }
-
-  std::string url = args(0).string_value ();
+  std::string url = args(0).xstring_value ("urlread: URL must be a string");
 
   std::string method;
   Array<std::string> param;
 
   if (nargin == 3)
     {
-      if (! args(1).is_string ())
-        {
-          error ("urlread: METHOD must be a string");
-          return retval;
-        }
-
-      method = args(1).string_value ();
+      method = args(1).xstring_value ("urlread: METHOD must be a string");
 
       if (method != "get" && method != "post")
-        {
-          error ("urlread: METHOD must be \"get\" or \"post\"");
-          return retval;
-        }
+        error ("urlread: METHOD must be \"get\" or \"post\"");
 
-      param = args(2).cellstr_value ();
-
-      if (error_state)
-        {
-          error ("urlread: parameters (PARAM) for get and post requests must be given as a cell array of strings");
-          return retval;
-        }
+      param = args(2).xcellstr_value ("urlread: parameters (PARAM) for get and post requests must be given as a cell array of strings");
 
       if (param.numel () % 2 == 1)
-        {
-          error ("urlread: number of elements in PARAM must be even");
-          return retval;
-        }
+        error ("urlread: number of elements in PARAM must be even");
     }
 
   std::ostringstream buf;
@@ -573,7 +501,7 @@
         error ("urlread: %s", curl.lasterror().c_str());
     }
   else
-    error ("support for url transfers was disabled when Octave was built");
+    error ("support for URL transfers was disabled when Octave was built");
 
   return retval;
 }
@@ -585,39 +513,25 @@
 Undocumented internal function\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   int nargin = args.length ();
-  std::string host;
-  std::string user = "anonymous";
-  std::string passwd = "";
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
-  else
-    {
-      host = args(0).string_value ();
+    print_usage ();
+
+  std::string host = args(0).xstring_value ("__ftp__: HOST must be a string");
 
-      if (nargin > 1)
-        user = args(1).string_value ();
+  std::string user = (nargin > 1)
+    ? args(1).xstring_value ("__ftp__: USER must be a string")
+    : std::string ("anonymous");
 
-      if (nargin > 2)
-        passwd = args(2).string_value ();
+  std::string passwd = (nargin > 2)
+    ? args(2).xstring_value ("__ftp__: PASSWD must be a string")
+    : std::string ();
 
-      if (! error_state)
-        {
-          curl_handle ch
-            = ch_manager::make_curl_handle (host, user, passwd, octave_stdout);
+  curl_handle ch
+    = ch_manager::make_curl_handle (host, user, passwd, octave_stdout);
 
-          if (! error_state)
-            retval = ch.value ();
-        }
-    }
-
-  return retval;
+  return octave_value (ch.value ());
 }
 
 DEFUN (__ftp_pwd__, args, ,
@@ -628,17 +542,12 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 1)
+  if (args.length () != 1)
     error ("__ftp_pwd__: incorrect number of arguments");
   else
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         retval = curl.pwd ();
       else
@@ -664,20 +573,14 @@
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         {
           std::string path = "";
 
           if (nargin > 1)
-            path = args(1).string_value ();
+            path = args(1).xstring_value ("__ftp_cwd__: PATH must be a string");
 
-          if (! error_state)
-            curl.cwd (path);
-          else
-            error ("__ftp_cwd__: expecting path as second argument");
+          curl.cwd (path);
         }
       else
         error ("__ftp_cwd__: invalid ftp handle");
@@ -694,17 +597,12 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 1)
+  if (args.length () != 1)
     error ("__ftp_dir__: incorrect number of arguments");
   else
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         {
           if (nargout == 0)
@@ -712,7 +610,7 @@
           else
             {
               string_vector sv = curl.list ();
-              octave_idx_type n = sv.length ();
+              octave_idx_type n = sv.numel ();
 
               if (n == 0)
                 {
@@ -775,17 +673,12 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 1)
+  if (args.length () != 1)
     error ("__ftp_ascii__: incorrect number of arguments");
   else
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         curl.ascii ();
       else
@@ -803,17 +696,12 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 1)
+  if (args.length () != 1)
     error ("__ftp_binary__: incorrect number of arguments");
   else
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         curl.binary ();
       else
@@ -831,17 +719,12 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 1)
+  if (args.length () != 1)
     error ("__ftp_close__: incorrect number of arguments");
   else
     {
       curl_handle h = ch_manager::lookup (args(0));
 
-      if (error_state)
-        return retval;
-
       if (h.ok ())
         ch_manager::free (h);
       else
@@ -859,17 +742,12 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 1)
+  if (args.length () != 1)
     error ("__ftp_mode__: incorrect number of arguments");
   else
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         retval = (curl.is_ascii () ? "ascii" : "binary");
       else
@@ -887,25 +765,17 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 2)
+  if (args.length () != 2)
     error ("__ftp_delete__: incorrect number of arguments");
   else
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         {
-          std::string file = args(1).string_value ();
+          std::string file = args(1).xstring_value ("__ftp_delete__: FILE must be a string");
 
-          if (! error_state)
-            curl.del (file);
-          else
-            error ("__ftp_delete__: expecting file name as second argument");
+          curl.del (file);
         }
       else
         error ("__ftp_delete__: invalid ftp handle");
@@ -922,25 +792,17 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 2)
+  if (args.length () != 2)
     error ("__ftp_rmdir__: incorrect number of arguments");
   else
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         {
-          std::string dir = args(1).string_value ();
+          std::string dir = args(1).xstring_value ("__ftp_rmdir__: DIR must be a string");
 
-          if (! error_state)
-            curl.rmdir (dir);
-          else
-            error ("__ftp_rmdir__: expecting directory name as second argument");
+          curl.rmdir (dir);
         }
       else
         error ("__ftp_rmdir__: invalid ftp handle");
@@ -957,25 +819,17 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 2)
+  if (args.length () != 2)
     error ("__ftp_mkdir__: incorrect number of arguments");
   else
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         {
-          std::string dir = args(1).string_value ();
+          std::string dir = args(1).xstring_value ("__ftp_mkdir__: DIR must be a string");
 
-          if (! error_state)
-            curl.mkdir (dir);
-          else
-            error ("__ftp_mkdir__: expecting directory name as second argument");
+          curl.mkdir (dir);
         }
       else
         error ("__ftp_mkdir__: invalid ftp handle");
@@ -992,26 +846,18 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 3)
+  if (args.length () != 3)
     error ("__ftp_rename__: incorrect number of arguments");
   else
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         {
-          std::string oldname = args(1).string_value ();
-          std::string newname = args(2).string_value ();
+          std::string oldname = args(1).xstring_value ("__ftp_rename__: OLDNAME must be a string");
+          std::string newname = args(2).xstring_value ("__ftp_rename__: NEWNAME must be a string");
 
-          if (! error_state)
-            curl.rename (oldname, newname);
-          else
-            error ("__ftp_rename__: expecting file names for second and third arguments");
+          curl.rename (oldname, newname);
         }
       else
         error ("__ftp_rename__: invalid ftp handle");
@@ -1028,81 +874,59 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin != 2)
+  if (args.length () != 2)
     error ("__ftp_mput__: incorrect number of arguments");
   else
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         {
-          std::string pat = args(1).string_value ();
+          std::string pat = args(1).xstring_value ("__ftp_mput__: PATTERN must be a string");
+
+          string_vector file_list;
 
-          if (! error_state)
+          glob_match pattern (file_ops::tilde_expand (pat));
+          string_vector files = pattern.glob ();
+
+          for (octave_idx_type i = 0; i < files.numel (); i++)
             {
-              string_vector file_list;
+              std::string file = files (i);
+
+              file_stat fs (file);
 
-              glob_match pattern (file_ops::tilde_expand (pat));
-              string_vector files = pattern.glob ();
+              if (! fs.exists ())
+                error ("__ftp__mput: file does not exist");
 
-              for (octave_idx_type i = 0; i < files.length (); i++)
+              if (fs.is_dir ())
                 {
-                  std::string file = files (i);
-
-                  file_stat fs (file);
-
-                  if (! fs.exists ())
-                    {
-                      error ("__ftp__mput: file does not exist");
-                      break;
-                    }
-
-                  if (fs.is_dir ())
-                    {
-                      file_list.append (curl.mput_directory ("", file));
+                  file_list.append (curl.mput_directory ("", file));
 
-                      if (! curl.good ())
-                        {
-                          error ("__ftp_mput__: %s", curl.lasterror().c_str());
-                          break;
-                        }
-                    }
-                  else
-                    {
-                      // FIXME: Does ascii mode need to be flagged here?
-                      std::ifstream ifile (file.c_str (), std::ios::in |
-                                           std::ios::binary);
+                  if (! curl.good ())
+                    error ("__ftp_mput__: %s", curl.lasterror().c_str());
+                }
+              else
+                {
+                  // FIXME: Does ascii mode need to be flagged here?
+                  std::ifstream ifile (file.c_str (), std::ios::in |
+                                       std::ios::binary);
 
-                      if (! ifile.is_open ())
-                        {
-                          error ("__ftp_mput__: unable to open file");
-                          break;
-                        }
+                  if (! ifile.is_open ())
+                    error ("__ftp_mput__: unable to open file");
 
-                      curl.put (file, ifile);
-
-                      ifile.close ();
+                  curl.put (file, ifile);
 
-                      if (! curl.good ())
-                        {
-                          error ("__ftp_mput__: %s", curl.lasterror().c_str());
-                          break;
-                        }
+                  ifile.close ();
+
+                  if (! curl.good ())
+                    error ("__ftp_mput__: %s", curl.lasterror().c_str());
 
-                      file_list.append (file);
-                    }
+                  file_list.append (file);
                 }
+            }
 
-              if (nargout > 0)
-                retval = file_list;
-            }
-          else
-            error ("__ftp_mput__: expecting file name patter as second argument");
+          if (nargout > 0)
+            retval = file_list;
         }
       else
         error ("__ftp_mput__: invalid ftp handle");
@@ -1113,7 +937,8 @@
 
 DEFUN (__ftp_mget__, args, ,
        "-*- texinfo -*-\n\
-@deftypefn {Loadable Function} {} __ftp_mget__ (@var{handle}, @var{files})\n\
+@deftypefn  {Loadable Function} {} __ftp_mget__ (@var{handle}, @var{pattern})\n\
+@deftypefnx {Loadable Function} {} __ftp_mget__ (@var{handle}, @var{pattern}, @var{target})\n\
 Undocumented internal function\n\
 @end deftypefn")
 {
@@ -1127,74 +952,61 @@
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         {
-          std::string file = args(1).string_value ();
+          std::string file = args(1).xstring_value ("__ftp_mget__: PATTERN must be a string");
           std::string target;
 
-          if (nargin == 3)
-            target = args(2).string_value () + file_ops::dir_sep_str ();
+          if (nargin == 3 && ! args(2).is_empty ())
+            target = args(2).xstring_value ("__ftp_mget__: TARGET must be a string") + file_ops::dir_sep_str ();
 
-          if (! error_state)
-            {
-              string_vector sv = curl.list ();
-              octave_idx_type n = 0;
-              glob_match pattern (file);
+          string_vector sv = curl.list ();
+          octave_idx_type n = 0;
+          glob_match pattern (file);
 
 
-              for (octave_idx_type i = 0; i < sv.length (); i++)
+          for (octave_idx_type i = 0; i < sv.numel (); i++)
+            {
+              if (pattern.match (sv(i)))
                 {
-                  if (pattern.match (sv(i)))
-                    {
-                      n++;
+                  n++;
 
-                      time_t ftime;
-                      bool fisdir;
-                      double fsize;
+                  time_t ftime;
+                  bool fisdir;
+                  double fsize;
 
-                      curl.get_fileinfo (sv(i), fsize, ftime, fisdir);
+                  curl.get_fileinfo (sv(i), fsize, ftime, fisdir);
 
-                      if (fisdir)
-                        curl.mget_directory (sv(i), target);
-                      else
-                        {
-                          std::ofstream ofile ((target + sv(i)).c_str (),
-                                               std::ios::out |
-                                               std::ios::binary);
+                  if (fisdir)
+                    curl.mget_directory (sv(i), target);
+                  else
+                    {
+                      std::ofstream ofile ((target + sv(i)).c_str (),
+                                           std::ios::out |
+                                           std::ios::binary);
 
-                          if (! ofile.is_open ())
-                            {
-                              error ("__ftp_mget__: unable to open file");
-                              break;
-                            }
+                      if (! ofile.is_open ())
+                        error ("__ftp_mget__: unable to open file");
+
+                      unwind_protect_safe frame;
 
-                          unwind_protect_safe frame;
-
-                          frame.add_fcn (delete_file, target + sv(i));
+                      frame.add_fcn (delete_file, target + sv(i));
 
-                          curl.get (sv(i), ofile);
+                      curl.get (sv(i), ofile);
 
-                          ofile.close ();
+                      ofile.close ();
 
-                          if (curl.good ())
-                            frame.discard ();
-                        }
+                      if (curl.good ())
+                        frame.discard ();
+                    }
 
-                      if (! curl.good ())
-                        {
-                          error ("__ftp_mget__: %s", curl.lasterror().c_str());
-                          break;
-                        }
-                    }
+                  if (! curl.good ())
+                    error ("__ftp_mget__: %s", curl.lasterror().c_str());
                 }
-              if (n == 0)
-                error ("__ftp_mget__: file not found");
             }
-          else
-            error ("__ftp_mget__: expecting file name and target as second and third arguments");
+
+          if (n == 0)
+            error ("__ftp_mget__: file not found");
         }
       else
         error ("__ftp_mget__: invalid ftp handle");
--- a/libinterp/corefcn/utils.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/utils.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -101,13 +101,13 @@
 {
   octave_value retval = false;
 
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin != 1)
-    print_usage ();
-  else if (args(0).is_string ())
+  if (args(0).is_string ())
     {
       std::string varname = args(0).string_value ();
+
       retval = valid_identifier (varname) && ! is_keyword (varname);
     }
 
@@ -267,7 +267,7 @@
 
   string_vector sv = p.find_all_first_of (names);
 
-  octave_idx_type len = sv.length ();
+  octave_idx_type len = sv.numel ();
 
   for (octave_idx_type i = 0; i < len; i++)
     sv[i] = octave_env::make_absolute (sv[i]);
@@ -278,7 +278,7 @@
 static string_vector
 make_absolute (const string_vector& sv)
 {
-  octave_idx_type len = sv.length ();
+  octave_idx_type len = sv.numel ();
 
   string_vector retval (len);
 
@@ -312,31 +312,29 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  string_vector names = args(0).xall_strings ("file_in_loadpath: FILE argument must be a string");
+
+  if (names.numel () > 0)
     {
-      string_vector names = args(0).all_strings ();
-
-      if (! error_state && names.length () > 0)
+      if (nargin == 1)
+        retval =
+          octave_env::make_absolute (load_path::find_first_of (names));
+      else if (nargin == 2)
         {
-          if (nargin == 1)
-            retval =
-              octave_env::make_absolute (load_path::find_first_of (names));
-          else if (nargin == 2)
-            {
-              std::string opt = args(1).string_value ();
+          std::string opt = args(1).xstring_value ("file_in_loadpath: optional second argument must be a string");
 
-              if (! error_state && opt == "all")
-                retval = Cell (make_absolute
-                               (load_path::find_all_first_of (names)));
-              else
-                error ("file_in_loadpath: invalid option");
-            }
+          if (opt == "all")
+            retval = Cell (make_absolute
+                           (load_path::find_all_first_of (names)));
+          else
+            error ("file_in_loadpath: \"all\" is only valid second argument");
         }
-      else
-        error ("file_in_loadpath: FILE argument must be a string");
     }
   else
-    print_usage ();
+    error ("file_in_loadpath: FILE argument must not be empty");
 
   return retval;
 }
@@ -391,37 +389,30 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
-    {
-      if (args(0).is_string ())
-        {
-          std::string path = args(0).string_value ();
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
 
-          string_vector names = args(1).all_strings ();
+  std::string path = args(0).xstring_value ("file_in_path: PATH must be a string");
+
+  string_vector names = args(1).xall_strings ("file_in_path: FILE argument must be a string");
 
-          if (! error_state && names.length () > 0)
-            {
-              if (nargin == 2)
-                retval = search_path_for_file (path, names);
-              else if (nargin == 3)
-                {
-                  std::string opt = args(2).string_value ();
+  if (names.numel () > 0)
+    {
+      if (nargin == 2)
+        retval = search_path_for_file (path, names);
+      else if (nargin == 3)
+        {
+          std::string opt = args(2).xstring_value ("file_in_path: optional third argument must be a string");
 
-                  if (! error_state && opt == "all")
-                    retval = Cell (make_absolute
-                                   (search_path_for_all_files (path, names)));
-                  else
-                    error ("file_in_path: invalid option");
-                }
-            }
+          if (opt == "all")
+            retval = Cell (make_absolute
+                           (search_path_for_all_files (path, names)));
           else
-            error ("file_in_path: all arguments must be strings");
+            error ("file_in_path: \"all\" is only valid third argument");
         }
-      else
-        error ("file_in_path: PATH must be a string");
     }
   else
-    print_usage ();
+    error ("file_in_path: FILE argument must not be empty");
 
   return retval;
 }
@@ -631,11 +622,7 @@
         {
           switch (s[++j])
             {
-            case '0':
-              retval[i] = '\0';
-              break;
-
-            case 'a':
+            case 'a': // alarm
               retval[i] = '\a';
               break;
 
@@ -675,6 +662,58 @@
               retval[i] = '"';
               break;
 
+            case '0':
+            case '1':
+            case '2':
+            case '3':
+            case '4':
+            case '5':
+            case '6':
+            case '7': // octal input
+            {
+              size_t k;
+              int tmpi = s[j] - '0';
+              for (k = j+1; k < std::min (j+3, len); k++)
+                {
+                  int digit = s[k] - '0';
+                  if (digit < 0 || digit > 7)
+                    break;
+                  tmpi <<= 3;
+                  tmpi += digit;
+                }
+              retval[i] = tmpi;
+              j = k - 1;
+              break;
+            }
+
+            case 'x': // hex input
+            {
+              size_t k;
+              int tmpi = 0;
+              for (k = j+1; k < std::min (j+3, len); k++)
+                {
+                  if (! isxdigit (s[k]))
+                    break;
+
+                  tmpi <<= 4;
+                  int digit = s[k];
+                  if (digit >= 'a')
+                    tmpi += digit - 'a' + 10;
+                  else if (digit >= 'A')
+                    tmpi += digit - 'A' + 10;
+                  else
+                    tmpi += digit - '0';
+                }
+
+              if (k == j+1)
+                warning ("malformed hex escape sequence '\\x' --\
+ converting to '\\0'");
+
+              retval[i] = tmpi;
+              j = k - 1;
+              break;
+            }
+
             default:
               warning ("unrecognized escape sequence '\\%c' --\
  converting to '%c'", s[j], s[j]);
@@ -707,21 +746,12 @@
 @seealso{undo_string_escapes}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      if (args(0).is_string ())
-        retval = do_string_escapes (args(0).string_value ());
-      else
-        error ("do_string_escapes: STRING argument must be of type string");
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  std::string str = args(0).xstring_value ("do_string_escapes: STRING argument must be of type string");
+
+  return octave_value (do_string_escapes (str));
 }
 
 /*
@@ -745,9 +775,20 @@
 %!assert (do_string_escapes ('\"double-quoted\"'), "\"double-quoted\"")
 %!assert (do_string_escapes ("\\\"double-quoted\\\""), "\"double-quoted\"")
 
+%!assert (do_string_escapes ('A\4B'), ["A" char(4) "B"])
+%!assert (do_string_escapes ('A\45B'), ["A" char(37) "B"])
+%!assert (do_string_escapes ('A\123B'), ["A" char(83) "B"])
+%!assert (sprintf ('\117\143\164\141\166\145'), "Octave")
+
+%!assert (do_string_escapes ('A\x4G'), ["A" char(4) "G"])
+%!assert (do_string_escapes ('A\x4AG'), ["A" char(74) "G"])
+%!assert (sprintf ('\x4f\x63\x74\x61\x76\x65'), "Octave")
+
 %!error do_string_escapes ()
 %!error do_string_escapes ("foo", "bar")
-%!error do_string_escapes (3)
+%!error <STRING argument> do_string_escapes (3)
+%!warning <malformed hex escape sequence> do_string_escapes ('\xG');
+%!warning <unrecognized escape sequence> do_string_escapes ('\G');
 */
 
 const char *
@@ -840,21 +881,12 @@
 @seealso{do_string_escapes}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      if (args(0).is_string ())
-        retval = undo_string_escapes (args(0).string_value ());
-      else
-        error ("undo_string_escapes: S argument must be a string");
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  std::string str = args(0).xstring_value ("undo_string_escapes: S argument must be a string");
+
+  return octave_value (undo_string_escapes (str));
 }
 
 /*
@@ -888,12 +920,12 @@
 {
   octave_value retval = false;
 
-  if (args.length () == 1)
-    retval = (args(0).is_string ()
-              && octave_env::absolute_pathname (args(0).string_value ()));
-  else
+  if (args.length () != 1)
     print_usage ();
 
+  retval = (args(0).is_string ()
+            && octave_env::absolute_pathname (args(0).string_value ()));
+
   return retval;
 }
 
@@ -913,12 +945,12 @@
 {
   octave_value retval = false;
 
-  if (args.length () == 1)
-    retval = (args(0).is_string ()
-              && octave_env::rooted_relative_pathname (args(0).string_value ()));
-  else
+  if (args.length () != 1)
     print_usage ();
 
+  retval = (args(0).is_string ()
+            && octave_env::rooted_relative_pathname (args(0).string_value ()));
+
   return retval;
 }
 
@@ -939,21 +971,12 @@
 @seealso{canonicalize_file_name, is_absolute_filename, is_rooted_relative_filename, isdir}\n\
 @end deftypefn")
 {
-  octave_value retval = std::string ();
-
-  if (args.length () == 1)
-    {
-      std::string nm = args(0).string_value ();
-
-      if (! error_state)
-        retval = octave_env::make_absolute (nm);
-      else
-        error ("make_absolute_filename: FILE argument must be a file name");
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  std::string nm = args(0).xstring_value ("make_absolute_filename: FILE argument must be a filename");
+
+  return octave_value (octave_env::make_absolute (nm));
 }
 
 /*
@@ -984,24 +1007,17 @@
 
   int nargin = args.length ();
 
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
   std::string dir;
 
-  if (nargin == 1 || nargin == 2)
-    {
-      dir = args(0).string_value ();
+  dir = args(0).xstring_value ("dir_in_loadpath: DIR must be a directory name");
 
-      if (! error_state)
-        {
-          if (nargin == 1)
-            retval = load_path::find_dir (dir);
-          else if (nargin == 2)
-            retval = Cell (load_path::find_matching_dirs (dir));
-        }
-      else
-        error ("dir_in_loadpath: DIR must be a directory name");
-    }
-  else
-    print_usage ();
+  if (nargin == 1)
+    retval = load_path::find_dir (dir);
+  else if (nargin == 2)
+    retval = Cell (load_path::find_matching_dirs (dir));
 
   return retval;
 }
@@ -1040,6 +1056,9 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 1)
     {
       if (args(0).is_string ())
@@ -1050,18 +1069,13 @@
         }
       else
         {
-          int val = args(0).int_value ();
+          int val = args(0).xint_value ("errno: argument must be string or integer");
 
-          if (! error_state)
-            retval = octave_errno::set (val);
-          else
-            error ("errno: argument must be string or integer");
+          retval = octave_errno::set (val);
         }
     }
-  else if (nargin == 0)
+  else
     retval = octave_errno::get ();
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1088,14 +1102,10 @@
 @seealso{errno}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 0)
-    retval = octave_errno::list ();
-  else
+  if (args.length () != 0)
     print_usage ();
 
-  return retval;
+  return octave_value (octave_errno::list ());
 }
 
 /*
@@ -1156,10 +1166,7 @@
         {
           Array<double> v = a.vector_value ();
 
-          if (error_state)
-            return;
-
-          octave_idx_type n = v.length ();
+          octave_idx_type n = v.numel ();
           dim.resize (n);
           for (octave_idx_type i = 0; i < n; i++)
             dim(i) = static_cast<int> (fix (v(i)));
@@ -1168,8 +1175,7 @@
         error ("%s (A): use %s (size (A)) instead", warn_for, warn_for);
     }
 
-  if (! error_state)
-    check_dimensions (dim, warn_for); // May set error_state.
+  check_dimensions (dim, warn_for);
 }
 
 
@@ -1190,8 +1196,6 @@
         {
           Array<double> v = a.vector_value ();
 
-          if (error_state)
-            return;
 
           nr = static_cast<octave_idx_type> (fix (v (0)));
           nc = static_cast<octave_idx_type> (fix (v (1)));
@@ -1200,29 +1204,27 @@
         error ("%s (A): use %s (size (A)) instead", warn_for, warn_for);
     }
 
-  if (! error_state)
-    check_dimensions (nr, nc, warn_for); // May set error_state.
+  check_dimensions (nr, nc, warn_for);
 }
 
 void
 get_dimensions (const octave_value& a, const octave_value& b,
                 const char *warn_for, octave_idx_type& nr, octave_idx_type& nc)
 {
-  nr = a.is_empty () ? 0 : a.int_value ();
-  nc = b.is_empty () ? 0 : b.int_value ();
+  nr = a.is_empty ()
+       ? 0 : a.int_value ("%s: row dimension must be a scalar", warn_for);
+  nc = b.is_empty ()
+       ? 0 : b.int_value ("%s: column dimension must be a scalar", warn_for);
 
-  if (error_state)
-    error ("%s: expecting two scalar arguments", warn_for);
-  else
-    check_dimensions (nr, nc, warn_for); // May set error_state.
+  check_dimensions (nr, nc, warn_for);
 }
 
 octave_idx_type
-dims_to_numel (const dim_vector& dims, const octave_value_list& idx)
+dims_to_numel (const dim_vector& dims, const octave_value_list& idx_arg)
 {
   octave_idx_type retval;
 
-  octave_idx_type len = idx.length ();
+  octave_idx_type len = idx_arg.length ();
 
   if (len == 0)
     retval = dims.numel ();
@@ -1232,17 +1234,27 @@
       retval = 1;
       for (octave_idx_type i = 0; i < len; i++)
         {
-          octave_value idxi = idx(i);
+          octave_value idxi = idx_arg(i);
           if (idxi.is_magic_colon ())
             retval *= dv(i);
           else if (idxi.is_numeric_type ())
             retval *= idxi.numel ();
           else
             {
-              idx_vector jdx = idxi.index_vector ();
-              if (error_state)
-                break;
-              retval *= jdx.length (dv(i));
+              try
+                {
+                  idx_vector jdx = idxi.index_vector ();
+
+                  retval *= jdx.length (dv(i));
+                }
+              catch (const index_exception& e)
+                {
+                  std::string idx = e.idx ();
+                  std::string msg = e.details ();
+
+                  error ("dims_to_numel: Invalid IDX %s. %s",
+                         idx.c_str (), msg.c_str ());
+                }
             }
         }
     }
@@ -1383,41 +1395,36 @@
 @end deftypefn")
 {
   octave_value retval;
+
+  octave_idx_type n = 0;
+
   int nargin = args.length ();
-  octave_idx_type n = 0;
+
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
 
   if (nargin == 2)
     n = args(1).idx_type_value ();
-  else if (nargin != 1)
-    print_usage ();
+
+  unwind_protect frame;
 
-  if (! error_state)
+  frame.protect_var (discard_error_messages);
+  discard_error_messages = true;
+
+  try
     {
-      unwind_protect frame;
-
-      frame.protect_var (error_state);
-
-      frame.protect_var (discard_error_messages);
-      discard_error_messages = true;
+      idx_vector idx = args(0).index_vector (true);
 
-      try
-        {
-          idx_vector idx = args(0).index_vector (true);
+      if (nargin == 2)
+        retval = idx.extent (n) <= n;
+      else
+        retval = true;
+    }
+  catch (const octave_execution_exception&)
+    {
+      recover_from_exception ();
 
-          if (! error_state)
-            {
-              if (nargin == 2)
-                retval = idx.extent (n) <= n;
-              else
-                retval = true;
-            }
-          else
-            retval = false;
-        }
-      catch (octave_execution_exception)
-        {
-          retval = false;
-        }
+      retval = false;
     }
 
   return retval;
@@ -1468,47 +1475,34 @@
               dims = ccells[i].dims ();
             }
           else if (dims != ccells[i].dims ())
-            {
-              error ("%s: cell arguments must have matching sizes", fun_name);
-              break;
-            }
+            error ("%s: cell arguments must have matching sizes", fun_name);
         }
     }
 
-  if (! error_state)
-    {
-      for (int i = 0; i < nargout; i++)
-        rcells[i].clear (dims);
+  for (int i = 0; i < nargout; i++)
+    rcells[i].clear (dims);
 
-      for (octave_idx_type j = 0; j < numel; j++)
-        {
-          for (int i = 0; i < nargin; i++)
-            if (iscell[i])
-              new_args(i) = ccells[i](j);
-
-          octave_quit ();
+  for (octave_idx_type j = 0; j < numel; j++)
+    {
+      for (int i = 0; i < nargin; i++)
+        if (iscell[i])
+          new_args(i) = ccells[i](j);
 
-          const octave_value_list tmp = fun (new_args, nargout);
+      octave_quit ();
+
+      const octave_value_list tmp = fun (new_args, nargout);
 
-          if (tmp.length () < nargout)
-            {
-              error ("%s: do_simple_cellfun: internal error", fun_name);
-              break;
-            }
-          else
-            {
-              for (int i = 0; i < nargout; i++)
-                rcells[i](j) = tmp(i);
-            }
-        }
+      if (tmp.length () < nargout)
+        error ("%s: do_simple_cellfun: internal error", fun_name);
+
+      for (int i = 0; i < nargout; i++)
+        rcells[i](j) = tmp(i);
     }
 
-  if (! error_state)
-    {
-      retval.resize (nargout);
-      for (int i = 0; i < nargout; i++)
-        retval(i) = rcells[i];
-    }
+  retval.resize (nargout);
+
+  for (int i = 0; i < nargout; i++)
+    retval(i) = rcells[i];
 
   return retval;
 }
--- a/libinterp/corefcn/utils.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/utils.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_utils_h)
+#if ! defined (octave_utils_h)
 #define octave_utils_h 1
 
 #include <cstdarg>
--- a/libinterp/corefcn/variables.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/variables.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -131,7 +131,7 @@
       ans = is_valid_function (fcn_name, warn_for, warn);
     }
   else if (warn)
-    error ("%s: expecting function name as argument", warn_for.c_str ());
+    error ("%s: argument must be a string containing function name", warn_for.c_str ());
 
   return ans;
 }
@@ -147,39 +147,31 @@
 
   if (! retval)
     {
-      if (arg.is_string ())
+      std::string s = arg.xstring_value ("%s: first argument must be a string",
+                                         warn_for.c_str ());
+
+      std::string cmd = header;
+      cmd.append (s);
+      cmd.append (trailer);
+
+      int parse_status;
+
+      eval_string (cmd, true, parse_status, 0);
+
+      if (parse_status == 0)
         {
-          std::string s = arg.string_value ();
-
-          std::string cmd = header;
-          cmd.append (s);
-          cmd.append (trailer);
-
-          int parse_status;
-
-          eval_string (cmd, true, parse_status, 0);
-
-          if (parse_status == 0)
-            {
-              retval = is_valid_function (fname, warn_for, 0);
-
-              if (! retval)
-                {
-                  error ("%s: '%s' is not valid as a function",
-                         warn_for.c_str (), fname.c_str ());
-                  return retval;
-                }
-
-              warning ("%s: passing function body as a string is obsolete; please use anonymous functions",
-                       warn_for.c_str ());
-            }
-          else
+          retval = is_valid_function (fname, warn_for, 0);
+
+          if (! retval)
             error ("%s: '%s' is not valid as a function",
                    warn_for.c_str (), fname.c_str ());
+
+          warning ("%s: passing function body as a string is obsolete; please use anonymous functions",
+                   warn_for.c_str ());
         }
       else
-        error ("%s: expecting first argument to be a string",
-               warn_for.c_str ());
+        error ("%s: '%s' is not valid as a function",
+               warn_for.c_str (), fname.c_str ());
     }
 
   return retval;
@@ -267,22 +259,26 @@
 
           unwind_protect frame;
 
-          frame.protect_var (error_state);
-          frame.protect_var (warning_state);
-
           frame.protect_var (discard_error_messages);
           frame.protect_var (discard_warning_messages);
 
           discard_error_messages = true;
           discard_warning_messages = true;
 
-          octave_value tmp = eval_string (prefix, true, parse_status);
-
-          frame.run ();
-
-          if (tmp.is_defined ()
-              && (tmp.is_map () || tmp.is_java () || tmp.is_classdef_object ()))
-            names = tmp.map_keys ();
+          try
+            {
+              octave_value tmp = eval_string (prefix, true, parse_status);
+
+              frame.run ();
+
+              if (tmp.is_defined ()
+                  && (tmp.is_map () || tmp.is_java () || tmp.is_classdef_object ()))
+                names = tmp.map_keys ();
+            }
+          catch (const octave_execution_exception&)
+            {
+              recover_from_exception ();
+            }
         }
     }
 
@@ -310,7 +306,6 @@
       unwind_protect frame;
 
       frame.protect_var (discard_error_messages);
-      frame.protect_var (error_state);
 
       discard_error_messages = true;
 
@@ -330,19 +325,11 @@
 {
   octave_value retval = false;
 
-  int nargin = args.length ();
-
-  if (nargin != 1)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 1)
+    print_usage ();
 
   if (! args(0).is_string ())
-    {
-      error ("isglobal: NAME must be a string");
-      return retval;
-    }
+    error ("isglobal: NAME must be a string");
 
   std::string name = args(0).string_value ();
 
@@ -377,9 +364,14 @@
   unwind_protect frame;
   interpreter_try (frame);
 
-  retval = symbol_table::find (symbol_name);
-
-  error_state = 0;
+  try
+    {
+      retval = symbol_table::find (symbol_name);
+    }
+  catch (const octave_execution_exception&)
+    {
+      recover_from_exception ();
+    }
 
   return retval;
 }
@@ -395,6 +387,11 @@
   bool search_dir = type == "dir";
   bool search_file = type == "file";
   bool search_builtin = type == "builtin";
+  bool search_class = type == "class";
+
+  if (! (search_any || search_var || search_dir || search_file ||
+         search_builtin || search_class))
+    error ("exist: unrecognized type argument \"%s\"", type.c_str ());
 
   if (search_any || search_var)
     {
@@ -526,7 +523,7 @@
 @var{name} is a variable.\n\
 \n\
 @item 2\n\
-@var{name} is an absolute file name, an ordinary file in Octave's\n\
+@var{name} is an absolute filename, an ordinary file in Octave's\n\
 @code{path}, or (after appending @samp{.m}) a function file in Octave's\n\
 @code{path}.\n\
 \n\
@@ -584,34 +581,22 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  std::string name = args(0).xstring_value ("exist: NAME must be a string");
+
+  if (nargin == 2)
     {
-      if (args(0).is_string ())
-        {
-          std::string name = args(0).string_value ();
-
-          if (nargin == 2)
-            {
-              if (args(1).is_string ())
-                {
-                  std::string type = args(1).string_value ();
-
-                  if (type == "class")
-                    warning ("exist: \"class\" type argument is not implemented");
-
-                  retval = symbol_exist (name, type);
-                }
-              else
-                error ("exist: TYPE must be a string");
-            }
-          else
-            retval = symbol_exist (name);
-        }
-      else
-        error ("exist: NAME must be a string");
+      std::string type = args(1).xstring_value ("exist: TYPE must be a string");
+
+      if (type == "class")
+        warning ("exist: \"class\" type argument is not implemented");
+
+      retval = symbol_exist (name, type);
     }
   else
-    print_usage ();
+    retval = symbol_exist (name);
 
   return retval;
 }
@@ -643,13 +628,13 @@
 %!assert (exist ("print_usage", "file"), 2)
 %!assert (exist ("print_usage", "dir"), 0)
 
-## Don't search path for rooted relative file names
+## Don't search path for rooted relative filenames
 %!assert (exist ("plot.m", "file"), 2);
 %!assert (exist ("./plot.m", "file"), 0);
 %!assert (exist ("./%nonexistentfile%", "file"), 0);
 %!assert (exist ("%nonexistentfile%", "file"), 0);
 
-## Don't search path for absolute file names
+## Don't search path for absolute filenames
 %!test
 %! tname = tempname (pwd ());
 %! unwind_protect
@@ -682,6 +667,7 @@
 %!warning <"class" type argument is not implemented> exist ("a", "class");
 %!error <TYPE must be a string> exist ("a", 1)
 %!error <NAME must be a string> exist (1)
+%!error <unrecognized type argument "foobar"> exist ("a", "foobar")
 
 */
 
@@ -743,7 +729,7 @@
         }
       else
         {
-          error_with_cfn ("expecting second argument to be \"local\"");
+          error_with_cfn ("second argument must be \"local\"");
           nargin = 0;
         }
     }
@@ -784,12 +770,9 @@
 
   if (nargin == 1)
     {
-      bool bval = args(0).bool_value ();
-
-      if (! error_state)
-        var = bval;
-      else
-        error ("%s: expecting arg to be a logical value", nm);
+      bool bval = args(0).xbool_value ("%s: argument must be a logical value", nm);
+
+      var = bval;
     }
   else if (nargin > 1)
     print_usage ();
@@ -816,27 +799,22 @@
 
   if (nargin == 1)
     {
-      std::string sval = args(0).string_value ();
-
-      if (! error_state)
+      std::string sval = args(0).xstring_value ("%s: argument must be a single character", nm);
+
+      switch (sval.length ())
         {
-          switch (sval.length ())
-            {
-            case 1:
-              var = sval[0];
-              break;
-
-            case 0:
-              var = '\0';
-              break;
-
-            default:
-              error ("%s: argument must be a single character", nm);
-              break;
-            }
+        case 1:
+          var = sval[0];
+          break;
+
+        case 0:
+          var = '\0';
+          break;
+
+        default:
+          error ("%s: argument must be a single character", nm);
+          break;
         }
-      else
-        error ("%s: argument must be a single character", nm);
     }
   else if (nargin > 1)
     print_usage ();
@@ -864,20 +842,15 @@
 
   if (nargin == 1)
     {
-      int ival = args(0).int_value ();
-
-      if (! error_state)
-        {
-          if (ival < minval)
-            error ("%s: expecting arg to be greater than %d", nm, minval);
-          else if (ival > maxval)
-            error ("%s: expecting arg to be less than or equal to %d",
-                   nm, maxval);
-          else
-            var = ival;
-        }
+      int ival = args(0).xint_value ("%s: argument must be an integer value", nm);
+
+      if (ival < minval)
+        error ("%s: arg must be greater than %d", nm, minval);
+      else if (ival > maxval)
+        error ("%s: arg must be less than or equal to %d",
+               nm, maxval);
       else
-        error ("%s: expecting arg to be an integer value", nm);
+        var = ival;
     }
   else if (nargin > 1)
     print_usage ();
@@ -905,19 +878,14 @@
 
   if (nargin == 1)
     {
-      double dval = args(0).scalar_value ();
-
-      if (! error_state)
-        {
-          if (dval < minval)
-            error ("%s: expecting arg to be greater than %g", minval);
-          else if (dval > maxval)
-            error ("%s: expecting arg to be less than or equal to %g", maxval);
-          else
-            var = dval;
-        }
+      double dval = args(0).xscalar_value ("%s: argument must be a scalar value", nm);
+
+      if (dval < minval)
+        error ("%s: argument must be greater than %g", minval);
+      else if (dval > maxval)
+        error ("%s: argument must be less than or equal to %g", maxval);
       else
-        error ("%s: expecting arg to be a scalar value", nm);
+        var = dval;
     }
   else if (nargin > 1)
     print_usage ();
@@ -944,17 +912,12 @@
 
   if (nargin == 1)
     {
-      if (args(0).is_string ())
-        {
-          std::string sval = args(0).string_value ();
-
-          if (empty_ok || ! sval.empty ())
-            var = sval;
-          else
-            error ("%s: value must not be empty", nm);
-        }
+      std::string sval = args(0).xstring_value ("%s: first argument must be a string", nm);
+
+      if (empty_ok || ! sval.empty ())
+        var = sval;
       else
-        error ("%s: first argument must be a string", nm);
+        error ("%s: value must not be empty", nm);
     }
   else if (nargin > 1)
     print_usage ();
@@ -972,6 +935,7 @@
     nchoices++;
 
   int nargin = args.length ();
+
   assert (var < nchoices);
 
   if (nargout > 0 || nargin == 0)
@@ -985,24 +949,19 @@
 
   if (nargin == 1)
     {
-      if (args(0).is_string ())
+      std::string sval = args(0).xstring_value ("%s: first argument must be a string", nm);
+
+      int i = 0;
+      for (; i < nchoices; i++)
         {
-          std::string sval = args(0).string_value ();
-
-          int i = 0;
-          for (; i < nchoices; i++)
+          if (sval == choices[i])
             {
-              if (sval == choices[i])
-                {
-                  var = i;
-                  break;
-                }
+              var = i;
+              break;
             }
-          if (i == nchoices)
-            error ("%s: value not allowed (\"%s\")", nm, sval.c_str ());
         }
-      else
-        error ("%s: first argument must be a string", nm);
+      if (i == nchoices)
+        error ("%s: value not allowed (\"%s\")", nm, sval.c_str ());
     }
   else if (nargin > 1)
     print_usage ();
@@ -1247,7 +1206,7 @@
                   break;
 
                 case 'e':
-                  os << varval.capacity ();
+                  os << varval.numel ();
                   break;
 
                 case 'n':
@@ -1395,7 +1354,7 @@
 
             octave_value val = p->varval;
 
-            elements += val.capacity ();
+            elements += val.numel ();
             bytes += val.byte_size ();
           }
 
@@ -1408,7 +1367,7 @@
 
   // Parse the string whos_line_format, and return a parameter list,
   // containing all information needed to print the given
-  // attributtes of the symbols.
+  // attributes of the symbols.
   std::list<whos_parameter> parse_whos_line_format (void)
   {
     int idx;
@@ -1467,7 +1426,7 @@
                                 > static_cast<size_t> (param_length(pos_t)))
                                ? str.length () : param_length(pos_t));
 
-        elements1 = val.capacity ();
+        elements1 = val.numel ();
         ss1 << elements1;
         str = ss1.str ();
         param_length(pos_e) = ((str.length ()
@@ -1522,10 +1481,7 @@
                               &a, &b, &balance) - 1;
 
             if (items < 2)
-              {
-                error ("whos_line_format: parameter structure without command in whos_line_format");
-                error_encountered = true;
-              }
+              error ("whos_line_format: parameter structure without command in whos_line_format");
 
             // Insert data into parameter
             param.first_parameter_length = 0;
@@ -1542,11 +1498,8 @@
                   param.first_parameter_length = b;
               }
             else
-              {
-                error ("whos_line_format: '%c' is not a command",
-                       param.command);
-                error_encountered = true;
-              }
+              error ("whos_line_format: '%c' is not a command",
+                     param.command);
 
             if (param.command == 's')
               {
@@ -1591,11 +1544,8 @@
                   }
               }
             else if (param.modifier == 'c')
-              {
-                error ("whos_line_format: modifier 'c' not available for command '%c'",
-                       param.command);
-                error_encountered = true;
-              }
+              error ("whos_line_format: modifier 'c' not available for command '%c'",
+                     param.command);
 
             // What happens if whos_line_format contains negative numbers
             // at param_length positions?
@@ -1662,7 +1612,7 @@
           // implement this option there so that the variables are never
           // stored at all.
           if (i == argc - 1)
-            error ("whos: -file argument must be followed by a file name");
+            error ("whos: -file argument must be followed by a filename");
           else
             {
               std::string nm = argv[i + 1];
@@ -1683,13 +1633,10 @@
 
               feval ("load", octave_value (nm), 0);
 
-              if (! error_state)
-                {
-                  std::string newmsg = std::string ("Variables in the file ") +
-                                       nm + ":\n\n";
-
-                  retval =  do_who (i, argv, return_list, verbose, newmsg);
-                }
+              std::string newmsg = std::string ("Variables in the file ")
+                + nm + ":\n\n";
+
+              retval =  do_who (i, argv, return_list, verbose, newmsg);
             }
 
           return retval;
@@ -1773,10 +1720,7 @@
                           octave_value expr_val
                             = eval_string (pat, true, parse_status);
 
-                          if (! error_state)
-                            symbol_stats.append (sr, pat, expr_val);
-                          else
-                            return retval;
+                          symbol_stats.append (sr, pat, expr_val);
                         }
                     }
                 }
@@ -1878,19 +1822,14 @@
 {
   octave_value retval;
 
-  if (nargout < 2)
-    {
-      int argc = args.length () + 1;
-
-      string_vector argv = args.make_argv ("who");
-
-      if (! error_state)
-        retval = do_who (argc, argv, nargout == 1);
-    }
-  else
+  if (nargout > 1)
     print_usage ();
 
-  return retval;
+  int argc = args.length () + 1;
+
+  string_vector argv = args.make_argv ("who");
+
+  return do_who (argc, argv, nargout == 1);
 }
 
 DEFUN (whos, args, nargout,
@@ -1959,19 +1898,14 @@
 {
   octave_value retval;
 
-  if (nargout < 2)
-    {
-      int argc = args.length () + 1;
-
-      string_vector argv = args.make_argv ("whos");
-
-      if (! error_state)
-        retval = do_who (argc, argv, nargout == 1, true);
-    }
-  else
+  if (nargout > 1)
     print_usage ();
 
-  return retval;
+  int argc = args.length () + 1;
+
+  string_vector argv = args.make_argv ("whos");
+
+  return do_who (argc, argv, nargout == 1, true);
 }
 
 // Defining variables.
@@ -2062,17 +1996,15 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 0)
-    {
-      octave_function *fcn = octave_call_stack::caller ();
-
-      if (fcn)
-        fcn->lock ();
-      else
-        error ("mlock: invalid use outside a function");
-    }
+  if (args.length () != 0)
+    print_usage ();
+
+  octave_function *fcn = octave_call_stack::caller ();
+
+  if (fcn)
+    fcn->lock ();
   else
-    print_usage ();
+    error ("mlock: invalid use outside a function");
 
   return retval;
 }
@@ -2089,17 +2021,18 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 1)
+  int nargin = args.length ();
+
+  if (nargin > 1)
+    print_usage ();
+
+  if (nargin == 1)
     {
-      if (args(0).is_string ())
-        {
-          std::string name = args(0).string_value ();
-          munlock (name);
-        }
-      else
-        error ("munlock: FCN must be a string");
+      std::string name = args(0).xstring_value ("munlock: FCN must be a string");
+
+      munlock (name);
     }
-  else if (args.length () == 0)
+  else
     {
       octave_function *fcn = octave_call_stack::caller ();
 
@@ -2108,8 +2041,6 @@
       else
         error ("munlock: invalid use outside a function");
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -2127,17 +2058,18 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
+  int nargin = args.length ();
+
+  if (nargin > 1)
+    print_usage ();
+
+  if (nargin == 1)
     {
-      if (args(0).is_string ())
-        {
-          std::string name = args(0).string_value ();
-          retval = mislocked (name);
-        }
-      else
-        error ("mislocked: FCN must be a string");
+      std::string name = args(0).xstring_value ("mislocked: FCN must be a string");
+
+      retval = mislocked (name);
     }
-  else if (args.length () == 0)
+  else
     {
       octave_function *fcn = octave_call_stack::caller ();
 
@@ -2146,8 +2078,6 @@
       else
         error ("mislocked: invalid use outside a function");
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -2208,7 +2138,7 @@
         {
           string_vector fcns = symbol_table::user_function_names ();
 
-          int fcount = fcns.length ();
+          int fcount = fcns.numel ();
 
           for (int i = 0; i < fcount; i++)
             {
@@ -2234,7 +2164,7 @@
     {
       string_vector gvars = symbol_table::global_variable_names ();
 
-      int gcount = gvars.length ();
+      int gcount = gvars.numel ();
 
       for (int i = 0; i < gcount; i++)
         symbol_table::clear_global (gvars[i]);
@@ -2245,7 +2175,7 @@
         {
           string_vector gvars = symbol_table::global_variable_names ();
 
-          int gcount = gvars.length ();
+          int gcount = gvars.numel ();
 
           for (int i = 0; i < gcount; i++)
             {
@@ -2275,7 +2205,7 @@
         {
           string_vector lvars = symbol_table::variable_names ();
 
-          int lcount = lvars.length ();
+          int lcount = lvars.numel ();
 
           for (int i = 0; i < lcount; i++)
             {
@@ -2368,10 +2298,7 @@
   do \
     { \
       if (cond) \
-        { \
-          print_usage (); \
-          return retval; \
-        } \
+        print_usage (); \
     } \
   while (0)
 
@@ -2455,129 +2382,126 @@
 
   string_vector argv = args.make_argv ("clear");
 
-  if (! error_state)
+  if (argc == 1)
+    {
+      do_clear_globals (argv, argc, true);
+      do_clear_variables (argv, argc, true);
+
+      octave_link::clear_workspace ();
+    }
+  else
     {
-      if (argc == 1)
-        {
-          do_clear_globals (argv, argc, true);
-          do_clear_variables (argv, argc, true);
-
-          octave_link::clear_workspace ();
-        }
-      else
+      int idx = 0;
+
+      bool clear_all = false;
+      bool clear_functions = false;
+      bool clear_globals = false;
+      bool clear_variables = false;
+      bool clear_objects = false;
+      bool exclusive = false;
+      bool have_regexp = false;
+      bool have_dash_option = false;
+
+      while (++idx < argc)
         {
-          int idx = 0;
-
-          bool clear_all = false;
-          bool clear_functions = false;
-          bool clear_globals = false;
-          bool clear_variables = false;
-          bool clear_objects = false;
-          bool exclusive = false;
-          bool have_regexp = false;
-          bool have_dash_option = false;
-
-          while (++idx < argc)
+          if (argv[idx] == "-all" || argv[idx] == "-a")
+            {
+              CLEAR_OPTION_ERROR (have_dash_option && ! exclusive);
+
+              have_dash_option = true;
+              clear_all = true;
+            }
+          else if (argv[idx] == "-exclusive" || argv[idx] == "-x")
+            {
+              have_dash_option = true;
+              exclusive = true;
+            }
+          else if (argv[idx] == "-functions" || argv[idx] == "-f")
+            {
+              CLEAR_OPTION_ERROR (have_dash_option && ! exclusive);
+
+              have_dash_option = true;
+              clear_functions = true;
+            }
+          else if (argv[idx] == "-global" || argv[idx] == "-g")
+            {
+              CLEAR_OPTION_ERROR (have_dash_option && ! exclusive);
+
+              have_dash_option = true;
+              clear_globals = true;
+            }
+          else if (argv[idx] == "-variables" || argv[idx] == "-v")
             {
-              if (argv[idx] == "-all" || argv[idx] == "-a")
-                {
-                  CLEAR_OPTION_ERROR (have_dash_option && ! exclusive);
-
-                  have_dash_option = true;
-                  clear_all = true;
-                }
-              else if (argv[idx] == "-exclusive" || argv[idx] == "-x")
-                {
-                  have_dash_option = true;
-                  exclusive = true;
-                }
-              else if (argv[idx] == "-functions" || argv[idx] == "-f")
+              CLEAR_OPTION_ERROR (have_dash_option && ! exclusive);
+
+              have_dash_option = true;
+              clear_variables = true;
+            }
+          else if (argv[idx] == "-classes" || argv[idx] == "-c")
+            {
+              CLEAR_OPTION_ERROR (have_dash_option && ! exclusive);
+
+              have_dash_option = true;
+              clear_objects = true;
+            }
+          else if (argv[idx] == "-regexp" || argv[idx] == "-r")
+            {
+              CLEAR_OPTION_ERROR (have_dash_option && ! exclusive);
+
+              have_dash_option = true;
+              have_regexp = true;
+            }
+          else
+            break;
+        }
+
+      if (idx <= argc)
+        {
+          if (! have_dash_option)
+            {
+              do_matlab_compatible_clear (argv, argc, idx);
+            }
+          else
+            {
+              if (clear_all)
                 {
-                  CLEAR_OPTION_ERROR (have_dash_option && ! exclusive);
-
-                  have_dash_option = true;
-                  clear_functions = true;
+                  maybe_warn_exclusive (exclusive);
+
+                  if (++idx < argc)
+                    warning
+                      ("clear: ignoring extra arguments after -all");
+
+                  symbol_table::clear_all ();
                 }
-              else if (argv[idx] == "-global" || argv[idx] == "-g")
+              else if (have_regexp)
                 {
-                  CLEAR_OPTION_ERROR (have_dash_option && ! exclusive);
-
-                  have_dash_option = true;
-                  clear_globals = true;
+                  do_clear_variables (argv, argc, idx, exclusive, true);
                 }
-              else if (argv[idx] == "-variables" || argv[idx] == "-v")
-                {
-                  CLEAR_OPTION_ERROR (have_dash_option && ! exclusive);
-
-                  have_dash_option = true;
-                  clear_variables = true;
-                }
-              else if (argv[idx] == "-classes" || argv[idx] == "-c")
+              else if (clear_functions)
                 {
-                  CLEAR_OPTION_ERROR (have_dash_option && ! exclusive);
-
-                  have_dash_option = true;
-                  clear_objects = true;
+                  do_clear_functions (argv, argc, idx, exclusive);
                 }
-              else if (argv[idx] == "-regexp" || argv[idx] == "-r")
+              else if (clear_globals)
+                {
+                  do_clear_globals (argv, argc, idx, exclusive);
+                }
+              else if (clear_variables)
                 {
-                  CLEAR_OPTION_ERROR (have_dash_option && ! exclusive);
-
-                  have_dash_option = true;
-                  have_regexp = true;
+                  do_clear_variables (argv, argc, idx, exclusive);
                 }
-              else
-                break;
-            }
-
-          if (idx <= argc)
-            {
-              if (! have_dash_option)
+              else if (clear_objects)
                 {
-                  do_matlab_compatible_clear (argv, argc, idx);
+                  symbol_table::clear_objects ();
+                  octave_class::clear_exemplar_map ();
+                  symbol_table::clear_all ();
                 }
               else
                 {
-                  if (clear_all)
-                    {
-                      maybe_warn_exclusive (exclusive);
-
-                      if (++idx < argc)
-                        warning
-                          ("clear: ignoring extra arguments after -all");
-
-                      symbol_table::clear_all ();
-                    }
-                  else if (have_regexp)
-                    {
-                      do_clear_variables (argv, argc, idx, exclusive, true);
-                    }
-                  else if (clear_functions)
-                    {
-                      do_clear_functions (argv, argc, idx, exclusive);
-                    }
-                  else if (clear_globals)
-                    {
-                      do_clear_globals (argv, argc, idx, exclusive);
-                    }
-                  else if (clear_variables)
-                    {
-                      do_clear_variables (argv, argc, idx, exclusive);
-                    }
-                  else if (clear_objects)
-                    {
-                      symbol_table::clear_objects ();
-                      octave_class::clear_exemplar_map ();
-                      symbol_table::clear_all ();
-                    }
-                  else
-                    {
-                      do_clear_symbols (argv, argc, idx, exclusive);
-                    }
+                  do_clear_symbols (argv, argc, idx, exclusive);
                 }
-
-              octave_link::set_workspace ();
             }
+
+          octave_link::set_workspace ();
         }
     }
 
@@ -2706,24 +2630,15 @@
 DEFUN (__varval__, args, ,
        "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} __varval__ (@var{name})\n\
-Undocumented internal function.\n\
+Return the value of the variable @var{name} directly from the symbol table.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    {
-      std::string name = args(0).string_value ();
-
-      if (! error_state)
-        retval = symbol_table::varval (args(0).string_value ());
-      else
-        error ("__varval__: expecting argument to be variable name");
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  std::string name = args(0).xstring_value ("__varval__: first argument must be a variable name");
+
+  return symbol_table::varval (args(0).string_value ());
 }
 
 static std::string Vmissing_component_hook;
--- a/libinterp/corefcn/variables.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/variables.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_variables_h)
+#if ! defined (octave_variables_h)
 #define octave_variables_h 1
 
 class octave_function;
--- a/libinterp/corefcn/workspace-element.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/workspace-element.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_workspace_element_h)
+#if ! defined (octave_workspace_element_h)
 #define octave_workspace_element_h 1
 
 #include <string>
--- a/libinterp/corefcn/xdiv.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/xdiv.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -289,7 +289,7 @@
 {
   NDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       result (i) = a / b (i);
@@ -303,7 +303,7 @@
 {
   ComplexNDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       result (i) = a / b (i);
@@ -317,7 +317,7 @@
 {
   ComplexNDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       result (i) = a / b (i);
@@ -331,7 +331,7 @@
 {
   ComplexNDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       result (i) = a / b (i);
@@ -590,7 +590,7 @@
 {
   FloatNDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       result (i) = a / b (i);
@@ -604,7 +604,7 @@
 {
   FloatComplexNDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       result (i) = a / b (i);
@@ -618,7 +618,7 @@
 {
   FloatComplexNDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       result (i) = a / b (i);
@@ -632,7 +632,7 @@
 {
   FloatComplexNDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       result (i) = a / b (i);
--- a/libinterp/corefcn/xdiv.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/xdiv.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_xdiv_h)
+#if ! defined (octave_xdiv_h)
 #define octave_xdiv_h 1
 
 #include "mx-defs.h"
--- a/libinterp/corefcn/xnorm.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/xnorm.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 // author: Jaroslav Hajek <highegg@gmail.com>
 
-#if !defined (octave_xnorm_h)
+#if ! defined (octave_xnorm_h)
 #define octave_xnorm_h 1
 
 #include "oct-norm.h"
--- a/libinterp/corefcn/xpow.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/xpow.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -54,6 +54,12 @@
 
 #include "bsxfun.h"
 
+static void
+gripe_failed_diagonalization (void)
+{
+  gripe_failed_diagonalization ();
+}
+
 static inline int
 xisint (double x)
 {
@@ -106,10 +112,10 @@
     error ("for x^A, A must be a square matrix. Use .^ for elementwise power.");
   else
     {
-      EIG b_eig (b);
-
-      if (! error_state)
+      try
         {
+          EIG b_eig (b);
+
           ComplexColumnVector lambda (b_eig.eigenvalues ());
           ComplexMatrix Q (b_eig.eigenvectors ());
 
@@ -129,8 +135,10 @@
           else
             retval = C;
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -159,7 +167,7 @@
     {
       EIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           ComplexColumnVector lambda (b_eig.eigenvalues ());
           ComplexMatrix Q (b_eig.eigenvectors ());
@@ -176,8 +184,10 @@
 
           retval = ComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -248,7 +258,7 @@
         {
           EIG a_eig (a);
 
-          if (! error_state)
+          try
             {
               ComplexColumnVector lambda (a_eig.eigenvalues ());
               ComplexMatrix Q (a_eig.eigenvectors ());
@@ -260,8 +270,10 @@
 
               retval = ComplexMatrix (Q * D * Q.inverse ());
             }
-          else
-            error ("xpow: matrix diagonalization failed");
+          catch (const octave_execution_exception&)
+            {
+              gripe_failed_diagonalization ();
+            }
         }
     }
 
@@ -327,7 +339,7 @@
     {
       EIG a_eig (a);
 
-      if (! error_state)
+      try
         {
           ComplexColumnVector lambda (a_eig.eigenvalues ());
           ComplexMatrix Q (a_eig.eigenvectors ());
@@ -339,8 +351,10 @@
 
           retval = ComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -375,7 +389,7 @@
     {
       EIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           ComplexColumnVector lambda (b_eig.eigenvalues ());
           ComplexMatrix Q (b_eig.eigenvectors ());
@@ -392,8 +406,10 @@
 
           retval = ComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -423,7 +439,7 @@
     {
       EIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           ComplexColumnVector lambda (b_eig.eigenvalues ());
           ComplexMatrix Q (b_eig.eigenvectors ());
@@ -440,8 +456,10 @@
 
           retval = ComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -512,7 +530,7 @@
         {
           EIG a_eig (a);
 
-          if (! error_state)
+          try
             {
               ComplexColumnVector lambda (a_eig.eigenvalues ());
               ComplexMatrix Q (a_eig.eigenvectors ());
@@ -524,8 +542,10 @@
 
               retval = ComplexMatrix (Q * D * Q.inverse ());
             }
-          else
-            error ("xpow: matrix diagonalization failed");
+          catch (const octave_execution_exception&)
+            {
+              gripe_failed_diagonalization ();
+            }
         }
     }
 
@@ -547,7 +567,7 @@
     {
       EIG a_eig (a);
 
-      if (! error_state)
+      try
         {
           ComplexColumnVector lambda (a_eig.eigenvalues ());
           ComplexMatrix Q (a_eig.eigenvectors ());
@@ -559,8 +579,10 @@
 
           retval = ComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -705,10 +727,10 @@
 
   // Only optimize powers with ranges that are integer and monotonic in
   // magnitude.
-  if (r.nelem () > 1 && r.all_elements_are_ints ()
+  if (r.numel () > 1 && r.all_elements_are_ints ()
       && same_sign (r.base (), r.limit ()))
     {
-      octave_idx_type n = r.nelem ();
+      octave_idx_type n = r.numel ();
       Matrix result (1, n);
       if (same_sign (r.base (), r.inc ()))
         {
@@ -940,10 +962,10 @@
 
   // Only optimize powers with ranges that are integer and monotonic in
   // magnitude.
-  if (r.nelem () > 1 && r.all_elements_are_ints ()
+  if (r.numel () > 1 && r.all_elements_are_ints ()
       && same_sign (r.base (), r.limit ()))
     {
-      octave_idx_type n = r.nelem ();
+      octave_idx_type n = r.numel ();
       ComplexMatrix result (1, n);
 
       if (same_sign (r.base (), r.inc ()))
@@ -1121,7 +1143,7 @@
     {
       Complex atmp (a);
       ComplexNDArray result (b.dims ());
-      for (octave_idx_type i = 0; i < b.length (); i++)
+      for (octave_idx_type i = 0; i < b.numel (); i++)
         {
           octave_quit ();
           result(i) = std::pow (atmp, b(i));
@@ -1132,7 +1154,7 @@
   else
     {
       NDArray result (b.dims ());
-      for (octave_idx_type i = 0; i < b.length (); i++)
+      for (octave_idx_type i = 0; i < b.numel (); i++)
         {
           octave_quit ();
           result (i) = std::pow (a, b(i));
@@ -1150,7 +1172,7 @@
 {
   ComplexNDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       result(i) = std::pow (a, b(i));
@@ -1171,7 +1193,7 @@
         {
           ComplexNDArray result (a.dims ());
 
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             {
               octave_quit ();
 
@@ -1185,7 +1207,7 @@
       else
         {
           NDArray result (a.dims ());
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             {
               octave_quit ();
               result(i) = std::pow (a(i), b);
@@ -1201,22 +1223,22 @@
       int ib = static_cast<int> (b);
       if (ib == 2)
         {
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             result(i) = a(i) * a(i);
         }
       else if (ib == 3)
         {
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             result(i) = a(i) * a(i) * a(i);
         }
       else if (ib == -1)
         {
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             result(i) = 1.0 / a(i);
         }
       else
         {
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             {
               octave_quit ();
               result(i) = std::pow (a(i), ib);
@@ -1257,7 +1279,7 @@
         }
     }
 
-  int len = a.length ();
+  int len = a.numel ();
 
   bool convert_to_complex = false;
 
@@ -1310,7 +1332,7 @@
 {
   ComplexNDArray result (a.dims ());
 
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     {
       octave_quit ();
       result(i) = std::pow (a(i), b);
@@ -1341,7 +1363,7 @@
 
   ComplexNDArray result (a_dims);
 
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     {
       octave_quit ();
       result(i) = std::pow (a(i), b(i));
@@ -1356,7 +1378,7 @@
 {
   ComplexNDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       double btmp = b(i);
@@ -1375,7 +1397,7 @@
 {
   ComplexNDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       result(i) = std::pow (a, b(i));
@@ -1394,12 +1416,12 @@
     {
       if (b == -1)
         {
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             result.xelem (i) = 1.0 / a(i);
         }
       else
         {
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             {
               octave_quit ();
               result(i) = std::pow (a(i), static_cast<int> (b));
@@ -1408,7 +1430,7 @@
     }
   else
     {
-      for (octave_idx_type i = 0; i < a.length (); i++)
+      for (octave_idx_type i = 0; i < a.numel (); i++)
         {
           octave_quit ();
           result(i) = std::pow (a(i), b);
@@ -1440,7 +1462,7 @@
 
   ComplexNDArray result (a_dims);
 
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     {
       octave_quit ();
       double btmp = b(i);
@@ -1459,7 +1481,7 @@
 {
   ComplexNDArray result (a.dims ());
 
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     {
       octave_quit ();
       result(i) = std::pow (a(i), b);
@@ -1490,7 +1512,7 @@
 
   ComplexNDArray result (a_dims);
 
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     {
       octave_quit ();
       result(i) = std::pow (a(i), b(i));
@@ -1553,7 +1575,7 @@
     {
       FloatEIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           FloatComplexColumnVector lambda (b_eig.eigenvalues ());
           FloatComplexMatrix Q (b_eig.eigenvectors ());
@@ -1575,8 +1597,10 @@
           else
             retval = C;
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -1605,7 +1629,7 @@
     {
       FloatEIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           FloatComplexColumnVector lambda (b_eig.eigenvalues ());
           FloatComplexMatrix Q (b_eig.eigenvectors ());
@@ -1622,8 +1646,10 @@
 
           retval = FloatComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -1694,7 +1720,7 @@
         {
           FloatEIG a_eig (a);
 
-          if (! error_state)
+          try
             {
               FloatComplexColumnVector lambda (a_eig.eigenvalues ());
               FloatComplexMatrix Q (a_eig.eigenvectors ());
@@ -1706,8 +1732,10 @@
 
               retval = FloatComplexMatrix (Q * D * Q.inverse ());
             }
-          else
-            error ("xpow: matrix diagonalization failed");
+          catch (const octave_execution_exception&)
+            {
+              gripe_failed_diagonalization ();
+            }
         }
     }
 
@@ -1762,7 +1790,7 @@
     {
       FloatEIG a_eig (a);
 
-      if (! error_state)
+      try
         {
           FloatComplexColumnVector lambda (a_eig.eigenvalues ());
           FloatComplexMatrix Q (a_eig.eigenvectors ());
@@ -1774,8 +1802,10 @@
 
           retval = FloatComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -1810,7 +1840,7 @@
     {
       FloatEIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           FloatComplexColumnVector lambda (b_eig.eigenvalues ());
           FloatComplexMatrix Q (b_eig.eigenvectors ());
@@ -1827,8 +1857,10 @@
 
           retval = FloatComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -1858,7 +1890,7 @@
     {
       FloatEIG b_eig (b);
 
-      if (! error_state)
+      try
         {
           FloatComplexColumnVector lambda (b_eig.eigenvalues ());
           FloatComplexMatrix Q (b_eig.eigenvectors ());
@@ -1875,8 +1907,10 @@
 
           retval = FloatComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -1947,7 +1981,7 @@
         {
           FloatEIG a_eig (a);
 
-          if (! error_state)
+          try
             {
               FloatComplexColumnVector lambda (a_eig.eigenvalues ());
               FloatComplexMatrix Q (a_eig.eigenvectors ());
@@ -1959,8 +1993,10 @@
 
               retval = FloatComplexMatrix (Q * D * Q.inverse ());
             }
-          else
-            error ("xpow: matrix diagonalization failed");
+          catch (const octave_execution_exception&)
+            {
+              gripe_failed_diagonalization ();
+            }
         }
     }
 
@@ -1982,7 +2018,7 @@
     {
       FloatEIG a_eig (a);
 
-      if (! error_state)
+      try
         {
           FloatComplexColumnVector lambda (a_eig.eigenvalues ());
           FloatComplexMatrix Q (a_eig.eigenvectors ());
@@ -1994,8 +2030,10 @@
 
           retval = FloatComplexMatrix (Q * D * Q.inverse ());
         }
-      else
-        error ("xpow: matrix diagonalization failed");
+      catch (const octave_execution_exception&)
+        {
+          gripe_failed_diagonalization ();
+        }
     }
 
   return retval;
@@ -2471,7 +2509,7 @@
     {
       FloatComplex atmp (a);
       FloatComplexNDArray result (b.dims ());
-      for (octave_idx_type i = 0; i < b.length (); i++)
+      for (octave_idx_type i = 0; i < b.numel (); i++)
         {
           octave_quit ();
           result(i) = std::pow (atmp, b(i));
@@ -2482,7 +2520,7 @@
   else
     {
       FloatNDArray result (b.dims ());
-      for (octave_idx_type i = 0; i < b.length (); i++)
+      for (octave_idx_type i = 0; i < b.numel (); i++)
         {
           octave_quit ();
           result (i) = std::pow (a, b(i));
@@ -2500,7 +2538,7 @@
 {
   FloatComplexNDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       result(i) = std::pow (a, b(i));
@@ -2521,7 +2559,7 @@
         {
           FloatComplexNDArray result (a.dims ());
 
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             {
               octave_quit ();
 
@@ -2535,7 +2573,7 @@
       else
         {
           FloatNDArray result (a.dims ());
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             {
               octave_quit ();
               result(i) = std::pow (a(i), b);
@@ -2551,22 +2589,22 @@
       int ib = static_cast<int> (b);
       if (ib == 2)
         {
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             result(i) = a(i) * a(i);
         }
       else if (ib == 3)
         {
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             result(i) = a(i) * a(i) * a(i);
         }
       else if (ib == -1)
         {
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             result(i) = 1.0f / a(i);
         }
       else
         {
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             {
               octave_quit ();
               result(i) = std::pow (a(i), ib);
@@ -2607,7 +2645,7 @@
         }
     }
 
-  int len = a.length ();
+  int len = a.numel ();
 
   bool convert_to_complex = false;
 
@@ -2660,7 +2698,7 @@
 {
   FloatComplexNDArray result (a.dims ());
 
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     {
       octave_quit ();
       result(i) = std::pow (a(i), b);
@@ -2691,7 +2729,7 @@
 
   FloatComplexNDArray result (a_dims);
 
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     {
       octave_quit ();
       result(i) = std::pow (a(i), b(i));
@@ -2706,7 +2744,7 @@
 {
   FloatComplexNDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       float btmp = b(i);
@@ -2725,7 +2763,7 @@
 {
   FloatComplexNDArray result (b.dims ());
 
-  for (octave_idx_type i = 0; i < b.length (); i++)
+  for (octave_idx_type i = 0; i < b.numel (); i++)
     {
       octave_quit ();
       result(i) = std::pow (a, b(i));
@@ -2744,12 +2782,12 @@
     {
       if (b == -1)
         {
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             result.xelem (i) = 1.0f / a(i);
         }
       else
         {
-          for (octave_idx_type i = 0; i < a.length (); i++)
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             {
               octave_quit ();
               result(i) = std::pow (a(i), static_cast<int> (b));
@@ -2758,7 +2796,7 @@
     }
   else
     {
-      for (octave_idx_type i = 0; i < a.length (); i++)
+      for (octave_idx_type i = 0; i < a.numel (); i++)
         {
           octave_quit ();
           result(i) = std::pow (a(i), b);
@@ -2790,7 +2828,7 @@
 
   FloatComplexNDArray result (a_dims);
 
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     {
       octave_quit ();
       float btmp = b(i);
@@ -2809,7 +2847,7 @@
 {
   FloatComplexNDArray result (a.dims ());
 
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     {
       octave_quit ();
       result(i) = std::pow (a(i), b);
@@ -2840,7 +2878,7 @@
 
   FloatComplexNDArray result (a_dims);
 
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     {
       octave_quit ();
       result(i) = std::pow (a(i), b(i));
--- a/libinterp/corefcn/xpow.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/xpow.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_xpow_h)
+#if ! defined (octave_xpow_h)
 #define octave_xpow_h 1
 
 #include "oct-cmplx.h"
--- a/libinterp/corefcn/zfstream.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/corefcn/zfstream.h	Thu Dec 10 12:50:06 2015 -0800
@@ -83,7 +83,7 @@
 
   /**
    *  @brief  Open gzipped file.
-   *  @param  name  File name.
+   *  @param  name  Filename.
    *  @param  mode  Open mode flags.
    *  @return  @c this on success, NULL on failure.
   */
@@ -286,7 +286,7 @@
 
   /**
    *  @brief  Construct stream on gzipped file to be opened.
-   *  @param  name  File name.
+   *  @param  name  Filename.
    *  @param  mode  Open mode flags (forced to contain ios::in).
   */
   explicit
@@ -318,7 +318,7 @@
 
   /**
    *  @brief  Open gzipped file.
-   *  @param  name  File name.
+   *  @param  name  Filename.
    *  @param  mode  Open mode flags (forced to contain ios::in).
    *
    *  Stream will be in state good() if file opens successfully;
@@ -375,7 +375,7 @@
 
   /**
    *  @brief  Construct stream on gzipped file to be opened.
-   *  @param  name  File name.
+   *  @param  name  Filename.
    *  @param  mode  Open mode flags (forced to contain ios::out).
   */
   explicit
@@ -407,7 +407,7 @@
 
   /**
    *  @brief  Open gzipped file.
-   *  @param  name  File name.
+   *  @param  name  Filename.
    *  @param  mode  Open mode flags (forced to contain ios::out).
    *
    *  Stream will be in state good() if file opens successfully;
--- a/libinterp/dldfcn/__delaunayn__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/__delaunayn__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -99,10 +99,7 @@
 
   int nargin = args.length ();
   if (nargin < 1 || nargin > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   Matrix p (args(0).matrix_value ());
   const octave_idx_type dim = p.columns ();
@@ -133,10 +130,7 @@
             options += tmp(i) + " ";
         }
       else
-        {
-          error ("__delaunayn__: OPTIONS argument must be a string, cell array of strings, or empty");
-          return retval;
-        }
+        error ("__delaunayn__: OPTIONS argument must be a string, cell array of strings, or empty");
     }
 
   if (n > dim + 1)
@@ -163,10 +157,7 @@
       if (outfile)
         frame.add_fcn (close_fcn, outfile);
       else
-        {
-          error ("__delaunayn__: unable to create temporary file for output");
-          return retval;
-        }
+        error ("__delaunayn__: unable to create temporary file for output");
 
       int exitcode = qh_new_qhull (dim, n, pt_array,
                                    ismalloc, flags, outfile, errfile);
@@ -187,11 +178,7 @@
 
               // Double check.  Non-simplicial facets will cause segfault below
               if (! facet->simplicial)
-                {
-                  error ("__delaunayn__: Qhull returned non-simplicial facets -- try delaunayn with different options");
-                  exitcode = 1;
-                  break;
-                }
+                error ("__delaunayn__: Qhull returned non-simplicial facets -- try delaunayn with different options");
             }
 
           if (! exitcode)
@@ -240,7 +227,9 @@
     }
 
 #else
+
   error ("__delaunayn__: not available in this version of Octave");
+
 #endif
 
   return retval;
--- a/libinterp/dldfcn/__eigs__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/__eigs__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -56,13 +56,15 @@
 
   if (eigs_fcn)
     {
-      octave_value_list tmp = eigs_fcn->do_multi_index_op (1, args);
+      octave_value_list tmp;
 
-      if (error_state)
+      try
         {
-          eigs_error = 1;
-          gripe_user_supplied_eval ("eigs");
-          return retval;
+          tmp = eigs_fcn->do_multi_index_op (1, args);
+        }
+      catch (octave_execution_exception& e)
+        {
+          gripe_user_supplied_eval (e, "eigs");
         }
 
       if (tmp.length () && tmp(0).is_defined ())
@@ -73,13 +75,7 @@
               warned_imaginary = true;
             }
 
-          retval = ColumnVector (tmp(0).vector_value ());
-
-          if (error_state)
-            {
-              eigs_error = 1;
-              gripe_user_supplied_eval ("eigs");
-            }
+          retval = tmp(0).xvector_value ("eigs: evaluation of user-supplied function failed");
         }
       else
         {
@@ -100,24 +96,20 @@
 
   if (eigs_fcn)
     {
-      octave_value_list tmp = eigs_fcn->do_multi_index_op (1, args);
+      octave_value_list tmp;
 
-      if (error_state)
+      try
         {
-          eigs_error = 1;
-          gripe_user_supplied_eval ("eigs");
-          return retval;
+          tmp = eigs_fcn->do_multi_index_op (1, args);
+        }
+      catch (octave_execution_exception& e)
+        {
+          gripe_user_supplied_eval (e, "eigs");
         }
 
       if (tmp.length () && tmp(0).is_defined ())
         {
-          retval = ComplexColumnVector (tmp(0).complex_vector_value ());
-
-          if (error_state)
-            {
-              eigs_error = 1;
-              gripe_user_supplied_eval ("eigs");
-            }
+          retval = tmp(0).complex_vector_value ("eigs: evaluation of user-supplied function failed");
         }
       else
         {
@@ -204,8 +196,9 @@
 
   if (nargin == 0)
     print_usage ();
-  else if (args(0).is_function_handle () || args(0).is_inline_function ()
-           || args(0).is_string ())
+
+  if (args(0).is_function_handle () || args(0).is_inline_function ()
+      || args(0).is_string ())
     {
       if (args(0).is_string ())
         {
@@ -221,16 +214,10 @@
         eigs_fcn = args(0).function_value ();
 
       if (!eigs_fcn)
-        {
-          error ("eigs: unknown function");
-          return retval;
-        }
+        error ("eigs: unknown function");
 
       if (nargin < 2)
-        {
-          error ("eigs: incorrect number of arguments");
-          return retval;
-        }
+        error ("eigs: incorrect number of arguments");
       else
         {
           n = args(1).nint_value ();
@@ -270,7 +257,7 @@
 
   // Note hold off reading B till later to avoid issues of double
   // copies of the matrix if B is full/real while A is complex.
-  if (! error_state && nargin > 1 + arg_offset
+  if (nargin > 1 + arg_offset
       && ! (args(1 + arg_offset).is_real_scalar ()))
     {
       if (args(1+arg_offset).is_complex_type ())
@@ -288,10 +275,10 @@
         }
     }
 
-  if (!error_state && nargin > (1+arg_offset))
+  if (nargin > (1+arg_offset))
     k = args(1+arg_offset).nint_value ();
 
-  if (!error_state && nargin > (2+arg_offset))
+  if (nargin > (2+arg_offset))
     {
       if (args(2+arg_offset).is_string ())
         {
@@ -304,95 +291,75 @@
         }
       else
         {
-          sigma = args(2+arg_offset).complex_value ();
+          sigma = args(2+arg_offset).xcomplex_value ("eigs: SIGMA must be a scalar or a string");
 
-          if (! error_state)
-            have_sigma = true;
-          else
-            {
-              error ("eigs: SIGMA must be a scalar or a string");
-              return retval;
-            }
+          have_sigma = true;
         }
     }
 
   sigmar = std::real (sigma);
   sigmai = std::imag (sigma);
 
-  if (!error_state && nargin > (3+arg_offset))
+  if (nargin > (3+arg_offset))
     {
       if (args(3+arg_offset).is_map ())
         {
-          octave_scalar_map map = args(3+arg_offset).scalar_map_value ();
+          octave_scalar_map map = args(3+arg_offset).xscalar_map_value ("eigs: OPTS argument must be a scalar structure");
+
+          octave_value tmp;
 
-          if (! error_state)
+          // issym is ignored for complex matrix inputs
+          tmp = map.getfield ("issym");
+          if (tmp.is_defined () && !sym_tested)
             {
-              octave_value tmp;
+              symmetric = tmp.double_value () != 0.;
+              sym_tested = true;
+            }
 
-              // issym is ignored for complex matrix inputs
-              tmp = map.getfield ("issym");
-              if (tmp.is_defined () && !sym_tested)
-                {
-                  symmetric = tmp.double_value () != 0.;
-                  sym_tested = true;
-                }
+          // isreal is ignored if A is not a function
+          tmp = map.getfield ("isreal");
+          if (tmp.is_defined () && have_a_fun)
+            a_is_complex = ! (tmp.double_value () != 0.);
 
-              // isreal is ignored if A is not a function
-              tmp = map.getfield ("isreal");
-              if (tmp.is_defined () && have_a_fun)
-                a_is_complex = ! (tmp.double_value () != 0.);
+          tmp = map.getfield ("tol");
+          if (tmp.is_defined ())
+            tol = tmp.double_value ();
 
-              tmp = map.getfield ("tol");
-              if (tmp.is_defined ())
-                tol = tmp.double_value ();
-
-              tmp = map.getfield ("maxit");
-              if (tmp.is_defined ())
-                maxit = tmp.nint_value ();
+          tmp = map.getfield ("maxit");
+          if (tmp.is_defined ())
+            maxit = tmp.nint_value ();
 
-              tmp = map.getfield ("p");
-              if (tmp.is_defined ())
-                p = tmp.nint_value ();
-
-              tmp = map.getfield ("v0");
-              if (tmp.is_defined ())
-                {
-                  if (a_is_complex || b_is_complex)
-                    cresid = ComplexColumnVector (tmp.complex_vector_value ());
-                  else
-                    resid = ColumnVector (tmp.vector_value ());
-                }
+          tmp = map.getfield ("p");
+          if (tmp.is_defined ())
+            p = tmp.nint_value ();
 
-              tmp = map.getfield ("disp");
-              if (tmp.is_defined ())
-                disp = tmp.nint_value ();
-
-              tmp = map.getfield ("cholB");
-              if (tmp.is_defined ())
-                cholB = tmp.double_value () != 0.;
+          tmp = map.getfield ("v0");
+          if (tmp.is_defined ())
+            {
+              if (a_is_complex || b_is_complex)
+                cresid = ComplexColumnVector (tmp.complex_vector_value ());
+              else
+                resid = ColumnVector (tmp.vector_value ());
+            }
 
-              tmp = map.getfield ("permB");
-              if (tmp.is_defined ())
-                permB = ColumnVector (tmp.vector_value ()) - 1.0;
-            }
-          else
-            {
-              error ("eigs: OPTS argument must be a scalar structure");
-              return retval;
-            }
+          tmp = map.getfield ("disp");
+          if (tmp.is_defined ())
+            disp = tmp.nint_value ();
+
+          tmp = map.getfield ("cholB");
+          if (tmp.is_defined ())
+            cholB = tmp.double_value () != 0.;
+
+          tmp = map.getfield ("permB");
+          if (tmp.is_defined ())
+            permB = ColumnVector (tmp.vector_value ()) - 1.0;
         }
       else
-        {
-          error ("eigs: OPTS argument must be a structure");
-          return retval;
-        }
+        error ("eigs: OPTS argument must be a structure");
     }
 
   if (nargin > (4+arg_offset))
-    {
-      error ("eigs: incorrect number of arguments");
-      return retval;
-    }
+    error ("eigs: incorrect number of arguments");
 
   // Test undeclared (no issym) matrix inputs for symmetry
   if (!sym_tested && !have_a_fun)
@@ -423,48 +390,128 @@
 
   // Mode 1 for SM mode seems unstable for some reason.
   // Use Mode 3 instead, with sigma = 0.
-  if (!error_state && !have_sigma && typ == "SM")
+  if (! have_sigma && typ == "SM")
     have_sigma = true;
 
-  if (!error_state)
+  octave_idx_type nconv;
+  if (a_is_complex || b_is_complex)
     {
-      octave_idx_type nconv;
-      if (a_is_complex || b_is_complex)
-        {
-          ComplexMatrix eig_vec;
-          ComplexColumnVector eig_val;
+      ComplexMatrix eig_vec;
+      ComplexColumnVector eig_val;
 
 
+      if (have_a_fun)
+        nconv = EigsComplexNonSymmetricFunc
+          (eigs_complex_func, n, typ, sigma, k, p, info, eig_vec,
+           eig_val, cresid, octave_stdout, tol, (nargout > 1), cholB,
+           disp, maxit);
+      else if (have_sigma)
+        {
+          if (a_is_sparse)
+            nconv = EigsComplexNonSymmetricMatrixShift
+              (ascm, sigma, k, p, info, eig_vec, eig_val, bscm, permB,
+               cresid, octave_stdout, tol, (nargout > 1), cholB, disp,
+               maxit);
+          else
+            nconv = EigsComplexNonSymmetricMatrixShift
+              (acm, sigma, k, p, info, eig_vec, eig_val, bcm, permB,
+               cresid, octave_stdout, tol, (nargout > 1), cholB, disp,
+               maxit);
+        }
+      else
+        {
+          if (a_is_sparse)
+            nconv = EigsComplexNonSymmetricMatrix
+              (ascm, typ, k, p, info, eig_vec, eig_val, bscm, permB,
+               cresid, octave_stdout, tol, (nargout > 1), cholB, disp,
+               maxit);
+          else
+            nconv = EigsComplexNonSymmetricMatrix
+              (acm, typ, k, p, info, eig_vec, eig_val, bcm, permB,
+               cresid, octave_stdout, tol, (nargout > 1), cholB, disp,
+               maxit);
+        }
+
+      if (nargout < 2)
+        retval(0) = eig_val;
+      else
+        {
+          retval(2) = double (info);
+          retval(1) = ComplexDiagMatrix (eig_val);
+          retval(0) = eig_vec;
+        }
+    }
+  else if (sigmai != 0.)
+    {
+      // Promote real problem to a complex one.
+      ComplexMatrix eig_vec;
+      ComplexColumnVector eig_val;
+
+      if (have_a_fun)
+        nconv = EigsComplexNonSymmetricFunc
+          (eigs_complex_func, n, typ,  sigma, k, p, info, eig_vec,
+           eig_val, cresid, octave_stdout, tol, (nargout > 1), cholB,
+           disp, maxit);
+      else
+        {
+          if (a_is_sparse)
+            nconv = EigsComplexNonSymmetricMatrixShift
+              (SparseComplexMatrix (asmm), sigma, k, p, info, eig_vec,
+               eig_val, SparseComplexMatrix (bsmm), permB, cresid,
+               octave_stdout, tol, (nargout > 1), cholB, disp, maxit);
+          else
+            nconv = EigsComplexNonSymmetricMatrixShift
+              (ComplexMatrix (amm), sigma, k, p, info, eig_vec,
+               eig_val, ComplexMatrix (bmm), permB, cresid,
+               octave_stdout, tol, (nargout > 1), cholB, disp, maxit);
+        }
+
+      if (nargout < 2)
+        retval(0) = eig_val;
+      else
+        {
+          retval(2) = double (info);
+          retval(1) = ComplexDiagMatrix (eig_val);
+          retval(0) = eig_vec;
+        }
+    }
+  else
+    {
+      if (symmetric)
+        {
+          Matrix eig_vec;
+          ColumnVector eig_val;
+
           if (have_a_fun)
-            nconv = EigsComplexNonSymmetricFunc
-                    (eigs_complex_func, n, typ, sigma, k, p, info, eig_vec,
-                     eig_val, cresid, octave_stdout, tol, (nargout > 1), cholB,
-                     disp, maxit);
+            nconv = EigsRealSymmetricFunc
+              (eigs_func, n, typ, sigmar, k, p, info, eig_vec,
+               eig_val, resid, octave_stdout, tol, (nargout > 1),
+               cholB, disp, maxit);
           else if (have_sigma)
             {
               if (a_is_sparse)
-                nconv = EigsComplexNonSymmetricMatrixShift
-                        (ascm, sigma, k, p, info, eig_vec, eig_val, bscm, permB,
-                         cresid, octave_stdout, tol, (nargout > 1), cholB, disp,
-                         maxit);
+                nconv = EigsRealSymmetricMatrixShift
+                  (asmm, sigmar, k, p, info, eig_vec, eig_val, bsmm,
+                   permB, resid, octave_stdout, tol, (nargout > 1),
+                   cholB, disp, maxit);
               else
-                nconv = EigsComplexNonSymmetricMatrixShift
-                        (acm, sigma, k, p, info, eig_vec, eig_val, bcm, permB,
-                         cresid, octave_stdout, tol, (nargout > 1), cholB, disp,
-                         maxit);
+                nconv = EigsRealSymmetricMatrixShift
+                  (amm, sigmar, k, p, info, eig_vec, eig_val, bmm,
+                   permB, resid, octave_stdout, tol, (nargout > 1),
+                   cholB, disp, maxit);
             }
           else
             {
               if (a_is_sparse)
-                nconv = EigsComplexNonSymmetricMatrix
-                        (ascm, typ, k, p, info, eig_vec, eig_val, bscm, permB,
-                         cresid, octave_stdout, tol, (nargout > 1), cholB, disp,
-                         maxit);
+                nconv = EigsRealSymmetricMatrix
+                  (asmm, typ, k, p, info, eig_vec, eig_val, bsmm,
+                   permB, resid, octave_stdout, tol, (nargout > 1),
+                   cholB, disp, maxit);
               else
-                nconv = EigsComplexNonSymmetricMatrix
-                        (acm, typ, k, p, info, eig_vec, eig_val, bcm, permB,
-                         cresid, octave_stdout, tol, (nargout > 1), cholB, disp,
-                         maxit);
+                nconv = EigsRealSymmetricMatrix
+                  (amm, typ, k, p, info, eig_vec, eig_val, bmm, permB,
+                   resid, octave_stdout, tol, (nargout > 1), cholB,
+                   disp, maxit);
             }
 
           if (nargout < 2)
@@ -472,33 +519,45 @@
           else
             {
               retval(2) = double (info);
-              retval(1) = ComplexDiagMatrix (eig_val);
+              retval(1) = DiagMatrix (eig_val);
               retval(0) = eig_vec;
             }
         }
-      else if (sigmai != 0.)
+      else
         {
-          // Promote real problem to a complex one.
           ComplexMatrix eig_vec;
           ComplexColumnVector eig_val;
 
           if (have_a_fun)
-            nconv = EigsComplexNonSymmetricFunc
-                    (eigs_complex_func, n, typ,  sigma, k, p, info, eig_vec,
-                     eig_val, cresid, octave_stdout, tol, (nargout > 1), cholB,
-                     disp, maxit);
+            nconv = EigsRealNonSymmetricFunc
+              (eigs_func, n, typ, sigmar, k, p, info, eig_vec,
+               eig_val, resid, octave_stdout, tol, (nargout > 1),
+               cholB, disp, maxit);
+          else if (have_sigma)
+            {
+              if (a_is_sparse)
+                nconv = EigsRealNonSymmetricMatrixShift
+                  (asmm, sigmar, k, p, info, eig_vec, eig_val, bsmm,
+                   permB, resid, octave_stdout, tol, (nargout > 1),
+                   cholB, disp, maxit);
+              else
+                nconv = EigsRealNonSymmetricMatrixShift
+                  (amm, sigmar, k, p, info, eig_vec, eig_val, bmm,
+                   permB, resid, octave_stdout, tol, (nargout > 1),
+                   cholB, disp, maxit);
+            }
           else
             {
               if (a_is_sparse)
-                nconv = EigsComplexNonSymmetricMatrixShift
-                        (SparseComplexMatrix (asmm), sigma, k, p, info, eig_vec,
-                         eig_val, SparseComplexMatrix (bsmm), permB, cresid,
-                         octave_stdout, tol, (nargout > 1), cholB, disp, maxit);
+                nconv = EigsRealNonSymmetricMatrix
+                  (asmm, typ, k, p, info, eig_vec, eig_val, bsmm,
+                   permB, resid, octave_stdout, tol, (nargout > 1),
+                   cholB, disp, maxit);
               else
-                nconv = EigsComplexNonSymmetricMatrixShift
-                        (ComplexMatrix (amm), sigma, k, p, info, eig_vec,
-                         eig_val, ComplexMatrix (bmm), permB, cresid,
-                         octave_stdout, tol, (nargout > 1), cholB, disp, maxit);
+                nconv = EigsRealNonSymmetricMatrix
+                  (amm, typ, k, p, info, eig_vec, eig_val, bmm, permB,
+                   resid, octave_stdout, tol, (nargout > 1), cholB,
+                   disp, maxit);
             }
 
           if (nargout < 2)
@@ -510,111 +569,17 @@
               retval(0) = eig_vec;
             }
         }
-      else
-        {
-          if (symmetric)
-            {
-              Matrix eig_vec;
-              ColumnVector eig_val;
-
-              if (have_a_fun)
-                nconv = EigsRealSymmetricFunc
-                        (eigs_func, n, typ, sigmar, k, p, info, eig_vec,
-                         eig_val, resid, octave_stdout, tol, (nargout > 1),
-                         cholB, disp, maxit);
-              else if (have_sigma)
-                {
-                  if (a_is_sparse)
-                    nconv = EigsRealSymmetricMatrixShift
-                            (asmm, sigmar, k, p, info, eig_vec, eig_val, bsmm,
-                             permB, resid, octave_stdout, tol, (nargout > 1),
-                             cholB, disp, maxit);
-                  else
-                    nconv = EigsRealSymmetricMatrixShift
-                            (amm, sigmar, k, p, info, eig_vec, eig_val, bmm,
-                             permB, resid, octave_stdout, tol, (nargout > 1),
-                             cholB, disp, maxit);
-                }
-              else
-                {
-                  if (a_is_sparse)
-                    nconv = EigsRealSymmetricMatrix
-                            (asmm, typ, k, p, info, eig_vec, eig_val, bsmm,
-                             permB, resid, octave_stdout, tol, (nargout > 1),
-                             cholB, disp, maxit);
-                  else
-                    nconv = EigsRealSymmetricMatrix
-                            (amm, typ, k, p, info, eig_vec, eig_val, bmm, permB,
-                             resid, octave_stdout, tol, (nargout > 1), cholB,
-                             disp, maxit);
-                }
+    }
 
-              if (nargout < 2)
-                retval(0) = eig_val;
-              else
-                {
-                  retval(2) = double (info);
-                  retval(1) = DiagMatrix (eig_val);
-                  retval(0) = eig_vec;
-                }
-            }
-          else
-            {
-              ComplexMatrix eig_vec;
-              ComplexColumnVector eig_val;
-
-              if (have_a_fun)
-                nconv = EigsRealNonSymmetricFunc
-                        (eigs_func, n, typ, sigmar, k, p, info, eig_vec,
-                         eig_val, resid, octave_stdout, tol, (nargout > 1),
-                         cholB, disp, maxit);
-              else if (have_sigma)
-                {
-                  if (a_is_sparse)
-                    nconv = EigsRealNonSymmetricMatrixShift
-                            (asmm, sigmar, k, p, info, eig_vec, eig_val, bsmm,
-                             permB, resid, octave_stdout, tol, (nargout > 1),
-                             cholB, disp, maxit);
-                  else
-                    nconv = EigsRealNonSymmetricMatrixShift
-                            (amm, sigmar, k, p, info, eig_vec, eig_val, bmm,
-                             permB, resid, octave_stdout, tol, (nargout > 1),
-                             cholB, disp, maxit);
-                }
-              else
-                {
-                  if (a_is_sparse)
-                    nconv = EigsRealNonSymmetricMatrix
-                            (asmm, typ, k, p, info, eig_vec, eig_val, bsmm,
-                             permB, resid, octave_stdout, tol, (nargout > 1),
-                             cholB, disp, maxit);
-                  else
-                    nconv = EigsRealNonSymmetricMatrix
-                            (amm, typ, k, p, info, eig_vec, eig_val, bmm, permB,
-                             resid, octave_stdout, tol, (nargout > 1), cholB,
-                             disp, maxit);
-                }
-
-              if (nargout < 2)
-                retval(0) = eig_val;
-              else
-                {
-                  retval(2) = double (info);
-                  retval(1) = ComplexDiagMatrix (eig_val);
-                  retval(0) = eig_vec;
-                }
-            }
-        }
-
-      if (nconv <= 0)
-        warning ("eigs: None of the %d requested eigenvalues converged", k);
-      else if (nconv < k)
-        warning ("eigs: Only %d of the %d requested eigenvalues converged",
-                 nconv, k);
-    }
+  if (nconv <= 0)
+    warning ("eigs: None of the %d requested eigenvalues converged", k);
+  else if (nconv < k)
+    warning ("eigs: Only %d of the %d requested eigenvalues converged",
+             nconv, k);
 
   if (! fcn_name.empty ())
     clear_function (fcn_name);
+
 #else
   error ("eigs: not available in this version of Octave");
 #endif
--- a/libinterp/dldfcn/__fltk_uigetfile__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/__fltk_uigetfile__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -136,10 +136,15 @@
   Fl::flush ();
 
   return retval;
+
 #else
+
   error ("__fltk_uigetfile__: not available without OpenGL and FLTK libraries");
-  return octave_value ();
+
+  return octave_value_list ();
+
 #endif
+
 }
 
 /*
--- a/libinterp/dldfcn/__glpk__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/__glpk__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -307,20 +307,9 @@
       if (tmp.is_defined ()) \
         { \
           if (! tmp.is_empty ()) \
-            { \
-              VAL = tmp.scalar_value (); \
- \
-              if (error_state) \
-                { \
-                  error ("glpk: invalid value in PARAM." NAME); \
-                  return retval; \
-                } \
-            } \
+            VAL = tmp.xscalar_value ("glpk: invalid value in PARAM" NAME); \
           else \
-            { \
-              error ("glpk: invalid value in PARAM." NAME); \
-              return retval; \
-            } \
+            error ("glpk: invalid value in PARAM" NAME); \
         } \
     } \
   while (0)
@@ -333,20 +322,9 @@
       if (tmp.is_defined ()) \
         { \
           if (! tmp.is_empty ()) \
-            { \
-              VAL = tmp.int_value (); \
- \
-              if (error_state) \
-                { \
-                  error ("glpk: invalid value in PARAM." NAME); \
-                  return retval; \
-                } \
-            } \
+            VAL = tmp.xint_value ("glpk: invalid value in PARAM" NAME); \
           else \
-            { \
-              error ("glpk: invalid value in PARAM." NAME); \
-              return retval; \
-            } \
+            error ("glpk: invalid value in PARAM" NAME); \
         } \
     } \
   while (0)
@@ -357,30 +335,19 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
-  // The list of values to return.  See the declaration in oct-obj.h
   octave_value_list retval;
 
 #if defined (HAVE_GLPK)
 
-  int nrhs = args.length ();
-
-  if (nrhs != 9)
-    {
-      print_usage ();
-      return retval;
-    }
+  // FIXME: Should we even need checking for an internal function?
+  if (args.length () != 9)
+    print_usage ();
 
   //-- 1nd Input. A column array containing the objective function
   //--            coefficients.
   volatile int mrowsc = args(0).rows ();
 
-  Matrix C (args(0).matrix_value ());
-
-  if (error_state)
-    {
-      error ("__glpk__: invalid value of C");
-      return retval;
-    }
+  Matrix C = args(0).xmatrix_value ("__glpk__: invalid value of C");
 
   double *c = C.fortran_vec ();
   Array<int> rn;
@@ -393,13 +360,7 @@
   // If matrix A is NOT a sparse matrix
   if (args(1).is_sparse_type ())
     {
-      SparseMatrix A = args(1).sparse_matrix_value (); // get the sparse matrix
-
-      if (error_state)
-        {
-          error ("__glpk__: invalid value of A");
-          return retval;
-        }
+      SparseMatrix A = args(1).xsparse_matrix_value ("__glpk__: invalid value of A");
 
       mrowsA = A.rows ();
       octave_idx_type Anc = A.cols ();
@@ -409,10 +370,7 @@
       a.resize (Anz+1, 0.0);
 
       if (Anc != mrowsc)
-        {
-          error ("__glpk__: invalid value of A");
-          return retval;
-        }
+        error ("__glpk__: invalid value of A");
 
       for (octave_idx_type j = 0; j < Anc; j++)
         for (octave_idx_type i = A.cidx (j); i < A.cidx (j+1); i++)
@@ -425,13 +383,7 @@
     }
   else
     {
-      Matrix A (args(1).matrix_value ()); // get the matrix
-
-      if (error_state)
-        {
-          error ("__glpk__: invalid value of A");
-          return retval;
-        }
+      Matrix A = args(1).xmatrix_value ("__glpk__: invalid value of A");
 
       mrowsA = A.rows ();
       rn.resize (dim_vector (mrowsA*mrowsc+1, 1));
@@ -456,25 +408,16 @@
 
   //-- 3rd Input. A column array containing the right-hand side value
   //               for each constraint in the constraint matrix.
-  Matrix B (args(2).matrix_value ());
-
-  if (error_state)
-    {
-      error ("__glpk__: invalid value of B");
-      return retval;
-    }
+  Matrix B = args(2).xmatrix_value ("__glpk__: invalid value of B");
 
   double *b = B.fortran_vec ();
 
   //-- 4th Input. An array of length mrowsc containing the lower
   //--            bound on each of the variables.
-  Matrix LB (args(3).matrix_value ());
+  Matrix LB = args(3).xmatrix_value ("__glpk__: invalid value of LB");
 
-  if (error_state || LB.length () < mrowsc)
-    {
-      error ("__glpk__: invalid value of LB");
-      return retval;
-    }
+  if (LB.numel () < mrowsc)
+    error ("__glpk__: invalid dimensions for LB");
 
   double *lb = LB.fortran_vec ();
 
@@ -493,13 +436,10 @@
 
   //-- 5th Input. An array of at least length numcols containing the upper
   //--            bound on each of the variables.
-  Matrix UB (args(4).matrix_value ());
+  Matrix UB = args(4).xmatrix_value ("__glpk__: invalid value of UB");
 
-  if (error_state || UB.length () < mrowsc)
-    {
-      error ("__glpk__: invalid value of UB");
-      return retval;
-    }
+  if (UB.numel () < mrowsc)
+    error ("__glpk__: invalid dimensions for UB");
 
   double *ub = UB.fortran_vec ();
 
@@ -517,24 +457,12 @@
 
   //-- 6th Input. A column array containing the sense of each constraint
   //--            in the constraint matrix.
-  charMatrix CTYPE (args(5).char_matrix_value ());
-
-  if (error_state)
-    {
-      error ("__glpk__: invalid value of CTYPE");
-      return retval;
-    }
+  charMatrix CTYPE = args(5).char_matrix_value ("__glpk__: invalid value of CTYPE");
 
   char *ctype = CTYPE.fortran_vec ();
 
   //-- 7th Input. A column array containing the types of the variables.
-  charMatrix VTYPE (args(6).char_matrix_value ());
-
-  if (error_state)
-    {
-      error ("__glpk__: invalid value of VARTYPE");
-      return retval;
-    }
+  charMatrix VTYPE = args(6).char_matrix_value ("__glpk__: invalid value of VARTYPE");
 
   Array<int> vartype (dim_vector (mrowsc, 1));
   volatile int isMIP = 0;
@@ -551,13 +479,7 @@
 
   //-- 8th Input. Sense of optimization.
   volatile int sense;
-  double SENSE = args(7).scalar_value ();
-
-  if (error_state)
-    {
-      error ("__glpk__: invalid value of SENSE");
-      return retval;
-    }
+  double SENSE = args(7).scalar_value ("__glpk__: invalid value of SENSE");
 
   if (SENSE >= 0)
     sense = 1;
@@ -565,13 +487,7 @@
     sense = -1;
 
   //-- 9th Input. A structure containing the control parameters.
-  octave_scalar_map PARAM = args(8).scalar_map_value ();
-
-  if (error_state)
-    {
-      error ("__glpk__: invalid value of PARAM");
-      return retval;
-    }
+  octave_scalar_map PARAM = args(8).xscalar_map_value ("__glpk__: invalid value of PARAM");
 
   control_params par;
 
@@ -583,37 +499,25 @@
   par.msglev = 1;
   OCTAVE_GLPK_GET_INT_PARAM ("msglev", par.msglev);
   if (par.msglev < 0 || par.msglev > 3)
-    {
-      error ("__glpk__: PARAM.msglev must be 0 (no output) or 1 (error and warning messages only [default]) or 2 (normal output) or 3 (full output)");
-      return retval;
-    }
+    error ("__glpk__: PARAM.msglev must be 0 (no output) or 1 (error and warning messages only [default]) or 2 (normal output) or 3 (full output)");
 
   //-- scaling option
   volatile int scale = 16;
   OCTAVE_GLPK_GET_INT_PARAM ("scale", scale);
   if (scale < 0 || scale > 128)
-    {
-      error ("__glpk__: PARAM.scale must either be 128 (automatic selection of scaling options), or a bitwise or of: 1 (geometric mean scaling), 16 (equilibration scaling), 32 (round scale factors to power of two), 64 (skip if problem is well scaled");
-      return retval;
-    }
+    error ("__glpk__: PARAM.scale must either be 128 (automatic selection of scaling options), or a bitwise or of: 1 (geometric mean scaling), 16 (equilibration scaling), 32 (round scale factors to power of two), 64 (skip if problem is well scaled");
 
   //-- Dual simplex option
   par.dual = 1;
   OCTAVE_GLPK_GET_INT_PARAM ("dual", par.dual);
   if (par.dual < 1 || par.dual > 3)
-    {
-      error ("__glpk__: PARAM.dual must be 1 (use two-phase primal simplex [default]) or 2 (use two-phase dual simplex) or 3 (use two-phase dual simplex, and if it fails, switch to the primal simplex)");
-      return retval;
-    }
+    error ("__glpk__: PARAM.dual must be 1 (use two-phase primal simplex [default]) or 2 (use two-phase dual simplex) or 3 (use two-phase dual simplex, and if it fails, switch to the primal simplex)");
 
   //-- Pricing option
   par.price = 34;
   OCTAVE_GLPK_GET_INT_PARAM ("price", par.price);
   if (par.price != 17 && par.price != 34)
-    {
-      error ("__glpk__: PARAM.price must be 17 (textbook pricing) or 34 (steepest edge pricing [default])");
-      return retval;
-    }
+    error ("__glpk__: PARAM.price must be 17 (textbook pricing) or 34 (steepest edge pricing [default])");
 
   //-- Simplex iterations limit
   par.itlim = std::numeric_limits<int>::max ();
@@ -627,46 +531,31 @@
   par.branch = 4;
   OCTAVE_GLPK_GET_INT_PARAM ("branch", par.branch);
   if (par.branch < 1 || par.branch > 5)
-    {
-      error ("__glpk__: PARAM.branch must be 1 (first fractional variable) or 2 (last fractional variable) or 3 (most fractional variable) or 4 (heuristic by Driebeck and Tomlin [default]) or 5 (hybrid pseudocost heuristic)");
-      return retval;
-    }
+    error ("__glpk__: PARAM.branch must be 1 (first fractional variable) or 2 (last fractional variable) or 3 (most fractional variable) or 4 (heuristic by Driebeck and Tomlin [default]) or 5 (hybrid pseudocost heuristic)");
 
   //-- Backtracking heuristic option
   par.btrack = 4;
   OCTAVE_GLPK_GET_INT_PARAM ("btrack", par.btrack);
   if (par.btrack < 1 || par.btrack > 4)
-    {
-      error ("__glpk__: PARAM.btrack must be 1 (depth first search) or 2 (breadth first search) or 3 (best local bound) or 4 (best projection heuristic [default]");
-      return retval;
-    }
+    error ("__glpk__: PARAM.btrack must be 1 (depth first search) or 2 (breadth first search) or 3 (best local bound) or 4 (best projection heuristic [default]");
 
   //-- Presolver option
   par.presol = 1;
   OCTAVE_GLPK_GET_INT_PARAM ("presol", par.presol);
   if (par.presol < 0 || par.presol > 1)
-    {
-      error ("__glpk__: PARAM.presol must be 0 (do NOT use LP presolver) or 1 (use LP presolver [default])");
-      return retval;
-    }
+    error ("__glpk__: PARAM.presol must be 0 (do NOT use LP presolver) or 1 (use LP presolver [default])");
 
   //-- LPsolver option
   volatile int lpsolver = 1;
   OCTAVE_GLPK_GET_INT_PARAM ("lpsolver", lpsolver);
   if (lpsolver < 1 || lpsolver > 2)
-    {
-      error ("__glpk__: PARAM.lpsolver must be 1 (simplex method) or 2 (interior point method)");
-      return retval;
-    }
+    error ("__glpk__: PARAM.lpsolver must be 1 (simplex method) or 2 (interior point method)");
 
   //-- Ratio test option
   par.rtest = 34;
   OCTAVE_GLPK_GET_INT_PARAM ("rtest", par.rtest);
   if (par.rtest != 17 && par.rtest != 34)
-    {
-      error ("__glpk__: PARAM.rtest must be 17 (standard ratio test) or 34 (Harris' two-pass ratio test [default])");
-      return retval;
-    }
+    error ("__glpk__: PARAM.rtest must be 17 (standard ratio test) or 34 (Harris' two-pass ratio test [default])");
 
   par.tmlim = std::numeric_limits<int>::max ();
   OCTAVE_GLPK_GET_INT_PARAM ("tmlim", par.tmlim);
--- a/libinterp/dldfcn/__init_fltk__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/__init_fltk__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -563,7 +563,7 @@
   {
     std::vector<int> delayed_menus;
     Matrix kids = find_uimenu_children (uimenup);
-    int len = kids.length ();
+    int len = kids.numel ();
     std::string fltk_label = uimenup.get_fltk_label ();
     int count = 0;
 
@@ -613,7 +613,7 @@
   {
     std::vector<int> delayed_menus;
     Matrix kids = find_uimenu_children (figp);
-    int len = kids.length ();
+    int len = kids.numel ();
     int count = 0;
     menubar->clear ();
     for (octave_idx_type ii = 0; ii < len; ii++)
@@ -658,7 +658,7 @@
     Matrix kids;
     std::string type = prop.get_type ();
     kids = find_uimenu_children (prop);
-    int len = kids.length ();
+    int len = kids.numel ();
 
     for (octave_idx_type ii = 0; ii < len; ii++)
       {
@@ -1113,7 +1113,7 @@
   graphics_handle pixel2axes_or_ca (int px, int py)
   {
     Matrix kids = fp.get_children ();
-    int len = kids.length ();
+    int len = kids.numel ();
 
     for (int k = 0; k < len; k++)
       {
@@ -1776,11 +1776,7 @@
       instance = new figure_manager ();
 
     if (! instance)
-      {
-        ::error ("unable to create figure_manager object!");
-
-        retval = false;
-      }
+      error ("unable to create figure_manager object!");
 
     return retval;
   }
@@ -2083,7 +2079,9 @@
         if (istr >> ind)
           return ind;
       }
+
     error ("figure_manager: could not recognize fltk index");
+
     return -1;
   }
 
@@ -2104,7 +2102,9 @@
         else
           return 0;
       }
+
     error ("figure_manager: figure is not fltk");
+
     return -1;
   }
 
@@ -2117,7 +2117,9 @@
           dynamic_cast<figure::properties&> (fobj.get_properties ());
         return figprops2idx (fp);
       }
+
     error ("figure_manager: H (= %g) is not a figure", h);
+
     return -1;
   }
 
@@ -2189,7 +2191,7 @@
         else if (go.isa ("figure") || go.isa ("uicontextmenu"))
           ;
         else
-          error ("unexpected parent object\n");
+          error ("invalid parent object\n");
 
         uimenup.set_fltk_label (fltk_label);
       }
--- a/libinterp/dldfcn/__init_gnuplot__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/__init_gnuplot__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -151,20 +151,17 @@
         octave_value_list args;
         Matrix fids = pstream.matrix_value ();
 
-        if (! error_state)
-          {
-            Ffputs (ovl (fids(0), "\nquit;\n"));
+        Ffputs (ovl (fids(0), "\nquit;\n"));
 
-            Ffflush (ovl (fids(0)));
-            Fpclose (ovl (fids(0)));
+        Ffflush (ovl (fids(0)));
+        Fpclose (ovl (fids(0)));
 
-            if (fids.numel () > 1)
-              {
-                Fpclose (ovl (fids(1)));
+        if (fids.numel () > 1)
+          {
+            Fpclose (ovl (fids(1)));
 
-                if (fids.numel () > 2)
-                  Fwaitpid (ovl (fids(2)));
-              }
+            if (fids.numel () > 2)
+              Fwaitpid (ovl (fids(2)));
           }
       }
   }
--- a/libinterp/dldfcn/__magick_read__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/__magick_read__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -115,15 +115,20 @@
 //  all to 1. So we will guess that if all channels have depth of 1,
 //  then we must have a binary image.
 //  Note that we can't use AllChannels it doesn't work for this.
-//  Instead of checking all of the individual channels, we check one
-//  from RGB, CMYK, grayscale, and transparency.
+//  We also can't check only one from RGB, one from CMYK, and grayscale
+// and transparency, we really need to check all of the channels (bug #41584).
 static octave_idx_type
 get_depth (Magick::Image& img)
 {
   octave_idx_type depth = img.depth ();
   if (depth == 8
       && img.channelDepth (Magick::RedChannel)     == 1
+      && img.channelDepth (Magick::GreenChannel)   == 1
+      && img.channelDepth (Magick::BlueChannel)    == 1
       && img.channelDepth (Magick::CyanChannel)    == 1
+      && img.channelDepth (Magick::MagentaChannel) == 1
+      && img.channelDepth (Magick::YellowChannel)  == 1
+      && img.channelDepth (Magick::BlackChannel)   == 1
       && img.channelDepth (Magick::OpacityChannel) == 1
       && img.channelDepth (Magick::GrayChannel)    == 1)
     depth = 1;
@@ -177,8 +182,8 @@
                         (region["row_cache"] + rows.inc () -1) - cols.inc ();
 
   // The actual height and width of the output image
-  region["row_out"] = rows.nelem ();
-  region["col_out"] = cols.nelem ();
+  region["row_out"] = rows.numel ();
+  region["col_out"] = cols.numel ();
 
   return region;
 }
@@ -216,7 +221,7 @@
   octave_value_list retval (3, Matrix ());
 
   std::map<std::string, octave_idx_type> region = calculate_region (options);
-  const octave_idx_type nFrames = frameidx.length ();
+  const octave_idx_type nFrames = frameidx.numel ();
   const octave_idx_type nRows = region["row_out"];
   const octave_idx_type nCols = region["col_out"];
 
@@ -311,7 +316,7 @@
   octave_value_list retval (3, Matrix ());
 
   std::map<std::string, octave_idx_type> region = calculate_region (options);
-  const octave_idx_type nFrames = frameidx.length ();
+  const octave_idx_type nFrames = frameidx.numel ();
   const octave_idx_type nRows = region["row_out"];
   const octave_idx_type nCols = region["col_out"];
   T img;
@@ -664,7 +669,6 @@
 
     default:
       error ("__magick_read__: unknown Magick++ image type");
-      return retval;
     }
 
   retval(0) = img;
@@ -686,7 +690,6 @@
   catch (Magick::Exception& e)
     {
       error ("Magick++ exception: %s", e.what ());
-      error_state = 1;
     }
 }
 
@@ -709,9 +712,28 @@
       // Restore locale from before GraphicsMagick initialisation
       setlocale (LC_ALL, locale.c_str ());
 
-      if (QuantumDepth < 32)
+      // Why should we give a warning?
+      // Magick does not tell us the real bitdepth of the image in file.
+      // The best we can have is the minimum between the bitdepth of the
+      // file and the quantum depth.  So we never know if the file will
+      // actually be read correctly so we warn the user that it might
+      // be limited.
+      //
+      // Why we warn if < 16 instead of < 32 ?
+      // The reasons for < 32 is simply that it's the maximum quantum
+      // depth they support.  However, very few people would actually
+      // need such support while being a major inconvenience to anyone
+      // else (8 bit images suddenly taking 4x more space will be
+      // critical for multi page images).  It would also suggests that
+      // it covers all images which does not (it still does not support
+      // float point and signed integer images).
+      // On the other hand, 16bit images are much more common. If quantum
+      // depth is 8, there's a good chance that we will be limited.  It
+      // is also the GraphicsMagick recommended setting and the default
+      // for ImageMagick.
+      if (QuantumDepth < 16)
         warning_with_id ("Octave:GraphicsMagic-Quantum-Depth",
-                         "your version of %s limits images to %d bits per pixel",
+                         "your version of %s limits images to %d bits per pixel\n",
                          MagickPackageName, QuantumDepth);
 
       initialized = true;
@@ -739,22 +761,12 @@
   maybe_initialize_magick ();
 
   if (args.length () != 2 || ! args(0).is_string ())
-    {
-      print_usage ();
-      return output;
-    }
+    print_usage ();
 
-  const octave_scalar_map options = args(1).scalar_map_value ();
-  if (error_state)
-    {
-      error ("__magick_read__: OPTIONS must be a struct");
-      return output;
-    }
+  const octave_scalar_map options = args(1).xscalar_map_value ("__magick_read__: OPTIONS must be a struct");
 
   std::vector<Magick::Image> imvec;
   read_file (args(0).string_value (), imvec);
-  if (error_state)
-    return output;
 
   // Prepare an Array with the indexes for the requested frames.
   const octave_idx_type nFrames = imvec.size ();
@@ -768,15 +780,11 @@
     }
   else
     {
-      frameidx = indexes.int_vector_value ();
-      if (error_state)
-        {
-          error ("__magick_read__: invalid value for Index/Frame");
-          return output;
-        }
+      frameidx = indexes.xint_vector_value ("__magick_read__: invalid value for Index/Frame");
+
       // Fix indexes from base 1 to base 0, and at the same time, make
       // sure none of the indexes is outside the range of image number.
-      const octave_idx_type n = frameidx.nelem ();
+      const octave_idx_type n = frameidx.numel ();
       for (octave_idx_type i = 0; i < n; i++)
         {
           frameidx(i)--;
@@ -786,7 +794,6 @@
               // need to be ordered (this is a feature and even allows for
               // some frames to be read multiple times).
               error ("imread: index/frames specified are outside the number of images");
-              return output;
             }
         }
     }
@@ -798,7 +805,7 @@
   {
     const unsigned int nRows = imvec[frameidx(0)].rows ();
     const unsigned int nCols = imvec[frameidx(0)].columns ();
-    const octave_idx_type n = frameidx.nelem ();
+    const octave_idx_type n = frameidx.numel ();
     for (octave_idx_type frame = 0; frame < n; frame++)
       {
         if (nRows != imvec[frameidx(frame)].rows ()
@@ -806,7 +813,6 @@
           {
             error ("imread: all frames must have the same size but frame %i is different",
                    frameidx(frame) +1);
-            return output;
           }
       }
   }
@@ -824,10 +830,7 @@
         output = read_indexed_images<uint16NDArray> (imvec, frameidx,
                                                      nargout, options);
       else
-        {
-          error ("imread: indexed images with depths greater than 16-bit are not supported");
-          return output;
-        }
+        error ("imread: indexed images with depths greater than 16-bit are not supported");
     }
 
   else
@@ -841,10 +844,8 @@
       else if (depth <= 32)
         output = read_images<FloatNDArray>  (imvec, frameidx, nargout, options);
       else
-        {
-          error ("imread: reading of images with %i-bit depth is not supported",
-                 depth);
-        }
+        error ("imread: reading of images with %i-bit depth is not supported",
+               depth);
     }
 
 #endif
@@ -1073,11 +1074,8 @@
       break;
 
     default:
-      {
-        // __imwrite should have already filtered this cases
-        error ("__magick_write__: wrong size on 3rd dimension");
-        return;
-      }
+      // __imwrite should have already filtered this cases
+      error ("__magick_write__: wrong size on 3rd dimension");
     }
 
   // We will be passing the values as integers with depth as specified
@@ -1306,11 +1304,9 @@
       }
 
     default:
-      {
-        error ("__magick_write__: unrecognized Magick::ImageType");
-        return;
-      }
+      error ("__magick_write__: unrecognized Magick::ImageType");
     }
+
   return;
 }
 
@@ -1377,7 +1373,6 @@
   catch (Magick::Exception& e)
     {
       error ("Magick++ exception: %s", e.what ());
-      error_state = 1;
     }
 }
 
@@ -1403,27 +1398,15 @@
   maybe_initialize_magick ();
 
   if (args.length () != 5 || ! args(0).is_string () || ! args(1).is_string ())
-    {
-      print_usage ();
-      return retval;
-    }
-  const std::string filename = args(0).string_value ();
-  const std::string ext      = args(1).string_value ();
+    print_usage ();
 
-  const octave_scalar_map options = args(4).scalar_map_value ();
-  if (error_state)
-    {
-      error ("__magick_write__: OPTIONS must be a struct");
-      return retval;
-    }
+  const std::string filename = args(0).string_value ();
+  const std::string ext = args(1).string_value ();
+
+  const octave_scalar_map options = args(4).xscalar_map_value ("__magick_write__: OPTIONS must be a struct");
 
   const octave_value img  = args(2);
-  const Matrix       cmap = args(3).matrix_value ();
-  if (error_state)
-    {
-      error ("__magick_write__: invalid IMG or MAP");
-      return retval;
-    }
+  const Matrix cmap = args(3).xmatrix_value ("__magick_write__: invalid MAP");
 
   std::vector<Magick::Image> imvec;
 
@@ -1465,10 +1448,7 @@
           encode_uint_image<uint32NDArray> (imvec, clip_img, clip_alpha);
         }
       else
-        {
-          error ("__magick_write__: image type not supported");
-          return retval;
-        }
+        error ("__magick_write__: image type not supported");
     }
   else
     {
@@ -1482,10 +1462,7 @@
         encode_indexed_images<uint16NDArray> (imvec, img.uint16_array_value (),
                                               cmap);
       else
-        {
-          error ("__magick_write__: indexed image must be uint8, uint16 or float.");
-          return retval;
-        }
+        error ("__magick_write__: indexed image must be uint8, uint16 or float.");
     }
   static std::map<std::string, octave_idx_type> disposal_methods
     = init_reverse_disposal_methods ();
@@ -1511,8 +1488,7 @@
     {
       std::vector<Magick::Image> ini_imvec;
       read_file (filename, ini_imvec);
-      if (error_state)
-        return retval;
+
       if (ini_imvec.size () > 0)
         {
           ini_imvec.insert (ini_imvec.end (), imvec.begin (), imvec.end ());
@@ -1546,9 +1522,24 @@
   // Note that this only needs to be set on the first frame
   imvec[0].animationIterations (options.getfield ("loopcount").uint_value ());
 
+  const std::string compression = options.getfield ("compression").string_value ();
+#define COMPRESS_MAGICK_IMAGE_VECTOR(COMPRESSION_STRING, GM_TYPE) \
+  if (compression == COMPRESSION_STRING) \
+    for (std::vector<Magick::Image>::size_type i = 0; i < imvec.size (); i++) \
+      imvec[i].compressType (GM_TYPE);
+
+  COMPRESS_MAGICK_IMAGE_VECTOR("none", Magick::NoCompression)
+  else COMPRESS_MAGICK_IMAGE_VECTOR("bzip", Magick::BZipCompression)
+  else COMPRESS_MAGICK_IMAGE_VECTOR("fax3", Magick::FaxCompression)
+  else COMPRESS_MAGICK_IMAGE_VECTOR("fax4", Magick::Group4Compression)
+  else COMPRESS_MAGICK_IMAGE_VECTOR("jpeg", Magick::JPEGCompression)
+  else COMPRESS_MAGICK_IMAGE_VECTOR("lzw", Magick::LZWCompression)
+  else COMPRESS_MAGICK_IMAGE_VECTOR("rle", Magick::RLECompression)
+  else COMPRESS_MAGICK_IMAGE_VECTOR("deflate", Magick::ZipCompression)
+
+#undef COMPRESS_MAGICK_IMAGE_VECTOR
+
   write_file (filename, ext, imvec);
-  if (error_state)
-    return retval;
 
 #endif
   return retval;
@@ -1574,16 +1565,15 @@
 @end deftypefn")
 {
   octave_value retval;
+
 #ifndef HAVE_MAGICK
   gripe_disabled_feature ("imfinfo", "Image IO");
 #else
   maybe_initialize_magick ();
 
   if (args.length () < 1 || ! args(0).is_string ())
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
+
   const std::string filename = args(0).string_value ();
   int idx;
   if (args.length () > 1)
@@ -1605,7 +1595,6 @@
   catch (Magick::Exception& e)
     {
       error ("Magick++ exception: %s", e.what ());
-      return retval;
     }
 
   static const char *fields[] = {"rows", "columns", "format", 0};
@@ -1803,16 +1792,13 @@
   maybe_initialize_magick ();
 
   if (args.length () < 1 || ! args(0).is_string ())
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
+
   const std::string filename = args(0).string_value ();
 
   std::vector<Magick::Image> imvec;
   read_file (filename, imvec);
-  if (error_state)
-    return retval;
+
   const octave_idx_type nFrames = imvec.size ();
   const std::string format = imvec[0].magick ();
 
@@ -1907,11 +1893,8 @@
       template_info.setfield ("FileSize",    octave_value (fs.size ()));
     }
   else
-    {
-      error ("imfinfo: error reading '%s': %s",
-             filename.c_str (), fs.error ().c_str ());
-      return retval;
-    }
+    error ("imfinfo: error reading '%s': %s", filename.c_str (),
+           fs.error ().c_str ());
 
   for (octave_idx_type frame = 0; frame < nFrames; frame++)
     {
@@ -2249,14 +2232,13 @@
 @end deftypefn")
 {
   octave_value retval;
+
 #ifndef HAVE_MAGICK
   gripe_disabled_feature ("imformats", "Image IO");
 #else
   if (args.length () != 1 || ! args(0).is_map ())
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
+
   octave_map formats = args(0).map_value ();
 
   maybe_initialize_magick ();
--- a/libinterp/dldfcn/__osmesa_print__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/__osmesa_print__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -95,33 +95,23 @@
 
   int nargin = args.length ();
 
-  if (! (nargin == 1 || nargin == 3))
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin != 1 && nargin != 3)
+    print_usage ();
 
   if (nargin == 3)
     {
       if (! (args(1).is_string () && args(2).is_string ()))
-        {
-          error ("__osmesa_print__: FILE and TERM must be strings");
-          return retval;
-        }
+        error ("__osmesa_print__: FILE and TERM must be strings");
 
 #ifndef HAVE_GL2PS_H
       error ("__osmesa_print__: Octave has been compiled without gl2ps");
-      return retval;
 #endif
     }
 
   int h = args(0).double_value ();
   graphics_object fobj = gh_manager::get_object (h);
   if (! (fobj && fobj.isa ("figure")))
-    {
-      error ("__osmesa_print__: H must be a valid figure handle");
-      return retval;
-    }
+    error ("__osmesa_print__: H must be a valid figure handle");
 
   figure::properties& fp =
     dynamic_cast<figure::properties&> (fobj.get_properties ());
@@ -135,20 +125,14 @@
   // Create an RGBA-mode context, specify Z=16, stencil=0, accum=0 sizes
   OSMesaContext ctx = OSMesaCreateContextExt (OSMESA_RGBA, 16, 0, 0, NULL);
   if (! ctx)
-    {
-      error ("__osmesa_print__: OSMesaCreateContext failed!\n");
-      return retval;
-    }
+    error ("__osmesa_print__: OSMesaCreateContext failed!\n");
 
   // Allocate the image buffer
   OCTAVE_LOCAL_BUFFER (GLubyte, buffer, 4 * Width * Height);
 
   // Bind the buffer to the context and make it current
   if (! OSMesaMakeCurrent (ctx, buffer, GL_UNSIGNED_BYTE, Width, Height))
-    {
-      error ("__osmesa_print__: OSMesaMakeCurrent failed!\n");
-      return retval;
-    }
+    error ("__osmesa_print__: OSMesaMakeCurrent failed!\n");
 
   // Test for a bug in OSMesa with version < 9.0
   //
@@ -182,41 +166,38 @@
       std::string file = args(1).string_value ();
       std::string term = args(2).string_value ();
 
-      if (! error_state)
-        {
-          size_t pos_p = file.find_first_of ("|");
-          size_t pos_c = file.find_first_not_of ("| ");
+      size_t pos_p = file.find_first_of ("|");
+      size_t pos_c = file.find_first_not_of ("| ");
 
-          if (pos_p == std::string::npos && pos_c == std::string::npos)
-            error ("__osmesa_print__: empty output ''");
-          else if (pos_c == std::string::npos)
-            error ("__osmesa_print__: empty pipe '|'");
-          else if (pos_p != std::string::npos && pos_p < pos_c)
+      if (pos_p == std::string::npos && pos_c == std::string::npos)
+        error ("__osmesa_print__: empty output ''");
+      else if (pos_c == std::string::npos)
+        error ("__osmesa_print__: empty pipe '|'");
+      else if (pos_p != std::string::npos && pos_p < pos_c)
+        {
+          // create process and pipe gl2ps output to it
+          std::string cmd = file.substr (pos_c);
+          gl2ps_print (fobj, cmd, term);
+        }
+      else
+        {
+          // write gl2ps output directly to file
+          FILE *filep = gnulib::fopen (file.substr (pos_c).c_str (), "w");
+
+          if (filep)
             {
-              // create process and pipe gl2ps output to it
-              std::string cmd = file.substr (pos_c);
-              gl2ps_print (fobj, cmd, term);
+              unwind_protect frame;
+
+              frame.add_fcn (close_fcn, filep);
+
+              glps_renderer rend (filep, term);
+              rend.draw (fobj, "");
+
+              // Make sure buffered commands are finished!!!
+              glFinish ();
             }
           else
-            {
-              // write gl2ps output directly to file
-              FILE *filep = gnulib::fopen (file.substr (pos_c).c_str (), "w");
-
-              if (filep)
-                {
-                  unwind_protect frame;
-
-                  frame.add_fcn (close_fcn, filep);
-
-                  glps_renderer rend (filep, term);
-                  rend.draw (fobj, "");
-
-                  // Make sure buffered commands are finished!!!
-                  glFinish ();
-                }
-              else
-                error ("__osmesa_print__: Couldn't create file \"%s\"", file.c_str ());
-            }
+            error ("__osmesa_print__: Couldn't create file \"%s\"", file.c_str ());
         }
 #endif
     }
--- a/libinterp/dldfcn/__voronoi__.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/__voronoi__.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -68,10 +68,7 @@
       int maxval = std::numeric_limits<int>::max ();
 
       if (dim > maxval || n > maxval)
-        {
-          error ("%s: dimension too large for Qhull", who);
-          return false;
-        }
+        error ("%s: dimension too large for Qhull", who);
     }
 
   return true;
@@ -87,7 +84,7 @@
 {
   octave_value_list retval;
 
-  std::string caller = args(0).string_value ();
+  std::string caller = args(0).xstring_value ("__voronoi__: CALLER must be a string");
 
 #if defined (HAVE_QHULL)
 
@@ -95,10 +92,7 @@
 
   int nargin = args.length ();
   if (nargin < 2 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   Matrix points = args(1).matrix_value ();
   const octave_idx_type dim = points.columns ();
@@ -134,11 +128,8 @@
             options += " " + tmp(i);
         }
       else
-        {
-          error ("%s: OPTIONS must be a string, cell array of strings, or empty",
-                 caller.c_str ());
-          return retval;
-        }
+        error ("%s: OPTIONS must be a string, cell array of strings, or empty",
+               caller.c_str ());
     }
 
   boolT ismalloc = false;
@@ -156,10 +147,7 @@
   if (outfile)
     frame.add_fcn (close_fcn, outfile);
   else
-    {
-      error ("__voronoi__: unable to create temporary file for output");
-      return retval;
-    }
+    error ("__voronoi__: unable to create temporary file for output");
 
   // qh_new_qhull command and points arguments are not const...
 
--- a/libinterp/dldfcn/amd.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/amd.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -91,111 +91,100 @@
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
-  else
+
+  octave_idx_type n_row, n_col;
+  const octave_idx_type *ridx, *cidx;
+  SparseMatrix sm;
+  SparseComplexMatrix scm;
+
+  if (args(0).is_sparse_type ())
     {
-      octave_idx_type n_row, n_col;
-      const octave_idx_type *ridx, *cidx;
-      SparseMatrix sm;
-      SparseComplexMatrix scm;
-
-      if (args(0).is_sparse_type ())
+      if (args(0).is_complex_type ())
         {
-          if (args(0).is_complex_type ())
-            {
-              scm = args(0).sparse_complex_matrix_value ();
-              n_row = scm.rows ();
-              n_col = scm.cols ();
-              ridx = scm.xridx ();
-              cidx = scm.xcidx ();
-            }
-          else
-            {
-              sm = args(0).sparse_matrix_value ();
-              n_row = sm.rows ();
-              n_col = sm.cols ();
-              ridx = sm.xridx ();
-              cidx = sm.xcidx ();
-            }
+          scm = args(0).sparse_complex_matrix_value ();
+          n_row = scm.rows ();
+          n_col = scm.cols ();
+          ridx = scm.xridx ();
+          cidx = scm.xcidx ();
         }
       else
         {
-          if (args(0).is_complex_type ())
-            sm = SparseMatrix (real (args(0).complex_matrix_value ()));
-          else
-            sm = SparseMatrix (args(0).matrix_value ());
-
+          sm = args(0).sparse_matrix_value ();
           n_row = sm.rows ();
           n_col = sm.cols ();
           ridx = sm.xridx ();
           cidx = sm.xcidx ();
         }
-
-      if (!error_state && n_row != n_col)
-        error ("amd: matrix S must be square");
+    }
+  else
+    {
+      if (args(0).is_complex_type ())
+        sm = SparseMatrix (real (args(0).complex_matrix_value ()));
+      else
+        sm = SparseMatrix (args(0).matrix_value ());
 
-      if (!error_state)
-        {
-          OCTAVE_LOCAL_BUFFER (double, Control, AMD_CONTROL);
-          AMD_NAME (_defaults) (Control) ;
-          if (nargin > 1)
-            {
-              octave_scalar_map arg1 = args(1).scalar_map_value ();
+      n_row = sm.rows ();
+      n_col = sm.cols ();
+      ridx = sm.xridx ();
+      cidx = sm.xcidx ();
+    }
 
-              if (!error_state)
-                {
-                  octave_value tmp;
+  if (n_row != n_col)
+    error ("amd: matrix S must be square");
 
-                  tmp = arg1.getfield ("dense");
-                  if (tmp.is_defined ())
-                    Control[AMD_DENSE] = tmp.double_value ();
+  OCTAVE_LOCAL_BUFFER (double, Control, AMD_CONTROL);
+  AMD_NAME (_defaults) (Control) ;
+  if (nargin > 1)
+    {
+      octave_scalar_map arg1 = args(1).xscalar_map_value ("amd: OPTS argument must be a scalar structure");
+
+      octave_value tmp;
 
-                  tmp = arg1.getfield ("aggressive");
-                  if (tmp.is_defined ())
-                    Control[AMD_AGGRESSIVE] = tmp.double_value ();
-                }
-              else
-                error ("amd: OPTS argument must be a scalar structure");
-            }
+      tmp = arg1.getfield ("dense");
+      if (tmp.is_defined ())
+        Control[AMD_DENSE] = tmp.double_value ();
 
-          if (!error_state)
-            {
-              OCTAVE_LOCAL_BUFFER (octave_idx_type, P, n_col);
-              Matrix xinfo (AMD_INFO, 1);
-              double *Info = xinfo.fortran_vec ();
+      tmp = arg1.getfield ("aggressive");
+      if (tmp.is_defined ())
+        Control[AMD_AGGRESSIVE] = tmp.double_value ();
+    }
 
-              // FIXME: how can we manage the memory allocation of amd
-              //        in a cleaner manner?
-              SUITESPARSE_ASSIGN_FPTR (malloc_func, amd_malloc, malloc);
-              SUITESPARSE_ASSIGN_FPTR (free_func, amd_free, free);
-              SUITESPARSE_ASSIGN_FPTR (calloc_func, amd_calloc, calloc);
-              SUITESPARSE_ASSIGN_FPTR (realloc_func, amd_realloc, realloc);
-              SUITESPARSE_ASSIGN_FPTR (printf_func, amd_printf, printf);
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, P, n_col);
+  Matrix xinfo (AMD_INFO, 1);
+  double *Info = xinfo.fortran_vec ();
 
-              octave_idx_type result = AMD_NAME (_order) (n_col, cidx, ridx, P,
-                                                          Control, Info);
+  // FIXME: how can we manage the memory allocation of amd
+  //        in a cleaner manner?
+  SUITESPARSE_ASSIGN_FPTR (malloc_func, amd_malloc, malloc);
+  SUITESPARSE_ASSIGN_FPTR (free_func, amd_free, free);
+  SUITESPARSE_ASSIGN_FPTR (calloc_func, amd_calloc, calloc);
+  SUITESPARSE_ASSIGN_FPTR (realloc_func, amd_realloc, realloc);
+  SUITESPARSE_ASSIGN_FPTR (printf_func, amd_printf, printf);
+
+  octave_idx_type result = AMD_NAME (_order) (n_col, cidx, ridx, P,
+                                              Control, Info);
 
-              switch (result)
-                {
-                case AMD_OUT_OF_MEMORY:
-                  error ("amd: out of memory");
-                  break;
-                case AMD_INVALID:
-                  error ("amd: matrix S is corrupted");
-                  break;
-                default:
-                  {
-                    if (nargout > 1)
-                      retval(1) = xinfo;
+  switch (result)
+    {
+    case AMD_OUT_OF_MEMORY:
+      error ("amd: out of memory");
+      break;
+
+    case AMD_INVALID:
+      error ("amd: matrix S is corrupted");
+      break;
 
-                    Matrix Pout (1, n_col);
-                    for (octave_idx_type i = 0; i < n_col; i++)
-                      Pout.xelem (i) = P[i] + 1;
+    default:
+      {
+        if (nargout > 1)
+          retval(1) = xinfo;
 
-                    retval(0) = Pout;
-                  }
-                }
-            }
-        }
+        Matrix Pout (1, n_col);
+        for (octave_idx_type i = 0; i < n_col; i++)
+          Pout.xelem (i) = P[i] + 1;
+
+        retval(0) = Pout;
+      }
     }
 #else
 
--- a/libinterp/dldfcn/audiodevinfo.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/audiodevinfo.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -114,18 +114,12 @@
   PaError err = Pa_Initialize ();
 
   if (err != paNoError)
-    {
-      error ("audiodevinfo: PortAudio initialization failed");
-      return retval;
-    }
+    error ("audiodevinfo: PortAudio initialization failed");
 
   int num_devices = Pa_GetDeviceCount ();
 
   if (num_devices < 0)
-    {
-      error ("audiodevinfo: no audio device found");
-      return retval;
-    }
+    error ("audiodevinfo: no audio device found");
 
   octave_idx_type numinput = 0, numoutput = 0;
   for (int i = 0; i < num_devices; i++)
@@ -211,10 +205,7 @@
       else if (args(0).int_value () == 1)
         retval = numinput;
       else
-        {
-          error ("audiodevinfo: please specify 0 for output and 1 for input devices");
-          return retval;
-        }
+        error ("audiodevinfo: please specify 0 for output and 1 for input devices");
     }
   // Return device name when given id or id when given device name.
   else if (nargin == 2)
@@ -248,10 +239,7 @@
                 }
             }
           else
-            {
-              error ("audiodevinfo: please specify 0 for output and 1 for input devices");
-              return retval;
-            }
+            error ("audiodevinfo: please specify 0 for output and 1 for input devices");
         }
       else
         {
@@ -280,11 +268,9 @@
                 }
             }
           else
-            {
-              error ("audiodevinfo: please specify 0 for output and 1 for input devices");
-              return retval;
-            }
+            error ("audiodevinfo: please specify 0 for output and 1 for input devices");
         }
+
       if (! found)
         error ("audiodevinfo: no device meeting the specified criteria found");
     }
@@ -310,10 +296,7 @@
           if (format != 0)
             stream_parameters.sampleFormat = format;
           else
-            {
-              error ("audiodevinfo: no such bits per sample format");
-              return retval;
-            }
+            error ("audiodevinfo: no such bits per sample format");
 
           const PaDeviceInfo *device_info = Pa_GetDeviceInfo (i);
 
@@ -372,18 +355,12 @@
       if (format != 0)
         stream_parameters.sampleFormat = format;
       else
-        {
-          error ("audiodevinfo: no such bits per sample format");
-          return retval;
-        }
+        error ("audiodevinfo: no such bits per sample format");
 
       const PaDeviceInfo *device_info = Pa_GetDeviceInfo (id);
 
       if (! device_info)
-        {
-          error ("invalid audio device ID = %d", id);
-          return retval;
-        }
+        error ("audiodevinfo: invalid audio device ID = %d", id);
 
       stream_parameters.suggestedLatency
         = device_info->defaultLowInputLatency;
@@ -418,17 +395,13 @@
             }
         }
       else
-        {
-          error ("audiodevinfo: please specify 0 for output and 1 for input devices");
-          return retval;
-        }
+        error ("audiodevinfo: please specify 0 for output and 1 for input devices");
+
       retval = 0;
     }
   else
-    {
-      error ("audiodevinfo: wrong number of arguments");
-      return retval;
-    }
+    error ("audiodevinfo: wrong number of arguments");
+
 #else
 
   error ("portaudio not found on your system and thus audio functionality is not present");
@@ -562,29 +535,20 @@
   audioplayer *player = static_cast<audioplayer *> (data);
 
   if (! player)
-    {
-      error ("audio player callback function called without player");
-      return paAbort;
-    }
+    error ("audio player callback function called without player");
 
   octave_value_list retval = feval (player->octave_callback_function,
                                     ovl (static_cast<double> (frames)), 1);
 
-  if (error_state || retval.length () < 2)
-    {
-      error ("audio player callback function failed");
-      return paAbort;
-    }
+  if (retval.length () < 2)
+    error ("audio player callback function failed");
 
   const Matrix sound = retval(0).matrix_value ();
   int return_status = retval(1).int_value ();
 
-  if (error_state || (frames - sound.rows () != 0)
-      || sound.columns () < 1 || sound.columns () > 2)
-    {
-      error ("audio player callback function failed");
-      return paAbort;
-    }
+  if (frames - sound.rows () != 0 || sound.columns () < 1
+      || sound.columns () > 2)
+    error ("audio player callback function failed");
 
   // Don't multiply the audio data by scale_factor here.  Although it
   // does move the operation outside of the loops below, it also causes
@@ -662,7 +626,6 @@
 
     default:
       error ("invalid player bit depth in callback function");
-      break;
     }
 
   return return_status;
@@ -676,10 +639,7 @@
   audioplayer *player = static_cast<audioplayer *> (data);
 
   if (! player)
-    {
-      error ("audio player callback function called without player");
-      return paAbort;
-    }
+    error ("audio player callback function called without player");
 
   // Don't multiply the audio data by scale_factor here.  Although it
   // would move the operation outside of the loops below, it also causes
@@ -785,7 +745,6 @@
 
         default:
           error ("invalid player bit depth in callback function");
-          break;
         }
     }
   else if (player->get_type () == TYPE_INT8)
@@ -889,16 +848,10 @@
 audioplayer::init_fn (void)
 {
   if (Pa_Initialize () != paNoError)
-    {
-      error ("audioplayer: initialization error!");
-      return;
-    }
+    error ("audioplayer: initialization error!");
 
   if (Pa_GetDeviceCount () < 1)
-    {
-      error ("audioplayer: no audio devices found or available!");
-      return;
-    }
+    error ("audioplayer: no audio devices found or available!");
 
   int device = get_id ();
 
@@ -931,16 +884,10 @@
   // RowVector *sound_l = get_left ();
 
   if (Pa_Initialize () != paNoError)
-    {
-      error ("audioplayer: initialization error!");
-      return;
-    }
+    error ("audioplayer: initialization error!");
 
   if (Pa_GetDeviceCount () < 1)
-    {
-      error ("audioplayer: no audio devices found or available!");
-      return;
-    }
+    error ("audioplayer: no audio devices found or available!");
 
   int device = get_id ();
 
@@ -1086,7 +1033,7 @@
 unsigned int
 audioplayer::get_total_samples (void)
 {
-  return left.length ();
+  return left.numel ();
 }
 
 void
@@ -1104,7 +1051,7 @@
 void
 audioplayer::reset_end_sample (void)
 {
-  set_end_sample (left.length ());
+  set_end_sample (left.numel ());
 }
 
 void
@@ -1144,17 +1091,11 @@
   err = Pa_OpenStream (&stream, 0, &(output_parameters), get_fs (),
                        buffer_size, paClipOff, 0, 0);
   if (err != paNoError)
-    {
-      error ("audioplayer: unable to open audio playback stream");
-      return;
-    }
+    error ("audioplayer: unable to open audio playback stream");
 
   err = Pa_StartStream (stream);
   if (err != paNoError)
-    {
-      error ("audioplayer: unable to start start audio playback stream");
-      return;
-    }
+    error ("audioplayer: unable to start start audio playback stream");
 
   unsigned int start, end;
   start = get_sample_number ();
@@ -1195,17 +1136,11 @@
                          portaudio_play_callback, this);
 
   if (err != paNoError)
-    {
-      error ("audioplayer: failed to open audio playback stream");
-      return;
-    }
+    error ("audioplayer: failed to open audio playback stream");
 
   err = Pa_StartStream (stream);
   if (err != paNoError)
-    {
-      error ("audioplayer: failed to start audio playback stream");
-      return;
-    }
+    error ("audioplayer: failed to start audio playback stream");
 }
 
 void
@@ -1217,10 +1152,7 @@
   PaError err;
   err = Pa_StopStream (stream);
   if (err != paNoError)
-    {
-      error ("audiorecorder: failed to stop audio recording stream");
-      return;
-    }
+    error ("audiorecorder: failed to stop audio recording stream");
 }
 
 void
@@ -1232,10 +1164,7 @@
   PaError err;
   err = Pa_StartStream (stream);
   if (err != paNoError)
-    {
-      error ("audiorecorder: failed to start audio recording stream");
-      return;
-    }
+    error ("audiorecorder: failed to start audio recording stream");
 }
 
 PaStream *
@@ -1257,18 +1186,12 @@
     {
       err = Pa_AbortStream (get_stream ());
       if (err != paNoError)
-        {
-          error ("audioplayer: failed to stop audio playback stream");
-          return;
-        }
+        error ("audioplayer: failed to stop audio playback stream");
     }
 
   err = Pa_CloseStream (get_stream ());
   if (err != paNoError)
-    {
-      error ("audioplayer: failed to close audio playback stream");
-      return;
-    }
+    error ("audioplayer: failed to close audio playback stream");
 
   stream = 0;
 }
@@ -1282,10 +1205,7 @@
   PaError err;
   err = Pa_IsStreamActive (stream);
   if (err != 0 && err != 1)
-    {
-      error ("audiorecorder: checking stream activity status failed");
-      return false;
-    }
+    error ("audiorecorder: checking stream activity status failed");
 
   return (err == 1);
 }
@@ -1372,10 +1292,7 @@
   audiorecorder *recorder = static_cast<audiorecorder *> (data);
 
   if (! recorder)
-    {
-      error ("audio recorder callback function called without player");
-      return paAbort;
-    }
+    error ("audio recorder callback function called without player");
 
   int channels = recorder->get_channels ();
 
@@ -1457,10 +1374,7 @@
   audiorecorder *recorder = static_cast<audiorecorder *> (data);
 
   if (! recorder)
-    {
-      error ("audio recorder callback function called without player");
-      return paAbort;
-    }
+    error ("audio recorder callback function called without player");
 
   int channels = recorder->get_channels ();
 
@@ -1569,16 +1483,10 @@
 audiorecorder::init (void)
 {
   if (Pa_Initialize () != paNoError)
-    {
-      error ("audiorecorder: initialization error!");
-      return;
-    }
+    error ("audiorecorder: initialization error!");
 
   if (Pa_GetDeviceCount () < 1)
-    {
-      error ("audiorecorder: no audio devices found or available!");
-      return;
-    }
+    error ("audiorecorder: no audio devices found or available!");
 
   int device = get_id ();
 
@@ -1752,10 +1660,7 @@
   PaError err;
   err = Pa_IsStreamActive (stream);
   if (err != 0 && err != 1)
-    {
-      error ("audiorecorder: checking stream activity status failed");
-      return false;
-    }
+    error ("audiorecorder: checking stream activity status failed");
 
   return (err == 1);
 }
@@ -1785,16 +1690,11 @@
                            portaudio_record_callback, this);
     }
   if (err != paNoError)
-    {
-      error ("audiorecorder: unable to open audio recording stream");
-      return;
-    }
+    error ("audiorecorder: unable to open audio recording stream");
+
   err = Pa_StartStream (stream);
   if (err != paNoError)
-    {
-      error ("audiorecorder: unable to start audio recording stream");
-      return;
-    }
+    error ("audiorecorder: unable to start audio recording stream");
 }
 
 void
@@ -1813,17 +1713,11 @@
   err = Pa_OpenStream (&stream, &(input_parameters), 0,
                        get_fs (), buffer_size, paClipOff, 0, this);
   if (err != paNoError)
-    {
-      error ("audiorecorder: unable to open audio recording stream");
-      return;
-    }
+    error ("audiorecorder: unable to open audio recording stream");
 
   err = Pa_StartStream (stream);
   if (err != paNoError)
-    {
-      error ("audiorecorder: unable to start audio recording stream");
-      return;
-    }
+    error ("audiorecorder: unable to start audio recording stream");
 
   unsigned int frames = seconds * get_fs ();
 
@@ -1852,10 +1746,7 @@
   PaError err;
   err = Pa_StopStream (stream);
   if (err != paNoError)
-    {
-      error ("audiorecorder: unable to stop audio recording stream");
-      return;
-    }
+    error ("audiorecorder: unable to stop audio recording stream");
 }
 
 void
@@ -1867,10 +1758,7 @@
   PaError err;
   err = Pa_StartStream (stream);
   if (err != paNoError)
-    {
-      error ("audiorecorder: unable to start audio recording stream");
-      return;
-    }
+    error ("audiorecorder: unable to start audio recording stream");
 }
 
 void
@@ -1884,18 +1772,12 @@
     {
       err = Pa_AbortStream (get_stream ());
       if (err != paNoError)
-        {
-          error ("audioplayer: unable to stop audio playback stream");
-          return;
-        }
+        error ("audioplayer: unable to stop audio playback stream");
     }
 
   err = Pa_CloseStream (stream);
   if (err != paNoError)
-    {
-      error ("audiorecorder: unable to close audio recording stream");
-      return;
-    }
+    error ("audiorecorder: unable to close audio recording stream");
 
   set_sample_number (0);
   reset_end_sample ();
@@ -1942,13 +1824,7 @@
                           || args(0).is_inline_function ());
 
       if (is_function)
-        {
-          error ("audioplayer: callbacks not yet implemented");
-          return retval;
-
-          // recorder->octave_callback_function = args(0).function_value ();
-          // offset = 1;
-        }
+        error ("audioplayer: callbacks not yet implemented");
     }
 
   switch (nargin - offset)
@@ -2007,10 +1883,7 @@
   audiorecorder *recorder = get_recorder (args(0));
 
   if (! recorder)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   retval = recorder->getaudiodata ();
 
@@ -2038,10 +1911,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = recorder->get_channels ();
     }
@@ -2070,10 +1940,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = recorder->get_fs ();
     }
@@ -2102,10 +1969,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = recorder->get_id ();
     }
@@ -2134,10 +1998,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = recorder->get_nbits ();
     }
@@ -2166,10 +2027,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = recorder->get_sample_number ();
     }
@@ -2198,10 +2056,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = recorder->get_tag ();
     }
@@ -2230,10 +2085,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = recorder->get_total_samples ();
     }
@@ -2262,10 +2114,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = recorder->get_userdata ();
     }
@@ -2294,10 +2143,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = recorder->isrecording () ? true : false;
     }
@@ -2326,10 +2172,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       recorder->pause ();
     }
@@ -2356,10 +2199,7 @@
   audiorecorder *recorder = get_recorder (args(0));
 
   if (! recorder)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   recorder->recordblocking (args(1).float_value ());
 
@@ -2386,10 +2226,7 @@
   audiorecorder *recorder = get_recorder (args(0));
 
   if (! recorder)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   if (args.length () == 1)
     recorder->record ();
@@ -2425,10 +2262,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       recorder->resume ();
     }
@@ -2457,10 +2291,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       recorder->set_fs (args(1).int_value ());
     }
@@ -2489,10 +2320,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       recorder->set_tag (args(1).char_matrix_value ());
     }
@@ -2521,10 +2349,7 @@
       audiorecorder *recorder = get_recorder (args(0));
 
       if (! recorder)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       recorder->set_userdata (args(1));
     }
@@ -2551,10 +2376,7 @@
   audiorecorder *recorder = get_recorder (args(0));
 
   if (! recorder)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   recorder->stop ();
 
@@ -2582,29 +2404,18 @@
   int nargin = args.length ();
 
   if (nargin < 2 || nargin > 4)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   audioplayer* recorder = new audioplayer ();
 
   if (! recorder)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   bool is_function = (args(0).is_string () || args(0).is_function_handle ()
                       || args(0).is_inline_function ());
 
   if (is_function)
-    {
-      error ("audioplayer: callbacks not yet implemented");
-      return retval;
-
-      // recorder->set_y (args(0).function_value ());
-    }
+    error ("audioplayer: callbacks not yet implemented");
   else
     recorder->set_y (args(0));
 
@@ -2667,10 +2478,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = player->get_channels ();
     }
@@ -2699,10 +2507,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = player->get_fs ();
     }
@@ -2731,10 +2536,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = player->get_id ();
     }
@@ -2763,10 +2565,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = player->get_nbits ();
     }
@@ -2795,10 +2594,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = player->get_sample_number ();
     }
@@ -2827,10 +2623,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = player->get_tag ();
     }
@@ -2859,10 +2652,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = player->get_total_samples ();
     }
@@ -2891,10 +2681,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = player->get_userdata ();
     }
@@ -2923,10 +2710,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       retval = player->isplaying () ? true : false;
     }
@@ -2955,10 +2739,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       player->pause ();
     }
@@ -2987,10 +2768,7 @@
   audioplayer *player = get_player (args(0));
 
   if (! player)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   if (args.length () == 1)
     player->playblocking ();
@@ -3005,10 +2783,7 @@
 
           if (start > player->get_total_samples ()
               || start > end || end > player->get_total_samples ())
-            {
-              error ("audioplayer: invalid range specified for playback");
-              return retval;
-            }
+            error ("audioplayer: invalid range specified for playback");
 
           player->set_sample_number (start);
           player->set_end_sample (end);
@@ -3018,10 +2793,7 @@
           unsigned int start = args(1).int_value () - 1;
 
           if (start > player->get_total_samples ())
-            {
-              error ("audioplayer: invalid range specified for playback");
-              return retval;
-            }
+            error ("audioplayer: invalid range specified for playback");
 
           player->set_sample_number (start);
         }
@@ -3055,10 +2827,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       player->play ();
     }
@@ -3075,10 +2844,7 @@
 
           if (start > player->get_total_samples ()
               || start > end || end > player->get_total_samples ())
-            {
-              error ("audioplayer: invalid range specified for playback");
-              return retval;
-            }
+            error ("audioplayer: invalid range specified for playback");
 
           player->set_sample_number (start);
           player->set_end_sample (end);
@@ -3088,10 +2854,7 @@
           unsigned int start = args(1).int_value () - 1;
 
           if (start > player->get_total_samples ())
-            {
-              error ("audioplayer: invalid range specified for playback");
-              return retval;
-            }
+            error ("audioplayer: invalid range specified for playback");
 
           player->set_sample_number (start);
         }
@@ -3123,10 +2886,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       player->resume ();
     }
@@ -3155,10 +2915,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       player->set_fs (args(1).int_value ());
     }
@@ -3187,10 +2944,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       player->set_tag (args(1).char_matrix_value ());
     }
@@ -3219,10 +2973,7 @@
       audioplayer *player = get_player (args(0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       player->set_userdata (args(1));
     }
@@ -3251,10 +3002,7 @@
       audioplayer *player = get_player (args (0));
 
       if (! player)
-        {
-          print_usage ();
-          return retval;
-        }
+        print_usage ();
 
       player->stop ();
     }
--- a/libinterp/dldfcn/audioread.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/audioread.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -77,25 +77,16 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   std::string filename = args(0).string_value ();
 
-  if (error_state)
-    return retval;
-
   SF_INFO info;
   info.format = 0;
   SNDFILE *file = sf_open (filename.c_str (), SFM_READ, &info);
 
   if (! file)
-    {
-      error ("audioread: failed to open input file %s", filename.c_str ());
-      return retval;
-    }
+    error ("audioread: failed to open input file %s", filename.c_str ());
 
   unwind_protect frame;
 
@@ -112,24 +103,15 @@
     {
       RowVector range = args(1).row_vector_value ();
 
-      if (error_state)
-        return retval;
-
-      if (range.nelem () != 2)
-        {
-          error ("audioread: invalid specification for range of frames");
-          return retval;
-        }
+      if (range.numel () != 2)
+        error ("audioread: invalid specification for range of frames");
 
       double dstart = xisinf (range(0)) ? info.frames : range(0);
       double dend = xisinf (range(1)) ? info.frames : range(1);
 
       if (dstart < 1 || dstart > dend || dend > info.frames
           || D_NINT (dstart) != dstart || D_NINT (dend) != dend)
-        {
-          error ("audioread: invalid specification for range of frames");
-          return retval;
-        }
+        error ("audioread: invalid specification for range of frames");
 
       start = dstart - 1;
       end = dend;
@@ -159,9 +141,6 @@
       else
         type = args(1).string_value ();
 
-      if (error_state)
-        return retval;
-
       if (type == "native")
         {
           switch (info.format & SF_FORMAT_SUBMASK)
@@ -294,21 +273,12 @@
   int nargin = args.length ();
 
   if (nargin < 3)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   std::string filename = args(0).string_value ();
 
-  if (error_state)
-    return retval;
-
   Matrix audio = args(1).matrix_value ();
 
-  if (error_state)
-    return retval;
-
   double bias = 0.0;
   double scale = 1.0;
 
@@ -326,9 +296,6 @@
 
   int samplerate = args(2).int_value ();
 
-  if (error_state)
-    return retval;
-
   std::string ext;
   size_t dotpos = filename.find_last_of (".");
   if (dotpos != std::string::npos)
@@ -402,10 +369,7 @@
           else if (bits == 32)
             info.format |= SF_FORMAT_PCM_32;
           else
-            {
-              error ("audiowrite: wrong number of bits specified");
-              return retval;
-            }
+            error ("audiowrite: wrong number of bits specified");
         }
       else if (args(i).string_value () == "BitRate")
         ;
@@ -420,19 +384,13 @@
       else if (args(i).string_value () == "Comment")
         comment = args(i + 1).string_value ();
       else
-        {
-          error ("audiowrite: wrong argument name");
-          return retval;
-        }
+        error ("audiowrite: wrong argument name");
     }
 
   SNDFILE *file = sf_open (filename.c_str (), SFM_WRITE, &info);
 
   if (! file)
-    {
-      error ("audiowrite: failed to open output file %s", filename.c_str ());
-      return retval;
-    }
+    error ("audiowrite: failed to open output file %s", filename.c_str ());
 
   unwind_protect frame;
 
@@ -461,11 +419,8 @@
       sf_count_t items_written = sf_write_float (file, data+offset, chunk_size);
 
       if (items_written != chunk_size)
-        {
-          error ("audiowrite: write failed, wrote %ld of %ld items\n",
-                 items_written, chunk_size);
-          return retval;
-        }
+        error ("audiowrite: write failed, wrote %ld of %ld items\n",
+               items_written, chunk_size);
 
       total_items_written += items_written;
       offset += chunk_size;
@@ -491,25 +446,16 @@
 #ifdef HAVE_SNDFILE
 
   if (args.length () != 1)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   std::string filename = args(0).string_value ();
 
-  if (error_state)
-    return retval;
-
   SF_INFO info;
   info.format = 0;
   SNDFILE *file = sf_open (filename.c_str (), SFM_READ, &info);
 
   if (! file)
-    {
-      error ("audioinfo: failed to open file %s", filename.c_str ());
-      return retval;
-    }
+    error ("audioinfo: failed to open file %s", filename.c_str ());
 
   unwind_protect frame;
 
--- a/libinterp/dldfcn/ccolamd.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/ccolamd.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -162,7 +162,7 @@
       if (nargin > 1)
         {
           NDArray User_knobs = args(1).array_value ();
-          int nel_User_knobs = User_knobs.length ();
+          int nel_User_knobs = User_knobs.numel ();
 
           if (nel_User_knobs > 0)
             knobs[CCOLAMD_LU] = (User_knobs(0) != 0);
@@ -273,7 +273,7 @@
       if (nargin > 2)
         {
           NDArray in_cmember = args(2).array_value ();
-          octave_idx_type cslen = in_cmember.length ();
+          octave_idx_type cslen = in_cmember.numel ();
           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
@@ -287,8 +287,8 @@
                                    knobs, stats, cmember))
               {
                 CCOLAMD_NAME (_report) (stats) ;
+
                 error ("ccolamd: internal error!");
-                return retval;
               }
         }
       else
@@ -297,8 +297,8 @@
           if (! CCOLAMD_NAME () (n_row, n_col, Alen, A, p, knobs, stats, 0))
             {
               CCOLAMD_NAME (_report) (stats) ;
+
               error ("ccolamd: internal error!");
-              return retval;
             }
         }
 
@@ -422,7 +422,7 @@
       if (nargin > 1)
         {
           NDArray User_knobs = args(1).array_value ();
-          int nel_User_knobs = User_knobs.length ();
+          int nel_User_knobs = User_knobs.numel ();
 
           if (nel_User_knobs > 0)
             knobs[CCOLAMD_DENSE_ROW] = User_knobs(0);
@@ -499,10 +499,7 @@
         }
 
       if (n_row != n_col)
-        {
-          error ("csymamd: matrix S must be square");
-          return retval;
-        }
+        error ("csymamd: matrix S must be square");
 
       // Allocate workspace for symamd
       OCTAVE_LOCAL_BUFFER (octave_idx_type, perm, n_col+1);
@@ -511,7 +508,7 @@
       if (nargin > 2)
         {
           NDArray in_cmember = args(2).array_value ();
-          octave_idx_type cslen = in_cmember.length ();
+          octave_idx_type cslen = in_cmember.numel ();
           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
@@ -523,8 +520,8 @@
                                      &calloc, &free, cmember, -1))
             {
               CSYMAMD_NAME (_report) (stats) ;
+
               error ("csymamd: internal error!") ;
-              return retval;
             }
         }
       else
@@ -533,8 +530,8 @@
                                 &calloc, &free, 0, -1))
             {
               CSYMAMD_NAME (_report) (stats) ;
+
               error ("csymamd: internal error!") ;
-              return retval;
             }
         }
 
--- a/libinterp/dldfcn/chol.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/chol.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -46,6 +46,13 @@
 
 template <class CHOLT>
 static octave_value
+get_chol (const CHOLT& fact)
+{
+  return octave_value (fact.chol_matrix());
+}
+
+template <class CHOLT>
+static octave_value
 get_chol_r (const CHOLT& fact)
 {
   return octave_value (fact.chol_matrix (),
@@ -147,228 +154,171 @@
 
   if (nargin < 1 || nargin > 3 || nargout > 3
       || (! args(0).is_sparse_type () && nargout > 2))
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   int n = 1;
-  while (n < nargin && ! error_state)
+  while (n < nargin)
     {
-      std::string tmp = args(n++).string_value ();
+      std::string tmp = args(n++).xstring_value ("chol: optional arguments must be strings");
 
-      if (! error_state)
-        {
-          if (tmp.compare ("vector") == 0)
-            vecout = true;
-          else if (tmp.compare ("lower") == 0)
-            // FIXME: currently the option "lower" is handled by transposing
-            //  the matrix, factorizing it with the lapack function
-            //  DPOTRF ('U', ...) and finally transposing the factor.  It would
-            //  be more efficient to use DPOTRF ('L', ...) in this case.
-            LLt = true;
-          else if (tmp.compare ("upper") == 0)
-            LLt = false;
-          else
-            error ("chol: unexpected second or third input");
-        }
+      if (tmp == "vector")
+        vecout = true;
+      else if (tmp == "lower")
+        LLt = true;
+      else if (tmp == "upper")
+        LLt = false;
       else
-        error ("chol: expecting trailing string arguments");
+        error ("chol: optional argument must be one of \"vector\", \"lower\", or \"upper\"");
     }
 
-  if (! error_state)
-    {
-      octave_value arg = args(0);
+  octave_value arg = args(0);
 
-      octave_idx_type nr = arg.rows ();
-      octave_idx_type nc = arg.columns ();
+  octave_idx_type nr = arg.rows ();
+  octave_idx_type nc = arg.columns ();
+
+  int arg_is_empty = empty_arg ("chol", nr, nc);
 
-      int arg_is_empty = empty_arg ("chol", nr, nc);
+  if (arg_is_empty < 0)
+    return retval;
+  if (arg_is_empty > 0)
+    return octave_value (Matrix ());
 
-      if (arg_is_empty < 0)
-        return retval;
-      if (arg_is_empty > 0)
-        return octave_value (Matrix ());
+  if (arg.is_sparse_type ())
+    {
+      octave_idx_type info;
+      bool natural = (nargout != 3);
+      bool force = nargout > 1;
 
-      if (arg.is_sparse_type ())
+      if (arg.is_real_type ())
         {
-          octave_idx_type info;
-          bool natural = (nargout != 3);
-          bool force = nargout > 1;
+          SparseMatrix m = arg.sparse_matrix_value ();
 
-          if (arg.is_real_type ())
-            {
-              SparseMatrix m = arg.sparse_matrix_value ();
+          SparseCHOL fact (m, info, natural, force);
 
-              if (! error_state)
-                {
-                  SparseCHOL fact (m, info, natural, force);
-
-                  if (nargout == 3)
-                    {
-                      if (vecout)
-                        retval(2) = fact.perm ();
-                      else
-                        retval(2) = fact.Q ();
-                    }
+          if (nargout == 3)
+            {
+              if (vecout)
+                retval(2) = fact.perm ();
+              else
+                retval(2) = fact.Q ();
+            }
 
-                  if (nargout > 1 || info == 0)
-                    {
-                      retval(1) = info;
-                      if (LLt)
-                        retval(0) = fact.L ();
-                      else
-                        retval(0) = fact.R ();
-                    }
-                  else
-                    error ("chol: input matrix must be positive definite");
-                }
+          if (nargout > 1 || info == 0)
+            {
+              retval(1) = info;
+              if (LLt)
+                retval(0) = fact.L ();
+              else
+                retval(0) = fact.R ();
             }
-          else if (arg.is_complex_type ())
-            {
-              SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
-
-              if (! error_state)
-                {
-                  SparseComplexCHOL fact (m, info, natural, force);
+          else
+            error ("chol: input matrix must be positive definite");
+        }
+      else if (arg.is_complex_type ())
+        {
+          SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
 
-                  if (nargout == 3)
-                    {
-                      if (vecout)
-                        retval(2) = fact.perm ();
-                      else
-                        retval(2) = fact.Q ();
-                    }
+          SparseComplexCHOL fact (m, info, natural, force);
 
-                  if (nargout > 1 || info == 0)
-                    {
-                      retval(1) = info;
-                      if (LLt)
-                        retval(0) = fact.L ();
-                      else
-                        retval(0) = fact.R ();
-                    }
-                  else
-                    error ("chol: input matrix must be positive definite");
-                }
+          if (nargout == 3)
+            {
+              if (vecout)
+                retval(2) = fact.perm ();
+              else
+                retval(2) = fact.Q ();
+            }
+
+          if (nargout > 1 || info == 0)
+            {
+              retval(1) = info;
+              if (LLt)
+                retval(0) = fact.L ();
+              else
+                retval(0) = fact.R ();
             }
           else
-            gripe_wrong_type_arg ("chol", arg);
+            error ("chol: input matrix must be positive definite");
         }
-      else if (arg.is_single_type ())
+      else
+        gripe_wrong_type_arg ("chol", arg);
+    }
+  else if (arg.is_single_type ())
+    {
+      if (arg.is_real_type ())
         {
-          if (arg.is_real_type ())
-            {
-              FloatMatrix m = arg.float_matrix_value ();
+          FloatMatrix m = arg.float_matrix_value ();
 
-              if (! error_state)
-                {
-                  octave_idx_type info;
+          octave_idx_type info;
 
-                  FloatCHOL fact;
-                  if (LLt)
-                    fact = FloatCHOL (m.transpose (), info);
-                  else
-                    fact = FloatCHOL (m, info);
+          FloatCHOL fact;
+          fact = FloatCHOL (m, info, LLt != true);
 
-                  if (nargout == 2 || info == 0)
-                    {
-                      retval(1) = info;
-                      if (LLt)
-                        retval(0) = get_chol_l (fact);
-                      else
-                        retval(0) = get_chol_r (fact);
-                    }
-                  else
-                    error ("chol: input matrix must be positive definite");
-                }
+          if (nargout == 2 || info == 0)
+            {
+              retval(1) = info;
+              retval(0) = get_chol (fact);
             }
-          else if (arg.is_complex_type ())
-            {
-              FloatComplexMatrix m = arg.float_complex_matrix_value ();
+          else
+            error ("chol: input matrix must be positive definite");
+        }
+      else if (arg.is_complex_type ())
+        {
+          FloatComplexMatrix m = arg.float_complex_matrix_value ();
 
-              if (! error_state)
-                {
-                  octave_idx_type info;
+          octave_idx_type info;
 
-                  FloatComplexCHOL fact;
-                  if (LLt)
-                    fact = FloatComplexCHOL (m.transpose (), info);
-                  else
-                    fact = FloatComplexCHOL (m, info);
+          FloatComplexCHOL fact;
+          fact = FloatComplexCHOL (m, info, LLt != true);
 
-                  if (nargout == 2 || info == 0)
-                    {
-                      retval(1) = info;
-                      if (LLt)
-                        retval(0) = get_chol_l (fact);
-                      else
-                        retval(0) = get_chol_r (fact);
-                    }
-                  else
-                    error ("chol: input matrix must be positive definite");
-                }
+          if (nargout == 2 || info == 0)
+            {
+              retval(1) = info;
+              retval(0) = get_chol (fact);
             }
           else
-            gripe_wrong_type_arg ("chol", arg);
+            error ("chol: input matrix must be positive definite");
         }
       else
+        gripe_wrong_type_arg ("chol", arg);
+    }
+  else
+    {
+      if (arg.is_real_type ())
         {
-          if (arg.is_real_type ())
-            {
-              Matrix m = arg.matrix_value ();
-
-              if (! error_state)
-                {
-                  octave_idx_type info;
-
-                  CHOL fact;
-                  if (LLt)
-                    fact = CHOL (m.transpose (), info);
-                  else
-                    fact = CHOL (m, info);
+          Matrix m = arg.matrix_value ();
 
-                  if (nargout == 2 || info == 0)
-                    {
-                      retval(1) = info;
-                      if (LLt)
-                        retval(0) = get_chol_l (fact);
-                      else
-                        retval(0) = get_chol_r (fact);
-                    }
-                  else
-                    error ("chol: input matrix must be positive definite");
-                }
-            }
-          else if (arg.is_complex_type ())
-            {
-              ComplexMatrix m = arg.complex_matrix_value ();
+          octave_idx_type info;
+
+          CHOL fact;
+          fact = CHOL (m, info, LLt != true);
 
-              if (! error_state)
-                {
-                  octave_idx_type info;
-
-                  ComplexCHOL fact;
-                  if (LLt)
-                    fact = ComplexCHOL (m.transpose (), info);
-                  else
-                    fact = ComplexCHOL (m, info);
-
-                  if (nargout == 2 || info == 0)
-                    {
-                      retval(1) = info;
-                      if (LLt)
-                        retval(0) = get_chol_l (fact);
-                      else
-                        retval(0) = get_chol_r (fact);
-                    }
-                  else
-                    error ("chol: input matrix must be positive definite");
-                }
+          if (nargout == 2 || info == 0)
+            {
+              retval(1) = info;
+              retval(0) = get_chol (fact);
             }
           else
-            gripe_wrong_type_arg ("chol", arg);
+            error ("chol: input matrix must be positive definite");
         }
+      else if (arg.is_complex_type ())
+        {
+          ComplexMatrix m = arg.complex_matrix_value ();
+
+          octave_idx_type info;
+
+          ComplexCHOL fact;
+          fact = ComplexCHOL (m, info, LLt != true);
+
+          if (nargout == 2 || info == 0)
+            {
+              retval(1) = info;
+              retval(0) = get_chol (fact);
+            }
+          else
+            error ("chol: input matrix must be positive definite");
+        }
+      else
+        gripe_wrong_type_arg ("chol", arg);
     }
 
   return retval;
@@ -386,7 +336,8 @@
 %!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)
+%!error <optional arguments must be strings> chol (1, 2)
+%!error <optional argument must be one of "vector", "lower"> chol (1, "foobar")
 */
 
 DEFUN_DLD (cholinv, args, ,
@@ -399,124 +350,102 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
+
+  octave_value arg = args(0);
+
+  octave_idx_type nr = arg.rows ();
+  octave_idx_type nc = arg.columns ();
+
+  if (nr == 0 || nc == 0)
+    retval = Matrix ();
+  else
+    {
+      if (arg.is_sparse_type ())
+        {
+          octave_idx_type info;
 
-  if (nargin == 1)
-    {
-      octave_value arg = args(0);
+          if (arg.is_real_type ())
+            {
+              SparseMatrix m = arg.sparse_matrix_value ();
+
+              SparseCHOL chol (m, info);
+
+              if (info == 0)
+                retval = chol.inverse ();
+              else
+                error ("cholinv: A must be positive definite");
+            }
+          else if (arg.is_complex_type ())
+            {
+              SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
+
+              SparseComplexCHOL chol (m, info);
 
-      octave_idx_type nr = arg.rows ();
-      octave_idx_type nc = arg.columns ();
+              if (info == 0)
+                retval = chol.inverse ();
+              else
+                error ("cholinv: A must be positive definite");
+            }
+          else
+            gripe_wrong_type_arg ("cholinv", arg);
+        }
+      else if (arg.is_single_type ())
+        {
+          if (arg.is_real_type ())
+            {
+              FloatMatrix m = arg.float_matrix_value ();
 
-      if (nr == 0 || nc == 0)
-        retval = Matrix ();
+              octave_idx_type info;
+              FloatCHOL chol (m, info);
+              if (info == 0)
+                retval = chol.inverse ();
+              else
+                error ("cholinv: A must be positive definite");
+            }
+          else if (arg.is_complex_type ())
+            {
+              FloatComplexMatrix m = arg.float_complex_matrix_value ();
+
+              octave_idx_type info;
+              FloatComplexCHOL chol (m, info);
+              if (info == 0)
+                retval = chol.inverse ();
+              else
+                error ("cholinv: A must be positive definite");
+            }
+          else
+            gripe_wrong_type_arg ("chol", arg);
+        }
       else
         {
-          if (arg.is_sparse_type ())
+          if (arg.is_real_type ())
             {
-              octave_idx_type info;
-
-              if (arg.is_real_type ())
-                {
-                  SparseMatrix m = arg.sparse_matrix_value ();
-
-                  if (! error_state)
-                    {
-                      SparseCHOL chol (m, info);
+              Matrix m = arg.matrix_value ();
 
-                      if (info == 0)
-                        retval = chol.inverse ();
-                      else
-                        error ("cholinv: A must be positive definite");
-                    }
-                }
-              else if (arg.is_complex_type ())
-                {
-                  SparseComplexMatrix m = arg.sparse_complex_matrix_value ();
-
-                  if (! error_state)
-                    {
-                      SparseComplexCHOL chol (m, info);
-
-                      if (info == 0)
-                        retval = chol.inverse ();
-                      else
-                        error ("cholinv: A must be positive definite");
-                    }
-                }
+              octave_idx_type info;
+              CHOL chol (m, info);
+              if (info == 0)
+                retval = chol.inverse ();
               else
-                gripe_wrong_type_arg ("cholinv", arg);
+                error ("cholinv: A must be positive definite");
             }
-          else if (arg.is_single_type ())
+          else if (arg.is_complex_type ())
             {
-              if (arg.is_real_type ())
-                {
-                  FloatMatrix m = arg.float_matrix_value ();
+              ComplexMatrix m = arg.complex_matrix_value ();
 
-                  if (! error_state)
-                    {
-                      octave_idx_type info;
-                      FloatCHOL chol (m, info);
-                      if (info == 0)
-                        retval = chol.inverse ();
-                      else
-                        error ("cholinv: A must be positive definite");
-                    }
-                }
-              else if (arg.is_complex_type ())
-                {
-                  FloatComplexMatrix m = arg.float_complex_matrix_value ();
-
-                  if (! error_state)
-                    {
-                      octave_idx_type info;
-                      FloatComplexCHOL chol (m, info);
-                      if (info == 0)
-                        retval = chol.inverse ();
-                      else
-                        error ("cholinv: A must be positive definite");
-                    }
-                }
+              octave_idx_type info;
+              ComplexCHOL chol (m, info);
+              if (info == 0)
+                retval = chol.inverse ();
               else
-                gripe_wrong_type_arg ("chol", arg);
+                error ("cholinv: A must be positive definite");
             }
           else
-            {
-              if (arg.is_real_type ())
-                {
-                  Matrix m = arg.matrix_value ();
-
-                  if (! error_state)
-                    {
-                      octave_idx_type info;
-                      CHOL chol (m, info);
-                      if (info == 0)
-                        retval = chol.inverse ();
-                      else
-                        error ("cholinv: A must be positive definite");
-                    }
-                }
-              else if (arg.is_complex_type ())
-                {
-                  ComplexMatrix m = arg.complex_matrix_value ();
-
-                  if (! error_state)
-                    {
-                      octave_idx_type info;
-                      ComplexCHOL chol (m, info);
-                      if (info == 0)
-                        retval = chol.inverse ();
-                      else
-                        error ("cholinv: A must be positive definite");
-                    }
-                }
-              else
-                gripe_wrong_type_arg ("chol", arg);
-            }
+            gripe_wrong_type_arg ("chol", arg);
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -550,81 +479,71 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
+
+  octave_value arg = args(0);
+
+  octave_idx_type nr = arg.rows ();
+  octave_idx_type nc = arg.columns ();
 
-  if (nargin == 1)
+  if (nr == 0 || nc == 0)
+    retval = Matrix ();
+  else
     {
-      octave_value arg = args(0);
+      if (arg.is_sparse_type ())
+        {
+          if (arg.is_real_type ())
+            {
+              SparseMatrix r = arg.sparse_matrix_value ();
+
+              retval = chol2inv (r);
+            }
+          else if (arg.is_complex_type ())
+            {
+              SparseComplexMatrix r = arg.sparse_complex_matrix_value ();
 
-      octave_idx_type nr = arg.rows ();
-      octave_idx_type nc = arg.columns ();
+              retval = chol2inv (r);
+            }
+          else
+            gripe_wrong_type_arg ("chol2inv", arg);
+        }
+      else if (arg.is_single_type ())
+        {
+          if (arg.is_real_type ())
+            {
+              FloatMatrix r = arg.float_matrix_value ();
 
-      if (nr == 0 || nc == 0)
-        retval = Matrix ();
+              retval = chol2inv (r);
+            }
+          else if (arg.is_complex_type ())
+            {
+              FloatComplexMatrix r = arg.float_complex_matrix_value ();
+
+              retval = chol2inv (r);
+            }
+          else
+            gripe_wrong_type_arg ("chol2inv", arg);
+
+        }
       else
         {
-          if (arg.is_sparse_type ())
+          if (arg.is_real_type ())
             {
-              if (arg.is_real_type ())
-                {
-                  SparseMatrix r = arg.sparse_matrix_value ();
+              Matrix r = arg.matrix_value ();
 
-                  if (! error_state)
-                    retval = chol2inv (r);
-                }
-              else if (arg.is_complex_type ())
-                {
-                  SparseComplexMatrix r = arg.sparse_complex_matrix_value ();
-
-                  if (! error_state)
-                    retval = chol2inv (r);
-                }
-              else
-                gripe_wrong_type_arg ("chol2inv", arg);
+              retval = chol2inv (r);
             }
-          else if (arg.is_single_type ())
+          else if (arg.is_complex_type ())
             {
-              if (arg.is_real_type ())
-                {
-                  FloatMatrix r = arg.float_matrix_value ();
+              ComplexMatrix r = arg.complex_matrix_value ();
 
-                  if (! error_state)
-                    retval = chol2inv (r);
-                }
-              else if (arg.is_complex_type ())
-                {
-                  FloatComplexMatrix r = arg.float_complex_matrix_value ();
-
-                  if (! error_state)
-                    retval = chol2inv (r);
-                }
-              else
-                gripe_wrong_type_arg ("chol2inv", arg);
-
+              retval = chol2inv (r);
             }
           else
-            {
-              if (arg.is_real_type ())
-                {
-                  Matrix r = arg.matrix_value ();
-
-                  if (! error_state)
-                    retval = chol2inv (r);
-                }
-              else if (arg.is_complex_type ())
-                {
-                  ComplexMatrix r = arg.complex_matrix_value ();
-
-                  if (! error_state)
-                    retval = chol2inv (r);
-                }
-              else
-                gripe_wrong_type_arg ("chol2inv", arg);
-            }
+            gripe_wrong_type_arg ("chol2inv", arg);
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -661,15 +580,12 @@
 @seealso{chol, cholinsert, choldelete, cholshift}\n\
 @end deftypefn")
 {
-  octave_idx_type nargin = args.length ();
+  int nargin = args.length ();
 
   octave_value_list retval;
 
   if (nargin > 3 || nargin < 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value argr = args(0);
   octave_value argu = args(1);
@@ -863,15 +779,10 @@
 @seealso{chol, cholupdate, choldelete, cholshift}\n\
 @end deftypefn")
 {
-  octave_idx_type nargin = args.length ();
-
   octave_value_list retval;
 
-  if (nargin != 3)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 3)
+    print_usage ();
 
   octave_value argr = args(0);
   octave_value argj = args(1);
@@ -1113,15 +1024,10 @@
 @seealso{chol, cholupdate, cholinsert, cholshift}\n\
 @end deftypefn")
 {
-  octave_idx_type nargin = args.length ();
-
   octave_value_list retval;
 
-  if (nargin != 2)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 2)
+    print_usage ();
 
   octave_value argr = args(0);
   octave_value argj = args(1);
@@ -1250,15 +1156,10 @@
 @seealso{chol, cholupdate, cholinsert, choldelete}\n\
 @end deftypefn")
 {
-  octave_idx_type nargin = args.length ();
-
   octave_value_list retval;
 
-  if (nargin != 3)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 3)
+    print_usage ();
 
   octave_value argr = args(0);
   octave_value argi = args(1);
--- a/libinterp/dldfcn/colamd.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/colamd.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -287,90 +287,75 @@
 
   if (nargout > 2 || nargin < 1 || nargin > 2)
     print_usage ();
-  else
-    {
-      // Get knobs
-      OCTAVE_LOCAL_BUFFER (double, knobs, COLAMD_KNOBS);
-      COLAMD_NAME (_set_defaults) (knobs);
+
+  // Get knobs
+  OCTAVE_LOCAL_BUFFER (double, knobs, COLAMD_KNOBS);
+  COLAMD_NAME (_set_defaults) (knobs);
 
-      // Check for user-passed knobs
-      if (nargin == 2)
-        {
-          NDArray User_knobs = args(1).array_value ();
-          int nel_User_knobs = User_knobs.length ();
+  // Check for user-passed knobs
+  if (nargin == 2)
+    {
+      NDArray User_knobs = args(1).array_value ();
+      int nel_User_knobs = User_knobs.numel ();
 
-          if (nel_User_knobs > 0)
-            knobs[COLAMD_DENSE_ROW] = User_knobs(0);
-          if (nel_User_knobs > 1)
-            knobs[COLAMD_DENSE_COL] = User_knobs(1) ;
-          if (nel_User_knobs > 2)
-            spumoni = static_cast<int> (User_knobs(2));
-
-          // print knob settings if spumoni is set
-          if (spumoni)
-            {
+      if (nel_User_knobs > 0)
+        knobs[COLAMD_DENSE_ROW] = User_knobs(0);
+      if (nel_User_knobs > 1)
+        knobs[COLAMD_DENSE_COL] = User_knobs(1) ;
+      if (nel_User_knobs > 2)
+        spumoni = static_cast<int> (User_knobs(2));
 
-              octave_stdout << "\ncolamd version " << COLAMD_MAIN_VERSION
-                            << "." <<  COLAMD_SUB_VERSION
-                            << ", " << COLAMD_DATE << ":\n";
+      // print knob settings if spumoni is set
+      if (spumoni)
+        {
 
-              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)))"
-                              << " entries removed\n";
-              else
-                octave_stdout << "knobs(1): " << User_knobs (0)
-                              << ", only completely dense rows removed\n";
+          octave_stdout << "\ncolamd version " << COLAMD_MAIN_VERSION
+                        << "." <<  COLAMD_SUB_VERSION
+                        << ", " << COLAMD_DATE << ":\n";
 
-              if (knobs[COLAMD_DENSE_COL] >= 0)
-                octave_stdout << "knobs(2): " << User_knobs (1)
-                              << ", cols with > max (16,"
-                              << knobs[COLAMD_DENSE_COL] << "*sqrt (size(A)))"
-                              << " entries removed\n";
-              else
-                octave_stdout << "knobs(2): " << User_knobs (1)
-                              << ", only completely dense columns removed\n";
+          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)))"
+                          << " entries removed\n";
+          else
+            octave_stdout << "knobs(1): " << User_knobs (0)
+                          << ", only completely dense rows removed\n";
 
-              octave_stdout << "knobs(3): " << User_knobs (2)
-                            << ", statistics and knobs printed\n";
-
-            }
-        }
-
-      octave_idx_type n_row, n_col, nnz;
-      octave_idx_type *ridx, *cidx;
-      SparseComplexMatrix scm;
-      SparseMatrix sm;
+          if (knobs[COLAMD_DENSE_COL] >= 0)
+            octave_stdout << "knobs(2): " << User_knobs (1)
+                          << ", cols with > max (16,"
+                          << knobs[COLAMD_DENSE_COL] << "*sqrt (size(A)))"
+                          << " entries removed\n";
+          else
+            octave_stdout << "knobs(2): " << User_knobs (1)
+                          << ", only completely dense columns removed\n";
 
-      if (args(0).is_sparse_type ())
+          octave_stdout << "knobs(3): " << User_knobs (2)
+                        << ", statistics and knobs printed\n";
+
+        }
+    }
+
+  octave_idx_type n_row, n_col, nnz;
+  octave_idx_type *ridx, *cidx;
+  SparseComplexMatrix scm;
+  SparseMatrix sm;
+
+  if (args(0).is_sparse_type ())
+    {
+      if (args(0).is_complex_type ())
         {
-          if (args(0).is_complex_type ())
-            {
-              scm = args(0). sparse_complex_matrix_value ();
-              n_row = scm.rows ();
-              n_col = scm.cols ();
-              nnz = scm.nnz ();
-              ridx = scm.xridx ();
-              cidx = scm.xcidx ();
-            }
-          else
-            {
-              sm = args(0).sparse_matrix_value ();
-
-              n_row = sm.rows ();
-              n_col = sm.cols ();
-              nnz = sm.nnz ();
-              ridx = sm.xridx ();
-              cidx = sm.xcidx ();
-            }
+          scm = args(0). sparse_complex_matrix_value ();
+          n_row = scm.rows ();
+          n_col = scm.cols ();
+          nnz = scm.nnz ();
+          ridx = scm.xridx ();
+          cidx = scm.xcidx ();
         }
       else
         {
-          if (args(0).is_complex_type ())
-            sm = SparseMatrix (real (args(0).complex_matrix_value ()));
-          else
-            sm = SparseMatrix (args(0).matrix_value ());
+          sm = args(0).sparse_matrix_value ();
 
           n_row = sm.rows ();
           n_col = sm.cols ();
@@ -378,67 +363,80 @@
           ridx = sm.xridx ();
           cidx = sm.xcidx ();
         }
+    }
+  else
+    {
+      if (args(0).is_complex_type ())
+        sm = SparseMatrix (real (args(0).complex_matrix_value ()));
+      else
+        sm = SparseMatrix (args(0).matrix_value ());
 
-      // Allocate workspace for colamd
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, p, n_col+1);
-      for (octave_idx_type i = 0; i < n_col+1; i++)
-        p[i] = cidx[i];
-
-      octave_idx_type Alen = COLAMD_NAME (_recommended) (nnz, n_row, n_col);
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, A, Alen);
-      for (octave_idx_type i = 0; i < nnz; i++)
-        A[i] = ridx[i];
+      n_row = sm.rows ();
+      n_col = sm.cols ();
+      nnz = sm.nnz ();
+      ridx = sm.xridx ();
+      cidx = sm.xcidx ();
+    }
 
-      // Order the columns (destroys A)
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, stats, COLAMD_STATS);
-      if (! COLAMD_NAME () (n_row, n_col, Alen, A, p, knobs, stats))
-        {
-          COLAMD_NAME (_report) (stats) ;
-          error ("colamd: internal error!");
-          return retval;
-        }
+  // Allocate workspace for colamd
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, p, n_col+1);
+  for (octave_idx_type i = 0; i < n_col+1; i++)
+    p[i] = cidx[i];
 
-      // column elimination tree post-ordering (reuse variables)
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, colbeg, n_col + 1);
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, colend, n_col + 1);
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, etree, n_col + 1);
+  octave_idx_type Alen = COLAMD_NAME (_recommended) (nnz, n_row, n_col);
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, A, Alen);
+  for (octave_idx_type i = 0; i < nnz; i++)
+    A[i] = ridx[i];
 
-      for (octave_idx_type i = 0; i < n_col; i++)
-        {
-          colbeg[i] = cidx[p[i]];
-          colend[i] = cidx[p[i]+1];
-        }
+  // Order the columns (destroys A)
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, stats, COLAMD_STATS);
+  if (! COLAMD_NAME () (n_row, n_col, Alen, A, p, knobs, stats))
+    {
+      COLAMD_NAME (_report) (stats) ;
+
+      error ("colamd: internal error!");
+    }
 
-      coletree (ridx, colbeg, colend, etree, n_row, n_col);
-
-      // Calculate the tree post-ordering
-      tree_postorder (n_col, etree, colbeg);
+  // column elimination tree post-ordering (reuse variables)
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, colbeg, n_col + 1);
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, colend, n_col + 1);
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, etree, n_col + 1);
 
-      // 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;
+  for (octave_idx_type i = 0; i < n_col; i++)
+    {
+      colbeg[i] = cidx[p[i]];
+      colend[i] = cidx[p[i]+1];
+    }
 
-      retval(0) = out_perm;
+  coletree (ridx, colbeg, colend, etree, n_row, n_col);
+
+  // Calculate the tree post-ordering
+  tree_postorder (n_col, etree, colbeg);
 
-      // print stats if spumoni > 0
-      if (spumoni > 0)
-        COLAMD_NAME (_report) (stats) ;
+  // 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;
+
+  retval(0) = out_perm;
+
+  // print stats if spumoni > 0
+  if (spumoni > 0)
+    COLAMD_NAME (_report) (stats) ;
 
-      // Return the stats vector
-      if (nargout == 2)
-        {
-          NDArray out_stats (dim_vector (1, COLAMD_STATS));
-          for (octave_idx_type i = 0 ; i < COLAMD_STATS ; i++)
-            out_stats(i) = stats[i] ;
-          retval(1) = out_stats;
+  // Return the stats vector
+  if (nargout == 2)
+    {
+      NDArray out_stats (dim_vector (1, COLAMD_STATS));
+      for (octave_idx_type i = 0 ; i < COLAMD_STATS ; i++)
+        out_stats(i) = stats[i] ;
+      retval(1) = out_stats;
 
-          // fix stats (5) and (6), for 1-based information on
-          // jumbled matrix.  note that this correction doesn't
-          // occur if symamd returns FALSE
-          out_stats (COLAMD_INFO1) ++ ;
-          out_stats (COLAMD_INFO2) ++ ;
-        }
+      // fix stats (5) and (6), for 1-based information on
+      // jumbled matrix.  note that this correction doesn't
+      // occur if symamd returns FALSE
+      out_stats (COLAMD_INFO1) ++ ;
+      out_stats (COLAMD_INFO2) ++ ;
     }
 
 #else
@@ -524,116 +522,111 @@
 
   if (nargout > 2 || nargin < 1 || nargin > 2)
     print_usage ();
-  else
-    {
-      // Get knobs
-      OCTAVE_LOCAL_BUFFER (double, knobs, COLAMD_KNOBS);
-      COLAMD_NAME (_set_defaults) (knobs);
+
+  // Get knobs
+  OCTAVE_LOCAL_BUFFER (double, knobs, COLAMD_KNOBS);
+  COLAMD_NAME (_set_defaults) (knobs);
 
-      // Check for user-passed knobs
-      if (nargin == 2)
-        {
-          NDArray User_knobs = args(1).array_value ();
-          int nel_User_knobs = User_knobs.length ();
+  // Check for user-passed knobs
+  if (nargin == 2)
+    {
+      NDArray User_knobs = args(1).array_value ();
+      int nel_User_knobs = User_knobs.numel ();
 
-          if (nel_User_knobs > 0)
-            knobs[COLAMD_DENSE_ROW] = User_knobs(COLAMD_DENSE_ROW);
-          if (nel_User_knobs > 1)
-            spumoni = static_cast<int> (User_knobs (1));
-        }
-
-      // print knob settings if spumoni is set
-      if (spumoni > 0)
-        octave_stdout << "symamd: dense row/col fraction: "
-                      << knobs[COLAMD_DENSE_ROW] << std::endl;
+      if (nel_User_knobs > 0)
+        knobs[COLAMD_DENSE_ROW] = User_knobs(COLAMD_DENSE_ROW);
+      if (nel_User_knobs > 1)
+        spumoni = static_cast<int> (User_knobs (1));
+    }
 
-      octave_idx_type n_row, n_col;
-      octave_idx_type *ridx, *cidx;
-      SparseMatrix sm;
-      SparseComplexMatrix scm;
+  // print knob settings if spumoni is set
+  if (spumoni > 0)
+    octave_stdout << "symamd: dense row/col fraction: "
+                  << knobs[COLAMD_DENSE_ROW] << std::endl;
 
-      if (args(0).is_sparse_type ())
+  octave_idx_type n_row, n_col;
+  octave_idx_type *ridx, *cidx;
+  SparseMatrix sm;
+  SparseComplexMatrix scm;
+
+  if (args(0).is_sparse_type ())
+    {
+      if (args(0).is_complex_type ())
         {
-          if (args(0).is_complex_type ())
-            {
-              scm = args(0).sparse_complex_matrix_value ();
-              n_row = scm.rows ();
-              n_col = scm.cols ();
-              ridx = scm.xridx ();
-              cidx = scm.xcidx ();
-            }
-          else
-            {
-              sm = args(0).sparse_matrix_value ();
-              n_row = sm.rows ();
-              n_col = sm.cols ();
-              ridx = sm.xridx ();
-              cidx = sm.xcidx ();
-            }
+          scm = args(0).sparse_complex_matrix_value ();
+          n_row = scm.rows ();
+          n_col = scm.cols ();
+          ridx = scm.xridx ();
+          cidx = scm.xcidx ();
         }
       else
         {
-          if (args(0).is_complex_type ())
-            sm = SparseMatrix (real (args(0).complex_matrix_value ()));
-          else
-            sm = SparseMatrix (args(0).matrix_value ());
-
+          sm = args(0).sparse_matrix_value ();
           n_row = sm.rows ();
           n_col = sm.cols ();
           ridx = sm.xridx ();
           cidx = sm.xcidx ();
         }
+    }
+  else
+    {
+      if (args(0).is_complex_type ())
+        sm = SparseMatrix (real (args(0).complex_matrix_value ()));
+      else
+        sm = SparseMatrix (args(0).matrix_value ());
 
-      if (n_row != n_col)
-        {
-          error ("symamd: matrix S must be square");
-          return retval;
-        }
+      n_row = sm.rows ();
+      n_col = sm.cols ();
+      ridx = sm.xridx ();
+      cidx = sm.xcidx ();
+    }
 
-      // Allocate workspace for symamd
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, perm, n_col+1);
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, stats, COLAMD_STATS);
-      if (!SYMAMD_NAME () (n_col, ridx, cidx, perm,
-                           knobs, stats, &calloc, &free))
-        {
-          SYMAMD_NAME (_report) (stats) ;
-          error ("symamd: internal error!") ;
-          return retval;
-        }
+  if (n_row != n_col)
+    error ("symamd: matrix S must be square");
 
-      // column elimination tree post-ordering
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, etree, n_col + 1);
-      symetree (ridx, cidx, etree, perm, n_col);
+  // Allocate workspace for symamd
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, perm, n_col+1);
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, stats, COLAMD_STATS);
+  if (!SYMAMD_NAME () (n_col, ridx, cidx, perm,
+                       knobs, stats, &calloc, &free))
+    {
+      SYMAMD_NAME (_report) (stats) ;
 
-      // Calculate the tree post-ordering
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, post, n_col + 1);
-      tree_postorder (n_col, etree, post);
+      error ("symamd: internal error!") ;
+    }
 
-      // 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;
+  // column elimination tree post-ordering
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, etree, n_col + 1);
+  symetree (ridx, cidx, etree, perm, n_col);
 
-      retval(0) = out_perm;
+  // Calculate the tree post-ordering
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, post, n_col + 1);
+  tree_postorder (n_col, etree, post);
 
-      // print stats if spumoni > 0
-      if (spumoni > 0)
-        SYMAMD_NAME (_report) (stats) ;
+  // 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;
+
+  retval(0) = out_perm;
 
-      // Return the stats vector
-      if (nargout == 2)
-        {
-          NDArray out_stats (dim_vector (1, COLAMD_STATS));
-          for (octave_idx_type i = 0 ; i < COLAMD_STATS ; i++)
-            out_stats(i) = stats[i] ;
-          retval(1) = out_stats;
+  // print stats if spumoni > 0
+  if (spumoni > 0)
+    SYMAMD_NAME (_report) (stats) ;
 
-          // fix stats (5) and (6), for 1-based information on
-          // jumbled matrix.  note that this correction doesn't
-          // occur if symamd returns FALSE
-          out_stats (COLAMD_INFO1) ++ ;
-          out_stats (COLAMD_INFO2) ++ ;
-        }
+  // Return the stats vector
+  if (nargout == 2)
+    {
+      NDArray out_stats (dim_vector (1, COLAMD_STATS));
+      for (octave_idx_type i = 0 ; i < COLAMD_STATS ; i++)
+        out_stats(i) = stats[i] ;
+      retval(1) = out_stats;
+
+      // fix stats (5) and (6), for 1-based information on
+      // jumbled matrix.  note that this correction doesn't
+      // occur if symamd returns FALSE
+      out_stats (COLAMD_INFO1) ++ ;
+      out_stats (COLAMD_INFO2) ++ ;
     }
 
 #else
@@ -669,105 +662,90 @@
 
   if (nargout > 2 || nargin < 1 || nargin > 2)
     print_usage ();
-  else
+
+  octave_idx_type n_row = 0, n_col = 0;
+  octave_idx_type *ridx = 0, *cidx = 0;
+
+  if (args(0).is_sparse_type ())
     {
-      octave_idx_type n_row, n_col;
-      octave_idx_type *ridx, *cidx;
-      bool is_sym = true;
-      SparseMatrix sm;
-      SparseComplexMatrix scm;
-
-      if (args(0).is_sparse_type ())
+      if (args(0).is_complex_type ())
         {
-          if (args(0).is_complex_type ())
-            {
-              scm = args(0).sparse_complex_matrix_value ();
-              n_row = scm.rows ();
-              n_col = scm.cols ();
-              ridx = scm.xridx ();
-              cidx = scm.xcidx ();
-            }
-          else
-            {
-              sm = args(0).sparse_matrix_value ();
-              n_row = sm.rows ();
-              n_col = sm.cols ();
-              ridx = sm.xridx ();
-              cidx = sm.xcidx ();
-            }
+          SparseComplexMatrix scm = args(0).sparse_complex_matrix_value ();
 
+          n_row = scm.rows ();
+          n_col = scm.cols ();
+          ridx = scm.xridx ();
+          cidx = scm.xcidx ();
         }
       else
         {
-          error ("etree: S must be a sparse matrix");
-          return retval;
-        }
+          SparseMatrix sm = args(0).sparse_matrix_value ();
 
-      if (nargin == 2)
-        {
-          if (args(1).is_string ())
-            {
-              std::string str = args(1).string_value ();
-              if (str.find ("C") == 0 || str.find ("c") == 0)
-                is_sym = false;
-            }
-          else
-            {
-              error ("etree: TYP must be a string");
-              return retval;
-            }
+          n_row = sm.rows ();
+          n_col = sm.cols ();
+          ridx = sm.xridx ();
+          cidx = sm.xcidx ();
         }
 
-      // column elimination tree post-ordering (reuse variables)
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, etree, n_col + 1);
+    }
+  else
+    error ("etree: S must be a sparse matrix");
+
+  bool is_sym = true;
 
-      if (is_sym)
-        {
-          if (n_row != n_col)
-            {
-              error ("etree: S is marked as symmetric, but is not square");
-              return retval;
-            }
+  if (nargin == 2)
+    {
+      std::string str = args(1).xstring_value ("etree: TYP must be a string");
+      if (str.find ("C") == 0 || str.find ("c") == 0)
+        is_sym = false;
+    }
+
+  // column elimination tree post-ordering (reuse variables)
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, etree, n_col + 1);
 
-          symetree (ridx, cidx, etree, 0, n_col);
-        }
-      else
-        {
-          OCTAVE_LOCAL_BUFFER (octave_idx_type, colbeg, n_col);
-          OCTAVE_LOCAL_BUFFER (octave_idx_type, colend, n_col);
+  if (is_sym)
+    {
+      if (n_row != n_col)
+        error ("etree: S is marked as symmetric, but is not square");
 
-          for (octave_idx_type i = 0; i < n_col; i++)
-            {
-              colbeg[i] = cidx[i];
-              colend[i] = cidx[i+1];
-            }
+      symetree (ridx, cidx, etree, 0, n_col);
+    }
+  else
+    {
+      OCTAVE_LOCAL_BUFFER (octave_idx_type, colbeg, n_col);
+      OCTAVE_LOCAL_BUFFER (octave_idx_type, colend, n_col);
 
-          coletree (ridx, colbeg, colend, etree, n_row, n_col);
+      for (octave_idx_type i = 0; i < n_col; i++)
+        {
+          colbeg[i] = cidx[i];
+          colend[i] = cidx[i+1];
         }
 
-      NDArray tree (dim_vector (1, n_col));
-      for (octave_idx_type i = 0; i < n_col; i++)
-        // We flag a root with n_col while Matlab does it with zero
-        // Convert for matlab compatiable output
-        if (etree[i] == n_col)
-          tree(i) = 0;
-        else
-          tree(i) = etree[i] + 1;
+      coletree (ridx, colbeg, colend, etree, n_row, n_col);
+    }
 
-      retval(0) = tree;
+  NDArray tree (dim_vector (1, n_col));
+  for (octave_idx_type i = 0; i < n_col; i++)
+    // We flag a root with n_col while Matlab does it with zero
+    // Convert for matlab compatiable output
+    if (etree[i] == n_col)
+      tree(i) = 0;
+    else
+      tree(i) = etree[i] + 1;
 
-      if (nargout == 2)
-        {
-          // Calculate the tree post-ordering
-          OCTAVE_LOCAL_BUFFER (octave_idx_type, post, n_col + 1);
-          tree_postorder (n_col, etree, post);
+  retval(0) = tree;
 
-          NDArray postorder (dim_vector (1, n_col));
-          for (octave_idx_type i = 0; i < n_col; i++)
-            postorder(i) = post[i] + 1;
+  if (nargout == 2)
+    {
+      // Calculate the tree post-ordering
+      OCTAVE_LOCAL_BUFFER (octave_idx_type, post, n_col + 1);
+      tree_postorder (n_col, etree, post);
 
-          retval(1) = postorder;
-        }
+      NDArray postorder (dim_vector (1, n_col));
+      for (octave_idx_type i = 0; i < n_col; i++)
+        postorder(i) = post[i] + 1;
+
+      retval(1) = postorder;
     }
 
   return retval;
--- a/libinterp/dldfcn/config-module.awk	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/config-module.awk	Thu Dec 10 12:50:06 2015 -0800
@@ -5,10 +5,10 @@
   print "## DO NOT EDIT -- generated from module-files by config-module.awk";
   print ""
   print "EXTRA_DIST += \\"
-  print "  dldfcn/config-module.sh \\"
-  print "  dldfcn/config-module.awk \\"
-  print "  dldfcn/module-files \\"
-  print "  dldfcn/oct-qhull.h"
+  print "  libinterp/dldfcn/config-module.sh \\"
+  print "  libinterp/dldfcn/config-module.awk \\"
+  print "  libinterp/dldfcn/module-files \\"
+  print "  libinterp/dldfcn/oct-qhull.h"
   print ""
 }
 /^#.*/ { next; }
@@ -24,7 +24,7 @@
   for (i = 1; i <= nfiles; i++) {
     if (i == nfiles)
       sep = "\n";
-    printf ("  dldfcn/%s%s", files[i], sep);
+    printf ("  libinterp/dldfcn/%s%s", files[i], sep);
   }
   print "";
 
@@ -39,7 +39,7 @@
   print "## of symbolic links";
   print "";
   print "%.oct : %.la"
-  print "	$(AM_V_GEN)$(INSTALL_PROGRAM) dldfcn/.libs/$(shell $(SED) -n -e \"s/dlname='\\([^']*\\)'/\\1/p\" < $<) $@"
+  print "	$(AM_V_GEN)$(INSTALL_PROGRAM) libinterp/dldfcn/.libs/$(shell $(SED) -n -e \"s/dlname='\\([^']*\\)'/\\1/p\" < $<) $@"
   print ""
   print "else";
   print "";
@@ -51,18 +51,22 @@
     basename = files[i];
     sub (/\.cc$/, "", basename);
     print "";
-    printf ("dldfcn_%s_la_SOURCES = dldfcn/%s\n",
+    printf ("libinterp_dldfcn_%s_la_SOURCES = libinterp/dldfcn/%s\n",
             basename, files[i]);
     if (cppflags[i])
       {
-        printf ("dldfcn/%s.df: CPPFLAGS += %s\n",
+        printf ("libinterp/dldfcn/%s.df: CPPFLAGS += %s\n",
                 basename, cppflags[i]);
-        printf ("dldfcn_%s_la_CPPFLAGS = $(AM_CPPFLAGS) %s\n",
+        printf ("libinterp_dldfcn_%s_la_CPPFLAGS = $(libinterp_liboctinterp_la_CPPFLAGS) %s\n",
                 basename, cppflags[i]);
       }
-    printf ("dldfcn_%s_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED_LDFLAG) %s $(OCT_LINK_OPTS)\n",
+    printf ("libinterp_dldfcn_%s_la_CFLAGS = $(libinterp_liboctinterp_la_CFLAGS) %s\n",
+            basename, cppflags[i]);
+    printf ("libinterp_dldfcn_%s_la_CXXFLAGS = $(libinterp_liboctinterp_la_CXXFLAGS) %s\n",
+            basename, cppflags[i]);
+    printf ("libinterp_dldfcn_%s_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED_LDFLAG) %s $(OCT_LINK_OPTS) $(WARN_LDFLAGS)\n",
             basename, ldflags[i]);
-    printf ("dldfcn_%s_la_LIBADD = $(DLD_LIBOCTINTERP_LIBADD) ../liboctave/liboctave.la %s $(OCT_LINK_DEPS)\n",
+    printf ("libinterp_dldfcn_%s_la_LIBADD = $(DLD_LIBOCTINTERP_LIBADD) liboctave/liboctave.la %s $(OCT_LINK_DEPS)\n",
             basename, libraries[i]);
   }
 }
--- a/libinterp/dldfcn/convhulln.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/convhulln.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -63,10 +63,7 @@
       int maxval = std::numeric_limits<int>::max ();
 
       if (dim > maxval || n > maxval)
-        {
-          error ("%s: dimension too large for Qhull", who);
-          return false;
-        }
+        error ("%s: dimension too large for Qhull", who);
     }
 
   return true;
@@ -113,10 +110,7 @@
 
   int nargin = args.length ();
   if (nargin < 1 || nargin > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   Matrix points (args(0).matrix_value ());
   const octave_idx_type dim = points.columns ();
@@ -150,10 +144,7 @@
             options += " " + tmp(i);
         }
       else
-        {
-          error ("convhulln: OPTIONS must be a string, cell array of strings, or empty");
-          return retval;
-        }
+        error ("convhulln: OPTIONS must be a string, cell array of strings, or empty");
     }
 
   boolT ismalloc = false;
@@ -171,10 +162,7 @@
   if (outfile)
     frame.add_fcn (close_fcn, outfile);
   else
-    {
-      error ("convhulln: unable to create temporary file for output");
-      return retval;
-    }
+    error ("convhulln: unable to create temporary file for output");
 
   // qh_new_qhull command and points arguments are not const...
 
@@ -207,11 +195,8 @@
               nonsimp_seen = true;
 
               if (cmd.find ("QJ") != std::string::npos)
-                {
-                  // Should never happen with QJ.
-                  error ("convhulln: qhull failed: option 'QJ' returned non-simplicial facet");
-                  return retval;
-                }
+                // Should never happen with QJ.
+                error ("convhulln: qhull failed: option 'QJ' returned non-simplicial facet");
             }
 
           if (dim == 3)
--- a/libinterp/dldfcn/dmperm.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/dmperm.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -82,51 +82,49 @@
       csm.i = cm.xridx ();
     }
 
-  if (!error_state)
+  if (nargout <= 1 || rank)
     {
-      if (nargout <= 1 || rank)
-        {
-#if defined(CS_VER) && (CS_VER >= 2)
-          octave_idx_type *jmatch = CXSPARSE_NAME (_maxtrans) (&csm, 0);
+#if defined (CS_VER) && (CS_VER >= 2)
+      octave_idx_type *jmatch = CXSPARSE_NAME (_maxtrans) (&csm, 0);
 #else
-          octave_idx_type *jmatch = CXSPARSE_NAME (_maxtrans) (&csm);
+      octave_idx_type *jmatch = CXSPARSE_NAME (_maxtrans) (&csm);
 #endif
-          if (rank)
-            {
-              octave_idx_type r = 0;
-              for (octave_idx_type i = 0; i < nc; i++)
-                if (jmatch[nr+i] >= 0)
-                  r++;
-              retval(0) = static_cast<double>(r);
-            }
-          else
-            retval(0) = put_int (jmatch + nr, nc);
-          CXSPARSE_NAME (_free) (jmatch);
+      if (rank)
+        {
+          octave_idx_type r = 0;
+          for (octave_idx_type i = 0; i < nc; i++)
+            if (jmatch[nr+i] >= 0)
+              r++;
+          retval(0) = static_cast<double>(r);
         }
       else
-        {
-#if defined(CS_VER) && (CS_VER >= 2)
-          CXSPARSE_NAME (d) *dm = CXSPARSE_NAME(_dmperm) (&csm, 0);
+        retval(0) = put_int (jmatch + nr, nc);
+      CXSPARSE_NAME (_free) (jmatch);
+    }
+  else
+    {
+#if defined (CS_VER) && (CS_VER >= 2)
+      CXSPARSE_NAME (d) *dm = CXSPARSE_NAME(_dmperm) (&csm, 0);
 #else
-          CXSPARSE_NAME (d) *dm = CXSPARSE_NAME(_dmperm) (&csm);
+      CXSPARSE_NAME (d) *dm = CXSPARSE_NAME(_dmperm) (&csm);
 #endif
 
-          //retval(5) = put_int (dm->rr, 5);
-          //retval(4) = put_int (dm->cc, 5);
-#if defined(CS_VER) && (CS_VER >= 2)
-          retval(3) = put_int (dm->s, dm->nb+1);
-          retval(2) = put_int (dm->r, dm->nb+1);
-          retval(1) = put_int (dm->q, nc);
-          retval(0) = put_int (dm->p, nr);
+      //retval(5) = put_int (dm->rr, 5);
+      //retval(4) = put_int (dm->cc, 5);
+#if defined (CS_VER) && (CS_VER >= 2)
+      retval(3) = put_int (dm->s, dm->nb+1);
+      retval(2) = put_int (dm->r, dm->nb+1);
+      retval(1) = put_int (dm->q, nc);
+      retval(0) = put_int (dm->p, nr);
 #else
-          retval(3) = put_int (dm->S, dm->nb+1);
-          retval(2) = put_int (dm->R, dm->nb+1);
-          retval(1) = put_int (dm->Q, nc);
-          retval(0) = put_int (dm->P, nr);
+      retval(3) = put_int (dm->S, dm->nb+1);
+      retval(2) = put_int (dm->R, dm->nb+1);
+      retval(1) = put_int (dm->Q, nc);
+      retval(0) = put_int (dm->P, nr);
 #endif
-          CXSPARSE_NAME (_dfree) (dm);
-        }
+      CXSPARSE_NAME (_dfree) (dm);
     }
+
   return retval;
 }
 #endif
@@ -155,14 +153,10 @@
 @seealso{colamd, ccolamd}\n\
 @end deftypefn")
 {
-  int nargin = args.length ();
   octave_value_list retval;
 
-  if (nargin != 1)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 1)
+    print_usage ();
 
 #if HAVE_CXSPARSE
   retval = dmperm_internal (false, args(0), nargout);
@@ -204,14 +198,10 @@
 @seealso{dmperm}\n\
 @end deftypefn")
 {
-  int nargin = args.length ();
   octave_value_list retval;
 
-  if (nargin != 1)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 1)
+    print_usage ();
 
 #if HAVE_CXSPARSE
   retval = dmperm_internal (true, args(0), nargout);
--- a/libinterp/dldfcn/fftw.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/fftw.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -137,203 +137,184 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
 #if defined (HAVE_FFTW)
-  if (args(0).is_string ())
+  std::string arg0 = args(0).xstring_value ("fftw: first argument must be a string");
+
+  if (arg0 == "planner")
     {
-      std::string arg0 = args(0).string_value ();
+      if (nargin == 2)  //planner setter
+        {
+          // Use STL function to convert to lower case
+          std::transform (arg0.begin (), arg0.end (), arg0.begin (), tolower);
+
+          std::string arg1 = args(1).xstring_value ("fftw: METHOD must be a string");
 
-      if (arg0 == "planner")
-        {
-          if (nargin == 2)  //planner setter
+          std::transform (arg1.begin (), arg1.end (), arg1.begin (), tolower);
+          octave_fftw_planner::FftwMethod meth
+            = octave_fftw_planner::UNKNOWN;
+          octave_float_fftw_planner::FftwMethod methf
+            = octave_float_fftw_planner::UNKNOWN;
+
+          if (arg1 == "estimate")
+            {
+              meth = octave_fftw_planner::ESTIMATE;
+              methf = octave_float_fftw_planner::ESTIMATE;
+            }
+          else if (arg1 == "measure")
+            {
+              meth = octave_fftw_planner::MEASURE;
+              methf = octave_float_fftw_planner::MEASURE;
+            }
+          else if (arg1 == "patient")
             {
-              if (args(1).is_string ())
-                {
-                  // Use STL function to convert to lower case
-                  std::transform (arg0.begin (), arg0.end (), arg0.begin (),
-                                  tolower);
-                  std::string arg1 = args(1).string_value ();
-                  if (!error_state)
-                    {
-                      std::transform (arg1.begin (), arg1.end (),
-                                      arg1.begin (), tolower);
-                      octave_fftw_planner::FftwMethod meth
-                        = octave_fftw_planner::UNKNOWN;
-                      octave_float_fftw_planner::FftwMethod methf
-                        = octave_float_fftw_planner::UNKNOWN;
+              meth = octave_fftw_planner::PATIENT;
+              methf = octave_float_fftw_planner::PATIENT;
+            }
+          else if (arg1 == "exhaustive")
+            {
+              meth = octave_fftw_planner::EXHAUSTIVE;
+              methf = octave_float_fftw_planner::EXHAUSTIVE;
+            }
+          else if (arg1 == "hybrid")
+            {
+              meth = octave_fftw_planner::HYBRID;
+              methf = octave_float_fftw_planner::HYBRID;
+            }
+          else
+            error ("fftw: unrecognized planner METHOD");
+
+          meth = octave_fftw_planner::method (meth);
+          octave_float_fftw_planner::method (methf);
+
+          if (meth == octave_fftw_planner::MEASURE)
+            retval = octave_value ("measure");
+          else if (meth == octave_fftw_planner::PATIENT)
+            retval = octave_value ("patient");
+          else if (meth == octave_fftw_planner::EXHAUSTIVE)
+            retval = octave_value ("exhaustive");
+          else if (meth == octave_fftw_planner::HYBRID)
+            retval = octave_value ("hybrid");
+          else
+            retval = octave_value ("estimate");
+        }
+      else //planner getter
+        {
+          octave_fftw_planner::FftwMethod meth =
+            octave_fftw_planner::method ();
 
-                      if (arg1 == "estimate")
-                        {
-                          meth = octave_fftw_planner::ESTIMATE;
-                          methf = octave_float_fftw_planner::ESTIMATE;
-                        }
-                      else if (arg1 == "measure")
-                        {
-                          meth = octave_fftw_planner::MEASURE;
-                          methf = octave_float_fftw_planner::MEASURE;
-                        }
-                      else if (arg1 == "patient")
-                        {
-                          meth = octave_fftw_planner::PATIENT;
-                          methf = octave_float_fftw_planner::PATIENT;
-                        }
-                      else if (arg1 == "exhaustive")
-                        {
-                          meth = octave_fftw_planner::EXHAUSTIVE;
-                          methf = octave_float_fftw_planner::EXHAUSTIVE;
-                        }
-                      else if (arg1 == "hybrid")
-                        {
-                          meth = octave_fftw_planner::HYBRID;
-                          methf = octave_float_fftw_planner::HYBRID;
-                        }
-                      else
-                        error ("fftw: unrecognized planner METHOD");
+          if (meth == octave_fftw_planner::MEASURE)
+            retval = octave_value ("measure");
+          else if (meth == octave_fftw_planner::PATIENT)
+            retval = octave_value ("patient");
+          else if (meth == octave_fftw_planner::EXHAUSTIVE)
+            retval = octave_value ("exhaustive");
+          else if (meth == octave_fftw_planner::HYBRID)
+            retval = octave_value ("hybrid");
+          else
+            retval = octave_value ("estimate");
+        }
+    }
+  else if (arg0 == "dwisdom")
+    {
+      if (nargin == 2)  //dwisdom setter
+        {
+          // Use STL function to convert to lower case
+          std::transform (arg0.begin (), arg0.end (), arg0.begin (),
+                          tolower);
+
+          std::string arg1 = args(1).xstring_value ("fftw: WISDOM must be a string");
+
+          char *str = fftw_export_wisdom_to_string ();
+
+          if (arg1.length () < 1)
+            fftw_forget_wisdom ();
+          else if (! fftw_import_wisdom_from_string (arg1.c_str ()))
+            error ("fftw: could not import supplied WISDOM");
+
+          retval = octave_value (std::string (str));
+
+          // FIXME: need to free string even if there is an
+          // exception.
+          free (str);
+        }
+      else //dwisdom getter
+        {
+          char *str = fftw_export_wisdom_to_string ();
+          retval = octave_value (std::string (str));
 
-                      if (!error_state)
-                        {
-                          meth = octave_fftw_planner::method (meth);
-                          octave_float_fftw_planner::method (methf);
+          // FIXME: need to free string even if there is an
+          // exception.
+          free (str);
+        }
+    }
+  else if (arg0 == "swisdom")
+    {
+      //swisdom uses fftwf_ functions (float), dwisdom fftw_ (real)
+      if (nargin == 2)  //swisdom setter
+        {
+          // Use STL function to convert to lower case
+          std::transform (arg0.begin (), arg0.end (), arg0.begin (),
+                          tolower);
+
+          std::string arg1 = args(1).xstring_value ("fftw: WISDOM must be a string");
+
+          char *str = fftwf_export_wisdom_to_string ();
+
+          if (arg1.length () < 1)
+            fftwf_forget_wisdom ();
+          else if (! fftwf_import_wisdom_from_string (arg1.c_str ()))
+            error ("fftw: could not import supplied WISDOM");
+
+          retval = octave_value (std::string (str));
 
-                          if (meth == octave_fftw_planner::MEASURE)
-                            retval = octave_value ("measure");
-                          else if (meth == octave_fftw_planner::PATIENT)
-                            retval = octave_value ("patient");
-                          else if (meth == octave_fftw_planner::EXHAUSTIVE)
-                            retval = octave_value ("exhaustive");
-                          else if (meth == octave_fftw_planner::HYBRID)
-                            retval = octave_value ("hybrid");
-                          else
-                            retval = octave_value ("estimate");
-                        }
-                    }
+          // FIXME: need to free string even if there is an
+          // exception.
+          free (str);
+        }
+      else //swisdom getter
+        {
+          char *str = fftwf_export_wisdom_to_string ();
+          retval = octave_value (std::string (str));
+
+          // FIXME: need to free string even if there is an
+          // exception.
+          free (str);
+        }
+    }
+  else if (arg0 == "threads")
+    {
+      if (nargin == 2)  //threads setter
+        {
+          if (args(1).is_real_scalar ())
+            {
+              int nthreads = args(1).int_value();
+              if (nthreads >= 1)
+                {
+#if defined (HAVE_FFTW3_THREADS)
+                  octave_fftw_planner::threads (nthreads);
+#else
+                  gripe_disabled_feature ("fftw", "multithreaded FFTW");
+#endif
+#if defined (HAVE_FFTW3F_THREADS)
+                  octave_float_fftw_planner::threads (nthreads);
+#else
+                  gripe_disabled_feature ("fftw", "multithreaded FFTW");
+#endif
                 }
               else
-                error ("fftw: planner expects a string value as METHOD");
-            }
-          else //planner getter
-            {
-              octave_fftw_planner::FftwMethod meth =
-                octave_fftw_planner::method ();
-
-              if (meth == octave_fftw_planner::MEASURE)
-                retval = octave_value ("measure");
-              else if (meth == octave_fftw_planner::PATIENT)
-                retval = octave_value ("patient");
-              else if (meth == octave_fftw_planner::EXHAUSTIVE)
-                retval = octave_value ("exhaustive");
-              else if (meth == octave_fftw_planner::HYBRID)
-                retval = octave_value ("hybrid");
-              else
-                retval = octave_value ("estimate");
+                error ("fftw: number of threads must be >=1");
             }
-        }
-      else if (arg0 == "dwisdom")
-        {
-          if (nargin == 2)  //dwisdom setter
-            {
-              if (args(1).is_string ())
-                {
-                  // Use STL function to convert to lower case
-                  std::transform (arg0.begin (), arg0.end (), arg0.begin (),
-                                  tolower);
-                  std::string arg1 = args(1).string_value ();
-                  if (!error_state)
-                    {
-                      char *str = fftw_export_wisdom_to_string ();
-
-                      if (arg1.length () < 1)
-                        fftw_forget_wisdom ();
-                      else if (! fftw_import_wisdom_from_string (arg1.c_str ()))
-                        error ("fftw: could not import supplied WISDOM");
-
-                      if (!error_state)
-                        retval = octave_value (std::string (str));
-
-                      free (str);
-                    }
-                }
-            }
-          else //dwisdom getter
-            {
-              char *str = fftw_export_wisdom_to_string ();
-              retval = octave_value (std::string (str));
-              free (str);
-            }
+          else
+            error ("fftw: setting threads needs one integer argument");
         }
-      else if (arg0 == "swisdom")
-        {
-          //swisdom uses fftwf_ functions (float), dwisdom fftw_ (real)
-          if (nargin == 2)  //swisdom setter
-            {
-              if (args(1).is_string ())
-                {
-                  // Use STL function to convert to lower case
-                  std::transform (arg0.begin (), arg0.end (), arg0.begin (),
-                                  tolower);
-                  std::string arg1 = args(1).string_value ();
-                  if (!error_state)
-                    {
-                      char *str = fftwf_export_wisdom_to_string ();
-
-                      if (arg1.length () < 1)
-                        fftwf_forget_wisdom ();
-                      else if (! fftwf_import_wisdom_from_string (arg1.c_str ()))
-                        error ("fftw: could not import supplied WISDOM");
-
-                      if (!error_state)
-                        retval = octave_value (std::string (str));
-
-                      free (str);
-                    }
-                }
-            }
-          else //swisdom getter
-            {
-              char *str = fftwf_export_wisdom_to_string ();
-              retval = octave_value (std::string (str));
-              free (str);
-            }
-        }
-      else if (arg0 == "threads")
-        {
-          if (nargin == 2)  //threads setter
-            {
-              if (args(1).is_real_scalar ())
-                {
-                  int nthreads = args(1).int_value();
-                  if (nthreads >= 1)
-                    {
+      else //threads getter
 #if defined (HAVE_FFTW3_THREADS)
-                      octave_fftw_planner::threads (nthreads);
+        retval = octave_value (octave_fftw_planner::threads());
 #else
-                      gripe_disabled_feature ("fftw", "multithreaded FFTW");
-#endif
-#if defined (HAVE_FFTW3F_THREADS)
-                      octave_float_fftw_planner::threads (nthreads);
-#else
-                      gripe_disabled_feature ("fftw", "multithreaded FFTW");
+      retval = 1;
 #endif
-                    }
-                  else
-                    error ("fftw: number of threads must be >=1");
-                }
-              else
-                error ("fftw: setting threads needs one integer argument");
-            }
-          else //threads getter
-#if defined (HAVE_FFTW3_THREADS)
-            retval = octave_value (octave_fftw_planner::threads());
-#else
-            retval = 1;
-#endif
-        }
-      else
-        error ("fftw: unrecognized argument");
     }
   else
     error ("fftw: unrecognized argument");
--- a/libinterp/dldfcn/oct-qhull.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/oct-qhull.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_qhull_h)
+#if ! defined (octave_oct_qhull_h)
 #define octave_oct_qhull_h 1
 
 #include <cstdio>
--- a/libinterp/dldfcn/qr.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/qr.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -204,10 +204,7 @@
   int nargin = args.length ();
 
   if (nargin < 1 || nargin > (args(0).is_sparse_type () ? 3 : 2))
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value arg = args(0);
 
@@ -240,52 +237,45 @@
             is_cmplx = true;
         }
 
-      if (!error_state)
+      if (have_b && nargout < 2)
+        error ("qr: incorrect number of output arguments");
+      else if (is_cmplx)
         {
-          if (have_b && nargout < 2)
-            error ("qr: incorrect number of output arguments");
-          else if (is_cmplx)
+          SparseComplexQR q (arg.sparse_complex_matrix_value ());
+
+          if (have_b > 0)
             {
-              SparseComplexQR q (arg.sparse_complex_matrix_value ());
-              if (!error_state)
-                {
-                  if (have_b > 0)
-                    {
-                      retval(1) = q.R (economy);
-                      retval(0) = q.C (args(have_b).complex_matrix_value ());
-                      if (arg.rows () < arg.columns ())
-                        warning ("qr: non minimum norm solution for under-determined problem");
-                    }
-                  else if (nargout > 1)
-                    {
-                      retval(1) = q.R (economy);
-                      retval(0) = q.Q ();
-                    }
-                  else
-                    retval(0) = q.R (economy);
-                }
+              retval(1) = q.R (economy);
+              retval(0) = q.C (args(have_b).complex_matrix_value ());
+              if (arg.rows () < arg.columns ())
+                warning ("qr: non minimum norm solution for under-determined problem");
+            }
+          else if (nargout > 1)
+            {
+              retval(1) = q.R (economy);
+              retval(0) = q.Q ();
             }
           else
+            retval(0) = q.R (economy);
+        }
+      else
+        {
+          SparseQR q (arg.sparse_matrix_value ());
+
+          if (have_b > 0)
             {
-              SparseQR q (arg.sparse_matrix_value ());
-              if (!error_state)
-                {
-                  if (have_b > 0)
-                    {
-                      retval(1) = q.R (economy);
-                      retval(0) = q.C (args(have_b).matrix_value ());
-                      if (args(0).rows () < args(0).columns ())
-                        warning ("qr: non minimum norm solution for under-determined problem");
-                    }
-                  else if (nargout > 1)
-                    {
-                      retval(1) = q.R (economy);
-                      retval(0) = q.Q ();
-                    }
-                  else
-                    retval(0) = q.R (economy);
-                }
+              retval(1) = q.R (economy);
+              retval(0) = q.C (args(have_b).matrix_value ());
+              if (args(0).rows () < args(0).columns ())
+                warning ("qr: non minimum norm solution for under-determined problem");
             }
+          else if (nargout > 1)
+            {
+              retval(1) = q.R (economy);
+              retval(0) = q.Q ();
+            }
+          else
+            retval(0) = q.R (economy);
         }
     }
   else
@@ -300,76 +290,70 @@
             {
               FloatMatrix m = arg.float_matrix_value ();
 
-              if (! error_state)
+              switch (nargout)
                 {
-                  switch (nargout)
-                    {
-                    case 0:
-                    case 1:
-                      {
-                        FloatQR fact (m, type);
-                        retval(0) = fact.R ();
-                      }
-                      break;
+                case 0:
+                case 1:
+                  {
+                    FloatQR fact (m, type);
+                    retval(0) = fact.R ();
+                  }
+                  break;
 
-                    case 2:
-                      {
-                        FloatQR fact (m, type);
-                        retval(1) = get_qr_r (fact);
-                        retval(0) = fact.Q ();
-                      }
-                      break;
+                case 2:
+                  {
+                    FloatQR fact (m, type);
+                    retval(1) = get_qr_r (fact);
+                    retval(0) = fact.Q ();
+                  }
+                  break;
 
-                    default:
-                      {
-                        FloatQRP fact (m, type);
-                        if (type == QR::economy)
-                          retval(2) = fact.Pvec ();
-                        else
-                          retval(2) = fact.P ();
-                        retval(1) = get_qr_r (fact);
-                        retval(0) = fact.Q ();
-                      }
-                      break;
-                    }
+                default:
+                  {
+                    FloatQRP fact (m, type);
+                    if (type == QR::economy)
+                      retval(2) = fact.Pvec ();
+                    else
+                      retval(2) = fact.P ();
+                    retval(1) = get_qr_r (fact);
+                    retval(0) = fact.Q ();
+                  }
+                  break;
                 }
             }
           else if (arg.is_complex_type ())
             {
               FloatComplexMatrix m = arg.float_complex_matrix_value ();
 
-              if (! error_state)
+              switch (nargout)
                 {
-                  switch (nargout)
-                    {
-                    case 0:
-                    case 1:
-                      {
-                        FloatComplexQR fact (m, type);
-                        retval(0) = fact.R ();
-                      }
-                      break;
+                case 0:
+                case 1:
+                  {
+                    FloatComplexQR fact (m, type);
+                    retval(0) = fact.R ();
+                  }
+                  break;
 
-                    case 2:
-                      {
-                        FloatComplexQR fact (m, type);
-                        retval(1) = get_qr_r (fact);
-                        retval(0) = fact.Q ();
-                      }
-                      break;
+                case 2:
+                  {
+                    FloatComplexQR fact (m, type);
+                    retval(1) = get_qr_r (fact);
+                    retval(0) = fact.Q ();
+                  }
+                  break;
 
-                    default:
-                      {
-                        FloatComplexQRP fact (m, type);
-                        if (type == QR::economy)
-                          retval(2) = fact.Pvec ();
-                        else
-                          retval(2) = fact.P ();
-                        retval(1) = get_qr_r (fact);
-                        retval(0) = fact.Q ();
-                      }
-                      break;
-                    }
+                default:
+                  {
+                    FloatComplexQRP fact (m, type);
+                    if (type == QR::economy)
+                      retval(2) = fact.Pvec ();
+                    else
+                      retval(2) = fact.P ();
+                    retval(1) = get_qr_r (fact);
+                    retval(0) = fact.Q ();
+                  }
+                  break;
                 }
             }
         }
@@ -379,76 +363,70 @@
             {
               Matrix m = arg.matrix_value ();
 
-              if (! error_state)
+              switch (nargout)
                 {
-                  switch (nargout)
-                    {
-                    case 0:
-                    case 1:
-                      {
-                        QR fact (m, type);
-                        retval(0) = fact.R ();
-                      }
-                      break;
+                case 0:
+                case 1:
+                  {
+                    QR fact (m, type);
+                    retval(0) = fact.R ();
+                  }
+                  break;
 
-                    case 2:
-                      {
-                        QR fact (m, type);
-                        retval(1) = get_qr_r (fact);
-                        retval(0) = fact.Q ();
-                      }
-                      break;
+                case 2:
+                  {
+                    QR fact (m, type);
+                    retval(1) = get_qr_r (fact);
+                    retval(0) = fact.Q ();
+                  }
+                  break;
 
-                    default:
-                      {
-                        QRP fact (m, type);
-                        if (type == QR::economy)
-                          retval(2) = fact.Pvec ();
-                        else
-                          retval(2) = fact.P ();
-                        retval(1) = get_qr_r (fact);
-                        retval(0) = fact.Q ();
-                      }
-                      break;
-                    }
+                default:
+                  {
+                    QRP fact (m, type);
+                    if (type == QR::economy)
+                      retval(2) = fact.Pvec ();
+                    else
+                      retval(2) = fact.P ();
+                    retval(1) = get_qr_r (fact);
+                    retval(0) = fact.Q ();
+                  }
+                  break;
                 }
             }
           else if (arg.is_complex_type ())
             {
               ComplexMatrix m = arg.complex_matrix_value ();
 
-              if (! error_state)
+              switch (nargout)
                 {
-                  switch (nargout)
-                    {
-                    case 0:
-                    case 1:
-                      {
-                        ComplexQR fact (m, type);
-                        retval(0) = fact.R ();
-                      }
-                      break;
+                case 0:
+                case 1:
+                  {
+                    ComplexQR fact (m, type);
+                    retval(0) = fact.R ();
+                  }
+                  break;
 
-                    case 2:
-                      {
-                        ComplexQR fact (m, type);
-                        retval(1) = get_qr_r (fact);
-                        retval(0) = fact.Q ();
-                      }
-                      break;
+                case 2:
+                  {
+                    ComplexQR fact (m, type);
+                    retval(1) = get_qr_r (fact);
+                    retval(0) = fact.Q ();
+                  }
+                  break;
 
-                    default:
-                      {
-                        ComplexQRP fact (m, type);
-                        if (type == QR::economy)
-                          retval(2) = fact.Pvec ();
-                        else
-                          retval(2) = fact.P ();
-                        retval(1) = get_qr_r (fact);
-                        retval(0) = fact.Q ();
-                      }
-                      break;
-                    }
+                default:
+                  {
+                    ComplexQRP fact (m, type);
+                    if (type == QR::economy)
+                      retval(2) = fact.Pvec ();
+                    else
+                      retval(2) = fact.P ();
+                    retval(1) = get_qr_r (fact);
+                    retval(0) = fact.Q ();
+                  }
+                  break;
                 }
             }
           else
@@ -778,14 +756,10 @@
 @seealso{qr, qrinsert, qrdelete, qrshift}\n\
 @end deftypefn")
 {
-  octave_idx_type nargin = args.length ();
   octave_value_list retval;
 
-  if (nargin != 4)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 4)
+    print_usage ();
 
   octave_value argq = args(0);
   octave_value argr = args(1);
@@ -966,14 +940,12 @@
 @seealso{qr, qrupdate, qrdelete, qrshift}\n\
 @end deftypefn")
 {
-  octave_idx_type nargin = args.length ();
   octave_value_list retval;
 
+  int nargin = args.length ();
+
   if (nargin < 4 || nargin > 5)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value argq = args(0);
   octave_value argr = args(1);
@@ -1185,14 +1157,11 @@
 @seealso{qr, qrupdate, qrinsert, qrshift}\n\
 @end deftypefn")
 {
-  octave_idx_type nargin = args.length ();
   octave_value_list retval;
+  int nargin = args.length ();
 
   if (nargin < 3 || nargin > 4)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   octave_value argq = args(0);
   octave_value argr = args(1);
@@ -1437,14 +1406,10 @@
 @seealso{qr, qrupdate, qrinsert, qrdelete}\n\
 @end deftypefn")
 {
-  octave_idx_type nargin = args.length ();
   octave_value_list retval;
 
-  if (nargin != 4)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 4)
+    print_usage ();
 
   octave_value argq = args(0);
   octave_value argr = args(1);
--- a/libinterp/dldfcn/symbfact.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/symbfact.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -99,11 +99,8 @@
   octave_value_list retval;
   int nargin = args.length ();
 
-  if (nargin < 1  || nargin > 3 || nargout > 5)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (nargin < 1 || nargin > 3 || nargout > 5)
+    print_usage ();
 
 #ifdef HAVE_CHOLMOD
 
@@ -198,165 +195,152 @@
   if (A->stype && A->nrow != A->ncol)
     error ("symbfact: S must be a square matrix");
 
-  if (!error_state)
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, Parent, n);
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, Post, n);
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, ColCount, n);
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, First, n);
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, Level, n);
+
+  cholmod_sparse *F = CHOLMOD_NAME(transpose) (A, 0, cm);
+  cholmod_sparse *Aup, *Alo;
+
+  if (A->stype == 1 || coletree)
     {
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, Parent, n);
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, Post, n);
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, ColCount, n);
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, First, n);
-      OCTAVE_LOCAL_BUFFER (octave_idx_type, Level, n);
+      Aup = A ;
+      Alo = F ;
+    }
+  else
+    {
+      Aup = F ;
+      Alo = A ;
+    }
+
+  CHOLMOD_NAME(etree) (Aup, Parent, cm);
+
+  if (cm->status < CHOLMOD_OK)
+    error ("symbfact: matrix corrupted");
 
-      cholmod_sparse *F = CHOLMOD_NAME(transpose) (A, 0, cm);
-      cholmod_sparse *Aup, *Alo;
+  if (CHOLMOD_NAME(postorder) (Parent, n, 0, Post, cm) != n)
+    error ("symbfact: postorder failed");
+
+  CHOLMOD_NAME(rowcolcounts) (Alo, 0, 0, Parent, Post, 0,
+                              ColCount, First, Level, cm);
+
+  if (cm->status < CHOLMOD_OK)
+    error ("symbfact: matrix corrupted");
+
+  if (nargout > 4)
+    {
+      cholmod_sparse *A1, *A2;
 
-      if (A->stype == 1 || coletree)
+      if (A->stype == 1)
+        {
+          A1 = A;
+          A2 = 0;
+        }
+      else if (A->stype == -1)
         {
-          Aup = A ;
-          Alo = F ;
+          A1 = F;
+          A2 = 0;
+        }
+      else if (coletree)
+        {
+          A1 = F;
+          A2 = A;
         }
       else
         {
-          Aup = F ;
-          Alo = A ;
-        }
-
-      CHOLMOD_NAME(etree) (Aup, Parent, cm);
-
-      if (cm->status < CHOLMOD_OK)
-        {
-          error ("matrix corrupted");
-          goto symbfact_error;
-        }
-
-      if (CHOLMOD_NAME(postorder) (Parent, n, 0, Post, cm) != n)
-        {
-          error ("postorder failed");
-          goto symbfact_error;
-        }
-
-      CHOLMOD_NAME(rowcolcounts) (Alo, 0, 0, Parent, Post, 0,
-                                  ColCount, First, Level, cm);
-
-      if (cm->status < CHOLMOD_OK)
-        {
-          error ("matrix corrupted");
-          goto symbfact_error;
+          A1 = A;
+          A2 = F;
         }
 
-      if (nargout > 4)
-        {
-          cholmod_sparse *A1, *A2;
-
-          if (A->stype == 1)
-            {
-              A1 = A;
-              A2 = 0;
-            }
-          else if (A->stype == -1)
-            {
-              A1 = F;
-              A2 = 0;
-            }
-          else if (coletree)
-            {
-              A1 = F;
-              A2 = A;
-            }
-          else
-            {
-              A1 = A;
-              A2 = F;
-            }
-
-          // count the total number of entries in L
-          octave_idx_type lnz = 0 ;
-          for (octave_idx_type j = 0 ; j < n ; j++)
-            lnz += ColCount[j];
+      // count the total number of entries in L
+      octave_idx_type lnz = 0 ;
+      for (octave_idx_type j = 0 ; j < n ; j++)
+        lnz += ColCount[j];
 
 
-          // allocate the output matrix L (pattern-only)
-          SparseBoolMatrix L (n, n, lnz);
+      // allocate the output matrix L (pattern-only)
+      SparseBoolMatrix L (n, n, lnz);
 
-          // initialize column pointers
-          lnz = 0;
-          for (octave_idx_type j = 0 ; j < n ; j++)
-            {
-              L.xcidx(j) = lnz;
-              lnz += ColCount[j];
-            }
-          L.xcidx(n) = lnz;
+      // initialize column pointers
+      lnz = 0;
+      for (octave_idx_type j = 0 ; j < n ; j++)
+        {
+          L.xcidx(j) = lnz;
+          lnz += ColCount[j];
+        }
+      L.xcidx(n) = lnz;
 
 
-          /* 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);
+      /* 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);
 
-          // get workspace for computing one row of L
-          cholmod_sparse *R
-            = CHOLMOD_NAME (allocate_sparse) (n, 1, n, false, true,
-                                              0, CHOLMOD_PATTERN, cm);
-          octave_idx_type *Rp = static_cast<octave_idx_type *>(R->p);
-          octave_idx_type *Ri = static_cast<octave_idx_type *>(R->i);
+      // get workspace for computing one row of L
+      cholmod_sparse *R
+        = CHOLMOD_NAME (allocate_sparse) (n, 1, n, false, true,
+                                          0, CHOLMOD_PATTERN, cm);
+      octave_idx_type *Rp = static_cast<octave_idx_type *>(R->p);
+      octave_idx_type *Ri = static_cast<octave_idx_type *>(R->i);
 
-          // compute L one row at a time
-          for (octave_idx_type k = 0 ; k < n ; k++)
-            {
-              // get the kth row of L and store in the columns of L
-              CHOLMOD_NAME (row_subtree) (A1, A2, k, Parent, R, cm) ;
-              for (octave_idx_type p = 0 ; p < Rp[1] ; p++)
-                L.xridx (W[Ri[p]]++) = k ;
+      // compute L one row at a time
+      for (octave_idx_type k = 0 ; k < n ; k++)
+        {
+          // get the kth row of L and store in the columns of L
+          CHOLMOD_NAME (row_subtree) (A1, A2, k, Parent, R, cm) ;
+          for (octave_idx_type p = 0 ; p < Rp[1] ; p++)
+            L.xridx (W[Ri[p]]++) = k ;
 
-              // add the diagonal entry
-              L.xridx (W[k]++) = k ;
-            }
+          // add the diagonal entry
+          L.xridx (W[k]++) = k ;
+        }
 
-          // free workspace
-          CHOLMOD_NAME (free_sparse) (&R, cm) ;
+      // free workspace
+      CHOLMOD_NAME (free_sparse) (&R, cm) ;
 
 
-          // transpose L to get R, or leave as is
-          if (nargin < 3)
-            L = L.transpose ();
-
-          // fill numerical values of L with one's
-          for (octave_idx_type p = 0 ; p < lnz ; p++)
-            L.xdata(p) = true;
+      // transpose L to get R, or leave as is
+      if (nargin < 3)
+        L = L.transpose ();
 
-          retval(4) = L;
-        }
-
-      ColumnVector tmp (n);
-      if (nargout > 3)
-        {
-          for (octave_idx_type i = 0; i < n; i++)
-            tmp(i) = Post[i] + 1;
-          retval(3) = tmp;
-        }
+      // fill numerical values of L with one's
+      for (octave_idx_type p = 0 ; p < lnz ; p++)
+        L.xdata(p) = true;
 
-      if (nargout > 2)
-        {
-          for (octave_idx_type i = 0; i < n; i++)
-            tmp(i) = Parent[i] + 1;
-          retval(2) = tmp;
-        }
+      retval(4) = L;
+    }
 
-      if (nargout > 1)
-        {
-          /* compute the elimination tree height */
-          octave_idx_type height = 0 ;
-          for (int i = 0 ; i < n ; i++)
-            height = (height > Level[i] ? height : Level[i]);
-          height++ ;
-          retval(1) = static_cast<double> (height);
-        }
-
+  ColumnVector tmp (n);
+  if (nargout > 3)
+    {
       for (octave_idx_type i = 0; i < n; i++)
-        tmp(i) = ColCount[i];
-      retval(0) = tmp;
+        tmp(i) = Post[i] + 1;
+      retval(3) = tmp;
     }
 
-symbfact_error:
+  if (nargout > 2)
+    {
+      for (octave_idx_type i = 0; i < n; i++)
+        tmp(i) = Parent[i] + 1;
+      retval(2) = tmp;
+    }
+
+  if (nargout > 1)
+    {
+      /* compute the elimination tree height */
+      octave_idx_type height = 0 ;
+      for (int i = 0 ; i < n ; i++)
+        height = (height > Level[i] ? height : Level[i]);
+      height++ ;
+      retval(1) = static_cast<double> (height);
+    }
+
+  for (octave_idx_type i = 0; i < n; i++)
+    tmp(i) = ColCount[i];
+  retval(0) = tmp;
+
 #else
   error ("symbfact: not available in this version of Octave");
 #endif
--- a/libinterp/dldfcn/symrcm.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/dldfcn/symrcm.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -438,13 +438,9 @@
 @end deftypefn")
 {
   octave_value retval;
-  int nargin = args.length ();
 
-  if (nargin != 1)
-    {
-      print_usage ();
-      return retval;
-    }
+  if (args.length () != 1)
+    print_usage ();
 
   octave_value arg = args(0);
 
@@ -469,9 +465,6 @@
       ridx = Ac.xridx ();
     }
 
-  if (error_state)
-    return retval;
-
   octave_idx_type nr = arg.rows ();
   octave_idx_type nc = arg.columns ();
 
--- a/libinterp/genprops.awk	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/genprops.awk	Thu Dec 10 12:50:06 2015 -0800
@@ -45,8 +45,7 @@
 ##   void
 ##   set_NAME (const TYPE& val)
 ##   {
-##     if (! error_state)
-##       NAME = val;
+##     NAME = val;
 ##   }
 ##
 ##   void
@@ -374,7 +373,7 @@
         else
           has_builtin_listeners = 0;
 
-        printf ("\n  {\n    if (! error_state)\n      {\n        if (%s.set (val, %s))\n          {\n",
+        printf ("\n  {\n      {\n        if (%s.set (val, %s))\n          {\n",
           name[i], (has_builtin_listeners ? "false" : "true"));
         if (mode[i])
           printf ("            set_%smode (\"manual\");\n", name[i]);
@@ -470,7 +469,7 @@
               class_name);
 
     if (! base)
-        printf ("  const std::set<std::string>& pnames = all_property_names ();\n\n  caseless_str pname = validate_property_name (\"set\", go_name, pnames, pname_arg);\n\n  if (error_state)\n    return;\n  else if (has_readonly_property (pname))\n    {\n      error (\"set: \\\"%%s\\\" is read-only\", pname.c_str ());\n      return;\n    }\n\n");
+        printf ("  const std::set<std::string>& pnames = all_property_names ();\n\n  caseless_str pname = validate_property_name (\"set\", go_name, pnames, pname_arg);\n\n  if (has_readonly_property (pname))\n    {\n      error (\"set: \\\"%%s\\\" is read-only\", pname.c_str ());\n      return;\n    }\n\n");
 
     first = 1;
 
@@ -524,7 +523,7 @@
     printf ("  octave_value retval;\n\n");
 
     if (! base)
-      printf ("  const std::set<std::string>& pnames = all_property_names ();\n\n  caseless_str pname = validate_property_name (\"get\", go_name, pnames, pname_arg);\n\n  if (error_state)\n    return retval;\n\n");
+      printf ("  const std::set<std::string>& pnames = all_property_names ();\n\n  caseless_str pname = validate_property_name (\"get\", go_name, pnames, pname_arg);\n\n");
 
     for (i = 1; i<= idx; i++)
     {
@@ -549,7 +548,7 @@
               class_name);
 
     if (! base)
-      printf ("  const std::set<std::string>& pnames = all_property_names ();\n\n  caseless_str pname = validate_property_name (\"get\", go_name, pnames, pname_arg);\n\n  if (error_state)\n    return property ();\n\n");
+      printf ("  const std::set<std::string>& pnames = all_property_names ();\n\n  caseless_str pname = validate_property_name (\"get\", go_name, pnames, pname_arg);\n\n");
 
     for (i = 1; i<= idx; i++)
     {
--- a/libinterp/link-deps.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/link-deps.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,5 +1,3 @@
-include $(top_srcdir)/liboctave/link-deps.mk
-
 if AMCOND_ENABLE_DYNAMIC_LINKING
   LIBOCTINTERP_LINK_DEPS =
 else
--- a/libinterp/mkbuiltins	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/mkbuiltins	Thu Dec 10 12:50:06 2015 -0800
@@ -47,7 +47,7 @@
   cat << \EOF
 // DO NOT EDIT!  Generated automatically by mkbuiltins.
 
-#if !defined (octave_builtin_defun_decls_h)
+#if ! defined (octave_builtin_defun_decls_h)
 #define octave_builtin_defun_decls_h 1
 
 #include "oct-obj.h"
--- a/libinterp/mkdefs	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/mkdefs	Thu Dec 10 12:50:06 2015 -0800
@@ -34,7 +34,7 @@
     xsrcdir=`echo "$file" | sed "s,^$srcdir,libinterp,"`
   ;;
   *)
-    xsrcdir="libinterp/$file"
+    xsrcdir="$file"
   ;;
 esac
 echo " XDEFUN_FILE_NAME (\"$xsrcdir\")"
--- a/libinterp/mkops	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/mkops	Thu Dec 10 12:50:06 2015 -0800
@@ -32,7 +32,7 @@
 EOF
 
 for file in "$@"; do
-  f=`echo $file | $SED 's,^\./,,; s%^operators/op-%%; s%\.cc%%; s%-%_%g'`
+  f=`echo $file | $SED 's,^\./,,; s%^libinterp/operators/op-%%; s%\.cc%%; s%-%_%g'`
   echo "extern void install_${f}_ops (void);"
 done
 
@@ -46,7 +46,7 @@
 EOF
 
 for file in "$@"; do
-  f=`echo $file | $SED 's,^\./,,; s%^operators/op-%%; s%\.cc%%; s%-%_%g'`
+  f=`echo $file | $SED 's,^\./,,; s%^libinterp/operators/op-%%; s%\.cc%%; s%-%_%g'`
   echo "  install_${f}_ops ();"
 done
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,403 @@
+libinterp_EXTRA_DIST =
+
+libinterp_CLEANFILES =
+libinterp_DISTCLEANFILES =
+libinterp_MAINTAINERCLEANFILES =
+
+## Search local directories before those specified by the user.
+libinterp_liboctinterp_la_CPPFLAGS = \
+  @OCTINTERP_DLL_DEFS@ \
+  -I$(top_builddir)/liboctave -I$(top_srcdir)/liboctave \
+  -I$(top_srcdir)/liboctave/cruft/misc \
+  -I$(top_srcdir)/liboctave/array \
+  -I$(top_builddir)/liboctave/numeric -I$(top_srcdir)/liboctave/numeric \
+  -I$(top_builddir)/liboctave/operators -I$(top_srcdir)/liboctave/operators \
+  -I$(top_srcdir)/liboctave/system \
+  -I$(top_srcdir)/liboctave/util \
+  -I$(srcdir)/libinterp/octave-value \
+  -Ilibinterp -I$(srcdir)/libinterp \
+  -I$(srcdir)/libinterp/operators \
+  -Ilibinterp/parse-tree -I$(srcdir)/libinterp/parse-tree \
+  -Ilibinterp/corefcn -I$(srcdir)/libinterp/corefcn \
+  -I$(top_builddir)/libgnu -I$(top_srcdir)/libgnu \
+  $(HDF5_CPPFLAGS)
+
+libinterp_liboctinterp_la_CFLAGS = $(AM_CFLAGS) $(WARN_CFLAGS)
+
+libinterp_liboctinterp_la_CXXFLAGS = $(AM_CFLAGS) $(WARN_CXXFLAGS)
+
+octlib_LTLIBRARIES += libinterp/liboctinterp.la
+
+## This is the subset of $(BUILT_SOURCES) that may be included by source
+## files that are preprocessed to make $(DEF_FILES).  This ensures that
+## files in $(BUILT_SOURCES) are built in the right dependency order.
+GENERATED_MAKE_BUILTINS_INCS = \
+  libinterp/corefcn/defaults.h \
+  libinterp/corefcn/graphics-props.cc \
+  libinterp/corefcn/graphics.h \
+  libinterp/corefcn/mxarray.h \
+  libinterp/oct-conf-features.h \
+  libinterp/oct-conf.h \
+  libinterp/parse-tree/oct-gperf.h \
+  libinterp/parse-tree/oct-parse.h \
+  libinterp/version.h
+
+BUILT_SOURCES += \
+  $(GENERATED_MAKE_BUILTINS_INCS) \
+  libinterp/builtin-defun-decls.h \
+  libinterp/builtins.cc \
+  libinterp/corefcn/oct-errno.cc \
+  libinterp/corefcn/oct-tex-lexer.cc \
+  libinterp/corefcn/oct-tex-parser.cc \
+  libinterp/corefcn/oct-tex-symbols.cc \
+  libinterp/operators/ops.cc \
+  libinterp/parse-tree/lex.cc \
+  libinterp/parse-tree/oct-parse.cc
+
+ULT_PARSER_SRC := \
+  libinterp/corefcn/oct-tex-lexer.in.ll \
+  libinterp/corefcn/oct-tex-parser.in.yy \
+  libinterp/parse-tree/oct-parse.in.yy
+
+GENERATED_PARSER_FILES := \
+  libinterp/corefcn/oct-tex-lexer.ll \
+  libinterp/corefcn/oct-tex-parser.yy \
+  libinterp/parse-tree/oct-parse.yy
+
+LIBINTERP_BUILT_DISTFILES = \
+  $(GENERATED_PARSER_FILES) \
+  libinterp/corefcn/oct-tex-parser.h \
+  libinterp/corefcn/oct-tex-symbols.cc \
+  libinterp/parse-tree/oct-gperf.h \
+  libinterp/parse-tree/oct-parse.h
+
+## Files that are created during build process and installed,
+## BUT not distributed in tarball.
+LIBINTERP_BUILT_NODISTFILES = \
+  libinterp/corefcn/mxarray.h \
+  libinterp/corefcn/oct-errno.cc \
+  libinterp/corefcn/defaults.h \
+  libinterp/corefcn/graphics.h \
+  libinterp/builtin-defun-decls.h \
+  libinterp/operators/ops.cc \
+  libinterp/oct-conf.h \
+  libinterp/oct-conf-features.h \
+  libinterp/version.h \
+  $(OPT_HANDLERS) \
+  $(ALL_DEF_FILES) \
+  libinterp/builtins.cc
+
+libinterp_EXTRA_DIST += \
+  libinterp/DOCSTRINGS \
+  libinterp/config-features.sh \
+  libinterp/find-defun-files.sh \
+  libinterp/gendoc.pl \
+  libinterp/genprops.awk \
+  libinterp/mk-errno-list \
+  libinterp/mk-pkg-add \
+  libinterp/mkbuiltins \
+  libinterp/mkdefs \
+  libinterp/mkops \
+  libinterp/oct-conf.in.h \
+  libinterp/version.in.h \
+  $(LIBINTERP_BUILT_DISTFILES)
+
+octinclude_HEADERS += \
+  libinterp/corefcn/graphics-props.cc \
+  libinterp/parse-tree/oct-gperf.h \
+  libinterp/builtins.h \
+  libinterp/builtin-defun-decls.h \
+  libinterp/octave.h \
+  libinterp/options-usage.h \
+  $(OCTAVE_VALUE_INC) \
+  $(PARSE_TREE_INC) \
+  $(PARSER_INC) \
+  $(LIBINTERP_OPERATORS_INC) \
+  $(COREFCN_INC)
+
+nodist_octinclude_HEADERS += \
+  libinterp/corefcn/mxarray.h \
+  libinterp/corefcn/defaults.h \
+  libinterp/corefcn/graphics.h \
+  libinterp/oct-conf.h \
+  libinterp/version.h
+
+DIST_SRC += \
+  libinterp/octave.cc \
+  libinterp/version.cc \
+  $(OCTAVE_VALUE_SRC) \
+  $(PARSE_TREE_SRC) \
+  $(PARSER_SRC) \
+  $(COREFCN_SRC) \
+  $(TEX_PARSER_SRC)
+
+include libinterp/parse-tree/module.mk
+include libinterp/octave-value/module.mk
+include libinterp/operators/module.mk
+include libinterp/template-inst/module.mk
+include libinterp/corefcn/module.mk
+include libinterp/dldfcn/module.mk
+
+$(srcdir)/libinterp/dldfcn/module.mk: $(srcdir)/libinterp/dldfcn/config-module.sh $(srcdir)/libinterp/dldfcn/config-module.awk $(srcdir)/libinterp/dldfcn/module-files
+	$(srcdir)/libinterp/dldfcn/config-module.sh $(top_srcdir)
+
+if AMCOND_ENABLE_DYNAMIC_LINKING
+  OCT_FILES = $(DLDFCN_LIBS:.la=.oct)
+  DLD_LIBOCTINTERP_LIBADD = libinterp/liboctinterp.la
+else
+  OCT_FILES =
+  DLD_LIBOCTINTERP_LIBADD =
+endif
+
+libinterp_liboctinterp_la_SOURCES = \
+  libinterp/octave.cc \
+  libinterp/version.cc \
+  $(LIBINTERP_OPERATORS_SRC) \
+  $(TEMPLATE_INST_SRC)
+
+nodist_libinterp_liboctinterp_la_SOURCES = \
+  libinterp/corefcn/mxarray.h \
+  libinterp/corefcn/oct-errno.cc \
+  libinterp/corefcn/defaults.h \
+  libinterp/corefcn/graphics.h \
+  libinterp/operators/ops.cc \
+  libinterp/builtin-defun-decls.h \
+  libinterp/builtins.cc \
+  libinterp/oct-conf.h \
+  libinterp/oct-conf-features.h \
+  libinterp/version.h
+
+libinterp_liboctinterp_la_LIBADD = \
+  libinterp/octave-value/liboctave-value.la \
+  libinterp/parse-tree/libparse-tree.la \
+  libinterp/parse-tree/libparser.la \
+  libinterp/corefcn/libcorefcn.la \
+  libinterp/corefcn/libtex_parser.la \
+  $(top_builddir)/liboctave/liboctave.la \
+  $(LIBOCTINTERP_LINK_DEPS)
+
+# Increment these as needed and according to the rules in the libtool manual:
+libinterp_liboctinterp_current = 3
+libinterp_liboctinterp_revision = 0
+libinterp_liboctinterp_age = 0
+
+libinterp_liboctinterp_version_info = $(libinterp_liboctinterp_current):$(libinterp_liboctinterp_revision):$(libinterp_liboctinterp_age)
+
+libinterp_liboctinterp_la_LDFLAGS = \
+  -version-info $(libinterp_liboctinterp_version_info) \
+  $(NO_UNDEFINED_LDFLAG) \
+  -bindir $(bindir) \
+  $(LIBOCTINTERP_LINK_OPTS) \
+  $(WARN_LDFLAGS)
+
+## Section for defining and creating DEF_FILES
+
+ULT_DIST_SRC := \
+  $(filter-out $(GENERATED_PARSER_FILES), $(DIST_SRC)) $(ULT_PARSER_SRC)
+
+SRC_DEF_FILES := $(shell $(srcdir)/libinterp/find-defun-files.sh "$(srcdir)" $(ULT_DIST_SRC))
+
+DLDFCN_DEF_FILES = $(DLDFCN_SRC:.cc=.df)
+
+## builtins.cc depends on $(DEF_FILES), so DEF_FILES should only include
+## .df files that correspond to sources included in liboctave.
+if AMCOND_ENABLE_DYNAMIC_LINKING
+  DEF_FILES = $(SRC_DEF_FILES)
+else
+  DEF_FILES = $(SRC_DEF_FILES) $(DLDFCN_DEF_FILES)
+endif
+
+ALL_DEF_FILES = $(SRC_DEF_FILES) $(DLDFCN_DEF_FILES)
+
+$(SRC_DEF_FILES): libinterp/mkdefs Makefile
+
+$(DEF_FILES): $(OPT_HANDLERS) $(LIBOCTAVE_OPT_INC)
+
+## FIXME: The following two variables are deprecated and should be removed
+##        in Octave version 3.12.
+DLL_CDEFS = @OCTINTERP_DLL_DEFS@
+DLL_CXXDEFS = @OCTINTERP_DLL_DEFS@
+
+## Rule to build a DEF file from a .cc file
+## See also module.mk files for overrides when speciall CPPFLAGS are needed.
+## FIXME: Shouldn't the build stop if CPP fails here?  Yes (10/31/2013)
+%.df: %.cc $(GENERATED_MAKE_BUILTINS_INCS)
+	$(AM_V_GEN)rm -f $@-t $@-t1 $@ && \
+	$(CXXCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	  $(libinterp_liboctinterp_la_CPPFLAGS) $(LLVM_CPPFLAGS) $(CPPFLAGS) \
+	  $(libinterp_liboctinterp_la_CXXFLAGS) $(CXXFLAGS) \
+	  -DMAKE_BUILTINS $< > $@-t1 && \
+	$(srcdir)/libinterp/mkdefs $(srcdir)/libinterp $< < $@-t1 > $@-t && \
+	rm -f $@-t1 && \
+	mv $@-t $@
+
+## Rules to build test files
+
+LIBINTERP_TST_FILES_SRC := $(shell $(top_srcdir)/build-aux/find-files-with-tests.sh "$(srcdir)" $(ULT_DIST_SRC) $(DLDFCN_SRC))
+
+LIBINTERP_TST_FILES := $(addsuffix -tst,$(LIBINTERP_TST_FILES_SRC))
+
+libinterptestsdir := $(octtestsdir)
+
+nobase_libinterptests_DATA = $(LIBINTERP_TST_FILES)
+
+## Override Automake's rule that forces a .hh extension on us even
+## though we don't want it.  It would be super awesome if automake
+## would allow users to choose the header file extension.
+.yy.cc:
+	$(AM_V_YACC)$(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE)
+
+## Special rules:
+## Mostly for sources which must be built before rest of compilation.
+
+## 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.
+libinterp/oct-conf.h: libinterp/oct-conf.in.h Makefile
+	$(AM_V_GEN)$(do_subst_config_vals)
+
+libinterp/oct-conf-features.h: $(top_builddir)/config.h libinterp/config-features.sh
+	$(AM_V_GEN)rm -f $@-t && \
+	$(srcdir)/libinterp/config-features.sh $< > $@-t && \
+	$(simple_move_if_change_rule)
+
+libinterp/version.h: libinterp/version.in.h Makefile
+	$(AM_V_GEN)rm -f $@-t && \
+	$(SED) < $< \
+	  -e "s|%NO_EDIT_WARNING%|DO NOT EDIT!  Generated automatically from $(<F) by Make.|" \
+	  -e "s|%OCTAVE_API_VERSION%|\"${OCTAVE_API_VERSION}\"|" \
+	  -e "s|%OCTAVE_COPYRIGHT%|\"${OCTAVE_COPYRIGHT}\"|" \
+          -e "s|%OCTAVE_MAJOR_VERSION%|${OCTAVE_MAJOR_VERSION}|" \
+          -e "s|%OCTAVE_MINOR_VERSION%|${OCTAVE_MINOR_VERSION}|" \
+          -e "s|%OCTAVE_PATCH_VERSION%|${OCTAVE_PATCH_VERSION}|" \
+	  -e "s|%OCTAVE_RELEASE_DATE%|\"${OCTAVE_RELEASE_DATE}\"|" \
+	  -e "s|%OCTAVE_VERSION%|\"${OCTAVE_VERSION}\"|" > $@-t && \
+	$(simple_move_if_change_rule)
+
+libinterp/builtins.cc: $(DEF_FILES) libinterp/mkbuiltins
+	$(AM_V_GEN)rm -f $@-t && \
+	$(srcdir)/libinterp/mkbuiltins --source $(DEF_FILES) > $@-t && \
+	$(simple_move_if_change_rule)
+
+libinterp/builtin-defun-decls.h: $(SRC_DEF_FILES) libinterp/mkbuiltins
+	$(AM_V_GEN)rm -f $@-t && \
+	$(srcdir)/libinterp/mkbuiltins --header $(SRC_DEF_FILES) > $@-t && \
+	$(simple_move_if_change_rule)
+
+if AMCOND_ENABLE_DYNAMIC_LINKING
+DLDFCN_PKG_ADD_FILE = libinterp/dldfcn/PKG_ADD
+
+libinterp/dldfcn/PKG_ADD: $(DLDFCN_DEF_FILES) libinterp/mk-pkg-add
+	$(AM_V_GEN)rm -f $@-t && \
+	$(srcdir)/libinterp/mk-pkg-add $(DLDFCN_DEF_FILES) > $@-t && \
+	$(simple_move_if_change_rule)
+endif
+
+if AMCOND_BUILD_DOCS
+
+DOCSTRING_FILES += libinterp/DOCSTRINGS
+
+libinterp/DOCSTRINGS: | libinterp/.DOCSTRINGS
+
+libinterp/.DOCSTRINGS: $(ALL_DEF_FILES) libinterp/gendoc.pl
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	if [ "x$(srcdir)" != "x." ] && [ -f $(srcdir)/libinterp/DOCSTRINGS ] && [ ! -f DOCSTRINGS ]; then \
+		cp $(srcdir)/libinterp/DOCSTRINGS libinterp/DOCSTRINGS; \
+		touch -r $(srcdir)/libinterp/DOCSTRINGS libinterp/DOCSTRINGS; \
+	fi && \
+	$(PERL) $(srcdir)/libinterp/gendoc.pl $(ALL_DEF_FILES) > $@-t && \
+	mv $@-t $@ && \
+	$(top_srcdir)/build-aux/move-if-change $@ libinterp/DOCSTRINGS && \
+	touch $@
+
+OCTAVE_INTERPRETER_TARGETS += \
+  libinterp/.DOCSTRINGS
+
+endif
+
+OCTAVE_INTERPRETER_TARGETS += \
+  $(OCT_FILES) \
+  $(DLDFCN_PKG_ADD_FILE)
+
+if AMCOND_BUILD_DOCS
+install-data-hook: install-oct install-built-in-docstrings
+else
+install-data-hook: install-oct uninstall-built-in-docstrings
+endif
+
+uninstall-local: uninstall-oct uninstall-built-in-docstrings
+
+if AMCOND_ENABLE_DYNAMIC_LINKING
+install-oct:
+	$(MKDIR_P) $(DESTDIR)$(octfiledir)
+	if [ -n "`cat $(DLDFCN_PKG_ADD_FILE)`" ]; then \
+	  $(INSTALL_DATA) $(DLDFCN_PKG_ADD_FILE) $(DESTDIR)$(octfiledir)/PKG_ADD; \
+	fi
+	cd $(DESTDIR)$(octlibdir) && \
+	for ltlib in $(DLDFCN_LIBS); do \
+	  f=`echo $$ltlib | $(SED) 's,.*/,,'`; \
+	  dl=`$(SED) -n -e "s/dlname='\([^']*\)'/\1/p" < $$f`; \
+	  if [ -n "$$dl" ]; then \
+	    $(INSTALL_PROGRAM) $$dl $(DESTDIR)$(octfiledir)/`echo $$f | $(SED) 's,^lib,,; s,\.la$$,.oct,'`; \
+	  else \
+	    echo "error: dlname is empty in $$ltlib!"; \
+	    exit 1; \
+	  fi; \
+	  lnames=`$(SED) -n -e "s/library_names='\([^']*\)'/\1/p" < $$f`; \
+	  if [ -n "$$lnames" ]; then \
+	    rm -f $$f $$lnames $$dl; \
+	  fi \
+	done
+
+uninstall-oct:
+	for f in $(notdir $(OCT_FILES)); do \
+	  rm -f $(DESTDIR)$(octfiledir)/$$f; \
+	done
+	rm -f $(DESTDIR)$(octfiledir)/PKG_ADD
+endif
+.PHONY: install-oct uninstall-oct
+
+if AMCOND_BUILD_DOCS
+install-built-in-docstrings:
+	$(MKDIR_P) $(DESTDIR)$(octetcdir)
+	$(INSTALL_DATA) libinterp/DOCSTRINGS $(DESTDIR)$(octetcdir)/built-in-docstrings
+
+uninstall-built-in-docstrings:
+	rm -f $(DESTDIR)$(octetcdir)/built-in-docstrings
+endif
+.PHONY: install-built-in-docstrings uninstall-built-in-docstrings
+
+EXTRA_DIST += $(libinterp_EXTRA_DIST)
+
+libinterp_CLEANFILES += \
+  $(DLDFCN_PKG_ADD_FILE) \
+  libinterp/corefcn/graphics-props.cc \
+  libinterp/corefcn/oct-tex-parser.output \
+  libinterp/parse-tree/oct-parse.output
+
+libinterp_DISTCLEANFILES += \
+  $(LIBINTERP_BUILT_NODISTFILES) \
+  $(OCT_FILES) \
+  $(LIBINTERP_TST_FILES)
+
+libinterp_MAINTAINERCLEANFILES += \
+  libinterp/.DOCSTRINGS \
+  libinterp/DOCSTRINGS \
+  $(LIBINTERP_BUILT_DISTFILES)
+
+BUILT_DISTFILES += $(LIBINTERP_BUILT_DISTFILES)
+BUILT_NODISTFILES += $(LIBINTERP_BUILT_NODISTFILES)
+
+CLEANFILES += $(libinterp_CLEANFILES)
+DISTCLEANFILES += $(libinterp_DISTCLEANFILES)
+MAINTAINERCLEANFILES += $(libinterp_MAINTAINERCLEANFILES)
+
+libinterp-clean:
+	rm -f $(libinterp_CLEANFILES)
+
+libinterp-distclean: libinterp-clean
+	rm -f $(libinterp_DISTCLEANFILES)
+
+libinterp-maintainer-clean: libinterp-distclean
+	rm -f $(libinterp_MAINTAINERCLEANFILES)
--- a/libinterp/oct-conf.in.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/oct-conf.in.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_conf_h)
+#if ! defined (octave_conf_h)
 #define octave_conf_h 1
 
 #ifndef OCTAVE_CONF_ALL_CFLAGS
--- a/libinterp/octave-value/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,164 +1,165 @@
-EXTRA_DIST += \
-  octave-value/module.mk
-
 OV_INTTYPE_INC = \
-  octave-value/ov-base-int.h \
-  octave-value/ov-base-int.cc \
-  octave-value/ov-int-traits.h \
-  octave-value/ov-int16.h \
-  octave-value/ov-int32.h \
-  octave-value/ov-int64.h \
-  octave-value/ov-int8.h \
-  octave-value/ov-intx.h \
-  octave-value/ov-uint16.h \
-  octave-value/ov-uint32.h \
-  octave-value/ov-uint64.h \
-  octave-value/ov-uint8.h
+  libinterp/octave-value/ov-base-int.h \
+  libinterp/octave-value/ov-base-int.cc \
+  libinterp/octave-value/ov-int-traits.h \
+  libinterp/octave-value/ov-int16.h \
+  libinterp/octave-value/ov-int32.h \
+  libinterp/octave-value/ov-int64.h \
+  libinterp/octave-value/ov-int8.h \
+  libinterp/octave-value/ov-intx.h \
+  libinterp/octave-value/ov-uint16.h \
+  libinterp/octave-value/ov-uint32.h \
+  libinterp/octave-value/ov-uint64.h \
+  libinterp/octave-value/ov-uint8.h
 
 OV_SPARSE_INC = \
-  octave-value/ov-base-sparse.h \
-  octave-value/ov-bool-sparse.h \
-  octave-value/ov-cx-sparse.h \
-  octave-value/ov-re-sparse.h
+  libinterp/octave-value/ov-base-sparse.h \
+  libinterp/octave-value/ov-bool-sparse.h \
+  libinterp/octave-value/ov-cx-sparse.h \
+  libinterp/octave-value/ov-re-sparse.h
 
 OCTAVE_VALUE_INC = \
-  octave-value/ov-base-diag.h \
-  octave-value/ov-base-diag.cc \
-  octave-value/ov-base-mat.h \
-  octave-value/ov-base-mat.cc \
-  octave-value/ov-base-scalar.h \
-  octave-value/ov-base-scalar.cc \
-  octave-value/ov-base.h \
-  octave-value/ov-bool-mat.h \
-  octave-value/ov-bool-mat.cc \
-  octave-value/ov-bool.h \
-  octave-value/ov-builtin.h \
-  octave-value/ov-cell.h \
-  octave-value/ov-ch-mat.h \
-  octave-value/ov-class.h \
-  octave-value/ov-classdef.h \
-  octave-value/ov-colon.h \
-  octave-value/ov-complex.h \
-  octave-value/ov-cs-list.h \
-  octave-value/ov-cx-diag.h \
-  octave-value/ov-cx-mat.h \
-  octave-value/ov-dld-fcn.h \
-  octave-value/ov-fcn-handle.h \
-  octave-value/ov-fcn-inline.h \
-  octave-value/ov-fcn.h \
-  octave-value/ov-float.h \
-  octave-value/ov-flt-complex.h \
-  octave-value/ov-flt-cx-diag.h \
-  octave-value/ov-flt-cx-mat.h \
-  octave-value/ov-flt-re-diag.h \
-  octave-value/ov-flt-re-mat.h \
-  octave-value/ov-java.h \
-  octave-value/ov-lazy-idx.h \
-  octave-value/ov-mex-fcn.h \
-  octave-value/ov-null-mat.h \
-  octave-value/ov-oncleanup.h \
-  octave-value/ov-perm.h \
-  octave-value/ov-range.h \
-  octave-value/ov-re-diag.h \
-  octave-value/ov-re-mat.h \
-  octave-value/ov-scalar.h \
-  octave-value/ov-str-mat.h \
-  octave-value/ov-struct.h \
-  octave-value/ov-type-conv.h \
-  octave-value/ov-typeinfo.h \
-  octave-value/ov-usr-fcn.h \
-  octave-value/ov.h \
+  libinterp/octave-value/ov-base-diag.h \
+  libinterp/octave-value/ov-base-diag.cc \
+  libinterp/octave-value/ov-base-mat.h \
+  libinterp/octave-value/ov-base-mat.cc \
+  libinterp/octave-value/ov-base-scalar.h \
+  libinterp/octave-value/ov-base-scalar.cc \
+  libinterp/octave-value/ov-base.h \
+  libinterp/octave-value/ov-bool-mat.h \
+  libinterp/octave-value/ov-bool-mat.cc \
+  libinterp/octave-value/ov-bool.h \
+  libinterp/octave-value/ov-builtin.h \
+  libinterp/octave-value/ov-cell.h \
+  libinterp/octave-value/ov-ch-mat.h \
+  libinterp/octave-value/ov-class.h \
+  libinterp/octave-value/ov-classdef.h \
+  libinterp/octave-value/ov-colon.h \
+  libinterp/octave-value/ov-complex.h \
+  libinterp/octave-value/ov-cs-list.h \
+  libinterp/octave-value/ov-cx-diag.h \
+  libinterp/octave-value/ov-cx-mat.h \
+  libinterp/octave-value/ov-dld-fcn.h \
+  libinterp/octave-value/ov-fcn-handle.h \
+  libinterp/octave-value/ov-fcn-inline.h \
+  libinterp/octave-value/ov-fcn.h \
+  libinterp/octave-value/ov-float.h \
+  libinterp/octave-value/ov-flt-complex.h \
+  libinterp/octave-value/ov-flt-cx-diag.h \
+  libinterp/octave-value/ov-flt-cx-mat.h \
+  libinterp/octave-value/ov-flt-re-diag.h \
+  libinterp/octave-value/ov-flt-re-mat.h \
+  libinterp/octave-value/ov-java.h \
+  libinterp/octave-value/ov-lazy-idx.h \
+  libinterp/octave-value/ov-mex-fcn.h \
+  libinterp/octave-value/ov-null-mat.h \
+  libinterp/octave-value/ov-oncleanup.h \
+  libinterp/octave-value/ov-perm.h \
+  libinterp/octave-value/ov-range.h \
+  libinterp/octave-value/ov-re-diag.h \
+  libinterp/octave-value/ov-re-mat.h \
+  libinterp/octave-value/ov-scalar.h \
+  libinterp/octave-value/ov-str-mat.h \
+  libinterp/octave-value/ov-struct.h \
+  libinterp/octave-value/ov-type-conv.h \
+  libinterp/octave-value/ov-typeinfo.h \
+  libinterp/octave-value/ov-usr-fcn.h \
+  libinterp/octave-value/ov.h \
   $(OV_INTTYPE_INC) \
   $(OV_SPARSE_INC)
 
 OV_INTTYPE_SRC = \
-  octave-value/ov-int16.cc \
-  octave-value/ov-int32.cc \
-  octave-value/ov-int64.cc \
-  octave-value/ov-int8.cc \
-  octave-value/ov-uint16.cc \
-  octave-value/ov-uint32.cc \
-  octave-value/ov-uint64.cc \
-  octave-value/ov-uint8.cc
+  libinterp/octave-value/ov-int16.cc \
+  libinterp/octave-value/ov-int32.cc \
+  libinterp/octave-value/ov-int64.cc \
+  libinterp/octave-value/ov-int8.cc \
+  libinterp/octave-value/ov-uint16.cc \
+  libinterp/octave-value/ov-uint32.cc \
+  libinterp/octave-value/ov-uint64.cc \
+  libinterp/octave-value/ov-uint8.cc
 
 OV_SPARSE_SRC = \
-  octave-value/ov-base-sparse.cc \
-  octave-value/ov-bool-sparse.cc \
-  octave-value/ov-cx-sparse.cc \
-  octave-value/ov-re-sparse.cc
+  libinterp/octave-value/ov-base-sparse.cc \
+  libinterp/octave-value/ov-bool-sparse.cc \
+  libinterp/octave-value/ov-cx-sparse.cc \
+  libinterp/octave-value/ov-re-sparse.cc
 
 OCTAVE_VALUE_SRC = \
-  octave-value/ov-base.cc \
-  octave-value/ov-bool-mat.cc \
-  octave-value/ov-bool.cc \
-  octave-value/ov-builtin.cc \
-  octave-value/ov-cell.cc \
-  octave-value/ov-ch-mat.cc \
-  octave-value/ov-class.cc \
-  octave-value/ov-classdef.cc \
-  octave-value/ov-colon.cc \
-  octave-value/ov-complex.cc \
-  octave-value/ov-cs-list.cc \
-  octave-value/ov-cx-diag.cc \
-  octave-value/ov-cx-mat.cc \
-  octave-value/ov-dld-fcn.cc \
-  octave-value/ov-fcn-handle.cc \
-  octave-value/ov-fcn-inline.cc \
-  octave-value/ov-fcn.cc \
-  octave-value/ov-float.cc \
-  octave-value/ov-flt-complex.cc \
-  octave-value/ov-flt-cx-diag.cc \
-  octave-value/ov-flt-cx-mat.cc \
-  octave-value/ov-flt-re-diag.cc \
-  octave-value/ov-flt-re-mat.cc \
-  octave-value/ov-java.cc \
-  octave-value/ov-lazy-idx.cc \
-  octave-value/ov-mex-fcn.cc \
-  octave-value/ov-null-mat.cc \
-  octave-value/ov-oncleanup.cc \
-  octave-value/ov-perm.cc \
-  octave-value/ov-range.cc \
-  octave-value/ov-re-diag.cc \
-  octave-value/ov-re-mat.cc \
-  octave-value/ov-scalar.cc \
-  octave-value/ov-str-mat.cc \
-  octave-value/ov-struct.cc \
-  octave-value/ov-typeinfo.cc \
-  octave-value/ov-usr-fcn.cc \
-  octave-value/ov.cc \
+  libinterp/octave-value/ov-base.cc \
+  libinterp/octave-value/ov-bool-mat.cc \
+  libinterp/octave-value/ov-bool.cc \
+  libinterp/octave-value/ov-builtin.cc \
+  libinterp/octave-value/ov-cell.cc \
+  libinterp/octave-value/ov-ch-mat.cc \
+  libinterp/octave-value/ov-class.cc \
+  libinterp/octave-value/ov-classdef.cc \
+  libinterp/octave-value/ov-colon.cc \
+  libinterp/octave-value/ov-complex.cc \
+  libinterp/octave-value/ov-cs-list.cc \
+  libinterp/octave-value/ov-cx-diag.cc \
+  libinterp/octave-value/ov-cx-mat.cc \
+  libinterp/octave-value/ov-dld-fcn.cc \
+  libinterp/octave-value/ov-fcn-handle.cc \
+  libinterp/octave-value/ov-fcn-inline.cc \
+  libinterp/octave-value/ov-fcn.cc \
+  libinterp/octave-value/ov-float.cc \
+  libinterp/octave-value/ov-flt-complex.cc \
+  libinterp/octave-value/ov-flt-cx-diag.cc \
+  libinterp/octave-value/ov-flt-cx-mat.cc \
+  libinterp/octave-value/ov-flt-re-diag.cc \
+  libinterp/octave-value/ov-flt-re-mat.cc \
+  libinterp/octave-value/ov-java.cc \
+  libinterp/octave-value/ov-lazy-idx.cc \
+  libinterp/octave-value/ov-mex-fcn.cc \
+  libinterp/octave-value/ov-null-mat.cc \
+  libinterp/octave-value/ov-oncleanup.cc \
+  libinterp/octave-value/ov-perm.cc \
+  libinterp/octave-value/ov-range.cc \
+  libinterp/octave-value/ov-re-diag.cc \
+  libinterp/octave-value/ov-re-mat.cc \
+  libinterp/octave-value/ov-scalar.cc \
+  libinterp/octave-value/ov-str-mat.cc \
+  libinterp/octave-value/ov-struct.cc \
+  libinterp/octave-value/ov-typeinfo.cc \
+  libinterp/octave-value/ov-usr-fcn.cc \
+  libinterp/octave-value/ov.cc \
   $(OV_INTTYPE_SRC) \
   $(OV_SPARSE_SRC)
 
 OV_JAVA_DF = \
-  octave-value/ov.df \
-  octave-value/ov-class.df \
-  octave-value/ov-java.df \
-  octave-value/ov-typeinfo.df
+  libinterp/octave-value/ov.df \
+  libinterp/octave-value/ov-class.df \
+  libinterp/octave-value/ov-java.df \
+  libinterp/octave-value/ov-typeinfo.df
 
 ## Special rules for Java .df files so that not all .df files are built with
 ## JAVA_CPPFLAGS
-$(OV_JAVA_DF) : octave-value/%.df : octave-value/%.cc $(GENERATED_MAKE_BUILTINS_INCS)
+$(OV_JAVA_DF) : libinterp/octave-value/%.df : libinterp/octave-value/%.cc $(GENERATED_MAKE_BUILTINS_INCS)
 	$(AM_V_GEN)rm -f $@-t $@-t1 $@ && \
 	$(CXXCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	  $(AM_CPPFLAGS) $(JAVA_CPPFLAGS) $(CPPFLAGS) \
-	  $(AM_CXXFLAGS) $(CXXFLAGS) \
+	  $(libinterp_octave_value_liboctave_value_la_CPPFLAGS) $(JAVA_CPPFLAGS) $(CPPFLAGS) \
+	  $(libinterp_octave_value_liboctave_value_la_CXXFLAGS) $(CXXFLAGS) \
 	  -DMAKE_BUILTINS $< > $@-t1 && \
-	$(srcdir)/mkdefs $(srcdir) $< < $@-t1 > $@-t && \
+	$(srcdir)/libinterp/mkdefs $(srcdir)/libinterp $< < $@-t1 > $@-t && \
 	mv $@-t $@ && \
 	rm -f $@-t1
 
-noinst_LTLIBRARIES += octave-value/liboctave-value.la
+noinst_LTLIBRARIES += libinterp/octave-value/liboctave-value.la
 
-octave_value_liboctave_value_la_SOURCES = $(OCTAVE_VALUE_SRC)
+libinterp_octave_value_liboctave_value_la_SOURCES = $(OCTAVE_VALUE_SRC)
 
 ## FIXME -- maybe it would be better to limit the JAVA flags to
 ## the compile commands for ov-java.cc?  Does JAVA_LIBS need to be
 ## added to LIBOCTINTERP_LINK_DEPS (see libinterp/link-deps.mk)?
 ## Should we have a separate set of JAVA_LDFLAGS?
 
-octave_value_liboctave_value_la_CPPFLAGS = \
-  $(liboctinterp_la_CPPFLAGS) \
+libinterp_octave_value_liboctave_value_la_CPPFLAGS = \
+  $(libinterp_liboctinterp_la_CPPFLAGS) \
   $(HDF5_CPPFLAGS) \
   $(JAVA_CPPFLAGS)
 
-octave_value_liboctave_value_la_LIBADD = $(JAVA_LIBS)
+libinterp_octave_value_liboctave_value_la_CFLAGS = $(AM_CFLAGS) $(WARN_CFLAGS)
+
+libinterp_octave_value_liboctave_value_la_CXXFLAGS = $(AM_CXXFLAGS) $(WARN_CXXFLAGS)
+
+libinterp_octave_value_liboctave_value_la_LIBADD = $(JAVA_LIBS)
--- a/libinterp/octave-value/ov-base-diag.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-base-diag.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -29,6 +29,7 @@
 #include "mach-info.h"
 #include "lo-ieee.h"
 
+#include "ov-base-diag.h"
 #include "mxarray.h"
 #include "ov-base.h"
 #include "ov-base-mat.h"
@@ -38,7 +39,7 @@
 #include "oct-stream.h"
 #include "ops.h"
 
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 
 template <class DMT, class MT>
 octave_value
@@ -103,26 +104,37 @@
 
   if (idx.length () == 2 && ! resize_ok)
     {
-      idx_vector idx0 = idx(0).index_vector ();
-      idx_vector idx1 = idx(1).index_vector ();
-
-      if (idx0.is_scalar () && idx1.is_scalar ())
-        {
-          retval = matrix.checkelem (idx0(0), idx1(0));
-        }
-      else
+      int k = 0;        // index we're accesing when index_vector throws
+      try
         {
-          octave_idx_type m = idx0.length (matrix.rows ());
-          octave_idx_type n = idx1.length (matrix.columns ());
-          if (idx0.is_colon_equiv (m) && idx1.is_colon_equiv (n)
-              && m <= matrix.rows () && n <= matrix.rows ())
+          idx_vector idx0 = idx(0).index_vector ();
+          k = 1;
+          idx_vector idx1 = idx(1).index_vector ();
+
+          if (idx0.is_scalar () && idx1.is_scalar ())
             {
-              DMT rm (matrix);
-              rm.resize (m, n);
-              retval = rm;
+              retval = matrix.checkelem (idx0(0), idx1(0));
             }
           else
-            retval = to_dense ().do_index_op (idx, resize_ok);
+            {
+              octave_idx_type m = idx0.length (matrix.rows ());
+              octave_idx_type n = idx1.length (matrix.columns ());
+              if (idx0.is_colon_equiv (m) && idx1.is_colon_equiv (n)
+                  && m <= matrix.rows () && n <= matrix.rows ())
+                {
+                  DMT rm (matrix);
+                  rm.resize (m, n);
+                  retval = rm;
+                }
+              else
+                retval = to_dense ().do_index_op (idx, resize_ok);
+            }
+        }
+      catch (index_exception& e)
+        {
+          // Rethrow to allow more info to be reported later.
+          e.set_pos_if_unset (2, k+1);
+          throw;
         }
     }
   else
@@ -146,28 +158,74 @@
         if (type.length () == 1)
           {
             octave_value_list jdx = idx.front ();
-            // Check for a simple element assignment. That means, if D is a
-            // diagonal matrix, 'D(i,i) = x' will not destroy its diagonality
-            // (provided i is a valid index).
-            if (jdx.length () == 2
-                && jdx(0).is_scalar_type () && jdx(1).is_scalar_type ())
+
+            // FIXME: Mostly repeated code for cases 1 and 2 could be
+            //        consolidated for DRY (Don't Repeat Yourself).
+            // Check for assignments to diagonal elements which should not
+            // destroy the diagonal property of the matrix.
+            // If D is a diagonal matrix then the assignment can be
+            // 1) linear, D(i) = x, where ind2sub results in case #2 below
+            // 2) subscript D(i,i) = x, where both indices are equal.
+            if (jdx.length () == 1 && jdx(0).is_scalar_type ())
               {
                 typename DMT::element_type val;
-                idx_vector i0 = jdx(0).index_vector ();
-                idx_vector i1 = jdx(1).index_vector ();
-                if (! error_state  && i0(0) == i1(0)
-                    && i0(0) < matrix.rows () && i1(0) < matrix.cols ()
-                    && chk_valid_scalar (rhs, val))
+                int k = 0;
+                try
+                  {
+                    idx_vector ind = jdx(0).index_vector ();
+                    k = 1;
+                    dim_vector dv (matrix.rows (), matrix.cols ());
+                    Array<idx_vector> ivec = ind2sub (dv, ind);
+                    idx_vector i0 = ivec(0);
+                    idx_vector i1 = ivec(1);
+
+                    if (i0(0) == i1(0)
+                        && chk_valid_scalar (rhs, val))
+                      {
+                        matrix.dgelem (i0(0)) = val;
+                        retval = this;
+                        this->count++;
+                        // invalidate cache
+                        dense_cache = octave_value ();
+                      }
+                  }
+                catch (index_exception& e)
                   {
-                    matrix.dgelem (i0(0)) = val;
-                    retval = this;
-                    this->count++;
-                    // invalidate cache
-                    dense_cache = octave_value ();
+                    // Rethrow to allow more info to be reported later.
+                    e.set_pos_if_unset (2, k+1);
+                    throw;
+                  }
+              }
+            else if (jdx.length () == 2
+                     && jdx(0).is_scalar_type () && jdx(1).is_scalar_type ())
+              {
+                typename DMT::element_type val;
+                int k = 0;
+                try
+                  {
+                    idx_vector i0 = jdx(0).index_vector ();
+                    k = 1;
+                    idx_vector i1 = jdx(1).index_vector ();
+                    if (i0(0) == i1(0)
+                        && i0(0) < matrix.rows () && i1(0) < matrix.cols ()
+                        && chk_valid_scalar (rhs, val))
+                      {
+                        matrix.dgelem (i0(0)) = val;
+                        retval = this;
+                        this->count++;
+                        // invalidate cache
+                        dense_cache = octave_value ();
+                      }
+                  }
+                catch (index_exception& e)
+                  {
+                    // Rethrow to allow more info to be reported later.
+                    e.set_pos_if_unset (2, k+1);
+                    throw;
                   }
               }
 
-            if (! error_state && ! retval.is_defined ())
+            if (! retval.is_defined ())
               retval = numeric_assign (type, idx, rhs);
           }
         else
--- a/libinterp/octave-value/ov-base-diag.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-base-diag.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_base_diag_h)
+#if ! defined (octave_ov_base_diag_h)
 #define octave_ov_base_diag_h 1
 
 #include <cstdlib>
@@ -86,7 +86,14 @@
   { return to_dense ().reshape (new_dims); }
 
   octave_value permute (const Array<int>& vec, bool inv = false) const
-  { return to_dense ().permute (vec, inv); }
+  {
+    if (vec.numel () == 2
+        && ((vec.xelem (0) == 1 && vec.xelem (1) == 0)
+            || (vec.xelem (0) == 0 && vec.xelem (1) == 1)))
+      return DMT (matrix);
+    else
+      return to_dense ().permute (vec, inv);
+  }
 
   octave_value resize (const dim_vector& dv, bool fill = false) const;
 
--- a/libinterp/octave-value/ov-base-int.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-base-int.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -52,7 +52,7 @@
 #include "variables.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
@@ -129,7 +129,7 @@
 {
   octave_base_value *retval = 0;
 
-  if (this->matrix.nelem () == 1)
+  if (this->matrix.numel () == 1)
     retval = new typename octave_value_int_traits<T>::scalar_type
                (this->matrix (0));
 
@@ -193,7 +193,7 @@
   os << "# ndims: " << d.length () << "\n";
 
   for (int i = 0; i < d.length (); i++)
-    os << " " << d (i);
+    os << " " << d(i);
 
   os << "\n" << this->matrix;
 
@@ -355,7 +355,7 @@
 
   // Octave uses column-major, while HDF5 uses row-major ordering
   for (int i = 0; i < rank; i++)
-    hdims[i] = dv (rank-i-1);
+    hdims[i] = dv(rank-i-1);
 
   space_hid = H5Screate_simple (rank, hdims, 0);
 
--- a/libinterp/octave-value/ov-base-int.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-base-int.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_base_int_h)
+#if ! defined (octave_ov_base_int_h)
 #define octave_ov_base_int_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-base-mat.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-base-mat.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -140,72 +140,73 @@
   int nd = matrix.ndims ();
   const MT& cmatrix = matrix;
 
-  switch (n_idx)
-    {
-    case 0:
-      retval = matrix;
-      break;
+  // If we catch an indexing error in index_vector, we flag an error in
+  // index k.  Ensure it is the right value befor each idx_vector call.
+  // Same variable as used in the for loop in the default case.
+
+  octave_idx_type k = 0;
 
-    case 1:
-      {
-        idx_vector i = idx (0).index_vector ();
+  try
+    {
+      switch (n_idx)
+        {
+        case 0:
+          retval = matrix;
+          break;
 
-        if (! error_state)
+        case 1:
           {
+            idx_vector i = idx (0).index_vector ();
+
             // optimize single scalar index.
             if (! resize_ok && i.is_scalar ())
               retval = cmatrix.checkelem (i(0));
             else
               retval = MT (matrix.index (i, resize_ok));
           }
-      }
-      break;
+          break;
 
-    case 2:
-      {
-        idx_vector i = idx (0).index_vector ();
+        case 2:
+          {
+            idx_vector i = idx (0).index_vector ();
 
-        if (! error_state)
-          {
+            k=1;
             idx_vector j = idx (1).index_vector ();
 
-            if (! error_state)
-              {
-                // optimize two scalar indices.
-                if (! resize_ok && i.is_scalar () && j.is_scalar ())
-                  retval = cmatrix.checkelem (i(0), j(0));
-                else
-                  retval = MT (matrix.index (i, j, resize_ok));
-              }
+            // optimize two scalar indices.
+            if (! resize_ok && i.is_scalar () && j.is_scalar ())
+              retval = cmatrix.checkelem (i(0), j(0));
+            else
+              retval = MT (matrix.index (i, j, resize_ok));
           }
-      }
-      break;
+          break;
 
-    default:
-      {
-        Array<idx_vector> idx_vec (dim_vector (n_idx, 1));
-        bool scalar_opt = n_idx == nd && ! resize_ok;
-        const dim_vector dv = matrix.dims ();
-
-        for (octave_idx_type i = 0; i < n_idx; i++)
+        default:
           {
-            idx_vec(i) = idx(i).index_vector ();
-
-            if (error_state)
-              break;
+            Array<idx_vector> idx_vec (dim_vector (n_idx, 1));
+            bool scalar_opt = n_idx == nd && ! resize_ok;
+            const dim_vector dv = matrix.dims ();
 
-            scalar_opt = (scalar_opt && idx_vec(i).is_scalar ());
-          }
+            for (k = 0; k < n_idx; k++)
+              {
+                idx_vec(k) = idx(k).index_vector ();
 
-        if (! error_state)
-          {
+                scalar_opt = (scalar_opt && idx_vec(k).is_scalar ());
+              }
+
             if (scalar_opt)
               retval = cmatrix.checkelem (conv_to_int_array (idx_vec));
             else
               retval = MT (matrix.index (idx_vec, resize_ok));
           }
-      }
-      break;
+          break;
+        }
+    }
+  catch (index_exception& e)
+    {
+      // Rethrow to allow more info to be reported later.
+      e.set_pos_if_unset (n_idx, k+1);
+      throw;
     }
 
   return retval;
@@ -217,51 +218,54 @@
 {
   octave_idx_type n_idx = idx.length ();
 
-  switch (n_idx)
-    {
-    case 0:
-      panic_impossible ();
-      break;
+  // If we catch an indexing error in index_vector, we flag an error in
+  // index k.  Ensure it is the right value befor each idx_vector call.
+  // Same variable as used in the for loop in the default case.
 
-    case 1:
-      {
-        idx_vector i = idx (0).index_vector ();
+  octave_idx_type k = 0;
 
-        if (! error_state)
-          matrix.assign (i, rhs);
-      }
-      break;
+  try
+    {
+      switch (n_idx)
+        {
+          case 0:
+            panic_impossible ();
+            break;
 
-    case 2:
-      {
-        idx_vector i = idx (0).index_vector ();
+          case 1:
+            {
+              idx_vector i = idx (0).index_vector ();
 
-        if (! error_state)
-          {
-            idx_vector j = idx (1).index_vector ();
+              matrix.assign (i, rhs);
+            }
+            break;
 
-            if (! error_state)
+          case 2:
+            {
+              idx_vector i = idx (0).index_vector ();
+
+              k = 1;
+              idx_vector j = idx (1).index_vector ();
+
               matrix.assign (i, j, rhs);
-          }
-      }
-      break;
-
-    default:
-      {
-        Array<idx_vector> idx_vec (dim_vector (n_idx, 1));
+            }
+            break;
 
-        for (octave_idx_type i = 0; i < n_idx; i++)
-          {
-            idx_vec(i) = idx(i).index_vector ();
+          default:
+            {
+              Array<idx_vector> idx_vec (dim_vector (n_idx, 1));
+
+              for (k = 0; k < n_idx; k++)
+                idx_vec(k) = idx(k).index_vector ();
 
-            if (error_state)
-              break;
-          }
-
-        if (! error_state)
-          matrix.assign (idx_vec, rhs);
-      }
-      break;
+              matrix.assign (idx_vec, rhs);
+            }
+            break;
+        }
+    }
+  catch (const index_exception& e)
+    {
+      gripe_invalid_index (e.idx (), n_idx, k+1);
     }
 
   // Clear cache.
@@ -288,85 +292,84 @@
 
   MT mrhs (dim_vector (1, 1), rhs);
 
-  switch (n_idx)
-    {
-    case 0:
-      panic_impossible ();
-      break;
+  // If we catch an indexing error in index_vector, we flag an error in
+  // index k.  Ensure it is the right value befor each idx_vector call.
+  // Same variable as used in the for loop in the default case.
+
+  octave_idx_type k = 0;
 
-    case 1:
-      {
-        idx_vector i = idx (0).index_vector ();
+  try
+    {
+      switch (n_idx)
+        {
+        case 0:
+          panic_impossible ();
+          break;
 
-        if (! error_state)
+        case 1:
           {
+            idx_vector i = idx (0).index_vector ();
+
             // optimize single scalar index.
             if (i.is_scalar () && i(0) < matrix.numel ())
               matrix(i(0)) = rhs;
             else
               matrix.assign (i, mrhs);
           }
-      }
-      break;
+          break;
 
-    case 2:
-      {
-        idx_vector i = idx (0).index_vector ();
+        case 2:
+          {
+            idx_vector i = idx (0).index_vector ();
 
-        if (! error_state)
-          {
+            k = 1;
             idx_vector j = idx (1).index_vector ();
 
-            if (! error_state)
-              {
-                // optimize two scalar indices.
-                if (i.is_scalar () && j.is_scalar () && nd == 2
-                    && i(0) < matrix.rows () && j(0) < matrix.columns ())
-                  matrix(i(0), j(0)) = rhs;
-                else
-                  matrix.assign (i, j, mrhs);
-              }
+            // optimize two scalar indices.
+            if (i.is_scalar () && j.is_scalar () && nd == 2
+                && i(0) < matrix.rows () && j(0) < matrix.columns ())
+              matrix(i(0), j(0)) = rhs;
+            else
+              matrix.assign (i, j, mrhs);
           }
-      }
-      break;
+          break;
 
-    default:
-      {
-        Array<idx_vector> idx_vec (dim_vector (n_idx, 1));
-        bool scalar_opt = n_idx == nd;
-        const dim_vector dv = matrix.dims ().redim (n_idx);
-
-        for (octave_idx_type i = 0; i < n_idx; i++)
+        default:
           {
-            idx_vec(i) = idx(i).index_vector ();
+            Array<idx_vector> idx_vec (dim_vector (n_idx, 1));
+            bool scalar_opt = n_idx == nd;
+            const dim_vector dv = matrix.dims ().redim (n_idx);
 
-            if (error_state)
-              break;
+            for (k = 0; k < n_idx; k++)
+              {
+                idx_vec(k) = idx(k).index_vector ();
 
-            scalar_opt = (scalar_opt && idx_vec(i).is_scalar ()
-                          && idx_vec(i)(0) < dv(i));
-          }
+                scalar_opt = (scalar_opt && idx_vec(k).is_scalar ()
+                              && idx_vec(k)(0) < dv(k));
+              }
 
-        if (! error_state)
-          {
             if (scalar_opt)
               {
-                // optimize all scalar indices. Don't construct an index array,
-                // but rather calc a scalar index directly.
-                octave_idx_type k = 1;
+                // optimize all scalar indices. Don't construct
+                // an index array, but rather calc a scalar index directly.
+                octave_idx_type n = 1;
                 octave_idx_type j = 0;
                 for (octave_idx_type i = 0; i < n_idx; i++)
                   {
-                    j += idx_vec(i)(0) * k;
-                    k *= dv (i);
+                    j += idx_vec(i)(0) * n;
+                    n *= dv (i);
                   }
                 matrix(j) = rhs;
               }
             else
               matrix.assign (idx_vec, mrhs);
           }
-      }
-      break;
+          break;
+        }
+    }
+  catch (const index_exception& e)
+    {
+      gripe_invalid_index (e.idx (), n_idx, k+1);
     }
 
   // Clear cache.
--- a/libinterp/octave-value/ov-base-mat.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-base-mat.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_base_mat_h)
+#if ! defined (octave_ov_base_mat_h)
 #define octave_ov_base_mat_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-base-scalar.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-base-scalar.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_base_scalar_h)
+#if ! defined (octave_ov_base_scalar_h)
 #define octave_ov_base_scalar_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-base-sparse.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-base-sparse.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -35,7 +35,7 @@
 #include "pr-output.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
@@ -44,6 +44,8 @@
 #include "pager.h"
 #include "utils.h"
 
+#include "lo-array-gripes.h"
+
 template <class T>
 octave_value
 octave_base_sparse<T>::do_index_op (const octave_value_list& idx,
@@ -53,36 +55,47 @@
 
   octave_idx_type n_idx = idx.length ();
 
-  switch (n_idx)
+  // If we catch an indexing error in index_vector, we flag an error in
+  // index k.  Ensure it is the right value befor each idx_vector call.
+  // Same variable as used in the for loop in the default case.
+
+  octave_idx_type k = 0;
+
+  try
     {
-    case 0:
-      retval = matrix;
-      break;
-
-    case 1:
-      {
-        idx_vector i = idx (0).index_vector ();
+      switch (n_idx)
+        {
+        case 0:
+          retval = matrix;
+          break;
 
-        if (! error_state)
-          retval = octave_value (matrix.index (i, resize_ok));
-      }
-      break;
+        case 1:
+          {
+            idx_vector i = idx (0).index_vector ();
 
-    case 2:
-      {
-        idx_vector i = idx (0).index_vector ();
+            retval = octave_value (matrix.index (i, resize_ok));
+          }
+          break;
 
-        if (! error_state)
+        case 2:
           {
+            idx_vector i = idx (0).index_vector ();
+
+            k = 1;
             idx_vector j = idx (1).index_vector ();
 
-            if (! error_state)
-              retval = octave_value (matrix.index (i, j, resize_ok));
+            retval = octave_value (matrix.index (i, j, resize_ok));
           }
-      }
-      break;
-    default:
-      error ("sparse indexing needs 1 or 2 indices");
+          break;
+        default:
+          error ("sparse indexing needs 1 or 2 indices");
+        }
+    }
+  catch (index_exception& e)
+    {
+      // Rethrow to allow more info to be reported later.
+      e.set_pos_if_unset (n_idx, k+1);
+      throw;
     }
 
   return retval;
@@ -170,35 +183,46 @@
 
   octave_idx_type len = idx.length ();
 
-  switch (len)
-    {
-    case 1:
-      {
-        idx_vector i = idx (0).index_vector ();
+  // If we catch an indexing error in index_vector, we flag an error in
+  // index k.  Ensure it is the right value befor each idx_vector call.
+  // Same variable as used in the for loop in the default case.
 
-        if (! error_state)
-          matrix.assign (i, rhs);
+  octave_idx_type k = 0;
 
-        break;
-      }
+  try
+    {
+      switch (len)
+        {
+        case 1:
+          {
+            idx_vector i = idx (0).index_vector ();
 
-    case 2:
-      {
-        idx_vector i = idx (0).index_vector ();
+            matrix.assign (i, rhs);
+
+            break;
+          }
 
-        if (! error_state)
+        case 2:
           {
+            idx_vector i = idx (0).index_vector ();
+
+            k = 1;
             idx_vector j = idx (1).index_vector ();
 
-            if (! error_state)
-              matrix.assign (i, j, rhs);
+            matrix.assign (i, j, rhs);
+
+            break;
           }
 
-        break;
-      }
-
-    default:
-      error ("sparse indexing needs 1 or 2 indices");
+        default:
+          error ("sparse indexing needs 1 or 2 indices");
+        }
+    }
+  catch (index_exception& e)
+    {
+      // Rethrow to allow more info to be reported later.
+      e.set_pos_if_unset (len, k+1);
+      throw;
     }
 
 
@@ -212,35 +236,46 @@
 {
   octave_idx_type len = idx.length ();
 
-  switch (len)
-    {
-    case 1:
-      {
-        idx_vector i = idx (0).index_vector ();
+  // If we catch an indexing error in index_vector, we flag an error in
+  // index k.  Ensure it is the right value befor each idx_vector call.
+  // Same variable as used in the for loop in the default case.
 
-        if (! error_state)
-          matrix.delete_elements (i);
+  octave_idx_type k = 0;
 
-        break;
-      }
+  try
+    {
+      switch (len)
+        {
+        case 1:
+          {
+            idx_vector i = idx (0).index_vector ();
 
-    case 2:
-      {
-        idx_vector i = idx (0).index_vector ();
+            matrix.delete_elements (i);
+
+            break;
+          }
 
-        if (! error_state)
+        case 2:
           {
+            idx_vector i = idx (0).index_vector ();
+
+            k = 1;
             idx_vector j = idx (1).index_vector ();
 
-            if (! error_state)
-              matrix.delete_elements (i, j);
+            matrix.delete_elements (i, j);
+
+            break;
           }
 
-        break;
-      }
-
-    default:
-      error ("sparse indexing needs 1 or 2 indices");
+        default:
+          error ("sparse indexing needs 1 or 2 indices");
+        }
+    }
+  catch (index_exception& e)
+    {
+      // Rethrow to allow more info to be reported later.
+      e.set_pos_if_unset (len, k+1);
+      throw;
     }
 
   // Invalidate the matrix type
@@ -394,8 +429,8 @@
   matrix.maybe_compress ();
 
   os << "# nnz: "      << nnz () << "\n";
-  os << "# rows: "     << dv (0) << "\n";
-  os << "# columns: "  << dv (1) << "\n";
+  os << "# rows: "     << dv(0) << "\n";
+  os << "# columns: "  << dv(1) << "\n";
 
   os << this->matrix;
 
--- a/libinterp/octave-value/ov-base-sparse.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-base-sparse.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_base_sparse_h)
+#if ! defined (octave_ov_base_sparse_h)
 #define octave_ov_base_sparse_h 1
 
 #include <cstdlib>
@@ -143,7 +143,7 @@
 
   bool is_true (void) const;
 
-  octave_idx_type capacity (void) const { return matrix.capacity (); }
+  GCC_ATTR_DEPRECATED octave_idx_type capacity (void) const { return nzmax (); }
 
   bool print_as_scalar (void) const;
 
--- a/libinterp/octave-value/ov-base.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-base.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -218,8 +218,8 @@
 idx_vector
 octave_base_value::index_vector (bool /* require_integers */) const
 {
-  std::string nm = type_name ();
-  error ("%s type invalid as index value", nm.c_str ());
+  std::string nm = "<" + type_name () + ">";
+  gripe_invalid_index (nm.c_str ());
   return idx_vector ();
 }
 
@@ -441,7 +441,7 @@
 
   print (output_buf);
 
-  if (print_padding  && pad_after && ! Vcompact_format)
+  if (print_padding && pad_after && ! Vcompact_format)
     newline (output_buf);
 }
 
@@ -458,22 +458,25 @@
   { \
     T retval = 0; \
  \
-    double d = double_value (frc_str_conv); \
+    double d = 0.0; \
  \
-    if (! error_state) \
+    try \
+      { \
+        d = double_value (frc_str_conv); \
+      } \
+    catch (octave_execution_exception& e) \
       { \
-        if (require_int && D_NINT (d) != d) \
-          error_with_cfn ("conversion of %g to " #T " value failed", d); \
-        else if (d < std::numeric_limits<T>::min ()) \
-          retval = std::numeric_limits<T>::min (); \
-        else if (d > std::numeric_limits<T>::max ()) \
-          retval = std::numeric_limits<T>::max (); \
-        else \
-          retval = static_cast<T> (::fix (d));  \
+        gripe_wrong_type_arg (e, "octave_base_value::" #F "_value ()", type_name ()); \
       } \
+ \
+    if (require_int && D_NINT (d) != d) \
+      error_with_cfn ("conversion of %g to " #T " value failed", d); \
+    else if (d < std::numeric_limits<T>::min ()) \
+      retval = std::numeric_limits<T>::min (); \
+    else if (d > std::numeric_limits<T>::max ()) \
+      retval = std::numeric_limits<T>::max (); \
     else \
-      gripe_wrong_type_arg ("octave_base_value::" #F "_value ()", \
-                            type_name ()); \
+      retval = static_cast<T> (::fix (d)); \
  \
     return retval; \
   }
@@ -493,24 +496,21 @@
 int
 octave_base_value::nint_value (bool frc_str_conv) const
 {
-  int retval = 0;
+  double d = 0.0;
 
-  double d = double_value (frc_str_conv);
-
-  if (! error_state)
+  try
+    {
+      d = double_value (frc_str_conv);
+    }
+  catch (octave_execution_exception& e)
     {
-      if (xisnan (d))
-        {
-          error ("conversion of NaN to integer value failed");
-          return retval;
-        }
+      gripe_wrong_type_arg (e, "octave_base_value::nint_value ()", type_name ());
+    }
 
-      retval = static_cast<int> (::fix (d));
-    }
-  else
-    gripe_wrong_type_arg ("octave_base_value::nint_value ()", type_name ());
+  if (xisnan (d))
+    error ("conversion of NaN to integer value failed");
 
-  return retval;
+  return static_cast<int> (::fix (d));
 }
 
 double
@@ -658,8 +658,7 @@
 
   octave_value tmp = convert_to_str (false, force);
 
-  if (! error_state)
-    retval = tmp.char_matrix_value ();
+  retval = tmp.char_matrix_value ();
 
   return retval;
 }
@@ -894,8 +893,7 @@
 
   octave_value tmp = convert_to_str (pad, true);
 
-  if (! error_state)
-    retval = tmp.all_strings ();
+  retval = tmp.all_strings ();
 
   return retval;
 }
@@ -907,9 +905,16 @@
 
   octave_value tmp = convert_to_str (force);
 
-  if (! error_state)
-    retval = tmp.string_value ();
+  retval = tmp.string_value ();
+
+  return retval;
+}
 
+std::string
+octave_base_value::xstring_value (void) const
+{
+  std::string retval;
+  wrong_type_arg_error ();
   return retval;
 }
 
@@ -917,7 +922,7 @@
 octave_base_value::cellstr_value (void) const
 {
   Array<std::string> retval;
-  gripe_wrong_type_arg ("octave_base_value::cellstry_value()",
+  gripe_wrong_type_arg ("octave_base_value::cellstr_value()",
                         type_name ());
   return retval;
 }
@@ -941,17 +946,16 @@
 octave_scalar_map
 octave_base_value::scalar_map_value (void) const
 {
+  octave_scalar_map retval;
+
   octave_map tmp = map_value ();
 
   if (tmp.numel () == 1)
-    return tmp.checkelem (0);
+    retval = tmp.checkelem (0);
   else
-    {
-      if (! error_state)
-        error ("invalid conversion of multi-dimensional struct to scalar struct");
+    error ("invalid conversion of multi-dimensional struct to scalar struct");
 
-      return octave_scalar_map ();
-    }
+  return retval;
 }
 
 string_vector
@@ -1272,6 +1276,12 @@
      t_name.c_str (), type);
 }
 
+void
+octave_base_value::wrong_type_arg_error (void) const
+{
+  gripe_wrong_type_arg (type_name ());
+}
+
 octave_value
 octave_base_value::map (unary_mapper_t umap) const
 {
@@ -1350,7 +1360,7 @@
     {
       f (*this, idx.front (), rhs.get_rep ());
 
-      done = (! error_state);
+      done = true;
     }
 
   if (done)
@@ -1378,7 +1388,7 @@
 
                   retval = val.subsasgn (type, idx, rhs);
 
-                  done = (! error_state);
+                  done = true;
                 }
               else
                 gripe_assign_conversion_failed (type_name (),
@@ -1388,7 +1398,7 @@
             gripe_indexed_assignment (type_name (), rhs.type_name ());
         }
 
-      if (! (done || error_state))
+      if (! done)
         {
           octave_value tmp_rhs;
 
@@ -1450,7 +1460,7 @@
             {
               retval = tmp_lhs.subsasgn (type, idx, tmp_rhs);
 
-              done = (! error_state);
+              done = true;
             }
           else
             gripe_no_conversion (octave_value::assign_op_as_string
--- a/libinterp/octave-value/ov-base.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-base.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_base_h)
+#if ! defined (octave_ov_base_h)
 #define octave_ov_base_h 1
 
 #include <cstdlib>
@@ -36,7 +36,7 @@
 #include "str-vec.h"
 
 #include "error.h"
-#include "oct-hdf5-id.h"
+#include "oct-hdf5-types.h"
 
 class Cell;
 class mxArray;
@@ -310,7 +310,8 @@
 
   virtual octave_idx_type numel (void) const { return dims ().numel (); }
 
-  virtual octave_idx_type capacity (void) const { return numel (); }
+  GCC_ATTR_DEPRECATED virtual octave_idx_type capacity (void) const
+  { return numel (); }
 
   virtual size_t byte_size (void) const { return 0; }
 
@@ -609,6 +610,11 @@
 
   virtual void convert_to_row_or_column_vector (void);
 
+  // The following extractor functions don't perform any implicit type
+  // conversions.
+
+  virtual std::string xstring_value () const;
+
   virtual bool print_as_scalar (void) const { return false; }
 
   virtual void print (std::ostream& os, bool pr_as_read_syntax = false);
@@ -824,6 +830,8 @@
 
 private:
 
+  void wrong_type_arg_error (void) const;
+
   static int curr_print_indent_level;
   static bool beginning_of_line;
 
--- a/libinterp/octave-value/ov-bool-mat.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-bool-mat.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -47,7 +47,7 @@
 #include "pr-output.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-hdf5.h"
 #include "ls-utils.h"
 
@@ -193,14 +193,14 @@
       os << "# ndims: " << d.length () << "\n";
 
       for (int i = 0; i < d.length (); i++)
-        os << " " << d (i);
+        os << " " << d(i);
 
       os << "\n" << tmp;
     }
   else
     {
       // Keep this case, rather than use generic code above for backward
-      // compatiability. Makes load_ascii much more complex!!
+      // compatibility.  Makes load_ascii much more complex!!
       os << "# rows: " << rows () << "\n"
          << "# columns: " << columns () << "\n";
 
@@ -252,7 +252,7 @@
 
                       if (is)
                         {
-                          for (octave_idx_type i = 0; i < btmp.nelem (); i++)
+                          for (octave_idx_type i = 0; i < btmp.numel (); i++)
                             btmp.elem (i) = (tmp.elem (i) != 0.);
 
                           matrix = btmp;
@@ -344,7 +344,7 @@
 
   boolNDArray m = bool_array_value ();
   bool *mtmp = m.fortran_vec ();
-  octave_idx_type nel = m.nelem ();
+  octave_idx_type nel = m.numel ();
   OCTAVE_LOCAL_BUFFER (char, htmp, nel);
 
   for (octave_idx_type i = 0; i < nel; i++)
@@ -431,7 +431,7 @@
 
   // Octave uses column-major, while HDF5 uses row-major ordering
   for (int i = 0; i < rank; i++)
-    hdims[i] = dv (rank-i-1);
+    hdims[i] = dv(rank-i-1);
 
   space_hid = H5Screate_simple (rank, hdims, 0);
   if (space_hid < 0) return false;
@@ -448,7 +448,7 @@
       return false;
     }
 
-  octave_idx_type nel = m.nelem ();
+  octave_idx_type nel = m.numel ();
   bool *mtmp = m.fortran_vec ();
   OCTAVE_LOCAL_BUFFER (hbool_t, htmp, nel);
 
@@ -572,25 +572,24 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
+  if (args.length () != 1)
+    print_usage ();
+
+  octave_value arg = args(0);
+
+  if (arg.is_bool_type ())
+    retval = arg;
+  else if (arg.is_numeric_type ())
     {
-      octave_value arg = args(0);
-      if (arg.is_bool_type ())
-        retval = arg;
-      else if (arg.is_numeric_type ())
-        {
-          if (arg.is_sparse_type ())
-            retval = arg.sparse_bool_matrix_value ();
-          else if (arg.is_scalar_type ())
-            retval = arg.bool_value ();
-          else
-            retval = arg.bool_array_value ();
-        }
+      if (arg.is_sparse_type ())
+        retval = arg.sparse_bool_matrix_value ();
+      else if (arg.is_scalar_type ())
+        retval = arg.bool_value ();
       else
-        gripe_wrong_type_arg ("logical", arg);
+        retval = arg.bool_array_value ();
     }
   else
-    print_usage ();
+    gripe_wrong_type_arg ("logical", arg);
 
   return retval;
 }
--- a/libinterp/octave-value/ov-bool-mat.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-bool-mat.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_bool_mat_h)
+#if ! defined (octave_ov_bool_mat_h)
 #define octave_ov_bool_mat_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-bool-sparse.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-bool-sparse.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -319,7 +319,7 @@
       m.ridx (i) = tmp;
     }
 
-  if (error_state || ! is)
+  if (! is)
     return false;
 
   OCTAVE_LOCAL_BUFFER (char, htmp, nz);
--- a/libinterp/octave-value/ov-bool-sparse.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-bool-sparse.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_bool_sparse_h)
+#if ! defined (octave_ov_bool_sparse_h)
 #define octave_ov_bool_sparse_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-bool.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-bool.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -42,7 +42,7 @@
 #include "ov-scalar.h"
 #include "pr-output.h"
 
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-hdf5.h"
 
 template class octave_base_scalar<bool>;
--- a/libinterp/octave-value/ov-bool.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-bool.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_bool_h)
+#if ! defined (octave_ov_bool_h)
 #define octave_ov_bool_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-builtin.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-builtin.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -105,11 +105,8 @@
 {
   octave_value_list retval;
 
-  if (error_state)
-    return retval;
-
   if (args.has_magic_colon ())
-    ::error ("invalid use of colon in function argument list");
+    error ("invalid use of colon in function argument list");
   else
     {
       unwind_protect frame;
@@ -124,29 +121,22 @@
           curr_lvalue_list = lvalue_list;
         }
 
-      try
-        {
-          BEGIN_PROFILER_BLOCK (octave_builtin)
+      BEGIN_PROFILER_BLOCK (octave_builtin)
 
-          retval = (*f) (args, nargout);
-          // Do not allow null values to be returned from functions.
-          // FIXME: perhaps true builtins should be allowed?
-          retval.make_storable_values ();
-          // Fix the case of a single undefined value.
-          // This happens when a compiled function uses
-          //   octave_value retval;
-          // instead of
-          //   octave_value_list retval;
-          // the idiom is very common, so we solve that here.
-          if (retval.length () == 1 && retval.xelem (0).is_undefined ())
-            retval.clear ();
+        retval = (*f) (args, nargout);
+      // Do not allow null values to be returned from functions.
+      // FIXME: perhaps true builtins should be allowed?
+      retval.make_storable_values ();
+      // Fix the case of a single undefined value.
+      // This happens when a compiled function uses
+      //   octave_value retval;
+      // instead of
+      //   octave_value_list retval;
+      // the idiom is very common, so we solve that here.
+      if (retval.length () == 1 && retval.xelem (0).is_undefined ())
+        retval.clear ();
 
-          END_PROFILER_BLOCK
-        }
-      catch (octave_execution_exception)
-        {
-          gripe_library_execution_error ();
-        }
+      END_PROFILER_BLOCK
     }
 
   return retval;
--- a/libinterp/octave-value/ov-builtin.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-builtin.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_builtin_h)
+#if ! defined (octave_ov_builtin_h)
 #define octave_ov_builtin_h 1
 
 #include <string>
--- a/libinterp/octave-value/ov-cell.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-cell.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -53,7 +53,7 @@
 #include "ov-scalar.h"
 #include "gripes.h"
 
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-oct-binary.h"
 #include "ls-hdf5.h"
 #include "ls-utils.h"
@@ -128,12 +128,6 @@
 
 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cell, "cell", "cell");
 
-static void
-gripe_failed_assignment (void)
-{
-  error ("assignment to cell array failed");
-}
-
 octave_value_list
 octave_cell::subsref (const std::string& type,
                       const std::list<octave_value_list>& idx,
@@ -152,15 +146,12 @@
       {
         octave_value tmp = do_index_op (idx.front ());
 
-        if (! error_state)
-          {
-            Cell tcell = tmp.cell_value ();
+        Cell tcell = tmp.cell_value ();
 
-            if (tcell.length () == 1)
-              retval(0) = tcell(0,0);
-            else
-              retval = octave_value (octave_value_list (tcell), true);
-          }
+        if (tcell.numel () == 1)
+          retval(0) = tcell(0,0);
+        else
+          retval = octave_value (octave_value_list (tcell), true);
       }
       break;
 
@@ -204,15 +195,12 @@
       {
         octave_value tmp = do_index_op (idx.front (), auto_add);
 
-        if (! error_state)
-          {
-            const Cell tcell = tmp.cell_value ();
+        const Cell tcell = tmp.cell_value ();
 
-            if (tcell.length () == 1)
-              retval = tcell(0,0);
-            else
-              retval = octave_value (octave_value_list (tcell), true);
-          }
+        if (tcell.numel () == 1)
+          retval = tcell(0,0);
+        else
+          retval = octave_value (octave_value_list (tcell), true);
       }
       break;
 
@@ -280,16 +268,13 @@
                 if (! tmp.is_defined ())
                   tmp = octave_value::empty_conv (type.substr (1), rhs);
 
-                if (! error_state)
-                  {
-                    std::list<octave_value_list> next_idx (idx);
+                std::list<octave_value_list> next_idx (idx);
+
+                next_idx.erase (next_idx.begin ());
 
-                    next_idx.erase (next_idx.begin ());
+                tmp.make_unique ();
 
-                    tmp.make_unique ();
-
-                    t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs);
-                  }
+                t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs);
               }
           }
           break;
@@ -299,34 +284,30 @@
             matrix.make_unique ();
             Cell tmpc = matrix.index (idx.front (), true);
 
-            if (! error_state)
-              {
-                std::list<octave_value_list> next_idx (idx);
+            std::list<octave_value_list> next_idx (idx);
+
+            next_idx.erase (next_idx.begin ());
+
+            std::string next_type = type.substr (1);
 
-                next_idx.erase (next_idx.begin ());
+            if (tmpc.numel () == 1)
+              {
+                octave_value tmp = tmpc(0);
+                tmpc = Cell ();
 
-                std::string next_type = type.substr (1);
-
-                if (tmpc.numel () == 1)
+                if (! tmp.is_defined () || tmp.is_zero_by_zero ())
                   {
-                    octave_value tmp = tmpc(0);
-                    tmpc = Cell ();
-
-                    if (! tmp.is_defined () || tmp.is_zero_by_zero ())
-                      {
-                        tmp = octave_value::empty_conv (type.substr (1), rhs);
-                        tmp.make_unique (); // probably a no-op.
-                      }
-                    else
-                      // optimization: ignore copy still stored inside array.
-                      tmp.make_unique (1);
-
-                    if (! error_state)
-                      t_rhs = tmp.subsasgn (next_type, next_idx, rhs);
+                    tmp = octave_value::empty_conv (type.substr (1), rhs);
+                    tmp.make_unique (); // probably a no-op.
                   }
                 else
-                  gripe_indexed_cs_list ();
+                  // optimization: ignore copy still stored inside array.
+                  tmp.make_unique (1);
+
+                t_rhs = tmp.subsasgn (next_type, next_idx, rhs);
               }
+            else
+              gripe_indexed_cs_list ();
           }
           break;
 
@@ -349,93 +330,80 @@
         }
     }
 
-  if (! error_state)
+  switch (type[0])
     {
-      switch (type[0])
-        {
-        case '(':
-          {
-            octave_value_list i = idx.front ();
+    case '(':
+      {
+        octave_value_list i = idx.front ();
 
-            if (t_rhs.is_cell ())
-              octave_base_matrix<Cell>::assign (i, t_rhs.cell_value ());
-            else if (t_rhs.is_null_value ())
-              octave_base_matrix<Cell>::delete_elements (i);
-            else
-              octave_base_matrix<Cell>::assign (i, Cell (t_rhs));
+        if (t_rhs.is_cell ())
+          octave_base_matrix<Cell>::assign (i, t_rhs.cell_value ());
+        else if (t_rhs.is_null_value ())
+          octave_base_matrix<Cell>::delete_elements (i);
+        else
+          octave_base_matrix<Cell>::assign (i, Cell (t_rhs));
 
-            if (! error_state)
-              {
-                count++;
-                retval = octave_value (this);
-              }
-            else
-              gripe_failed_assignment ();
-          }
-          break;
+        count++;
+        retval = octave_value (this);
+      }
+      break;
 
-        case '{':
+    case '{':
+      {
+        octave_value_list idxf = idx.front ();
+
+        if (t_rhs.is_cs_list ())
           {
-            octave_value_list idxf = idx.front ();
+            Cell tmp_cell = Cell (t_rhs.list_value ());
 
-            if (t_rhs.is_cs_list ())
-              {
-                Cell tmp_cell = Cell (t_rhs.list_value ());
+            // Inquire the proper shape of the RHS.
 
-                // Inquire the proper shape of the RHS.
+            dim_vector didx = dims ().redim (idxf.length ());
+            for (octave_idx_type k = 0; k < idxf.length (); k++)
+              if (! idxf(k).is_magic_colon ()) didx(k) = idxf(k).numel ();
 
-                dim_vector didx = dims ().redim (idxf.length ());
-                for (octave_idx_type k = 0; k < idxf.length (); k++)
-                  if (! idxf(k).is_magic_colon ()) didx(k) = idxf(k).numel ();
-
-                if (didx.numel () == tmp_cell.numel ())
-                  tmp_cell = tmp_cell.reshape (didx);
+            if (didx.numel () == tmp_cell.numel ())
+              tmp_cell = tmp_cell.reshape (didx);
 
 
-                octave_base_matrix<Cell>::assign (idxf, tmp_cell);
-              }
-            else if (idxf.all_scalars ()
-                     || do_index_op (idxf, true).numel () == 1)
-              // Regularize a null matrix if stored into a cell.
-              octave_base_matrix<Cell>::assign (idxf,
-                                                Cell (t_rhs.storable_value ()));
-            else if (! error_state)
-              gripe_nonbraced_cs_list_assignment ();
+            octave_base_matrix<Cell>::assign (idxf, tmp_cell);
+          }
+        else if (idxf.all_scalars ()
+                 || do_index_op (idxf, true).numel () == 1)
+          // Regularize a null matrix if stored into a cell.
+          octave_base_matrix<Cell>::assign (idxf,
+                                            Cell (t_rhs.storable_value ()));
+        else
+          gripe_nonbraced_cs_list_assignment ();
 
-            if (! error_state)
-              {
-                count++;
-                retval = octave_value (this);
-              }
-            else
-              gripe_failed_assignment ();
-          }
-          break;
+        count++;
+        retval = octave_value (this);
+      }
+      break;
 
-        case '.':
+    case '.':
+      {
+        if (is_empty ())
           {
-            if (is_empty ())
-              {
-                // Allow conversion of empty cell array to some other
-                // type in cases like
-                //
-                //  x = {}; x.f = rhs
+            // Allow conversion of empty cell array to some other
+            // type in cases like
+            //
+            //  x = {}; x.f = rhs
 
-                octave_value tmp = octave_value::empty_conv (type, rhs);
+            octave_value tmp = octave_value::empty_conv (type, rhs);
 
-                return tmp.subsasgn (type, idx, rhs);
-              }
-            else
-              {
-                std::string nm = type_name ();
-                error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
-              }
+            return tmp.subsasgn (type, idx, rhs);
           }
-          break;
+        else
+          {
+            std::string nm = type_name ();
+            error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
+          }
+      }
+      break;
 
-        default:
-          panic_impossible ();
-        }
+    default:
+      panic_impossible ();
     }
 
   return retval;
@@ -496,17 +464,15 @@
 {
   octave_value retval;
 
-  if (is_cellstr ())
-    {
-      Array<std::string> tmp = cellstr_value ();
+  if (! is_cellstr ())
+    error ("sort: only cell arrays of character strings may be sorted");
 
-      tmp = tmp.sort (dim, mode);
+  Array<std::string> tmp = cellstr_value ();
 
-      // We already have the cache.
-      retval = new octave_cell (tmp);
-    }
-  else
-    error ("sort: only cell arrays of character strings may be sorted");
+  tmp = tmp.sort (dim, mode);
+
+  // We already have the cache.
+  retval = new octave_cell (tmp);
 
   return retval;
 }
@@ -517,17 +483,15 @@
 {
   octave_value retval;
 
-  if (is_cellstr ())
-    {
-      Array<std::string> tmp = cellstr_value ();
+  if (! is_cellstr ())
+    error ("sort: only cell arrays of character strings may be sorted");
 
-      tmp = tmp.sort (sidx, dim, mode);
+  Array<std::string> tmp = cellstr_value ();
 
-      // We already have the cache.
-      retval = new octave_cell (tmp);
-    }
-  else
-    error ("sort: only cell arrays of character strings may be sorted");
+  tmp = tmp.sort (sidx, dim, mode);
+
+  // We already have the cache.
+  retval = new octave_cell (tmp);
 
   return retval;
 }
@@ -537,14 +501,12 @@
 {
   sortmode retval = UNSORTED;
 
-  if (is_cellstr ())
-    {
-      Array<std::string> tmp = cellstr_value ();
+  if (! is_cellstr ())
+    error ("issorted: A is not a cell array of strings");
 
-      retval = tmp.is_sorted (mode);
-    }
-  else
-    error ("issorted: A is not a cell array of strings");
+  Array<std::string> tmp = cellstr_value ();
+
+  retval = tmp.is_sorted (mode);
 
   return retval;
 }
@@ -555,14 +517,12 @@
 {
   Array<octave_idx_type> retval;
 
-  if (is_cellstr ())
-    {
-      Array<std::string> tmp = cellstr_value ();
+  if (! is_cellstr ())
+    error ("sortrows: only cell arrays of character strings may be sorted");
 
-      retval = tmp.sort_rows_idx (mode);
-    }
-  else
-    error ("sortrows: only cell arrays of character strings may be sorted");
+  Array<std::string> tmp = cellstr_value ();
+
+  retval = tmp.sort_rows_idx (mode);
 
   return retval;
 }
@@ -572,14 +532,12 @@
 {
   sortmode retval = UNSORTED;
 
-  if (is_cellstr ())
-    {
-      Array<std::string> tmp = cellstr_value ();
+  if (! is_cellstr ())
+    error ("issorted: A is not a cell array of strings");
 
-      retval = tmp.is_sorted_rows (mode);
-    }
-  else
-    error ("issorted: A is not a cell array of strings");
+  Array<std::string> tmp = cellstr_value ();
+
+  retval = tmp.is_sorted_rows (mode);
 
   return retval;
 }
@@ -614,10 +572,7 @@
     {
       string_vector s = matrix(i).all_strings ();
 
-      if (error_state)
-        return retval;
-
-      octave_idx_type s_len = s.length ();
+      octave_idx_type s_len = s.numel ();
 
       n_elts += s_len ? s_len : 1;
 
@@ -638,7 +593,7 @@
       const string_vector s = strvec_queue.front ();
       strvec_queue.pop ();
 
-      octave_idx_type s_len = s.length ();
+      octave_idx_type s_len = s.numel ();
 
       if (s_len)
         {
@@ -767,7 +722,7 @@
       os << "# ndims: " << d.length () << "\n";
 
       for (int i = 0; i < d.length (); i++)
-        os << " " << d (i);
+        os << " " << d(i);
       os << "\n";
 
       Cell tmp = cell_value ();
@@ -777,7 +732,7 @@
           octave_value o_val = tmp.elem (i);
 
           // Recurse to print sub-value.
-          bool b = save_ascii_data (os, o_val, CELL_ELT_TAG, false, 0);
+          bool b = save_text_data (os, o_val, CELL_ELT_TAG, false, 0);
 
           if (! b)
             return ! os.fail ();
@@ -786,7 +741,7 @@
   else
     {
       // Keep this case, rather than use generic code above for backward
-      // compatiability. Makes load_ascii much more complex!!
+      // compatibility.  Makes load_ascii much more complex!!
       os << "# rows: " << rows () << "\n"
          << "# columns: " << columns () << "\n";
 
@@ -799,7 +754,7 @@
               octave_value o_val = tmp.elem (i, j);
 
               // Recurse to print sub-value.
-              bool b = save_ascii_data (os, o_val, CELL_ELT_TAG, false, 0);
+              bool b = save_text_data (os, o_val, CELL_ELT_TAG, false, 0);
 
               if (! b)
                 return ! os.fail ();
@@ -849,7 +804,7 @@
                   bool dummy;
 
                   // recurse to read cell elements
-                  std::string nm = read_ascii_data (is, std::string (),
+                  std::string nm = read_text_data (is, std::string (),
                                                     dummy, t2, i);
 
                   if (nm == CELL_ELT_TAG)
@@ -898,7 +853,7 @@
                           bool dummy;
 
                           // recurse to read cell elements
-                          std::string nm = read_ascii_data (is, std::string (),
+                          std::string nm = read_text_data (is, std::string (),
                                                             dummy, t2, i);
 
                           if (nm == CELL_ELT_TAG)
@@ -1282,14 +1237,10 @@
 @seealso{ismatrix, isstruct, iscellstr, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_cell ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_cell ());
 }
 
 DEFUN (cell, args, ,
@@ -1328,28 +1279,17 @@
         dims.resize (nargin);
 
         for (int i = 0; i < nargin; i++)
-          {
-            dims(i) = args(i).is_empty () ? 0 : args(i).nint_value ();
-
-            if (error_state)
-              {
-                error ("cell: expecting scalar arguments");
-                break;
-              }
-          }
+          dims(i) = (args(i).is_empty ()
+                     ? 0 : args(i).xnint_value ("cell: dimension must be a scalar integer"));
       }
       break;
     }
 
-  if (! error_state)
-    {
-      dims.chop_trailing_singletons ();
+  dims.chop_trailing_singletons ();
 
-      check_dimensions (dims, "cell");
+  check_dimensions (dims, "cell");
 
-      if (! error_state)
-        retval = Cell (dims, Matrix ());
-    }
+  retval = Cell (dims, Matrix ());
 
   return retval;
 }
@@ -1362,14 +1302,10 @@
 @seealso{ischar}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_cellstr ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_cellstr ());
 }
 
 // Note that since Fcellstr calls Fiscellstr, we need to have
@@ -1392,26 +1328,21 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      octave_value_list tmp = Fiscellstr (args, 1);
+  if (args.length () != 1)
+    print_usage ();
 
-      if (tmp(0).is_true ())
-        retval = args(0);
-      else
-        {
-          string_vector s = args(0).all_strings ();
+  octave_value_list tmp = Fiscellstr (args, 1);
 
-          if (! error_state)
-            retval = (s.is_empty ()
-                      ? Cell (octave_value (std::string ()))
-                      : Cell (s, true));
-          else
-            error ("cellstr: argument STRING must be a 2-D character array");
-        }
+  if (tmp(0).is_true ())
+    retval = args(0);
+  else
+    {
+      string_vector s = args(0).xall_strings ("cellstr: argument STRING must be a 2-D character array");
+
+      retval = (s.is_empty ()
+                ? Cell (octave_value (std::string ()))
+                : Cell (s, true));
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1451,54 +1382,41 @@
 @seealso{cell2struct, fieldnames}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    {
-      const octave_map m = args(0).map_value ();
-
-      if (! error_state)
-        {
-          const dim_vector m_dv = m.dims ();
-
-          octave_idx_type num_fields = m.nfields ();
-
-          // The resulting dim_vector should have dimensions:
-          // [numel(fields) size(struct)]
-          // except if the struct is a column vector.
-
-          dim_vector result_dv;
-          if (m_dv (m_dv.length () - 1) == 1)
-            result_dv.resize (m_dv.length ());
-          else
-            result_dv.resize (m_dv.length () + 1); // Add 1 for the fields.
-
-          result_dv(0) = num_fields;
-
-          for (int i = 1; i < result_dv.length (); i++)
-            result_dv(i) = m_dv(i-1);
-
-          NoAlias<Cell> c (result_dv);
-
-          octave_idx_type n_elts = m.numel ();
-
-          // Fill c in one sweep. Note that thanks to octave_map structure,
-          // we don't need a key lookup at all.
-          for (octave_idx_type j = 0; j < n_elts; j++)
-            for (octave_idx_type i = 0; i < num_fields; i++)
-              c(i,j) = m.contents(i)(j);
-
-          retval = c;
-        }
-      else
-        error ("struct2cell: argument S must be a structure");
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  const octave_map m = args(0).xmap_value ("struct2cell: argument S must be a structure");
+
+  const dim_vector m_dv = m.dims ();
+
+  octave_idx_type num_fields = m.nfields ();
+
+  // The resulting dim_vector should have dimensions:
+  // [numel(fields) size(struct)]
+  // except if the struct is a column vector.
+
+  dim_vector result_dv;
+  if (m_dv(m_dv.length () - 1) == 1)
+    result_dv.resize (m_dv.length ());
+  else
+    result_dv.resize (m_dv.length () + 1); // Add 1 for the fields.
+
+  result_dv(0) = num_fields;
+
+  for (int i = 1; i < result_dv.length (); i++)
+    result_dv(i) = m_dv(i-1);
+
+  NoAlias<Cell> c (result_dv);
+
+  octave_idx_type n_elts = m.numel ();
+
+  // Fill c in one sweep. Note that thanks to octave_map structure,
+  // we don't need a key lookup at all.
+  for (octave_idx_type j = 0; j < n_elts; j++)
+    for (octave_idx_type i = 0; i < num_fields; i++)
+      c(i,j) = m.contents(i)(j);
+
+  return octave_value (c);
 }
 
 /*
--- a/libinterp/octave-value/ov-cell.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-cell.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_cell_h)
+#if ! defined (octave_ov_cell_h)
 #define octave_ov_cell_h 1
 
 #include <cstdlib>
@@ -144,6 +144,8 @@
 
   Array<std::string> cellstr_value (void) const;
 
+  Array<std::string> cellstr_value (const char *fmt, ...) const;
+
   bool print_as_scalar (void) const;
 
   void print (std::ostream& os, bool pr_as_read_syntax = false);
--- a/libinterp/octave-value/ov-ch-mat.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-ch-mat.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -238,8 +238,8 @@
     STRING_MAPPER (xtolower, std::tolower, char);
     STRING_MAPPER (xtoupper, std::toupper, char);
 
-      // For Matlab compatibility, these should work on ASCII values
-      // without error or warning.
+    // For Matlab compatibility, these should work on ASCII values
+    // without error or warning.
     case umap_abs:
     case umap_ceil:
     case umap_fix:
@@ -255,7 +255,7 @@
       }
 
     default:
-      error ("%s: expecting numeric argument", get_umap_name (umap));
+      error ("%s: argument must be numeric", get_umap_name (umap));
       break;
     }
 
--- a/libinterp/octave-value/ov-ch-mat.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-ch-mat.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_ch_mat_h)
+#if ! defined (octave_ov_ch_mat_h)
 #define octave_ov_ch_mat_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-class.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-class.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -39,7 +39,7 @@
 #include "gripes.h"
 #include "load-path.h"
 #include "ls-hdf5.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-oct-binary.h"
 #include "ls-utils.h"
 #include "mxarray.h"
@@ -203,8 +203,7 @@
         }
     }
 
-  if (! error_state)
-    symbol_table::add_to_parent_map (id, parent_list);
+  symbol_table::add_to_parent_map (id, parent_list);
 }
 
 octave_base_value *
@@ -262,12 +261,6 @@
   error ("%s cannot be indexed with %c", nm.c_str (), t);
 }
 
-static void
-gripe_failed_assignment (void)
-{
-  error ("assignment to class element failed");
-}
-
 Cell
 octave_class::dotref (const octave_value_list& idx)
 {
@@ -290,19 +283,14 @@
 
   octave_map my_map = (obvp != this) ? obvp->map_value () : map;
 
-  std::string nm = idx(0).string_value ();
+  std::string nm = idx(0).xstring_value ("invalid index for class");
 
-  if (! error_state)
-    {
-      octave_map::const_iterator p = my_map.seek (nm);
+  octave_map::const_iterator p = my_map.seek (nm);
 
-      if (p != my_map.end ())
-        retval = my_map.contents (p);
-      else
-        error ("class has no member '%s'", nm.c_str ());
-    }
+  if (p != my_map.end ())
+    retval = my_map.contents (p);
   else
-    gripe_invalid_index1 ();
+    error ("class has no member '%s'", nm.c_str ());
 
   return retval;
 }
@@ -402,18 +390,15 @@
 
                 Cell tmp = dotref (key_idx);
 
-                if (! error_state)
-                  {
-                    Cell t = tmp.index (idx.front ());
+                Cell t = tmp.index (idx.front ());
+
+                retval(0) = (t.numel () == 1) ? t(0)
+                  : octave_value (t, true);
 
-                    retval(0) = (t.length () == 1) ? t(0)
-                                                   : octave_value (t, true);
+                // We handled two index elements, so tell
+                // next_subsref to skip both of them.
 
-                    // We handled two index elements, so tell
-                    // next_subsref to skip both of them.
-
-                    skip++;
-                  }
+                skip++;
               }
             else
               retval(0) = octave_value (map.index (idx.front ()),
@@ -427,7 +412,7 @@
               {
                 Cell t = dotref (idx.front ());
 
-                retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true);
+                retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true);
               }
           }
           break;
@@ -457,9 +442,6 @@
 
           args(1) = make_idx_args (type, idx, "subsref");
 
-          if (error_state)
-            return octave_value_list ();
-
           count++;
           args(0) = octave_value (this);
 
@@ -508,7 +490,7 @@
 {
   octave_value retval;
 
-  if (val.length () == 1)
+  if (val.numel () == 1)
     {
       retval = val(0);
 
@@ -569,10 +551,6 @@
             args(2) = rhs;
 
           args(1) = make_idx_args (type, idx, "subsasgn");
-
-          if (error_state)
-            return octave_value_list ();
-
           args(0) = obj;
 
           // Now comes the magic. Count copies with me:
@@ -602,11 +580,11 @@
           else
             tmp = feval (meth.function_value (), args);
 
-          // FIXME: should the subsasgn method be able to return
-          // more than one value?
+          // FIXME: Should the subsasgn method be able to return
+          //        more than one value?
 
           if (tmp.length () > 1)
-            error ("expecting single return value from @%s/subsasgn",
+            error ("@%s/subsasgn returned more than one value",
                    class_name ().c_str ());
 
           else
@@ -628,13 +606,9 @@
       if (obvp)
         {
           obvp->subsasgn (type, idx, rhs);
-          if (! error_state)
-            {
-              count++;
-              retval = octave_value (this);
-            }
-          else
-            gripe_failed_assignment ();
+
+          count++;
+          retval = octave_value (this);
         }
       else
         error ("malformed class");
@@ -665,40 +639,32 @@
 
                 assert (key_idx.length () == 1);
 
-                std::string key = key_idx(0).string_value ();
+                std::string key = key_idx(0).xstring_value ("invalid index for class assignment");
 
-                if (! error_state)
-                  {
-                    octave_value u;
+                octave_value u;
 
-                    if (! map.contains (key))
-                      u = octave_value::empty_conv (type.substr (2), rhs);
-                    else
-                      {
-                        Cell map_val = map.contents (key);
+                if (! map.contains (key))
+                  u = octave_value::empty_conv (type.substr (2), rhs);
+                else
+                  {
+                    Cell map_val = map.contents (key);
 
-                        Cell map_elt = map_val.index (idx.front (), true);
-
-                        u = numeric_conv (map_elt, type.substr (2));
-                      }
+                    Cell map_elt = map_val.index (idx.front (), true);
 
-                    if (! error_state)
-                      {
-                        std::list<octave_value_list> next_idx (idx);
+                    u = numeric_conv (map_elt, type.substr (2));
+                  }
 
-                        // We handled two index elements, so subsasgn to
-                        // needs to skip both of them.
+                std::list<octave_value_list> next_idx (idx);
 
-                        next_idx.erase (next_idx.begin ());
-                        next_idx.erase (next_idx.begin ());
-
-                        u.make_unique ();
+                // We handled two index elements, so subsasgn to
+                // needs to skip both of them.
 
-                        t_rhs = u.subsasgn (type.substr (2), next_idx, rhs);
-                      }
-                  }
-                else
-                  gripe_invalid_index_for_assignment ();
+                next_idx.erase (next_idx.begin ());
+                next_idx.erase (next_idx.begin ());
+
+                u.make_unique ();
+
+                t_rhs = u.subsasgn (type.substr (2), next_idx, rhs);
               }
             else
               gripe_invalid_index_for_assignment ();
@@ -728,27 +694,23 @@
               }
 
             // FIXME: better code reuse?
-            if (! error_state)
+            if (tmpc.numel () == 1)
               {
-                if (tmpc.numel () == 1)
-                  {
-                    octave_value& tmp = tmpc(0);
+                octave_value& tmp = tmpc(0);
 
-                    if (! tmp.is_defined () || tmp.is_zero_by_zero ())
-                      {
-                        tmp = octave_value::empty_conv (next_type, rhs);
-                        tmp.make_unique (); // probably a no-op.
-                      }
-                    else
-                      // optimization: ignore copy still stored inside our map.
-                      tmp.make_unique (1);
-
-                    if (! error_state)
-                      t_rhs = tmp.subsasgn (next_type, next_idx, rhs);
+                if (! tmp.is_defined () || tmp.is_zero_by_zero ())
+                  {
+                    tmp = octave_value::empty_conv (next_type, rhs);
+                    tmp.make_unique (); // probably a no-op.
                   }
                 else
-                  gripe_indexed_cs_list ();
+                  // optimization: ignore copy still stored inside our map.
+                  tmp.make_unique (1);
+
+                t_rhs = tmp.subsasgn (next_type, next_idx, rhs);
               }
+            else
+              gripe_indexed_cs_list ();
           }
           break;
 
@@ -761,126 +723,91 @@
         }
     }
 
-  if (! error_state)
+  switch (type[0])
     {
-      switch (type[0])
-        {
-        case '(':
+    case '(':
+      {
+        if (n > 1 && type[1] == '.')
           {
-            if (n > 1 && type[1] == '.')
-              {
-                std::list<octave_value_list>::const_iterator p = idx.begin ();
-                octave_value_list key_idx = *++p;
-
-                assert (key_idx.length () == 1);
-
-                std::string key = key_idx(0).string_value ();
-
-                if (! error_state)
-                  {
-                    map.assign (idx.front (), key, t_rhs);
-
-                    if (! error_state)
-                      {
-                        count++;
-                        retval = octave_value (this);
-                      }
-                    else
-                      gripe_failed_assignment ();
-                  }
-                else
-                  gripe_failed_assignment ();
-              }
-            else
-              {
-                if (t_rhs.is_object () || t_rhs.is_map ())
-                  {
-                    octave_map rhs_map = t_rhs.map_value ();
-
-                    if (! error_state)
-                      {
-                        map.assign (idx.front (), rhs_map);
-
-                        if (! error_state)
-                          {
-                            count++;
-                            retval = octave_value (this);
-                          }
-                        else
-                          gripe_failed_assignment ();
-                      }
-                    else
-                      error ("invalid class assignment");
-                  }
-                else
-                  {
-                    if (t_rhs.is_empty ())
-                      {
-                        map.delete_elements (idx.front ());
-
-                        if (! error_state)
-                          {
-                            count++;
-                            retval = octave_value (this);
-                          }
-                        else
-                          gripe_failed_assignment ();
-                      }
-                    else
-                      error ("invalid class assignment");
-                  }
-              }
-          }
-          break;
-
-        case '.':
-          {
-            octave_value_list key_idx = idx.front ();
+            std::list<octave_value_list>::const_iterator p = idx.begin ();
+            octave_value_list key_idx = *++p;
 
             assert (key_idx.length () == 1);
 
-            std::string key = key_idx(0).string_value ();
+            std::string key = key_idx(0).xstring_value ("assignment to class element failed");
 
-            if (t_rhs.is_cs_list ())
-              {
-                Cell tmp_cell = Cell (t_rhs.list_value ());
-
-                // The shape of the RHS is irrelevant, we just want
-                // the number of elements to agree and to preserve the
-                // shape of the left hand side of the assignment.
+            map.assign (idx.front (), key, t_rhs);
 
-                if (numel () == tmp_cell.numel ())
-                  tmp_cell = tmp_cell.reshape (dims ());
-
-                map.setfield (key, tmp_cell);
-              }
-            else
+            count++;
+            retval = octave_value (this);
+          }
+        else
+          {
+            if (t_rhs.is_object () || t_rhs.is_map ())
               {
-                Cell tmp_cell(1, 1);
-                tmp_cell(0) = t_rhs.storable_value ();
-                map.setfield (key, tmp_cell);
-              }
+                octave_map rhs_map = t_rhs.xmap_value ("invalid class assignment");
 
-            if (! error_state)
-              {
+                map.assign (idx.front (), rhs_map);
+
                 count++;
                 retval = octave_value (this);
               }
             else
-              gripe_failed_assignment ();
+              {
+                if (t_rhs.is_empty ())
+                  {
+                    map.delete_elements (idx.front ());
+
+                    count++;
+                    retval = octave_value (this);
+                  }
+                else
+                  error ("invalid class assignment");
+              }
           }
-          break;
+      }
+      break;
+
+    case '.':
+      {
+        octave_value_list key_idx = idx.front ();
+
+        assert (key_idx.length () == 1);
+
+        std::string key = key_idx(0).string_value ();
+
+        if (t_rhs.is_cs_list ())
+          {
+            Cell tmp_cell = Cell (t_rhs.list_value ());
 
-        case '{':
-          gripe_invalid_index_type (type_name (), type[0]);
-          break;
+            // The shape of the RHS is irrelevant, we just want
+            // the number of elements to agree and to preserve the
+            // shape of the left hand side of the assignment.
+
+            if (numel () == tmp_cell.numel ())
+              tmp_cell = tmp_cell.reshape (dims ());
 
-        default:
-          panic_impossible ();
-        }
+            map.setfield (key, tmp_cell);
+          }
+        else
+          {
+            Cell tmp_cell(1, 1);
+            tmp_cell(0) = t_rhs.storable_value ();
+            map.setfield (key, tmp_cell);
+          }
+
+        count++;
+        retval = octave_value (this);
+      }
+      break;
+
+    case '{':
+      gripe_invalid_index_type (type_name (), type[0]);
+      break;
+
+    default:
+      panic_impossible ();
     }
-  else
-    gripe_failed_assignment ();
 
   return retval;
 }
@@ -899,18 +826,15 @@
 
       octave_value_list tmp = feval (meth.function_value (), args, 1);
 
-      if (!error_state && tmp.length () >= 1)
-        {
-          if (tmp(0).is_object ())
-            error ("subsindex function must return a valid index vector");
-          else
-            // Index vector returned by subsindex is zero based
-            // (why this inconsistency Mathworks?), and so we must
-            // add one to the value returned as the index_vector method
-            // expects it to be one based.
-            retval = do_binary_op (octave_value::op_add, tmp (0),
-                                   octave_value (1.0)).index_vector (require_integers);
-        }
+      if (tmp(0).is_object ())
+        error ("subsindex function must return a valid index vector");
+      else
+        // Index vector returned by subsindex is zero based
+        // (why this inconsistency Mathworks?), and so we must
+        // add one to the value returned as the index_vector method
+        // expects it to be one based.
+        retval = do_binary_op (octave_value::op_add, tmp (0),
+                               octave_value (1.0)).index_vector (require_integers);
     }
   else
     error ("no subsindex method defined for class %s",
@@ -1058,7 +982,7 @@
 
       octave_value_list tmp = feval (meth.function_value (), args, 1);
 
-      if (!error_state && tmp.length () >= 1)
+      if (tmp.length () >= 1)
         {
           if (tmp(0).is_string ())
             retval = tmp(0).all_strings (pad);
@@ -1172,13 +1096,23 @@
 
           interpreter_try (frame);
 
-          octave_value_list result
-            = ctor.do_multi_index_op (1, octave_value_list ());
+          bool execution_error = false;
+
+          octave_value_list result;
 
-          if (! error_state && result.length () == 1)
+          try
+            {
+              result = ctor.do_multi_index_op (1, octave_value_list ());
+            }
+          catch (const octave_execution_exception&)
+            {
+              recover_from_exception ();
+
+              execution_error = true;
+            }
+
+          if (! execution_error && result.length () == 1)
             retval = true;
-
-          error_state = false;
         }
       else
         warning ("no constructor for class %s", c_name.c_str ());
@@ -1262,10 +1196,8 @@
     {
       octave_value in = new octave_class (*this);
       octave_value_list tmp = feval ("saveobj", in, 1);
-      if (! error_state)
-        m = tmp(0).map_value ();
-      else
-        return false;
+
+      m = tmp(0).map_value ();
     }
   else
     m = map_value ();
@@ -1277,7 +1209,7 @@
     {
       octave_value val = map.contents (i);
 
-      bool b = save_ascii_data (os, val, m.key (i), false, 0);
+      bool b = save_text_data (os, val, m.key (i), false, 0);
 
       if (! b)
         return ! os.fail ();
@@ -1310,18 +1242,12 @@
 
                   // recurse to read cell elements
                   std::string nm
-                    = read_ascii_data (is, std::string (), dummy, t2, j);
+                    = read_text_data (is, std::string (), dummy, t2, j);
 
                   if (! is)
                     break;
 
-                  Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2);
-
-                  if (error_state)
-                    {
-                      error ("load: internal error loading class elements");
-                      return false;
-                    }
+                  Cell tcell = t2.is_cell () ? t2.xcell_value ("load: internal error loading class elements") : Cell (t2);
 
                   m.assign (nm, tcell);
                 }
@@ -1342,10 +1268,7 @@
                       octave_value in = new octave_class (*this);
                       octave_value_list tmp = feval ("loadobj", in, 1);
 
-                      if (! error_state)
-                        map = tmp(0).map_value ();
-                      else
-                        success = false;
+                      map = tmp(0).map_value ();
                     }
                 }
               else
@@ -1390,10 +1313,8 @@
     {
       octave_value in = new octave_class (*this);
       octave_value_list tmp = feval ("saveobj", in, 1);
-      if (! error_state)
-        m = tmp(0).map_value ();
-      else
-        return false;
+
+      m = tmp(0).map_value ();
     }
   else
     m = map_value ();
@@ -1463,13 +1384,7 @@
           if (! is)
             break;
 
-          Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2);
-
-          if (error_state)
-            {
-              error ("load: internal error loading class elements");
-              return false;
-            }
+          Cell tcell = t2.is_cell () ? t2.xcell_value ("load: internal error loading class elements") : Cell (t2);
 
           m.assign (nm, tcell);
         }
@@ -1486,10 +1401,7 @@
               octave_value in = new octave_class (*this);
               octave_value_list tmp = feval ("loadobj", in, 1);
 
-              if (! error_state)
-                map = tmp(0).map_value ();
-              else
-                success = false;
+              map = tmp(0).map_value ();
             }
         }
       else
@@ -1561,10 +1473,8 @@
     {
       octave_value in = new octave_class (*this);
       octave_value_list tmp = feval ("saveobj", in, 1);
-      if (! error_state)
-        m = tmp(0).map_value ();
-      else
-        goto error_cleanup;
+
+      m = tmp(0).map_value ();
     }
   else
     m = map_value ();
@@ -1708,13 +1618,7 @@
     {
       octave_value t2 = dsub.tc;
 
-      Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2);
-
-      if (error_state)
-        {
-          error ("load: internal error loading class elements");
-          return false;
-        }
+      Cell tcell = t2.is_cell () ? t2.xcell_value ("load: internal error loading class elements") : Cell (t2);
 
       m.assign (dsub.name, tcell);
 
@@ -1732,13 +1636,8 @@
           octave_value in = new octave_class (*this);
           octave_value_list tmp = feval ("loadobj", in, 1);
 
-          if (! error_state)
-            {
-              map = tmp(0).map_value ();
-              retval = true;
-            }
-          else
-            retval = false;
+          map = tmp(0).map_value ();
+          retval = true;
         }
     }
 
@@ -1877,7 +1776,8 @@
 
   if (nargin == 0)
     print_usage ();
-  else if (nargin == 1)
+
+  if (nargin == 1)
     // Called for class of object
     retval = args(0).class_name ();
   else
@@ -1885,55 +1785,42 @@
       // Called as class constructor
       octave_function *fcn = octave_call_stack::caller ();
 
-      if (args(1).is_string ())
-        {
-          std::string id = args(1).string_value ();
-
-          if (fcn)
-            {
-              if (fcn->is_class_constructor (id) || fcn->is_class_method (id))
-                {
-                  octave_map m = args(0).map_value ();
+      std::string id = args(1).xstring_value ("class: ID (class name) must be a string");
 
-                  if (! error_state)
-                    {
-                      if (nargin == 2)
-                        retval
-                          = octave_value (new octave_class
-                                          (m, id, std::list<std::string> ()));
-                      else
-                        {
-                          octave_value_list parents = args.slice (2, nargin-2);
+      if (fcn)
+        {
+          if (fcn->is_class_constructor (id) || fcn->is_class_method (id))
+            {
+              octave_map m = args(0).xmap_value ("class: S must be a valid structure");
 
-                          retval
-                            = octave_value (new octave_class (m, id, parents));
-                        }
-
-                      if (! error_state)
-                        {
-                          octave_class::exemplar_const_iterator it
-                            = octave_class::exemplar_map.find (id);
+              if (nargin == 2)
+                retval
+                  = octave_value (new octave_class
+                                  (m, id, std::list<std::string> ()));
+              else
+                {
+                  octave_value_list parents = args.slice (2, nargin-2);
 
-                          if (it == octave_class::exemplar_map.end ())
-                            octave_class::exemplar_map[id]
-                              = octave_class::exemplar_info (retval);
-                          else if (! it->second.compare (retval))
-                            error ("class: object of class '%s' does not match previously constructed objects",
-                                   id.c_str ());
-                        }
-                    }
-                  else
-                    error ("class: expecting structure S as first argument");
+                  retval
+                    = octave_value (new octave_class (m, id, parents));
                 }
-              else
-                error ("class: '%s' is invalid as a class name in this context",
+
+              octave_class::exemplar_const_iterator it
+                = octave_class::exemplar_map.find (id);
+
+              if (it == octave_class::exemplar_map.end ())
+                octave_class::exemplar_map[id]
+                  = octave_class::exemplar_info (retval);
+              else if (! it->second.compare (retval))
+                error ("class: object of class '%s' does not match previously constructed objects",
                        id.c_str ());
             }
           else
-            error ("class: invalid call from outside class constructor or method");
+            error ("class: '%s' is invalid as a class name in this context",
+                   id.c_str ());
         }
       else
-        error ("class: ID (class name) must be a string");
+        error ("class: invalid call from outside class constructor or method");
     }
 
   return retval;
@@ -1980,28 +1867,21 @@
   octave_value retval;
 
   if (args.length () != 2)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
-  octave_value obj = args(0); // not const because of find_parent_class ()
-  const Array<std::string> cls = args(1).cellstr_value ();
-  if (error_state)
+  octave_value obj = args(0);  // not const because of find_parent_class ()
+  std::string obj_cls = obj.class_name ();
+  Array<std::string> clsnames = args(1).xcellstr_value ("isa: CLASSNAME must be a string or cell array of strings");
+
+  boolNDArray matches (clsnames.dims (), false);
+  for (octave_idx_type idx = 0; idx < clsnames.numel (); idx++)
     {
-      error ("isa: CLASSNAME must be a string or cell array of strings");
-      return retval;
-    }
-
-  boolNDArray matches (cls.dims (), false);
-  const octave_idx_type n = cls.numel ();
-  for (octave_idx_type idx = 0; idx < n; idx++)
-    {
-      const std::string cl = cls(idx);
-      if ((cl == "float"   && obj.is_float_type   ())
-          || (cl == "integer" && obj.is_integer_type ())
-          || (cl == "numeric" && obj.is_numeric_type ())
-          || obj.class_name () == cl || obj.is_instance_of (cl))
+      std::string cls = clsnames(idx);
+      if (obj_cls == cls
+          || (cls == "float"   && obj.is_float_type   ())
+          || (cls == "integer" && obj.is_integer_type ())
+          || (cls == "numeric" && obj.is_numeric_type ())
+          || obj.is_instance_of (cls))
         matches(idx) = true;
     }
   return octave_value (matches);
@@ -2075,15 +1955,13 @@
 {
   octave_value retval = Cell ();
 
-  if (args.length () == 1)
-    {
-      octave_value arg = args(0);
+  if (args.length () != 1)
+    print_usage ();
 
-      if (arg.is_object ())
-        retval = Cell (arg.parent_class_names ());
-    }
-  else
-    print_usage ();
+  octave_value arg = args(0);
+
+  if (arg.is_object ())
+    retval = Cell (arg.parent_class_names ());
 
   return retval;
 }
@@ -2095,54 +1973,43 @@
 @seealso{class, typeinfo, isa, ismethod, isprop}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_object ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_object ());
 }
 
 DEFUN (ismethod, args, ,
        "-*- texinfo -*-\n\
-@deftypefn {Built-in Function} {} ismethod (@var{obj}, @var{method})\n\
-Return true if @var{obj} is a class object and the string @var{method}\n\
-is a method of this class.\n\
+@deftypefn  {Built-in Function} {} ismethod (@var{obj}, @var{method})\n\
+@deftypefnx {Built-in Function} {} ismethod (@var{clsname}, @var{method})\n\
+Return true if the string @var{method} is a valid method of the object\n\
+@var{obj} or of the class @var{clsname}.\n\
 @seealso{isprop, isobject}\n\
 @end deftypefn")
 {
   octave_value retval;
 
-  if (args.length () == 2)
-    {
-      octave_value arg = args(0);
-
-      std::string class_name;
+  if (args.length () != 2)
+    print_usage ();
 
-      if (arg.is_object ())
-        class_name = arg.class_name ();
-      else if (arg.is_string ())
-        class_name = arg.string_value ();
-      else
-        error ("ismethod: expecting object or class name as first argument");
+  octave_value arg = args(0);
+
+  std::string class_name;
 
-      if (! error_state)
-        {
-          std::string method = args(1).string_value ();
+  if (arg.is_object ())
+    class_name = arg.class_name ();
+  else if (arg.is_string ())
+    class_name = arg.string_value ();
+  else
+    error ("ismethod: first argument must be object or class name");
 
-          if (! error_state)
-            {
-              if (load_path::find_method (class_name, method) != std::string ())
-                retval = true;
-              else
-                retval = false;
-            }
-        }
-    }
+  std::string method = args(1).string_value ();
+
+  if (load_path::find_method (class_name, method) != std::string ())
+    retval = true;
   else
-    print_usage ();
+    retval = false;
 
   return retval;
 }
@@ -2169,11 +2036,8 @@
   else if (arg.is_string ())
     class_name = arg.string_value ();
 
-  if (! error_state)
-    {
-      string_vector sv = load_path::methods (class_name);
-      retval = Cell (sv);
-    }
+  string_vector sv = load_path::methods (class_name);
+  retval = Cell (sv);
 
   return retval;
 }
@@ -2227,12 +2091,7 @@
 
   for (int i = 0; i < args.length (); i++)
     {
-      std::string inf_class = args(i).string_value ();
-      if (error_state)
-        {
-          error ("superiorto: expecting argument to be class name");
-          break;
-        }
+      std::string inf_class = args(i).xstring_value ("superiorto: CLASS_NAME must be a string");
 
       // User defined classes always have higher precedence
       // than built-in classes
@@ -2273,12 +2132,7 @@
 
   for (int i = 0; i < args.length (); i++)
     {
-      std::string sup_class = args(i).string_value ();
-      if (error_state)
-        {
-          error ("inferiorto: expecting argument to be class name");
-          break;
-        }
+      std::string sup_class = args(i).xstring_value ("inferiorto: CLASS_NAME must be a string");
 
       if (is_built_in_class (sup_class))
         {
--- a/libinterp/octave-value/ov-class.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-class.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_class_h)
+#if ! defined (octave_ov_class_h)
 #define octave_ov_class_h 1
 
 #include <cstdlib>
@@ -257,7 +257,7 @@
       return *this;
     }
 
-    octave_idx_type nfields (void) const { return field_names.length (); }
+    octave_idx_type nfields (void) const { return field_names.numel (); }
 
     size_t nparents (void) const { return parent_class_names.size (); }
 
--- a/libinterp/octave-value/ov-classdef.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-classdef.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -100,22 +100,19 @@
 {
   octave_function *of = fcn.function_value ();
 
-  if (! error_state)
+  of->stash_dispatch_class (class_name);
+
+  octave_user_function *uf = of->user_function_value (true);
+
+  if (uf)
     {
-      of->stash_dispatch_class (class_name);
-
-      octave_user_function *uf = of->user_function_value (true);
-
-      if (! error_state && uf)
+      if (get_base_name (class_name) == uf->name ())
         {
-          if (get_base_name (class_name) == uf->name ())
-            {
-              uf->mark_as_class_constructor ();
-              uf->mark_as_classdef_constructor ();
-            }
-          else
-            uf->mark_as_class_method ();
+          uf->mark_as_class_constructor ();
+          uf->mark_as_classdef_constructor ();
         }
+      else
+        uf->mark_as_class_method ();
     }
 }
 
@@ -182,8 +179,7 @@
     {
       cdef_class cls (to_cdef (ov));
 
-      if (! error_state)
-        return lookup_class (cls);
+      return lookup_class (cls);
     }
 
   return cdef_class ();
@@ -198,13 +194,7 @@
     {
       cdef_class c = lookup_class (cls_list(i));
 
-      if (! error_state)
-        retval.push_back (c);
-      else
-        {
-          retval.clear ();
-          break;
-        }
+      retval.push_back (c);
     }
 
   return retval;
@@ -235,13 +225,12 @@
     {
       Cell c = clsb.get ("SuperClasses").cell_value ();
 
-      for (int i = 0; ! error_state && ! retval && i < c.numel (); i++)
+      for (int i = 0; ! retval && i < c.numel (); i++)
         {
           cdef_class cls = lookup_class (c(i));
 
-          if (! error_state)
-            retval = is_superclass (clsa, cls, true,
-                                    max_depth < 0 ? max_depth : max_depth-1);
+          retval = is_superclass (clsa, cls, true,
+                                  max_depth < 0 ? max_depth : max_depth-1);
         }
     }
 
@@ -287,11 +276,9 @@
                   && ! fcn->dispatch_class ().empty ())))
     {
       cls = lookup_class (fcn->dispatch_class ());
-      if (! error_state)
-        {
-          name = fcn->name ();
-          in_constructor = fcn->is_classdef_constructor ();
-        }
+
+      name = fcn->name ();
+      in_constructor = fcn->is_classdef_constructor ();
     }
 
   return cls;
@@ -332,7 +319,7 @@
       // The access is private or protected, this requires a
       // valid class context.
 
-      if (! error_state && ctx.ok ())
+      if (ctx.ok ())
         {
           if (acc_s == "private")
             return (ctx == cls);
@@ -390,20 +377,17 @@
 
       // At this point, a class context is always required.
 
-      if (! error_state && ctx.ok ())
+      if (ctx.ok ())
         {
           if (ctx == cls)
             return true;
 
-          for (int i = 0; ! error_state && i < acc.numel (); i++)
+          for (int i = 0; i < acc.numel (); i++)
             {
               cdef_class acc_cls (to_cdef (acc_c(i)));
 
-              if (! error_state)
-                {
-                  if (is_superclass (acc_cls, ctx))
-                    return true;
-                }
+              if (is_superclass (acc_cls, ctx))
+                return true;
             }
         }
     }
@@ -538,12 +522,9 @@
 
   if (args.length () == 1)
     {
-      std::string name = args(0).string_value ();
-
-      if (! error_state)
-        retval(0) = to_ov (lookup_class (name));
-      else
-        error ("fromName: invalid class name, expected a string value");
+      std::string name = args(0).xstring_value ("fromName: CLASS_NAME must be a string");
+
+      retval(0) = to_ov (lookup_class (name));
     }
   else
     error ("fromName: invalid number of parameters");
@@ -560,34 +541,24 @@
     {
       cdef_class cls (to_cdef (args(0)));
 
-      if (! error_state)
+      std::string meth_name = args(1).xstring_value ("fevalStatic: method name must be a string");
+
+      cdef_method meth = cls.find_method (meth_name);
+
+      if (meth.ok ())
         {
-          std::string meth_name = args(1).string_value ();
-
-          if (! error_state)
-            {
-              cdef_method meth = cls.find_method (meth_name);
-
-              if (meth.ok ())
-                {
-                  if (meth.is_static ())
-                    retval = meth.execute (args.splice (0, 2), nargout,
-                                           true, "fevalStatic");
-                  else
-                    error ("fevalStatic: method `%s' is not static",
-                           meth_name.c_str ());
-                }
-              else
-                error ("fevalStatic: method not found: %s",
-                       meth_name.c_str ());
-            }
+          if (meth.is_static ())
+            retval = meth.execute (args.splice (0, 2), nargout,
+                                   true, "fevalStatic");
           else
-            error ("fevalStatic: invalid method name, expected a string value");
+            error ("fevalStatic: method `%s' is not static",
+                   meth_name.c_str ());
         }
-      error ("fevalStatic: invalid object, expected a meta.class object");
+      else
+        error ("fevalStatic: method not found: %s", meth_name.c_str ());
     }
   else
-    error ("fevalStatic: invalid arguments");
+    error ("fevalStatic: first argument must be a meta.class object");
 
   return retval;
 }
@@ -602,34 +573,24 @@
     {
       cdef_class cls = to_cdef (args(0));
 
-      if (! error_state)
+      std::string prop_name = args(1).xstring_value ("getConstant: property name must be a string");
+
+      cdef_property prop = cls.find_property (prop_name);
+
+      if (prop.ok ())
         {
-          std::string prop_name = args(1).string_value ();
-
-          if (! error_state)
-            {
-              cdef_property prop = cls.find_property (prop_name);
-
-              if (prop.ok ())
-                {
-                  if (prop.is_constant ())
-                    retval(0) = prop.get_value (true, "getConstant");
-                  else
-                    error ("getConstant: property `%s' is not constant",
-                           prop_name.c_str ());
-                }
-              else
-                error ("getConstant: property not found: %s",
-                       prop_name.c_str ());
-            }
+          if (prop.is_constant ())
+            retval(0) = prop.get_value (true, "getConstant");
           else
-            error ("getConstant: invalid property name, expected a string value");
+            error ("getConstant: property `%s' is not constant",
+                   prop_name.c_str ());
         }
       else
-        error ("getConstant: invalid object, expected a meta.class object");
+        error ("getConstant: property not found: %s",
+               prop_name.c_str ());
     }
   else
-    error ("getConstant: invalid arguments");
+    error ("getConstant: first argument must be a meta.class object");
 
   return retval;
 }
@@ -650,10 +611,7 @@
 \
       cdef_class clsb = to_cdef (args(1)); \
 \
-      if (! error_state) \
-        retval(0) = FUN (CLSA, CLSB); \
-      else \
-        error (#OP ": invalid objects, expected meta.class objects"); \
+      retval(0) = FUN (CLSA, CLSB); \
     } \
   else \
     error (#OP ": invalid arguments"); \
@@ -740,8 +698,8 @@
         }
 
       if (has_handle_class && ! all_handle_compatible)
-        ::error ("%s: cannot mix handle and non-HandleCompatible classes",
-                 name.c_str ());
+        error ("%s: cannot mix handle and non-HandleCompatible classes",
+               name.c_str ());
       else
         {
           cls.put ("HandleCompatible", all_handle_compatible);
@@ -750,9 +708,6 @@
         }
     }
 
-  if (error_state)
-    return cdef_class ();
-
   if (! name.empty ())
     cdef_manager::register_class (cls);
 
@@ -910,13 +865,10 @@
 
           args(1) = make_idx_args (type, idx, "subsref");
 
-          if (! error_state)
-            {
-              count++;
-              args(0) = octave_value (this);
-
-              retval = meth.execute (args, nargout, true, "subsref");
-            }
+          count++;
+          args(0) = octave_value (this);
+
+          retval = meth.execute (args, nargout, true, "subsref");
 
           return retval;
         }
@@ -926,11 +878,8 @@
 
   retval = object.subsref (type, idx, nargout, skip, cdef_class ());
 
-  if (! error_state)
-    {
-      if (type.length () > skip && idx.size () > skip)
-        retval = retval(0).next_subsref (nargout, type, idx, skip);
-    }
+  if (type.length () > skip && idx.size () > skip)
+    retval = retval(0).next_subsref (nargout, type, idx, skip);
 
   return retval;
 }
@@ -950,11 +899,8 @@
 
   retval = object.subsref (type, idx, 1, skip, cdef_class (), auto_add);
 
-  if (! error_state)
-    {
-      if (type.length () > skip && idx.size () > skip)
-        retval = retval(0).next_subsref (1, type, idx, skip);
-    }
+  if (type.length () > skip && idx.size () > skip)
+    retval = retval(0).next_subsref (1, type, idx, skip);
 
   return retval.length () > 0 ? retval(0) : octave_value ();
 }
@@ -978,28 +924,22 @@
 
           args(1) = make_idx_args (type, idx, "subsasgn");
 
-          if (! error_state)
-            {
-              count++;
-              args(0) = octave_value (this);
-              args(2) = rhs;
-
-              octave_value_list retlist;
-
-              retlist = meth.execute (args, 1, true, "subsasgn");
-
-              if (! error_state)
-                {
-                  if (retlist.length () > 0)
-                    retval = retlist(0);
-                  else
-                    ::error ("overloaded method `subsasgn' did not return any value");
-                }
-            }
+          count++;
+          args(0) = octave_value (this);
+          args(2) = rhs;
+
+          octave_value_list retlist;
+
+          retlist = meth.execute (args, 1, true, "subsasgn");
+
+          if (retlist.length () > 0)
+            retval = retlist(0);
+          else
+            error ("overloaded method `subsasgn' did not return any value");
         }
     }
 
-  if (! error_state && ! retval.is_defined ())
+  if (! retval.is_defined ())
     retval = object.subsasgn (type, idx, rhs);
 
   return retval;
@@ -1014,8 +954,7 @@
     {
       object = object.make_array ();
 
-      if (! error_state)
-        return subsasgn (type, idx, rhs);
+      return subsasgn (type, idx, rhs);
     }
   else
     return octave_base_value::undef_subsasgn (type, idx, rhs);
@@ -1202,12 +1141,9 @@
         break;
       }
 
-    if (! error_state)
-      {
-        if (type.length () > skip && idx.size () > skip
-            && retval.length () > 0)
-          retval = retval(0).next_subsref (nargout, type, idx, skip);
-      }
+    if (type.length () > skip && idx.size () > skip
+        && retval.length () > 0)
+      retval = retval(0).next_subsref (nargout, type, idx, skip);
 
     return retval;
   }
@@ -1234,73 +1170,70 @@
 
     ctx = get_class_context (meth_name, in_constructor);
 
-    if (! error_state && ctx.ok ())
+    if (ctx.ok ())
       {
         std::string mname = args(0).string_value ();
         std::string cname = args(1).string_value ();
 
         cdef_class cls = lookup_class (cname);
 
-        if (! error_state)
+        if (in_constructor)
           {
-            if (in_constructor)
+            if (is_direct_superclass (cls, ctx))
               {
-                if (is_direct_superclass (cls, ctx))
+                if (is_constructed_object (mname))
                   {
-                    if (is_constructed_object (mname))
-                      {
-                        octave_value sym = symbol_table::varval (mname);
-
-                        cls.run_constructor (to_cdef_ref (sym), idx);
-
-                        retval(0) = sym;
-                      }
-                    else
-                      ::error ("cannot call superclass constructor with "
-                               "variable `%s'", mname.c_str ());
+                    octave_value sym = symbol_table::varval (mname);
+
+                    cls.run_constructor (to_cdef_ref (sym), idx);
+
+                    retval(0) = sym;
                   }
                 else
-                  ::error ("`%s' is not a direct superclass of `%s'",
-                           cname.c_str (), ctx.get_name ().c_str ());
+                  error ("cannot call superclass constructor with "
+                         "variable `%s'", mname.c_str ());
               }
             else
+              error ("`%s' is not a direct superclass of `%s'",
+                     cname.c_str (), ctx.get_name ().c_str ());
+          }
+        else
+          {
+            if (mname == meth_name)
               {
-                if (mname == meth_name)
+                if (is_strict_superclass (cls, ctx))
                   {
-                    if (is_strict_superclass (cls, ctx))
-                      {
-                        // I see 2 possible implementations here:
-                        // 1) use cdef_object::subsref with a different class
-                        //    context; this avoids duplicating code, but
-                        //    assumes the object is always the first argument
-                        // 2) lookup the method manually and call
-                        //    cdef_method::execute; this duplicates part of
-                        //    logic in cdef_object::subsref, but avoid the
-                        //    assumption of 1)
-                        // Not being sure about the assumption of 1), I
-                        // go with option 2) for the time being.
-
-                        cdef_method meth = cls.find_method (meth_name, false);
-
-                        if (meth.ok ())
-                          retval = meth.execute (idx, nargout, true,
-                                                 meth_name);
-                        else
-                          ::error ("no method `%s' found in superclass `%s'",
-                                   meth_name.c_str (), cname.c_str ());
-                      }
+                    // I see 2 possible implementations here:
+                    // 1) use cdef_object::subsref with a different class
+                    //    context; this avoids duplicating code, but
+                    //    assumes the object is always the first argument
+                    // 2) lookup the method manually and call
+                    //    cdef_method::execute; this duplicates part of
+                    //    logic in cdef_object::subsref, but avoid the
+                    //    assumption of 1)
+                    // Not being sure about the assumption of 1), I
+                    // go with option 2) for the time being.
+
+                    cdef_method meth = cls.find_method (meth_name, false);
+
+                    if (meth.ok ())
+                      retval = meth.execute (idx, nargout, true,
+                                             meth_name);
                     else
-                      ::error ("`%s' is not a superclass of `%s'",
-                               cname.c_str (), ctx.get_name ().c_str ());
+                      error ("no method `%s' found in superclass `%s'",
+                             meth_name.c_str (), cname.c_str ());
                   }
                 else
-                  ::error ("method name mismatch (`%s' != `%s')",
-                           mname.c_str (), meth_name.c_str ());
+                  error ("`%s' is not a superclass of `%s'",
+                         cname.c_str (), ctx.get_name ().c_str ());
               }
+            else
+              error ("method name mismatch (`%s' != `%s')",
+                     mname.c_str (), meth_name.c_str ());
           }
       }
-    else if (! error_state)
-      ::error ("superclass calls can only occur in methods or constructors");
+    else
+      error ("superclass calls can only occur in methods or constructors");
 
     return retval;
   }
@@ -1363,27 +1296,17 @@
               Cell cvalue (a_obj.dims ());
 
               for (octave_idx_type i = 0; i < a_obj.numel (); i++)
-                {
-                  cvalue (i) = it->second.get_value (a_obj(i), false);
-
-                  if (error_state)
-                    break;
-                }
-
-              if (! error_state)
-                retval.setfield (it->first, cvalue);
+                cvalue (i) = it->second.get_value (a_obj(i), false);
+
+              retval.setfield (it->first, cvalue);
             }
           else
             {
               Cell cvalue (dim_vector (1, 1),
                            it->second.get_value (*this, false));
 
-              if (! error_state)
-                retval.setfield (it->first, cvalue);
+              retval.setfield (it->first, cvalue);
             }
-
-          if (error_state)
-            break;
         }
     }
 
@@ -1451,7 +1374,7 @@
               }
           }
 
-        if (skip == 0 && ! error_state)
+        if (skip == 0)
           {
             cdef_property prop = cls.find_property (name);
 
@@ -1476,17 +1399,26 @@
 
     case '(':
       {
+        const octave_value_list& ival = idx.front ();
+
         refcount++;
-
         cdef_object this_obj (this);
 
-        Array<cdef_object> arr (dim_vector (1, 1), this_obj);
-
-        cdef_object new_obj = cdef_object (new cdef_object_array (arr));
-
-        new_obj.set_class (get_class ());
-
-        retval = new_obj.subsref (type, idx, nargout, skip, cls, auto_add);
+        if (ival.empty ())
+          {
+            skip++;
+            retval(0) = to_ov (this_obj);
+          }
+        else
+          {
+            Array<cdef_object> arr (dim_vector (1, 1), this_obj);
+
+            cdef_object new_obj = cdef_object (new cdef_object_array (arr));
+
+            new_obj.set_class (get_class ());
+
+            retval = new_obj.subsref (type, idx, nargout, skip, cls, auto_add);
+          }
       }
       break;
 
@@ -1513,58 +1445,47 @@
       {
         std::string name = (idx.front ())(0).string_value ();
 
-        if (! error_state)
+        cdef_property prop = cls.find_property (name);
+
+        if (prop.ok ())
           {
-            cdef_property prop = cls.find_property (name);
-
-            if (prop.ok ())
+            if (prop.is_constant ())
+              error ("subsasgn: cannot assign constant property: %s",
+                     name.c_str ());
+            else
               {
-                if (prop.is_constant ())
-                  error ("subsasgn: cannot assign constant property: %s",
-                         name.c_str ());
+                refcount++;
+
+                cdef_object obj (this);
+
+                if (type.length () == 1)
+                  {
+                    prop.set_value (obj, rhs, true, "subsasgn");
+
+                    retval = to_ov (obj);
+                  }
                 else
                   {
-                    refcount++;
-
-                    cdef_object obj (this);
-
-                    if (type.length () == 1)
-                      {
-                        prop.set_value (obj, rhs, true, "subsasgn");
-
-                        if (! error_state)
-                          retval = to_ov (obj);
-                      }
-                    else
-                      {
-                        octave_value val =
-                          prop.get_value (obj, true, "subsasgn");
-
-                        if (! error_state)
-                          {
-                            std::list<octave_value_list> args (idx);
-
-                            args.erase (args.begin ());
-
-                            val = val.assign (octave_value::op_asn_eq,
-                                              type.substr (1), args, rhs);
-
-                            if (! error_state)
-                              {
-                                if (val.class_name () != "object"
-                                    || ! to_cdef (val).is_handle_object ())
-                                  prop.set_value (obj, val, true, "subsasgn");
-
-                                if (! error_state)
-                                  retval = to_ov (obj);
-                              }
-                          }
-                      }
+                    octave_value val =
+                      prop.get_value (obj, true, "subsasgn");
+
+                    std::list<octave_value_list> args (idx);
+
+                    args.erase (args.begin ());
+
+                    val = val.assign (octave_value::op_asn_eq,
+                                      type.substr (1), args, rhs);
+
+                    if (val.class_name () != "object"
+                        || ! to_cdef (val).is_handle_object ())
+                      prop.set_value (obj, val, true, "subsasgn");
+
+                    retval = to_ov (obj);
                   }
               }
-            else
-              error ("subsasgn: unknown property: %s", name.c_str ());
           }
+        else
+          error ("subsasgn: unknown property: %s", name.c_str ());
       }
       break;
 
@@ -1582,8 +1503,7 @@
 
         octave_value tmp = new_obj.subsasgn (type, idx, rhs);
 
-        if (! error_state)
-          retval = tmp;
+        retval = tmp;
       }
       break;
 
@@ -1602,13 +1522,9 @@
 
   Cell supcls = cls.get ("SuperClasses").cell_value ();
 
-  if (! error_state)
-    {
-      std::list<cdef_class> supcls_list = lookup_classes (supcls);
-
-      if (! error_state)
-        ctor_list[cls] = supcls_list;
-    }
+  std::list<cdef_class> supcls_list = lookup_classes (supcls);
+
+  ctor_list[cls] = supcls_list;
 }
 
 octave_value_list
@@ -1626,47 +1542,51 @@
     case '(':
       {
         const octave_value_list& ival = idx.front ();
-        bool is_scalar = true;
-        Array<idx_vector> iv (dim_vector (1, ival.length ()));
 
         if (ival.empty ())
           {
-            ::error ("can't index %s object(s) with empty parentheses",
-                     class_name ().c_str ());
+            refcount++;
+            retval(0) = to_ov (cdef_object (this));
             break;
           }
 
-        for (int i = 0; ! error_state && i < ival.length (); i++)
+        bool is_scalar = true;
+        Array<idx_vector> iv (dim_vector (1, ival.length ()));
+
+        for (int i = 0; i < ival.length (); i++)
           {
-            iv(i) = ival(i).index_vector ();
-            if (! error_state)
-              is_scalar = is_scalar && iv(i).is_scalar ();
-          }
-
-        if (! error_state)
-          {
-            Array<cdef_object> ires = array.index (iv, auto_add);
-
-            if (! error_state)
+            try
+              {
+                iv(i) = ival(i).index_vector ();
+              }
+            catch (index_exception& e)
               {
-                // If resizing is enabled (auto_add = true), it's possible
-                // indexing was out-of-bound and the result array contains
-                // invalid cdef_objects.
-
-                if (auto_add)
-                  fill_empty_values (ires);
-
-                if (is_scalar)
-                  retval(0) = to_ov (ires(0));
-                else
-                  {
-                    cdef_object array_obj (new cdef_object_array (ires));
-
-                    array_obj.set_class (get_class ());
-
-                    retval(0) = to_ov (array_obj);
-                  }
+                // Rethrow to allow more info to be reported later.
+                e.set_pos_if_unset (ival.length (), i+1);
+                throw;
               }
+
+            is_scalar = is_scalar && iv(i).is_scalar ();
+          }
+
+        Array<cdef_object> ires = array.index (iv, auto_add);
+
+        // If resizing is enabled (auto_add = true), it's possible
+        // indexing was out-of-bound and the result array contains
+        // invalid cdef_objects.
+
+        if (auto_add)
+          fill_empty_values (ires);
+
+        if (is_scalar)
+          retval(0) = to_ov (ires(0));
+        else
+          {
+            cdef_object array_obj (new cdef_object_array (ires));
+
+            array_obj.set_class (get_class ());
+
+            retval(0) = to_ov (array_obj);
           }
       }
       break;
@@ -1687,25 +1607,19 @@
               octave_value_list r = array(i).subsref (type, idx, 1, dummy_skip,
                                                       dummy_cls);
 
-              if (! error_state)
-                {
-                  if (r.length () > 0)
-                    c(i) = r(0);
-                }
-              else
-                break;
+              if (r.length () > 0)
+                c(i) = r(0);
             }
 
-          if (! error_state)
-            retval(0) = octave_value (c, true);
+          retval(0) = octave_value (c, true);
 
           break;
         }
       // fall through "default"
 
     default:
-      ::error ("can't perform indexing operation on array of %s objects",
-               class_name ().c_str ());
+      error ("can't perform indexing operation on array of %s objects",
+             class_name ().c_str ());
       break;
     }
 
@@ -1726,58 +1640,51 @@
         {
           cdef_object rhs_obj = to_cdef (rhs);
 
-          if (! error_state)
+          if (rhs_obj.get_class () == get_class ())
             {
-              if (rhs_obj.get_class () == get_class ())
+              const octave_value_list& ival = idx.front ();
+              bool is_scalar = true;
+              Array<idx_vector> iv (dim_vector (1, ival.length ()));
+
+              for (int i = 0; i < ival.length (); i++)
                 {
-                  const octave_value_list& ival = idx.front ();
-                  bool is_scalar = true;
-                  Array<idx_vector> iv (dim_vector (1, ival.length ()));
-
-                  for (int i = 0; ! error_state && i < ival.length (); i++)
+                  try
                     {
                       iv(i) = ival(i).index_vector ();
-                      if (! error_state)
-                        is_scalar = is_scalar && iv(i).is_scalar ();
                     }
-
-                  if (! error_state)
+                  catch (index_exception& e)
                     {
-                      Array<cdef_object> rhs_mat;
-
-                      if (! rhs_obj.is_array ())
-                        {
-                          rhs_mat = Array<cdef_object> (dim_vector (1, 1));
-                          rhs_mat(0) = rhs_obj;
-                        }
-                      else
-                        rhs_mat = rhs_obj.array_value ();
-
-                      if (! error_state)
-                        {
-                          octave_idx_type n = array.numel ();
-
-                          array.assign (iv, rhs_mat, cdef_object ());
-
-                          if (! error_state)
-                            {
-                              if (array.numel () > n)
-                                fill_empty_values ();
-
-                              if (! error_state)
-                                {
-                                  refcount++;
-                                  retval = to_ov (cdef_object (this));
-                                }
-                            }
-                        }
+                      e.set_pos_if_unset (ival.length (), i+1);
+                      throw;   // var name set in pt-idx.cc / pt-assign.cc
                     }
+
+                  is_scalar = is_scalar && iv(i).is_scalar ();
+                }
+
+              Array<cdef_object> rhs_mat;
+
+              if (! rhs_obj.is_array ())
+                {
+                  rhs_mat = Array<cdef_object> (dim_vector (1, 1));
+                  rhs_mat(0) = rhs_obj;
                 }
               else
-                ::error ("can't assign %s object into array of %s objects.",
-                         rhs_obj.class_name ().c_str (),
-                         class_name ().c_str ());
+                rhs_mat = rhs_obj.array_value ();
+
+              octave_idx_type n = array.numel ();
+
+              array.assign (iv, rhs_mat, cdef_object ());
+
+              if (array.numel () > n)
+                fill_empty_values ();
+
+              refcount++;
+              retval = to_ov (cdef_object (this));
             }
+          else
+            error ("can't assign %s object into array of %s objects.",
+                   rhs_obj.class_name ().c_str (),
+                   class_name ().c_str ());
         }
       else
         {
@@ -1787,95 +1694,92 @@
 
           Array<idx_vector> iv (dim_vector (1, ival.length ()));
 
-          for (int i = 0; ! error_state && i < ival.length (); i++)
+          for (int i = 0; i < ival.length (); i++)
             {
-              iv(i) = ival(i).index_vector ();
-
-              if (! error_state)
+              try
                 {
-                  is_scalar = is_scalar && iv(i).is_scalar ();
-
-                  if (! is_scalar)
-                    error ("subsasgn: invalid indexing for object array "
-                           "assignment, the index must reference a single "
-                           "object in the array.");
+                  iv(i) = ival(i).index_vector ();
                 }
-            }
-
-          if (! error_state)
-            {
-              Array<cdef_object> a = array.index (iv, true);
-
-              if (a.numel () != 1)
-                error ("subsasgn: invalid indexing for object array "
-                       "assignment");
-
-              if (! error_state)
+              catch (index_exception& e)
                 {
-                  cdef_object obj = a(0);
-
-                  int ignore_copies = 0;
-
-                  // If the object in 'a' is not valid, this means the index
-                  // was out-of-bound and we need to create a new object.
-
-                  if (! obj.ok ())
-                    obj = get_class ().construct_object (octave_value_list ());
-                  else
-                    // Optimize the subsasgn call to come. There are 2 copies
-                    // that we can safely ignore:
-                    // - 1 in "array"
-                    // - 1 in "a"
-                    ignore_copies = 2;
-
-                  std::list<octave_value_list> next_idx (idx);
-
-                  next_idx.erase (next_idx.begin ());
-
-                  octave_value tmp = obj.subsasgn (type.substr (1), next_idx,
-                                                   rhs, ignore_copies);
-
-                  if (! error_state)
-                    {
-                      cdef_object robj = to_cdef (tmp);
-
-                      if (robj.ok ()
-                          && ! robj.is_array ()
-                          && robj.get_class () == get_class ())
-                        {
-                          // Small optimization, when dealing with handle
-                          // objects, we don't need to re-assign the result
-                          // of subsasgn back into the array.
-
-                          if (! robj.is (a(0)))
-                            {
-                              Array<cdef_object> rhs_a (dim_vector (1, 1),
-                                                        robj);
-
-                              octave_idx_type n = array.numel ();
-
-                              array.assign (iv, rhs_a);
-
-                              if (array.numel () > n)
-                                fill_empty_values ();
-                            }
-
-                          refcount++;
-
-                          retval = to_ov (cdef_object (this));
-                        }
-                      else
-                        error ("subasgn: invalid assignment into array of %s "
-                               "objects", class_name ().c_str ());
-                    }
+                  // Rethrow to allow more info to be reported later.
+                  e.set_pos_if_unset (ival.length (), i+1);
+                  throw;
                 }
+
+              is_scalar = is_scalar && iv(i).is_scalar ();
+
+              if (! is_scalar)
+                error ("subsasgn: invalid indexing for object array "
+                       "assignment, the index must reference a single "
+                       "object in the array.");
             }
+
+          Array<cdef_object> a = array.index (iv, true);
+
+          if (a.numel () != 1)
+            error ("subsasgn: invalid indexing for object array "
+                   "assignment");
+
+          cdef_object obj = a(0);
+
+          int ignore_copies = 0;
+
+          // If the object in 'a' is not valid, this means the index
+          // was out-of-bound and we need to create a new object.
+
+          if (! obj.ok ())
+            obj = get_class ().construct_object (octave_value_list ());
+          else
+            // Optimize the subsasgn call to come. There are 2 copies
+            // that we can safely ignore:
+            // - 1 in "array"
+            // - 1 in "a"
+            ignore_copies = 2;
+
+          std::list<octave_value_list> next_idx (idx);
+
+          next_idx.erase (next_idx.begin ());
+
+          octave_value tmp = obj.subsasgn (type.substr (1), next_idx,
+                                           rhs, ignore_copies);
+
+          cdef_object robj = to_cdef (tmp);
+
+          if (robj.ok ()
+              && ! robj.is_array ()
+              && robj.get_class () == get_class ())
+            {
+              // Small optimization, when dealing with handle
+              // objects, we don't need to re-assign the result
+              // of subsasgn back into the array.
+
+              if (! robj.is (a(0)))
+                {
+                  Array<cdef_object> rhs_a (dim_vector (1, 1),
+                                            robj);
+
+                  octave_idx_type n = array.numel ();
+
+                  array.assign (iv, rhs_a);
+
+                  if (array.numel () > n)
+                    fill_empty_values ();
+                }
+
+              refcount++;
+
+              retval = to_ov (cdef_object (this));
+            }
+          else
+            error ("subasgn: invalid assignment into array of %s "
+                   "objects", class_name ().c_str ());
         }
       break;
 
     default:
-      ::error ("can't perform indexing operation on array of %s objects",
-               class_name ().c_str ());
+      error ("can't perform indexing operation on array of %s objects",
+             class_name ().c_str ());
       break;
     }
 
@@ -1887,26 +1791,22 @@
 {
   cdef_class cls = get_class ();
 
-  if (! error_state)
+  cdef_object obj;
+
+  int n = arr.numel ();
+
+  for (int i = 0; i < n; i++)
     {
-      cdef_object obj;
-
-      int n = arr.numel ();
-
-      for (int i = 0; ! error_state && i < n; i++)
+      if (! arr.xelem (i).ok ())
         {
-          if (! arr.xelem (i).ok ())
+          if (! obj.ok ())
             {
-              if (! obj.ok ())
-                {
-                  obj = cls.construct_object (octave_value_list ());
-
-                  if (! error_state)
-                    arr.xelem (i) = obj;
-                }
-              else
-                arr.xelem (i) = obj.copy ();
+              obj = cls.construct_object (octave_value_list ());
+
+              arr.xelem (i) = obj;
             }
+          else
+            arr.xelem (i) = obj.copy ();
         }
     }
 }
@@ -1937,6 +1837,12 @@
   return true;
 }
 
+void
+cdef_object_scalar::mark_as_constructed (const cdef_class& cls)
+{
+  ctor_list.erase (cls);
+}
+
 handle_cdef_object::~handle_cdef_object (void)
 {
 #if DEBUG_TRACE
@@ -1991,13 +1897,10 @@
         {
           cdef_class cls = lookup_class (super_classes(i));
 
-          if (! error_state)
-            {
-              cdef_method meth = cls.find_method (nm);
-
-              if (meth.ok ())
-                return meth;
-            }
+          cdef_method meth = cls.find_method (nm);
+
+          if (meth.ok ())
+            return meth;
         }
     }
 
@@ -2013,7 +1916,7 @@
   void visit_statement_list (tree_statement_list& t)
   {
     for (tree_statement_list::const_iterator it = t.begin ();
-         ! error_state && it != t.end (); ++it)
+         it != t.end (); ++it)
       (*it)->accept (*this);
   }
 
@@ -2147,28 +2050,26 @@
                   ctor_analyzer a (meth.get_name (), obj_name);
 
                   body->accept (a);
-                  if (! error_state)
+
+                  std::list<cdef_class> explicit_ctor_list
+                    = a.get_constructor_list ();
+
+                  for (std::list<cdef_class>::const_iterator
+                         it = explicit_ctor_list.begin ();
+                       it != explicit_ctor_list.end ();
+                       ++it)
                     {
-                      std::list<cdef_class> explicit_ctor_list
-                        = a.get_constructor_list ();
-
-                      for (std::list<cdef_class>::const_iterator
-                           it = explicit_ctor_list.begin ();
-                           ! error_state && it != explicit_ctor_list.end ();
-                           ++it)
-                        {
 #if DEBUG_TRACE
-                          std::cerr << "explicit superclass constructor: "
-                                    << it->get_name () << std::endl;
+                      std::cerr << "explicit superclass constructor: "
+                                << it->get_name () << std::endl;
 #endif
 
-                          implicit_ctor_list.remove (*it);
-                        }
+                      implicit_ctor_list.remove (*it);
                     }
                 }
               else
-                ::error ("%s: invalid constructor output arguments",
-                         meth.get_name ().c_str ());
+                error ("%s: invalid constructor output arguments",
+                       meth.get_name ().c_str ());
             }
         }
     }
@@ -2187,20 +2088,15 @@
 
   find_methods (meths, false);
 
-  if (! error_state)
-    {
-      Cell c (meths.size (), 1);
-
-      int idx = 0;
-
-      for (std::map<std::string,cdef_method>::const_iterator
-            it = meths.begin (); it != meths.end (); ++it, ++idx)
-        c (idx, 0) = to_ov (it->second);
-
-      return c;
-    }
-
-  return Cell ();
+  Cell c (meths.size (), 1);
+
+  int idx = 0;
+
+  for (std::map<std::string,cdef_method>::const_iterator
+         it = meths.begin (); it != meths.end (); ++it, ++idx)
+    c (idx, 0) = to_ov (it->second);
+
+  return c;
 }
 
 void
@@ -2242,10 +2138,7 @@
     {
       cdef_class cls = lookup_class (super_classes(i));
 
-      if (! error_state)
-        cls.get_rep ()->find_methods (meths, true);
-      else
-        break;
+      cls.get_rep ()->find_methods (meths, true);
     }
 }
 
@@ -2270,13 +2163,10 @@
     {
       cdef_class cls = lookup_class (super_classes(i));
 
-      if (! error_state)
-        {
-          cdef_property prop = cls.find_property (nm);
-
-          if (prop.ok ())
-            return prop;
-        }
+      cdef_property prop = cls.find_property (nm);
+
+      if (prop.ok ())
+        return prop;
     }
 
   return cdef_property ();
@@ -2297,20 +2187,15 @@
 
   props = get_property_map (mode);
 
-  if (! error_state)
-    {
-      Cell c (props.size (), 1);
-
-      int idx = 0;
-
-      for (std::map<std::string,cdef_property>::const_iterator
-            it = props.begin (); it != props.end (); ++it, ++idx)
-        c (idx, 0) = to_ov (it->second);
-
-      return c;
-    }
-
-  return Cell ();
+  Cell c (props.size (), 1);
+
+  int idx = 0;
+
+  for (std::map<std::string,cdef_property>::const_iterator
+         it = props.begin (); it != props.end (); ++it, ++idx)
+    c (idx, 0) = to_ov (it->second);
+
+  return c;
 }
 
 std::map<std::string, cdef_property>
@@ -2330,8 +2215,7 @@
 {
   property_const_iterator it;
 
-  for (it = property_map.begin (); ! error_state && it != property_map.end ();
-       ++it)
+  for (it = property_map.begin (); it != property_map.end (); ++it)
     {
       std::string nm = it->second.get_name ();
 
@@ -2354,17 +2238,14 @@
 
   Cell super_classes = get ("SuperClasses").cell_value ();
 
-  for (int i = 0; ! error_state && i < super_classes.numel (); i++)
+  for (int i = 0; i < super_classes.numel (); i++)
     {
       cdef_class cls = lookup_class (super_classes(i));
 
-      if (! error_state)
-        cls.get_rep ()->find_properties (props,
-                                         (mode == property_all ?
-                                          property_all :
-                                          property_inherited));
-      else
-        break;
+      cls.get_rep ()->find_properties (props,
+                                       (mode == property_all
+                                        ? property_all
+                                        : property_inherited));
     }
 }
 
@@ -2375,7 +2256,7 @@
   load_all_methods ();
 
   for (method_const_iterator it = method_map.begin ();
-       ! error_state && it != method_map.end(); ++it)
+       it != method_map.end(); ++it)
     {
       if (! it->second.is_constructor ())
         {
@@ -2395,7 +2276,7 @@
     }
 
   for (property_const_iterator it = property_map.begin ();
-       ! error_state && it != property_map.end (); ++it)
+       it != property_map.end (); ++it)
     {
       std::string nm = it->second.get_name ();
 
@@ -2415,14 +2296,11 @@
 
   Cell super_classes = get ("SuperClasses").cell_value ();
 
-  for (int i = 0; ! error_state && i < super_classes.numel (); i++)
+  for (int i = 0; i < super_classes.numel (); i++)
     {
       cdef_class cls = lookup_class (super_classes(i));
 
-      if (! error_state)
-        cls.get_rep ()->find_names (names, all);
-      else
-        break;
+      cls.get_rep ()->find_names (names, all);
     }
 }
 
@@ -2433,19 +2311,14 @@
 
   find_names (names, false);
 
-  if (! error_state)
-    {
-      string_vector v (names.size ());
-
-      int idx = 0;
-      for (std::set<std::string>::const_iterator it = names.begin ();
-           it != names.end (); ++it, ++idx)
-        v[idx] = *it;
-
-      return v.sort (true);
-    }
-
-  return string_vector ();
+  string_vector v (names.size ());
+
+  int idx = 0;
+  for (std::set<std::string>::const_iterator it = names.begin ();
+       it != names.end (); ++it, ++idx)
+    v[idx] = *it;
+
+  return v.sort (true);
 }
 
 void
@@ -2474,8 +2347,7 @@
     {
       cdef_class cls = lookup_class (super_classes(i));
 
-      if (!error_state)
-        cls.delete_object (obj);
+      cls.delete_object (obj);
     }
 }
 
@@ -2509,65 +2381,56 @@
 
       if (idx.front ().length () == 1)
         {
-          std::string nm = idx.front ()(0).string_value ();
-
-          if (! error_state)
+          std::string nm = idx.front ()(0).xstring_value ("invalid meta.class indexing, expected a method or property name");
+
+          cdef_method meth = find_method (nm);
+
+          if (meth.ok ())
             {
-              cdef_method meth = find_method (nm);
-
-              if (meth.ok ())
+              if (meth.is_static ())
                 {
-                  if (meth.is_static ())
+                  octave_value_list args;
+
+                  if (type.length () > 1 && idx.size () > 1
+                      && type[1] == '(')
                     {
-                      octave_value_list args;
-
-                      if (type.length () > 1 && idx.size () > 1
-                          && type[1] == '(')
-                        {
-                          args = *(++(idx.begin ()));
-                          skip++;
-                        }
-
-                      retval = meth.execute (args, (type.length () > skip
-                                                    ? 1 : nargout), true,
-                                             "meta.class");
+                      args = *(++(idx.begin ()));
+                      skip++;
                     }
-                  else
-                    ::error ("method `%s' is not static", nm.c_str ());
+
+                  retval = meth.execute (args, (type.length () > skip
+                                                ? 1 : nargout), true,
+                                         "meta.class");
                 }
               else
-                {
-                  cdef_property prop = find_property (nm);
-
-                  if (prop.ok ())
-                    {
-                      if (prop.is_constant ())
-                        retval(0) = prop.get_value (true, "meta.class");
-                      else
-                        ::error ("property `%s' is not constant",
-                                 nm.c_str ());
-                    }
-                  else
-                    ::error ("no such method or property `%s'", nm.c_str ());
-                }
+                error ("method `%s' is not static", nm.c_str ());
             }
           else
-            ::error ("invalid meta.class indexing, expected a method or property name");
+            {
+              cdef_property prop = find_property (nm);
+
+              if (prop.ok ())
+                {
+                  if (prop.is_constant ())
+                    retval(0) = prop.get_value (true, "meta.class");
+                  else
+                    error ("property `%s' is not constant", nm.c_str ());
+                }
+              else
+                error ("no such method or property `%s'", nm.c_str ());
+            }
         }
       else
-        ::error ("invalid meta.class indexing");
+        error ("invalid meta.class indexing");
       break;
 
     default:
-      ::error ("invalid meta.class indexing");
+      error ("invalid meta.class indexing");
       break;
     }
 
-  if (! error_state)
-    {
-      if (type.length () > skip && idx.size () > skip && ! retval.empty ())
-        retval = retval(0).next_subsref (nargout, type, idx, skip);
-    }
+  if (type.length () > skip && idx.size () > skip && ! retval.empty ())
+    retval = retval(0).next_subsref (nargout, type, idx, skip);
 
   return retval;
 }
@@ -2586,35 +2449,26 @@
   std::list<cdef_class> super_classes = lookup_classes (
                                           get ("SuperClasses").cell_value ());
 
-  if (! error_state)
+  for (std::list<cdef_class>::iterator it = super_classes.begin ();
+       it != super_classes.end (); ++it)
+    it->initialize_object (obj);
+
+  for (property_const_iterator it = property_map.begin ();
+       it != property_map.end (); ++it)
     {
-      for (std::list<cdef_class>::iterator it = super_classes.begin ();
-           ! error_state && it != super_classes.end (); ++it)
-        it->initialize_object (obj);
-
-      if (! error_state)
+      if (! it->second.get ("Dependent").bool_value ())
         {
-          for (property_const_iterator it = property_map.begin ();
-               ! error_state && it != property_map.end (); ++it)
-            {
-              if (! it->second.get ("Dependent").bool_value ())
-                {
-                  octave_value pvalue = it->second.get ("DefaultValue");
-
-                  if (pvalue.is_defined ())
-                    obj.put (it->first, pvalue);
-                  else
-                    obj.put (it->first, octave_value (Matrix ()));
-                }
-            }
-
-          if (! error_state)
-            {
-              refcount++;
-              obj.mark_for_construction (cdef_class (this));
-            }
+          octave_value pvalue = it->second.get ("DefaultValue");
+
+          if (pvalue.is_defined ())
+            obj.put (it->first, pvalue);
+          else
+            obj.put (it->first, octave_value (Matrix ()));
         }
     }
+
+  refcount++;
+  obj.mark_for_construction (cdef_class (this));
 }
 
 void
@@ -2624,17 +2478,13 @@
   octave_value_list empty_args;
 
   for (std::list<cdef_class>::const_iterator it = implicit_ctor_list.begin ();
-       ! error_state && it != implicit_ctor_list.end (); ++it)
+       it != implicit_ctor_list.end (); ++it)
     {
       cdef_class supcls = lookup_class (*it);
 
-      if (! error_state)
-        supcls.run_constructor (obj, empty_args);
+      supcls.run_constructor (obj, empty_args);
     }
 
-  if (error_state)
-    return;
-
   std::string cls_name = get_name ();
   std::string ctor_name = get_base_name (cls_name);
 
@@ -2648,16 +2498,13 @@
       ctor_args.prepend (to_ov (obj));
       ctor_retval = ctor.execute (ctor_args, 1, true, "constructor");
 
-      if (! error_state)
+      if (ctor_retval.length () == 1)
+        obj = to_cdef (ctor_retval(0));
+      else
         {
-          if (ctor_retval.length () == 1)
-            obj = to_cdef (ctor_retval(0));
-          else
-            {
-              ::error ("%s: invalid number of output arguments for classdef constructor",
-                       ctor_name.c_str ());
-              return;
-            }
+          error ("%s: invalid number of output arguments for classdef constructor",
+                 ctor_name.c_str ());
+          return;
         }
     }
 
@@ -2669,7 +2516,7 @@
 {
   cdef_object obj = construct_object (args);
 
-  if (! error_state && obj.ok ())
+  if (obj.ok ())
     return to_ov (obj);
 
   return octave_value ();
@@ -2740,13 +2587,9 @@
 
           initialize_object (obj);
 
-          if (! error_state)
-            {
-              run_constructor (obj, args);
-
-              if (! error_state)
-                return obj;
-            }
+          run_constructor (obj, args);
+
+          return obj;
         }
     }
   else
@@ -2813,7 +2656,7 @@
     {
       for (tree_classdef_superclass_list::iterator it =
              t->superclass_list ()->begin ();
-           ! error_state && it != t->superclass_list ()->end (); ++it)
+           it != t->superclass_list ()->end (); ++it)
         {
           std::string sclass_name = (*it)->class_name ();
 
@@ -2823,35 +2666,27 @@
 
           cdef_class sclass = lookup_class (sclass_name);
 
-          if (! error_state)
+          if (! sclass.get ("Sealed").bool_value ())
+            slist.push_back (sclass);
+          else
             {
-              if (! sclass.get ("Sealed").bool_value ())
-                slist.push_back (sclass);
-              else
-                {
-                  ::error ("`%s' cannot inherit from `%s', because it is sealed",
-                           full_class_name.c_str (), sclass_name.c_str ());
-                  return retval;
-                }
+              error ("`%s' cannot inherit from `%s', because it is sealed",
+                     full_class_name.c_str (), sclass_name.c_str ());
+              return retval;
             }
-          else
-            return retval;
 
         }
     }
 
   retval = ::make_class (full_class_name, slist);
 
-  if (error_state)
-    return cdef_class ();
-
   // Package owning this class
 
   if (! t->package_name ().empty ())
     {
       cdef_package pack = cdef_manager::find_package (t->package_name ());
 
-      if (! error_state && pack.ok ())
+      if (pack.ok ())
         retval.put ("ContainingPackage", to_ov (pack));
     }
 
@@ -3142,8 +2977,8 @@
 
       if (! obj.is_partially_constructed_for (cls))
         {
-          ::error ("cannot reference properties of class `%s' for non-constructed object",
-                   cls.get_name ().c_str ());
+          error ("cannot reference properties of class `%s' for non-constructed object",
+                 cls.get_name ().c_str ());
           return retval;
         }
     }
@@ -3162,8 +2997,7 @@
 
       args = execute_ov (get_fcn, args, 1);
 
-      if (! error_state)
-        retval = args(0);
+      retval = args(0);
     }
 
   return retval;
@@ -3209,8 +3043,8 @@
 
       if (! obj.is_partially_constructed_for (cls))
         {
-          ::error ("cannot reference properties of class `%s' for non-constructed object",
-                   cls.get_name ().c_str ());
+          error ("cannot reference properties of class `%s' for non-constructed object",
+                 cls.get_name ().c_str ());
           return;
         }
     }
@@ -3228,21 +3062,17 @@
 
       args = execute_ov (set_fcn, args, 1);
 
-      if (! error_state)
+      if (args.length () > 0 && args(0).is_defined ())
         {
-          if (args.length () > 0 && args(0).is_defined ())
+          if (args (0).is_classdef_object ())
             {
-              if (args (0).is_classdef_object ())
-                {
-                  cdef_object new_obj = to_cdef (args(0));
-
-                  if (! error_state)
-                    obj = new_obj;
-                }
-              else
-                ::warning ("set-method of property `%s' returned a non-classdef object",
-                           get_name ().c_str ());
+              cdef_object new_obj = to_cdef (args(0));
+
+              obj = new_obj;
             }
+          else
+            ::warning ("set-method of property `%s' returned a non-classdef object",
+                       get_name ().c_str ());
         }
     }
 }
@@ -3252,9 +3082,8 @@
 {
   cdef_class cls (to_cdef (get ("DefiningClass")));
 
-  if (! error_state)
-    return ::check_access (cls, get ("GetAccess"), std::string (),
-                           get_name (), false);
+  return ::check_access (cls, get ("GetAccess"), std::string (),
+                         get_name (), false);
 
   return false;
 }
@@ -3264,9 +3093,8 @@
 {
   cdef_class cls (to_cdef (get ("DefiningClass")));
 
-  if (! error_state)
-    return ::check_access (cls, get ("SetAccess"), std::string (),
-                           get_name (), true);
+  return ::check_access (cls, get ("SetAccess"), std::string (),
+                         get_name (), true);
 
   return false;
 }
@@ -3314,8 +3142,8 @@
         }
 
       if (is_dummy_method (function))
-        ::error ("no definition found for method `%s' of class `%s'",
-                 get_name ().c_str (), dispatch_type.c_str ());
+        error ("no definition found for method `%s' of class `%s'",
+               get_name ().c_str (), dispatch_type.c_str ());
     }
 }
 
@@ -3337,10 +3165,8 @@
     {
       check_method ();
 
-      if (! error_state && function.is_defined ())
-        {
-          retval = execute_ov (function, args, nargout);
-        }
+      if (function.is_defined ())
+        retval = execute_ov (function, args, nargout);
     }
   else
     error ("%s: cannot execute abstract method",
@@ -3368,7 +3194,7 @@
     {
       check_method ();
 
-      if (! error_state && function.is_defined ())
+      if (function.is_defined ())
         {
           octave_value_list new_args;
 
@@ -3402,10 +3228,7 @@
 {
   cdef_class cls (to_cdef (get ("DefiningClass")));
 
-  if (! error_state)
-    return ::check_access (cls, get ("Access"), get_name ());
-
-  return false;
+  return ::check_access (cls, get ("Access"), get_name ());
 }
 
 octave_value_list
@@ -3426,11 +3249,8 @@
       break;
     }
 
-  if (! error_state)
-    {
-      if (type.length () > 1 && idx.size () > 1 && ! retval.empty ())
-        retval = retval(0).next_subsref (nargout, type, idx, 1);
-    }
+  if (type.length () > 1 && idx.size () > 1 && ! retval.empty ())
+    retval = retval(0).next_subsref (nargout, type, idx, 1);
 
   return retval;
 }
@@ -3448,12 +3268,9 @@
 
   if (args.length () == 1)
     {
-      std::string name = args(0).string_value ();
-
-      if (! error_state)
-        retval(0) = to_ov (lookup_package (name));
-      else
-        error ("fromName: invalid package name, expected a string value");
+      std::string name = args(0).xstring_value ("fromName: PACKAGE_NAME must be a string");
+
+      retval(0) = to_ov (lookup_package (name));
     }
   else
     error ("fromName: invalid number of parameters");
@@ -3608,57 +3425,49 @@
     case '.':
       if (idx.front ().length () == 1)
         {
-          std::string nm = idx.front ()(0).string_value ();
-
-          if (! error_state)
-            {
+          std::string nm = idx.front ()(0).xstring_value ("invalid meta.package indexing, expected a symbol name");
+
 #if DEBUG_TRACE
-              std::cerr << "meta.package query: " << nm << std::endl;
+          std::cerr << "meta.package query: " << nm << std::endl;
 #endif
 
-              octave_value o = find (nm);
-
-              if (o.is_defined ())
+          octave_value o = find (nm);
+
+          if (o.is_defined ())
+            {
+              if (o.is_function ())
                 {
-                  if (o.is_function ())
+                  octave_function* fcn = o.function_value ();
+
+                  // NOTE: the case where the package query is the last
+                  // part of this subsref index is handled in the parse
+                  // tree, because there is some logic to handle magic
+                  // "end" that makes it impossible to execute the
+                  // function call at this stage.
+
+                  if (type.size () > 1
+                      && ! fcn->is_postfix_index_handled (type[1]))
                     {
-                      octave_function* fcn = o.function_value ();
-
-                      if (! error_state)
-                        {
-                          // NOTE: the case where the package query is the last
-                          // part of this subsref index is handled in the parse
-                          // tree, because there is some logic to handle magic
-                          // "end" that makes it impossible to execute the
-                          // function call at this stage.
-
-                          if (type.size () > 1
-                              && ! fcn->is_postfix_index_handled (type[1]))
-                            {
-                              octave_value_list tmp_args;
-
-                              retval = o.do_multi_index_op (nargout,
-                                                            tmp_args);
-                            }
-                          else
-                            retval(0) = o;
-
-                          if (type.size () > 1 && idx.size () > 1)
-                            retval = retval(0).next_subsref (nargout, type,
-                                                             idx, 1);
-                        }
+                      octave_value_list tmp_args;
+
+                      retval = o.do_multi_index_op (nargout,
+                                                    tmp_args);
                     }
-                  else if (type.size () > 1 && idx.size () > 1)
-                    retval = o.next_subsref (nargout, type, idx, 1);
                   else
                     retval(0) = o;
+
+                  if (type.size () > 1 && idx.size () > 1)
+                    retval = retval(0).next_subsref (nargout, type,
+                                                     idx, 1);
                 }
-              else if (! error_state)
-                error ("member `%s' in package `%s' does not exist",
-                       nm.c_str (), get_name ().c_str ());
+              else if (type.size () > 1 && idx.size () > 1)
+                retval = o.next_subsref (nargout, type, idx, 1);
+              else
+                retval(0) = o;
             }
           else
-            error ("invalid meta.package indexing, expected a symbol name");
+            error ("member `%s' in package `%s' does not exist",
+                   nm.c_str (), get_name ().c_str ());
         }
       else
         error ("invalid meta.package indexing");
@@ -3999,19 +3808,12 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      std::string cname = args(0).string_value ();
-
-      if (! error_state)
-        retval = to_ov (lookup_package (cname));
-      else
-        error ("invalid package name, expected a string value");
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  std::string cname = args(0).xstring_value ("PACKAGE_NAME must be a string");
+
+  return to_ov (lookup_package (cname));
 }
 
 DEFUN (__superclass_reference__, args, /* nargout */,
@@ -4037,19 +3839,12 @@
             << std::endl;
 #endif
 
-  if (args.length () == 1)
-    {
-      std::string cls = args(0).string_value ();
-
-      if (! error_state)
-        retval = to_ov (lookup_class (cls));
-      else
-        error ("invalid class name, expected a string value");
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  std::string cls = args(0).xstring_value ("CLASS_NAME must be a string");
+
+  return to_ov (lookup_class (cls));
 }
 
 DEFUN (metaclass, args, /* nargout */,
@@ -4060,19 +3855,12 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      cdef_object obj = to_cdef (args(0));
-
-      if (! error_state)
-        retval = to_ov (obj.get_class ());
-      else
-        print_usage ();
-    }
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  cdef_object obj = to_cdef (args(0));
+
+  return to_ov (obj.get_class ());
 }
 
 /*
--- a/libinterp/octave-value/ov-classdef.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-classdef.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_classdef_h)
+#if ! defined (octave_classdef_h)
 #define octave_classdef_h 1
 
 #include <map>
@@ -438,7 +438,7 @@
 
   void mark_as_constructed (void) { ctor_list.clear (); }
 
-  void mark_as_constructed (const cdef_class& cls) { ctor_list.erase (cls); }
+  void mark_as_constructed (const cdef_class& cls);
 
   bool is_constructed (void) const { return ctor_list.empty (); }
 
@@ -546,7 +546,7 @@
                 const std::list<octave_value_list>& /* idx */,
                 int /* nargout */)
   {
-    ::error ("subsref: invalid meta object");
+    error ("subsref: invalid meta object");
     return octave_value_list ();
   }
 
@@ -1208,7 +1208,7 @@
     {
       cdef_class cls (get_class ());
 
-      if (! error_state && cls.ok ())
+      if (cls.ok ())
         cls.register_object ();
     }
 }
@@ -1220,7 +1220,7 @@
     {
       cdef_class cls (get_class ());
 
-      if (! error_state && cls.ok ())
+      if (cls.ok ())
         cls.unregister_object ();
     }
 }
@@ -1628,7 +1628,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create cdef_manager!");
+        error ("unable to create cdef_manager!");
 
         retval = false;
       }
--- a/libinterp/octave-value/ov-colon.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-colon.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_colon_h)
+#if ! defined (octave_ov_colon_h)
 #define octave_ov_colon_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-complex.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-complex.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -25,6 +25,7 @@
 #endif
 
 #include <iostream>
+#include <sstream>
 
 #include "lo-ieee.h"
 #include "lo-specfun.h"
@@ -46,7 +47,7 @@
 #include "pr-output.h"
 #include "ops.h"
 
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-hdf5.h"
 
 template class octave_base_scalar<Complex>;
@@ -55,6 +56,39 @@
 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex,
                                      "complex scalar", "double");
 
+// Complain if a complex value is used as a subscript.
+
+class complex_index_exception : public index_exception
+{
+public:
+
+  complex_index_exception (const std::string& value)
+    : index_exception (value) { }
+
+  ~complex_index_exception (void) { }
+
+  std::string details (void) const
+  {
+    return "subscripts must be real (forgot to initialize i or j?)";
+  }
+
+  // ID of error to throw.
+  const char *err_id (void) const
+  {
+    return error_id_invalid_index;
+  }
+};
+
+static void
+gripe_complex_index (const Complex& idx)
+{
+  std::ostringstream buf;
+  buf << std::real (idx) << std::showpos << std::imag (idx) << "i";
+  complex_index_exception e (buf.str ());
+
+  throw e;
+}
+
 static octave_base_value *
 default_numeric_demotion_function (const octave_base_value& a)
 {
@@ -102,6 +136,14 @@
   return tmp.do_index_op (idx, resize_ok);
 }
 
+idx_vector
+octave_complex::index_vector (bool) const
+{
+  gripe_complex_index (scalar);
+
+  return idx_vector ();
+}
+
 double
 octave_complex::double_value (bool force_conversion) const
 {
@@ -301,7 +343,8 @@
   Complex ctmp;
   read_doubles (is, reinterpret_cast<double *> (&ctmp),
                 static_cast<save_type> (tmp), 2, swap, fmt);
-  if (error_state || ! is)
+
+  if (! is)
     return false;
 
   scalar = ctmp;
--- a/libinterp/octave-value/ov-complex.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-complex.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_complex_h)
+#if ! defined (octave_ov_complex_h)
 #define octave_ov_complex_h 1
 
 #include <cstdlib>
@@ -78,13 +78,8 @@
   octave_value do_index_op (const octave_value_list& idx,
                             bool resize_ok = false);
 
-  // Use this to give a more specific error message
-  idx_vector index_vector (bool /* require_integers */ = false) const
-  {
-    error ("attempted to use a complex scalar as an index\n"
-           "       (forgot to initialize i or j?)");
-    return idx_vector ();
-  }
+  // Use this to give a more specific error message.
+  idx_vector index_vector (bool /* require_integers */ = false) const;
 
   octave_value any (int = 0) const
   {
--- a/libinterp/octave-value/ov-cs-list.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-cs-list.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_cs_list_h)
+#if ! defined (octave_ov_cs_list_h)
 #define octave_ov_cs_list_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-cx-diag.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-cx-diag.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -218,8 +218,10 @@
   octave_idx_type len = m.length ();
   read_doubles (is, reinterpret_cast<double *> (im),
                 static_cast<save_type> (tmp), 2 * len, swap, fmt);
-  if (error_state || ! is)
+
+  if (! is)
     return false;
+
   matrix = m;
 
   return true;
--- a/libinterp/octave-value/ov-cx-diag.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-cx-diag.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_cx_diag_h)
+#if ! defined (octave_ov_cx_diag_h)
 #define octave_ov_cx_diag_h 1
 
 #include "ov-base.h"
--- a/libinterp/octave-value/ov-cx-mat.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-cx-mat.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -53,7 +53,7 @@
 #include "pr-output.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-hdf5.h"
 #include "ls-utils.h"
 
@@ -320,7 +320,7 @@
 
       retval = mat.diag (m, n);
     }
-  else
+  else  // FIXME: Is this ever reachable?
     error ("diag: expecting vector argument");
 
   return retval;
@@ -337,14 +337,14 @@
       os << "# ndims: " << d.length () << "\n";
 
       for (int i = 0; i < d.length (); i++)
-        os << " " << d (i);
+        os << " " << d(i);
 
       os << "\n" << tmp;
     }
   else
     {
       // Keep this case, rather than use generic code above for backward
-      // compatiability. Makes load_ascii much more complex!!
+      // compatibility.  Makes load_ascii much more complex!!
       os << "# rows: " << rows () << "\n"
          << "# columns: " << columns () << "\n";
 
@@ -537,8 +537,10 @@
       Complex *im = m.fortran_vec ();
       read_doubles (is, reinterpret_cast<double *> (im),
                     static_cast<save_type> (tmp), 2 * dv.numel (), swap, fmt);
-      if (error_state || ! is)
+
+      if (! is)
         return false;
+
       matrix = m;
     }
   else
@@ -556,8 +558,10 @@
       octave_idx_type len = nr * nc;
       read_doubles (is, reinterpret_cast<double *> (im),
                     static_cast<save_type> (tmp), 2*len, swap, fmt);
-      if (error_state || ! is)
+
+      if (! is)
         return false;
+
       matrix = m;
     }
   return true;
@@ -584,7 +588,7 @@
 
   // Octave uses column-major, while HDF5 uses row-major ordering
   for (int i = 0; i < rank; i++)
-    hdims[i] = dv (rank-i-1);
+    hdims[i] = dv(rank-i-1);
 
   space_hid = H5Screate_simple (rank, hdims, 0);
   if (space_hid < 0) return false;
--- a/libinterp/octave-value/ov-cx-mat.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-cx-mat.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_cx_mat_h)
+#if ! defined (octave_ov_cx_mat_h)
 #define octave_ov_cx_mat_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-cx-sparse.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-cx-sparse.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -357,7 +357,7 @@
   read_doubles (is, reinterpret_cast<double *> (m.data ()),
                 static_cast<save_type> (ctmp), 2 * nz, swap, fmt);
 
-  if (error_state || ! is)
+  if (! is)
     return false;
 
   if (! m.indices_ok ())
--- a/libinterp/octave-value/ov-cx-sparse.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-cx-sparse.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_cx_sparse_h)
+#if ! defined (octave_ov_cx_sparse_h)
 #define octave_ov_cx_sparse_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-dld-fcn.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-dld-fcn.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_dld_fcn_h)
+#if ! defined (octave_ov_dld_fcn_h)
 #define octave_ov_dld_fcn_h 1
 
 #include <string>
--- a/libinterp/octave-value/ov-fcn-handle.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-fcn-handle.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -61,7 +61,7 @@
 #include "byte-swap.h"
 #include "ls-ascii-helper.h"
 #include "ls-hdf5.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-oct-binary.h"
 #include "ls-utils.h"
 
@@ -82,7 +82,7 @@
     symbol_table::cache_name (uf->scope (), nm);
 
   if (uf && uf->is_nested_function ())
-    ::error ("handles to nested functions are not yet supported");
+    error ("handles to nested functions are not yet supported");
 }
 
 octave_value_list
@@ -379,7 +379,7 @@
           for (std::list<symbol_table::symbol_record>::const_iterator
                p = vars.begin (); p != vars.end (); p++)
             {
-              if (! save_ascii_data (os, p->varval (0), p->name (), false, 0))
+              if (! save_text_data (os, p->varval (0), p->name (), false, 0))
                 return ! os.fail ();
             }
         }
@@ -462,7 +462,7 @@
                   bool dummy;
 
                   std::string name
-                    = read_ascii_data (is, std::string (), dummy, t2, i);
+                    = read_text_data (is, std::string (), dummy, t2, i);
 
                   if (!is)
                     {
@@ -1159,22 +1159,19 @@
               success = false;
             }
 
-          if (! error_state)
+          hdf5_callback_data dsub;
+          int current_item = 0;
+          for (octave_idx_type i = 0; i < len; i++)
             {
-              hdf5_callback_data dsub;
-              int current_item = 0;
-              for (octave_idx_type i = 0; i < len; i++)
+              if (H5Giterate (group_hid, "symbol table", &current_item,
+                              hdf5_read_next_data, &dsub) <= 0)
                 {
-                  if (H5Giterate (group_hid, "symbol table", &current_item,
-                                  hdf5_read_next_data, &dsub) <= 0)
-                    {
-                      error ("load: failed to load anonymous function handle");
-                      success = false;
-                      break;
-                    }
+                  error ("load: failed to load anonymous function handle");
+                  success = false;
+                  break;
+                }
 
-                  symbol_table::assign (dsub.name, dsub.tc, local_scope);
-                }
+              symbol_table::assign (dsub.name, dsub.tc, local_scope);
             }
         }
 
@@ -1719,91 +1716,84 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      octave_fcn_handle *fh = args(0).fcn_handle_value ();
+  if (args.length () != 1)
+    print_usage ();
+
+  octave_fcn_handle *fh = args(0).fcn_handle_value ("functions: FCN_HANDLE argument must be a function handle object");
 
-      if (! error_state)
-        {
-          octave_function *fcn = fh ? fh->function_value () : 0;
+  octave_function *fcn = fh ? fh->function_value () : 0;
+
+  if (fcn)
+    {
+      octave_scalar_map m;
 
-          if (fcn)
-            {
-              octave_scalar_map m;
-
-              std::string fh_nm = fh->fcn_name ();
+      std::string fh_nm = fh->fcn_name ();
 
-              if (fh_nm == octave_fcn_handle::anonymous)
-                {
-                  std::ostringstream buf;
-                  fh->print_raw (buf);
-                  m.setfield ("function", buf.str ());
+      if (fh_nm == octave_fcn_handle::anonymous)
+        {
+          std::ostringstream buf;
+          fh->print_raw (buf);
+          m.setfield ("function", buf.str ());
+
+          m.setfield ("type", "anonymous");
+        }
+      else
+        {
+          m.setfield ("function", fh_nm);
 
-                  m.setfield ("type", "anonymous");
-                }
-              else
-                {
-                  m.setfield ("function", fh_nm);
+          if (fcn->is_subfunction ())
+            {
+              m.setfield ("type", "subfunction");
+              Cell parentage (dim_vector (1, 2));
+              parentage.elem (0) = fh_nm;
+              parentage.elem (1) = fcn->parent_fcn_name ();
+              m.setfield ("parentage", octave_value (parentage));
+            }
+          else if (fcn->is_private_function ())
+            m.setfield ("type", "private");
+          else if (fh->is_overloaded ())
+            m.setfield ("type", "overloaded");
+          else
+            m.setfield ("type", "simple");
+        }
+
+      std::string nm = fcn->fcn_file_name ();
 
-                  if (fcn->is_subfunction ())
-                    {
-                      m.setfield ("type", "subfunction");
-                      Cell parentage (dim_vector (1, 2));
-                      parentage.elem (0) = fh_nm;
-                      parentage.elem (1) = fcn->parent_fcn_name ();
-                      m.setfield ("parentage", octave_value (parentage));
-                    }
-                  else if (fcn->is_private_function ())
-                    m.setfield ("type", "private");
-                  else if (fh->is_overloaded ())
-                    m.setfield ("type", "overloaded");
-                  else
-                    m.setfield ("type", "simple");
+      if (fh_nm == octave_fcn_handle::anonymous)
+        {
+          m.setfield ("file", nm);
+
+          octave_user_function *fu = fh->user_function_value ();
+
+          std::list<symbol_table::symbol_record> vars
+            = symbol_table::all_variables (fu->scope (), 0);
+
+          size_t varlen = vars.size ();
+
+          if (varlen > 0)
+            {
+              octave_scalar_map ws;
+              for (std::list<symbol_table::symbol_record>::const_iterator
+                     p = vars.begin (); p != vars.end (); p++)
+                {
+                  ws.assign (p->name (), p->varval (0));
                 }
 
-              std::string nm = fcn->fcn_file_name ();
-
-              if (fh_nm == octave_fcn_handle::anonymous)
-                {
-                  m.setfield ("file", nm);
-
-                  octave_user_function *fu = fh->user_function_value ();
-
-                  std::list<symbol_table::symbol_record> vars
-                    = symbol_table::all_variables (fu->scope (), 0);
-
-                  size_t varlen = vars.size ();
-
-                  if (varlen > 0)
-                    {
-                      octave_scalar_map ws;
-                      for (std::list<symbol_table::symbol_record>::const_iterator
-                           p = vars.begin (); p != vars.end (); p++)
-                        {
-                          ws.assign (p->name (), p->varval (0));
-                        }
-
-                      m.setfield ("workspace", ws);
-                    }
-                }
-              else if (fcn->is_user_function () || fcn->is_user_script ())
-                {
-                  octave_function *fu = fh->function_value ();
-                  m.setfield ("file", fu->fcn_file_name ());
-                }
-              else
-                m.setfield ("file", "");
-
-              retval = m;
+              m.setfield ("workspace", ws);
             }
-          else
-            error ("functions: FCN_HANDLE is not a valid function handle object");
+        }
+      else if (fcn->is_user_function () || fcn->is_user_script ())
+        {
+          octave_function *fu = fh->function_value ();
+          m.setfield ("file", fu->fcn_file_name ());
         }
       else
-        error ("functions: FCN_HANDLE argument must be a function handle object");
+        m.setfield ("file", "");
+
+      retval = m;
     }
   else
-    print_usage ();
+    error ("functions: FCN_HANDLE is not a valid function handle object");
 
   return retval;
 }
@@ -1818,30 +1808,28 @@
 {
   octave_value retval;
 
-  if (args.length () == 1)
-    {
-      octave_fcn_handle *fh = args(0).fcn_handle_value ();
+  if (args.length () != 1)
+    print_usage ();
 
-      if (! error_state && fh)
-        {
-          std::string fh_nm = fh->fcn_name ();
+  octave_fcn_handle *fh = args(0).fcn_handle_value ("func2str: FCN_HANDLE argument must be a function handle object");
 
-          if (fh_nm == octave_fcn_handle::anonymous)
-            {
-              std::ostringstream buf;
+  if (fh)
+    {
+      std::string fh_nm = fh->fcn_name ();
 
-              fh->print_raw (buf);
+      if (fh_nm == octave_fcn_handle::anonymous)
+        {
+          std::ostringstream buf;
 
-              retval = buf.str ();
-            }
-          else
-            retval = fh_nm;
+          fh->print_raw (buf);
+
+          retval = buf.str ();
         }
       else
-        error ("func2str: FCN_HANDLE must be a valid function handle");
+        retval = fh_nm;
     }
   else
-    print_usage ();
+    error ("func2str: FCN_HANDLE must be a valid function handle");
 
   return retval;
 }
@@ -1854,33 +1842,50 @@
 \n\
 If the optional @qcode{\"global\"} argument is passed, locally visible\n\
 functions are ignored in the lookup.\n\
-\n\
-Note: @code{str2func} does not currently accept strings which define\n\
-anonymous functions (those which begin with @samp{@@}).\n\
-Use @w{@code{eval (@var{str})}} as a replacement.\n\
 @seealso{func2str, inline}\n\
 @end deftypefn")
 {
   octave_value retval;
+
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  std::string nm = args(0).xstring_value ("str2func: FCN_NAME must be a string");
+
+  if (nm[0] == '@')
     {
-      if (args(0).is_string ())
-        {
-          std::string nm = args(0).string_value ();
-          retval = make_fcn_handle (nm, nargin != 2);
-        }
-      else
-        error ("str2func: FCN_NAME must be a string");
+      int parse_status;
+      octave_value anon_fcn_handle =
+        eval_string (nm, true, parse_status);
+
+      if (parse_status == 0)
+        retval = anon_fcn_handle;
     }
   else
-    print_usage ();
+    retval = make_fcn_handle (nm, nargin != 2);
 
   return retval;
 }
 
 /*
+%!test
+%! f = str2func ("<");
+%! assert (class (f), "function_handle");
+%! assert (func2str (f), "lt");
+%! assert (f (1, 2), true);
+%! assert (f (2, 1), false);
+
+%!test
+%! f = str2func ("@(x) sin (x)");
+%! assert (func2str (f), "@(x) sin (x)");
+%! assert (f (0:3), sin (0:3));
+
+%!error <FCN_NAME must be a string> str2func ({"sin"})
+*/
+
+/*
 %!function y = __testrecursionfunc (f, x, n)
 %!  if (nargin < 3)
 %!    n = 0;
@@ -1903,16 +1908,10 @@
 @seealso{isa, typeinfo, class, functions}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1)
-    retval = args(0).is_function_handle ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_function_handle ());
 }
 
 /*
@@ -2051,19 +2050,34 @@
                     {
                       // It's a name.
                       std::string head_name = head_id->name ();
-                      // Function handles can't handle legacy dispatch, so
-                      // we make sure it's not defined.
-                      if (symbol_table::get_dispatch (head_name).size () > 0)
+
+                      if (head_name == "eval" || head_name == "feval")
                         bad = true;
                       else
                         {
-                          // Simulate try/catch.
-                          unwind_protect frame;
-                          interpreter_try (frame);
+                          // Function handles can't handle legacy
+                          // dispatch, so we make sure it's not
+                          // defined.
+
+                          if (symbol_table::get_dispatch (head_name).size () > 0)
+                            bad = true;
+                          else
+                            {
+                              // Simulate try/catch.
+                              unwind_protect frame;
+                              interpreter_try (frame);
 
-                          root_val = make_fcn_handle (head_name);
-                          if (error_state)
-                            bad = true;
+                              try
+                                {
+                                  root_val = make_fcn_handle (head_name);
+                                }
+                              catch (const octave_execution_exception&)
+                                {
+                                  recover_from_exception ();
+
+                                  bad = true;
+                                }
+                            }
                         }
                     }
                 }
@@ -2088,6 +2102,12 @@
   return retval;
 }
 
+/*
+%!test
+%! f = @(t) eval ('2*t');
+%! assert (f (21), 42);
+*/
+
 octave_value_list
 octave_fcn_binder::do_multi_index_op (int nargout,
                                       const octave_value_list& args)
--- a/libinterp/octave-value/ov-fcn-handle.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-fcn-handle.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_fcn_handle_h)
+#if ! defined (octave_ov_fcn_handle_h)
 #define octave_ov_fcn_handle_h 1
 
 #include <iosfwd>
--- a/libinterp/octave-value/ov-fcn-inline.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-fcn-inline.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -50,7 +50,7 @@
 
 #include "byte-swap.h"
 #include "ls-ascii-helper.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-hdf5.h"
 #include "ls-utils.h"
 
@@ -70,7 +70,7 @@
 
   buf << "@(";
 
-  for (int i = 0; i < ifargs.length (); i++)
+  for (int i = 0; i < ifargs.numel (); i++)
     {
       if (i > 0)
         buf << ", ";
@@ -128,12 +128,12 @@
 
   string_vector args = fcn_arg_names ();
 
-  m.assign ("numArgs", args.length ());
+  m.assign ("numArgs", args.numel ());
   m.assign ("args", args);
 
   std::ostringstream buf;
 
-  for (int i = 0; i < args.length (); i++)
+  for (int i = 0; i < args.numel (); i++)
     buf << args(i) << " = INLINE_INPUTS_{" << i + 1 << "}; ";
 
   m.assign ("inputExpr", buf.str ());
@@ -144,8 +144,8 @@
 bool
 octave_fcn_inline::save_ascii (std::ostream& os)
 {
-  os << "# nargs: " <<  ifargs.length () << "\n";
-  for (int i = 0; i < ifargs.length (); i++)
+  os << "# nargs: " <<  ifargs.numel () << "\n";
+  for (int i = 0; i < ifargs.numel (); i++)
     os << ifargs(i) << "\n";
   if (nm.length () < 1)
     // Write an invalid value to flag empty fcn handle name.
@@ -195,9 +195,9 @@
 bool
 octave_fcn_inline::save_binary (std::ostream& os, bool&)
 {
-  int32_t tmp = ifargs.length ();
+  int32_t tmp = ifargs.numel ();
   os.write (reinterpret_cast<char *> (&tmp), 4);
-  for (int i = 0; i < ifargs.length (); i++)
+  for (int i = 0; i < ifargs.numel (); i++)
     {
       tmp = ifargs(i).length ();
       os.write (reinterpret_cast<char *> (&tmp), 4);
@@ -291,7 +291,7 @@
   if (group_hid < 0) return false;
 
   size_t len = 0;
-  for (int i = 0; i < ifargs.length (); i++)
+  for (int i = 0; i < ifargs.numel (); i++)
     if (len < ifargs(i).length ())
       len = ifargs(i).length ();
 
@@ -304,7 +304,7 @@
   OCTAVE_LOCAL_BUFFER (hsize_t, hdims, 2);
 
   // Octave uses column-major, while HDF5 uses row-major ordering
-  hdims[1] = ifargs.length ();
+  hdims[1] = ifargs.numel ();
   hdims[0] = len + 1;
 
   space_hid = H5Screate_simple (2, hdims, 0);
@@ -327,10 +327,10 @@
       return false;
     }
 
-  OCTAVE_LOCAL_BUFFER (char, s, ifargs.length () * (len + 1));
+  OCTAVE_LOCAL_BUFFER (char, s, ifargs.numel () * (len + 1));
 
   // Save the args as a null teminated list
-  for (int i = 0; i < ifargs.length (); i++)
+  for (int i = 0; i < ifargs.numel (); i++)
     {
       const char * cptr = ifargs(i).c_str ();
       for (size_t j = 0; j < ifargs(i).length (); j++)
@@ -627,7 +627,7 @@
   else
     buf << nm << "(";
 
-  for (int i = 0; i < ifargs.length (); i++)
+  for (int i = 0; i < ifargs.numel (); i++)
     {
       if (i)
         buf << ", ";
@@ -679,169 +679,145 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
-    {
-      if (args(0).is_string ())
-        {
-          std::string fun = args(0).string_value ();
-          string_vector fargs;
+  if (nargin == 0)
+    print_usage ();
 
-          if (nargin == 1)
-            {
-              bool is_arg = false;
-              bool in_string = false;
-              std::string tmp_arg;
-              size_t i = 0;
-              size_t fun_length = fun.length ();
+  std::string fun = args(0).xstring_value ("inline: STR argument must be a string");
 
-              while (i < fun_length)
-                {
-                  bool terminate_arg = false;
-                  char c = fun[i++];
+  string_vector fargs;
 
-                  if (in_string)
-                    {
-                      if (c == '\'' || c == '\"')
-                        in_string = false;
-                    }
-                  else if (c == '\'' || c == '\"')
-                    {
-                      in_string = true;
-                      if (is_arg)
-                        terminate_arg = true;
-                    }
-                  else if (! isalpha (c) && c != '_')
-                    if (! is_arg)
-                      continue;
-                    else if (isdigit (c))
-                      tmp_arg.append (1, c);
-                    else
-                      {
-                        // Before we do anything remove trailing whitespaces.
-                        while (i < fun_length && isspace (c))
-                          c = fun[i++];
+  if (nargin == 1)
+    {
+      bool is_arg = false;
+      bool in_string = false;
+      std::string tmp_arg;
+      size_t i = 0;
+      size_t fun_length = fun.length ();
+
+      while (i < fun_length)
+        {
+          bool terminate_arg = false;
+          char c = fun[i++];
 
-                        // Do we have a variable or a function?
-                        if (c != '(')
-                          terminate_arg = true;
-                        else
-                          {
-                            tmp_arg = std::string ();
-                            is_arg = false;
-                          }
-                      }
-                  else if (! is_arg)
-                    {
-                      if (c == 'e' || c == 'E')
-                        {
-                          // possible number in exponent form, not arg
-                          if (isdigit (fun[i])
-                              || fun[i] == '-' || fun[i] == '+')
-                            continue;
-                        }
-                      is_arg = true;
-                      tmp_arg.append (1, c);
-                    }
-                  else
-                    {
-                      tmp_arg.append (1, c);
-                    }
-
-                  if (terminate_arg || (i == fun_length && is_arg))
-                    {
-                      bool have_arg = false;
-
-                      for (int j = 0; j < fargs.length (); j++)
-                        if (tmp_arg == fargs (j))
-                          {
-                            have_arg = true;
-                            break;
-                          }
-
-                      if (! have_arg && tmp_arg != "i" && tmp_arg != "j"
-                          && tmp_arg != "NaN" && tmp_arg != "nan"
-                          && tmp_arg != "Inf" && tmp_arg != "inf"
-                          && tmp_arg != "NA" && tmp_arg != "pi"
-                          && tmp_arg != "e" && tmp_arg != "eps")
-                        fargs.append (tmp_arg);
+          if (in_string)
+            {
+              if (c == '\'' || c == '\"')
+                in_string = false;
+            }
+          else if (c == '\'' || c == '\"')
+            {
+              in_string = true;
+              if (is_arg)
+                terminate_arg = true;
+            }
+          else if (! isalpha (c) && c != '_')
+            if (! is_arg)
+              continue;
+            else if (isdigit (c))
+              tmp_arg.append (1, c);
+            else
+              {
+                // Before we do anything remove trailing whitespaces.
+                while (i < fun_length && isspace (c))
+                  c = fun[i++];
 
-                      tmp_arg = std::string ();
-                      is_arg = false;
-                    }
-                }
-
-              // Sort the arguments into ascii order.
-              fargs.sort ();
-
-              if (fargs.length () == 0)
-                fargs.append (std::string ("x"));
-
-            }
-          else if (nargin == 2 && args(1).is_numeric_type ())
+                // Do we have a variable or a function?
+                if (c != '(')
+                  terminate_arg = true;
+                else
+                  {
+                    tmp_arg = std::string ();
+                    is_arg = false;
+                  }
+              }
+          else if (! is_arg)
             {
-              if (! args(1).is_scalar_type ())
-                {
-                  error ("inline: N must be an integer");
-                  return retval;
-                }
-
-              int n = args(1).int_value ();
-
-              if (! error_state)
+              if (c == 'e' || c == 'E')
                 {
-                  if (n >= 0)
-                    {
-                      fargs.resize (n+1);
-
-                      fargs(0) = "x";
-
-                      for (int i = 1; i < n+1; i++)
-                        {
-                          std::ostringstream buf;
-                          buf << "P" << i;
-                          fargs(i) = buf.str ();
-                        }
-                    }
-                  else
-                    {
-                      error ("inline: N must be a positive integer or zero");
-                      return retval;
-                    }
+                  // possible number in exponent form, not arg
+                  if (isdigit (fun[i])
+                      || fun[i] == '-' || fun[i] == '+')
+                    continue;
                 }
-              else
-                {
-                  error ("inline: N must be an integer");
-                  return retval;
-                }
+              is_arg = true;
+              tmp_arg.append (1, c);
             }
           else
             {
-              fargs.resize (nargin - 1);
-
-              for (int i = 1; i < nargin; i++)
-                {
-                  if (args(i).is_string ())
-                    {
-                      std::string s = args(i).string_value ();
-                      fargs(i-1) = s;
-                    }
-                  else
-                    {
-                      error ("inline: expecting string arguments");
-                      return retval;
-                    }
-                }
+              tmp_arg.append (1, c);
             }
 
-          retval = octave_value (new octave_fcn_inline (fun, fargs));
+          if (terminate_arg || (i == fun_length && is_arg))
+            {
+              bool have_arg = false;
+
+              for (int j = 0; j < fargs.numel (); j++)
+                if (tmp_arg == fargs (j))
+                  {
+                    have_arg = true;
+                    break;
+                  }
+
+              if (! have_arg && tmp_arg != "i" && tmp_arg != "j"
+                  && tmp_arg != "NaN" && tmp_arg != "nan"
+                  && tmp_arg != "Inf" && tmp_arg != "inf"
+                  && tmp_arg != "NA" && tmp_arg != "pi"
+                  && tmp_arg != "e" && tmp_arg != "eps")
+                fargs.append (tmp_arg);
+
+              tmp_arg = std::string ();
+              is_arg = false;
+            }
+        }
+
+      // Sort the arguments into ascii order.
+      fargs.sort ();
+
+      if (fargs.numel () == 0)
+        fargs.append (std::string ("x"));
+
+    }
+  else if (nargin == 2 && args(1).is_numeric_type ())
+    {
+      if (! args(1).is_scalar_type ())
+        {
+          error ("inline: N must be an integer");
+          return retval;
+        }
+
+      int n = args(1).int_value ("inline: N must be an integer");
+
+      if (n >= 0)
+        {
+          fargs.resize (n+1);
+
+          fargs(0) = "x";
+
+          for (int i = 1; i < n+1; i++)
+            {
+              std::ostringstream buf;
+              buf << "P" << i;
+              fargs(i) = buf.str ();
+            }
         }
       else
-        error ("inline: STR argument must be a string");
+        {
+          error ("inline: N must be a positive integer or zero");
+          return retval;
+        }
     }
   else
-    print_usage ();
+    {
+      fargs.resize (nargin - 1);
 
-  return retval;
+      for (int i = 1; i < nargin; i++)
+        {
+          std::string s = args(i).xstring_value ("inline: additional arguments must be strings");
+          fargs(i-1) = s;
+        }
+    }
+
+  return octave_value (new octave_fcn_inline (fun, fargs));
 }
 
 /*
@@ -858,7 +834,7 @@
 %!error <STR argument must be a string> inline (1)
 %!error <N must be an integer> inline ("2", ones (2,2))
 %!error <N must be a positive integer> inline ("2", -1)
-%!error <expecting string arguments> inline ("2", "x", -1, "y")
+%!error <additional arguments must be strings> inline ("2", "x", -1, "y")
 */
 
 DEFUN (formula, args, ,
@@ -873,19 +849,15 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin == 1)
-    {
-      octave_fcn_inline* fn = args(0).fcn_inline_value (true);
+  octave_fcn_inline* fn = args(0).fcn_inline_value (true);
 
-      if (fn)
-        retval = octave_value (fn->fcn_text ());
-      else
-        error ("formula: FUN must be an inline function");
-    }
+  if (fn)
+    retval = octave_value (fn->fcn_text ());
   else
-    print_usage ();
+    error ("formula: FUN must be an inline function");
 
   return retval;
 }
@@ -910,28 +882,24 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin == 1)
-    {
-      octave_fcn_inline *fn = args(0).fcn_inline_value (true);
-
-      if (fn)
-        {
-          string_vector t1 = fn->fcn_arg_names ();
+  octave_fcn_inline *fn = args(0).fcn_inline_value (true);
 
-          Cell t2 (dim_vector (t1.length (), 1));
-
-          for (int i = 0; i < t1.length (); i++)
-            t2(i) = t1(i);
+  if (fn)
+    {
+      string_vector t1 = fn->fcn_arg_names ();
 
-          retval = t2;
-        }
-      else
-        error ("argnames: FUN must be an inline function");
+      Cell t2 (dim_vector (t1.numel (), 1));
+
+      for (int i = 0; i < t1.numel (); i++)
+        t2(i) = t1(i);
+
+      retval = t2;
     }
   else
-    print_usage ();
+    error ("argnames: FUN must be an inline function");
 
   return retval;
 }
@@ -969,62 +937,55 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin == 1)
-    {
-      std::string old_func;
-      octave_fcn_inline* old = 0;
-      bool func_is_string = true;
+  std::string old_func;
+  octave_fcn_inline* old = 0;
+  bool func_is_string = true;
 
-      if (args(0).is_string ())
-        old_func = args(0).string_value ();
-      else
-        {
-          old = args(0).fcn_inline_value (true);
-          func_is_string = false;
-
-          if (old)
-            old_func = old->fcn_text ();
-          else
-            error ("vectorize: FUN must be a string or inline function");
-        }
+  if (args(0).is_string ())
+    old_func = args(0).string_value ();
+  else
+    {
+      old = args(0).fcn_inline_value (true);
+      func_is_string = false;
 
-      if (! error_state)
-        {
-          std::string new_func;
-          size_t i = 0;
+      if (old)
+        old_func = old->fcn_text ();
+      else
+        error ("vectorize: FUN must be a string or inline function");
+    }
 
-          while (i < old_func.length ())
-            {
-              std::string t1 = old_func.substr (i, 1);
+  std::string new_func;
+  size_t i = 0;
 
-              if (t1 == "*" || t1 == "/" || t1 == "\\" || t1 == "^")
-                {
-                  if (i && old_func.substr (i-1, 1) != ".")
-                    new_func.append (".");
+  while (i < old_func.length ())
+    {
+      std::string t1 = old_func.substr (i, 1);
 
-                  // Special case for ** operator.
-                  if (t1 == "*" && i < (old_func.length () - 1)
-                      && old_func.substr (i+1, 1) == "*")
-                    {
-                      new_func.append ("*");
-                      i++;
-                    }
-                }
-              new_func.append (t1);
+      if (t1 == "*" || t1 == "/" || t1 == "\\" || t1 == "^")
+        {
+          if (i && old_func.substr (i-1, 1) != ".")
+            new_func.append (".");
+
+          // Special case for ** operator.
+          if (t1 == "*" && i < (old_func.length () - 1)
+              && old_func.substr (i+1, 1) == "*")
+            {
+              new_func.append ("*");
               i++;
             }
+        }
+      new_func.append (t1);
+      i++;
+    }
 
-          if (func_is_string)
-            retval = octave_value (new_func);
-          else
-            retval = octave_value (new octave_fcn_inline
-                                   (new_func, old->fcn_arg_names ()));
-        }
-    }
+  if (func_is_string)
+    retval = octave_value (new_func);
   else
-    print_usage ();
+    retval = octave_value (new octave_fcn_inline
+                           (new_func, old->fcn_arg_names ()));
 
   return retval;
 }
--- a/libinterp/octave-value/ov-fcn-inline.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-fcn-inline.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_fcn_inline_h)
+#if ! defined (octave_ov_fcn_inline_h)
 #define octave_ov_fcn_inline_h 1
 
 #include <iosfwd>
--- a/libinterp/octave-value/ov-fcn.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-fcn.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_fcn_h)
+#if ! defined (octave_ov_fcn_h)
 #define octave_ov_fcn_h 1
 
 #include <string>
--- a/libinterp/octave-value/ov-float.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-float.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -49,7 +49,7 @@
 #include "xpow.h"
 #include "ops.h"
 
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-hdf5.h"
 
 template class octave_base_scalar<float>;
@@ -177,7 +177,8 @@
 
   float dtmp;
   read_floats (is, &dtmp, static_cast<save_type> (tmp), 1, swap, fmt);
-  if (error_state || ! is)
+
+  if (! is)
     return false;
 
   scalar = dtmp;
@@ -357,7 +358,7 @@
     case umap_xtoascii:
       {
         octave_value str_conv = convert_to_str (true, true);
-        return error_state ? octave_value () : str_conv.map (umap);
+        return str_conv.map (umap);
       }
 
     default:
--- a/libinterp/octave-value/ov-float.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-float.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_float_h)
+#if ! defined (octave_ov_float_h)
 #define octave_ov_float_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-flt-complex.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-flt-complex.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -46,7 +46,7 @@
 #include "pr-output.h"
 #include "ops.h"
 
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-hdf5.h"
 
 template class octave_base_scalar<FloatComplex>;
@@ -287,7 +287,8 @@
   FloatComplex ctmp;
   read_floats (is, reinterpret_cast<float *> (&ctmp),
                static_cast<save_type> (tmp), 2, swap, fmt);
-  if (error_state || ! is)
+
+  if (! is)
     return false;
 
   scalar = ctmp;
--- a/libinterp/octave-value/ov-flt-complex.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-flt-complex.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_flt_complex_h)
+#if ! defined (octave_ov_flt_complex_h)
 #define octave_ov_flt_complex_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-flt-cx-diag.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-flt-cx-diag.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -190,8 +190,10 @@
   octave_idx_type len = m.length ();
   read_floats (is, reinterpret_cast<float *> (re),
                static_cast<save_type> (tmp), 2 * len, swap, fmt);
-  if (error_state || ! is)
+
+  if (! is)
     return false;
+
   matrix = m;
 
   return true;
--- a/libinterp/octave-value/ov-flt-cx-diag.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-flt-cx-diag.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_flt_cx_diag_h)
+#if ! defined (octave_ov_flt_cx_diag_h)
 #define octave_ov_flt_cx_diag_h 1
 
 #include "ov-base.h"
--- a/libinterp/octave-value/ov-flt-cx-mat.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-flt-cx-mat.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -57,7 +57,7 @@
 #include "ops.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-hdf5.h"
 #include "ls-utils.h"
 
@@ -311,14 +311,14 @@
       os << "# ndims: " << d.length () << "\n";
 
       for (int i = 0; i < d.length (); i++)
-        os << " " << d (i);
+        os << " " << d(i);
 
       os << "\n" << tmp;
     }
   else
     {
       // Keep this case, rather than use generic code above for backward
-      // compatiability. Makes load_ascii much more complex!!
+      // compatibility.  Makes load_ascii much more complex!!
       os << "# rows: " << rows () << "\n"
          << "# columns: " << columns () << "\n";
 
@@ -499,8 +499,10 @@
       FloatComplex *im = m.fortran_vec ();
       read_floats (is, reinterpret_cast<float *> (im),
                    static_cast<save_type> (tmp), 2 * dv.numel (), swap, fmt);
-      if (error_state || ! is)
+
+      if (! is)
         return false;
+
       matrix = m;
     }
   else
@@ -518,8 +520,10 @@
       octave_idx_type len = nr * nc;
       read_floats (is, reinterpret_cast<float *> (im),
                    static_cast<save_type> (tmp), 2*len, swap, fmt);
-      if (error_state || ! is)
+
+      if (! is)
         return false;
+
       matrix = m;
     }
   return true;
@@ -546,7 +550,7 @@
 
   // Octave uses column-major, while HDF5 uses row-major ordering
   for (int i = 0; i < rank; i++)
-    hdims[i] = dv (rank-i-1);
+    hdims[i] = dv(rank-i-1);
 
   space_hid = H5Screate_simple (rank, hdims, 0);
   if (space_hid < 0) return false;
--- a/libinterp/octave-value/ov-flt-cx-mat.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-flt-cx-mat.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_flt_cx_mat_h)
+#if ! defined (octave_ov_flt_cx_mat_h)
 #define octave_ov_flt_cx_mat_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-flt-re-diag.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-flt-re-diag.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -158,8 +158,10 @@
   float *re = m.fortran_vec ();
   octave_idx_type len = m.length ();
   read_floats (is, re, static_cast<save_type> (tmp), len, swap, fmt);
-  if (error_state || ! is)
+
+  if (! is)
     return false;
+
   matrix = m;
 
   return true;
--- a/libinterp/octave-value/ov-flt-re-diag.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-flt-re-diag.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_flt_re_diag_h)
+#if ! defined (octave_ov_flt_re_diag_h)
 #define octave_ov_flt_re_diag_h 1
 
 #include "ov-base.h"
--- a/libinterp/octave-value/ov-flt-re-mat.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-flt-re-mat.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -65,7 +65,7 @@
 #include "ops.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
@@ -80,7 +80,7 @@
 {
   octave_base_value *retval = 0;
 
-  if (matrix.nelem () == 1)
+  if (matrix.numel () == 1)
     retval = new octave_float_scalar (matrix (0));
 
   return retval;
@@ -338,14 +338,14 @@
       os << "# ndims: " << d.length () << "\n";
 
       for (int i=0; i < d.length (); i++)
-        os << " " << d (i);
+        os << " " << d(i);
 
       os << "\n" << tmp;
     }
   else
     {
       // Keep this case, rather than use generic code above for backward
-      // compatiability. Makes load_ascii much more complex!!
+      // compatibility.  Makes load_ascii much more complex!!
       os << "# rows: " << rows () << "\n"
          << "# columns: " << columns () << "\n";
 
@@ -527,8 +527,10 @@
       float *re = m.fortran_vec ();
       read_floats (is, re, static_cast<save_type> (tmp), dv.numel (),
                    swap, fmt);
-      if (error_state || ! is)
+
+      if (! is)
         return false;
+
       matrix = m;
     }
   else
@@ -545,8 +547,10 @@
       float *re = m.fortran_vec ();
       octave_idx_type len = nr * nc;
       read_floats (is, re, static_cast<save_type> (tmp), len, swap, fmt);
-      if (error_state || ! is)
+
+      if (! is)
         return false;
+
       matrix = m;
     }
   return true;
@@ -573,7 +577,7 @@
 
   // Octave uses column-major, while HDF5 uses row-major ordering
   for (int i = 0; i < rank; i++)
-    hdims[i] = dv (rank-i-1);
+    hdims[i] = dv(rank-i-1);
 
   space_hid = H5Screate_simple (rank, hdims, 0);
 
@@ -841,7 +845,7 @@
     case umap_xtoascii:
       {
         octave_value str_conv = convert_to_str (true, true);
-        return error_state ? octave_value () : str_conv.map (umap);
+        return str_conv.map (umap);
       }
 
     default:
@@ -860,38 +864,36 @@
   // inside their own scopes, and we don't declare retval here to
   // avoid a shadowed declaration warning.
 
-  if (args.length () == 1)
+  if (args.length () != 1)
+    print_usage ();
+
+  if (args(0).is_diag_matrix ())
     {
-      if (args(0).is_diag_matrix ())
+      if (args(0).is_complex_type ())
         {
-          if (args(0).is_complex_type ())
-            {
-              OCTAVE_TYPE_CONV_BODY3 (single, octave_float_complex_diag_matrix,
-                                      octave_float_complex);
-            }
-          else
-            {
-              OCTAVE_TYPE_CONV_BODY3 (single, octave_float_diag_matrix,
-                                      octave_float_scalar);
-            }
-        }
-      else if (args(0).is_sparse_type ())
-        {
-          error ("single: sparse type does not support single precision");
-        }
-      else if (args(0).is_complex_type ())
-        {
-          OCTAVE_TYPE_CONV_BODY3 (single, octave_float_complex_matrix,
+          OCTAVE_TYPE_CONV_BODY3 (single, octave_float_complex_diag_matrix,
                                   octave_float_complex);
         }
       else
         {
-          OCTAVE_TYPE_CONV_BODY3 (single, octave_float_matrix,
+          OCTAVE_TYPE_CONV_BODY3 (single, octave_float_diag_matrix,
                                   octave_float_scalar);
         }
     }
+  else if (args(0).is_sparse_type ())
+    {
+      error ("single: sparse type does not support single precision");
+    }
+  else if (args(0).is_complex_type ())
+    {
+      OCTAVE_TYPE_CONV_BODY3 (single, octave_float_complex_matrix,
+                              octave_float_complex);
+    }
   else
-    print_usage ();
+    {
+      OCTAVE_TYPE_CONV_BODY3 (single, octave_float_matrix,
+                              octave_float_scalar);
+    }
 
   return octave_value ();
 }
--- a/libinterp/octave-value/ov-flt-re-mat.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-flt-re-mat.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_flt_re_mat_h)
+#if ! defined (octave_ov_flt_re_mat_h)
 #define octave_ov_flt_re_mat_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-int-traits.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-int-traits.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_int_traits_h)
+#if ! defined (octave_ov_int_traits_h)
 #define octave_ov_int_traits_h 1
 
 #include "ov-int8.h"
--- a/libinterp/octave-value/ov-int16.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-int16.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -52,7 +52,7 @@
 #include "variables.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
--- a/libinterp/octave-value/ov-int16.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-int16.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_int16_h)
+#if ! defined (octave_ov_int16_h)
 #define octave_ov_int16_h 1
 
 #define OCTAVE_INT_T octave_int16
--- a/libinterp/octave-value/ov-int32.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-int32.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -52,7 +52,7 @@
 #include "variables.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
--- a/libinterp/octave-value/ov-int32.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-int32.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_int32_h)
+#if ! defined (octave_ov_int32_h)
 #define octave_ov_int32_h 1
 
 #define OCTAVE_INT_T octave_int32
--- a/libinterp/octave-value/ov-int64.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-int64.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -52,7 +52,7 @@
 #include "variables.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
--- a/libinterp/octave-value/ov-int64.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-int64.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_int64_h)
+#if ! defined (octave_ov_int64_h)
 #define octave_ov_int64_h 1
 
 #define OCTAVE_INT_T octave_int64
--- a/libinterp/octave-value/ov-int8.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-int8.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -52,7 +52,7 @@
 #include "variables.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
--- a/libinterp/octave-value/ov-int8.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-int8.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_int8_h)
+#if ! defined (octave_ov_int8_h)
 #define octave_ov_int8_h 1
 
 #define OCTAVE_INT_T octave_int8
--- a/libinterp/octave-value/ov-java.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-java.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -135,8 +135,7 @@
         while (! js.eof () && ! js.fail ())
           {
             std::getline (js, line);
-            if (line.length () > 2
-                && (line.find ("-D") == 0 || line.find ("-X") == 0))
+            if (line.find ("-") == 0)
               java_opts.push_back (line);
             else if (line.length () > 0 && Vdebug_java)
               std::cerr << "invalid JVM option, skipping: " << line << std::endl;
@@ -350,6 +349,9 @@
           // 2) User's home directory
           // 3) Octave installation directory where octave.jar resides
 
+          std::string cwd = octave_env::get_current_directory ();
+          std::string home_dir = octave_env::get_home_directory ();
+
           // The filename is "javaclasspath.txt", but historically
           // has been "classpath.txt" so both are supported.
           std::string cp_list[] = {"javaclasspath.txt", "classpath.txt"};
@@ -372,25 +374,31 @@
 
               // Try to find classpath file in the user's home directory.
 
-              cp_file = "~" + sep + filename;
-              cp_file = file_ops::tilde_expand (cp_file);
-              cp_exists = file_stat (cp_file);
-              if (cp_exists)
+              if (cwd != home_dir)
                 {
-                  // File found.  Add its contents to the static classpath.
-                  std::string classpath = read_classpath_txt (cp_file);
-                  retval.append (classpath);
+                  cp_file = "~" + sep + filename;
+                  cp_file = file_ops::tilde_expand (cp_file);
+                  cp_exists = file_stat (cp_file);
+                  if (cp_exists)
+                    {
+                      // File found.  Add its contents to the static classpath.
+                      std::string classpath = read_classpath_txt (cp_file);
+                      retval.append (classpath);
+                    }
                 }
 
               // Try to find classpath file in the Octave install directory.
 
-              cp_file = java_dir + sep + filename;
-              cp_exists = file_stat (cp_file);
-              if (cp_exists)
+              if (cwd != java_dir)
                 {
-                  // File found.  Add its contents to the static classpath.
-                  std::string classpath = read_classpath_txt (cp_file);
-                  retval.append (classpath);
+                  cp_file = java_dir + sep + filename;
+                  cp_exists = file_stat (cp_file);
+                  if (cp_exists)
+                    {
+                      // File found.  Add its contents to the static classpath.
+                      std::string classpath = read_classpath_txt (cp_file);
+                      retval.append (classpath);
+                    }
                 }
             }
         }
@@ -818,28 +826,27 @@
   jobjectArray retval = jni_env->NewObjectArray (idx.length (), ocls, 0);
 
   for (int i = 0; i < idx.length (); i++)
-    {
-      idx_vector v = idx(i).index_vector ();
-
-      if (! error_state)
-        {
-          jintArray_ref i_array (jni_env, jni_env->NewIntArray (v.length ()));
-          jint *buf = jni_env->GetIntArrayElements (i_array, 0);
-
-          for (int k = 0; k < v.length (); k++)
-            buf[k] = v(k);
-
-          jni_env->ReleaseIntArrayElements (i_array, buf, 0);
-          jni_env->SetObjectArrayElement (retval, i, i_array);
-
-          check_exception (jni_env);
-
-          if (error_state)
-            break;
-        }
-      else
-        break;
-    }
+    try
+      {
+        idx_vector v = idx(i).index_vector ();
+
+        jintArray_ref i_array (jni_env, jni_env->NewIntArray (v.length ()));
+        jint *buf = jni_env->GetIntArrayElements (i_array, 0);
+
+        for (int k = 0; k < v.length (); k++)
+          buf[k] = v(k);
+
+        jni_env->ReleaseIntArrayElements (i_array, buf, 0);
+        jni_env->SetObjectArrayElement (retval, i, i_array);
+
+        check_exception (jni_env);
+      }
+    catch (index_exception& e)
+      {
+        // Rethrow to allow more info to be reported later.
+        e.set_pos_if_unset (idx.length (), i+1);
+        throw;
+      }
 
   return retval;
 }
@@ -852,12 +859,9 @@
   jobject_ref resObj (jni_env);
   jobject_ref java_idx (jni_env, make_java_index (jni_env, idx));
 
-  if (! error_state)
-    {
-      jclass_ref helperClass (jni_env, find_octave_class (jni_env, "org/octave/ClassHelper"));
-      jmethodID mID = jni_env->GetStaticMethodID (helperClass, "arraySubsref", "(Ljava/lang/Object;[[I)Ljava/lang/Object;");
-      resObj = jni_env->CallStaticObjectMethod (helperClass, mID, jobj, jobject (java_idx));
-    }
+  jclass_ref helperClass (jni_env, find_octave_class (jni_env, "org/octave/ClassHelper"));
+  jmethodID mID = jni_env->GetStaticMethodID (helperClass, "arraySubsref", "(Ljava/lang/Object;[[I)Ljava/lang/Object;");
+  resObj = jni_env->CallStaticObjectMethod (helperClass, mID, jobj, jobject (java_idx));
 
   if (resObj)
     retval = box (jni_env, resObj);
@@ -880,7 +884,7 @@
   jobject_ref rhsObj (jni_env);
   jobject_ref java_idx (jni_env, make_java_index (jni_env, idx));
 
-  if (! error_state && unbox (jni_env, rhs, rhsObj, rhsCls))
+  if (unbox (jni_env, rhs, rhsObj, rhsCls))
     {
       jclass_ref helperClass (jni_env, find_octave_class (jni_env, "org/octave/ClassHelper"));
       jmethodID mID = jni_env->GetStaticMethodID (helperClass, "arraySubsasgn",
@@ -969,12 +973,7 @@
                   if (js)
                     c(i) = octave_value (jstring_to_string (jni_env, js), type);
                   else
-                    {
-                      c(i) = check_exception (jni_env);
-
-                      if (error_state)
-                        break;
-                    }
+                    c(i) = check_exception (jni_env);
                 }
 
               retval = octave_value (c);
@@ -1060,14 +1059,14 @@
           break; \
         }
 
-BOX_PRIMITIVE_ARRAY (jboolean, "[Z", Boolean, bool)
-BOX_PRIMITIVE_ARRAY (jchar,    "[C", Char,    char)
-BOX_PRIMITIVE_ARRAY (jbyte,    "[B", Byte,    int8)
-BOX_PRIMITIVE_ARRAY (jshort,   "[S", Short,   int16)
-BOX_PRIMITIVE_ARRAY (jint,     "[I", Int,     int32)
-BOX_PRIMITIVE_ARRAY (jlong,    "[J", Long,    int64)
-BOX_PRIMITIVE_ARRAY (jfloat,   "[F", Float,   Float)
-BOX_PRIMITIVE_ARRAY (jdouble,  "[D", Double,  )
+      BOX_PRIMITIVE_ARRAY (jdouble,  "[D", Double,  )
+      BOX_PRIMITIVE_ARRAY (jboolean, "[Z", Boolean, bool)
+      BOX_PRIMITIVE_ARRAY (jfloat,   "[F", Float,   Float)
+      BOX_PRIMITIVE_ARRAY (jchar,    "[C", Char,    char)
+      BOX_PRIMITIVE_ARRAY (jbyte,    "[B", Byte,    int8)
+      BOX_PRIMITIVE_ARRAY (jshort,   "[S", Short,   int16)
+      BOX_PRIMITIVE_ARRAY (jint,     "[I", Int,     int32)
+      BOX_PRIMITIVE_ARRAY (jlong,    "[J", Long,    int64)
 
 #undef BOX_PRIMITIVE_ARRAY
 
@@ -1097,7 +1096,7 @@
                   NDArray m (dims);
                   mID = jni_env->GetMethodID (cls, "toDouble", "()[D");
                   jdoubleArray_ref dv (jni_env, reinterpret_cast<jdoubleArray> (jni_env->CallObjectMethod (jobj, mID)));
-                  jni_env->GetDoubleArrayRegion (dv, 0, m.length (), m.fortran_vec ());
+                  jni_env->GetDoubleArrayRegion (dv, 0, m.numel (), m.fortran_vec ());
                   retval = m;
                   break;
                 }
@@ -1108,7 +1107,7 @@
                       uint8NDArray m (dims);
                       mID = jni_env->GetMethodID (cls, "toByte", "()[B");
                       jbyteArray_ref dv (jni_env, reinterpret_cast<jbyteArray> (jni_env->CallObjectMethod (jobj, mID)));
-                      jni_env->GetByteArrayRegion (dv, 0, m.length (), reinterpret_cast<jbyte *> (m.fortran_vec ()));
+                      jni_env->GetByteArrayRegion (dv, 0, m.numel (), reinterpret_cast<jbyte *> (m.fortran_vec ()));
                       retval = m;
                       break;
                     }
@@ -1117,7 +1116,7 @@
                       int8NDArray m (dims);
                       mID = jni_env->GetMethodID (cls, "toByte", "()[B");
                       jbyteArray_ref dv (jni_env, reinterpret_cast<jbyteArray> (jni_env->CallObjectMethod (jobj, mID)));
-                      jni_env->GetByteArrayRegion (dv, 0, m.length (), reinterpret_cast<jbyte *> (m.fortran_vec ()));
+                      jni_env->GetByteArrayRegion (dv, 0, m.numel (), reinterpret_cast<jbyte *> (m.fortran_vec ()));
                       retval = m;
                       break;
                     }
@@ -1129,7 +1128,7 @@
                       uint32NDArray m (dims);
                       mID = jni_env->GetMethodID (cls, "toInt", "()[I");
                       jintArray_ref dv (jni_env, reinterpret_cast<jintArray> (jni_env->CallObjectMethod (jobj, mID)));
-                      jni_env->GetIntArrayRegion (dv, 0, m.length (), reinterpret_cast<jint *> (m.fortran_vec ()));
+                      jni_env->GetIntArrayRegion (dv, 0, m.numel (), reinterpret_cast<jint *> (m.fortran_vec ()));
                       retval = m;
                       break;
                     }
@@ -1138,7 +1137,7 @@
                       int32NDArray m (dims);
                       mID = jni_env->GetMethodID (cls, "toInt", "()[I");
                       jintArray_ref dv (jni_env, reinterpret_cast<jintArray> (jni_env->CallObjectMethod (jobj, mID)));
-                      jni_env->GetIntArrayRegion (dv, 0, m.length (), reinterpret_cast<jint *> (m.fortran_vec ()));
+                      jni_env->GetIntArrayRegion (dv, 0, m.numel (), reinterpret_cast<jint *> (m.fortran_vec ()));
                       retval = m;
                       break;
                     }
@@ -1217,7 +1216,7 @@
                       jdoubleArray_ref row (jni_env,
                                             reinterpret_cast<jdoubleArray> (jni_env->GetObjectArrayElement (jarr, r)));
 
-                      if (m.length () == 0)
+                      if (m.numel () == 0)
                         {
                           cols = jni_env->GetArrayLength (row);
                           m.resize (cols, rows);
@@ -1338,8 +1337,8 @@
          }
 
            IF_UNBOX_PRIMITIVE_SCALAR(double, double,   double,        "java/lang/Double",  "(D)V")
+      else IF_UNBOX_PRIMITIVE_SCALAR(bool,   bool,     bool,          "java/lang/Boolean", "(Z)V")
       else IF_UNBOX_PRIMITIVE_SCALAR(float,  float,    float,         "java/lang/Float",   "(F)V")
-      else IF_UNBOX_PRIMITIVE_SCALAR(bool,   bool,     bool,          "java/lang/Boolean", "(Z)V")
       else IF_UNBOX_PRIMITIVE_SCALAR(int8,   int8_t,   int8_scalar,   "java/lang/Byte",    "(B)V")
       else IF_UNBOX_PRIMITIVE_SCALAR(uint8,  uint8_t,  uint8_scalar,  "java/lang/Byte",    "(B)V")
       else IF_UNBOX_PRIMITIVE_SCALAR(int16,  int16_t,  int16_scalar,  "java/lang/Short",   "(S)V")
@@ -1363,8 +1362,8 @@
                || val.is_range ()))
     {
       Matrix m = val.matrix_value ();
-      jdoubleArray dv = jni_env->NewDoubleArray (m.length ());
-      jni_env->SetDoubleArrayRegion (dv, 0, m.length (), m.fortran_vec ());
+      jdoubleArray dv = jni_env->NewDoubleArray (m.numel ());
+      jni_env->SetDoubleArrayRegion (dv, 0, m.numel (), m.fortran_vec ());
       jobj = dv;
       jcls = jni_env->GetObjectClass (jobj);
     }
@@ -1384,8 +1383,8 @@
       if (val.is_double_type ())
         {
           NDArray m = val.array_value ();
-          jdoubleArray_ref dv (jni_env, jni_env->NewDoubleArray (m.length ()));
-          jni_env->SetDoubleArrayRegion (jdoubleArray (dv), 0, m.length (),
+          jdoubleArray_ref dv (jni_env, jni_env->NewDoubleArray (m.numel ()));
+          jni_env->SetDoubleArrayRegion (jdoubleArray (dv), 0, m.numel (),
                                          m.fortran_vec ());
           jmethodID mID = jni_env->GetMethodID (mcls, "<init>", "([D[I)V");
           jobj = jni_env->NewObject (jclass (mcls), mID, jdoubleArray (dv),
@@ -1395,8 +1394,8 @@
       else if (val.is_int8_type ())
         {
           int8NDArray m = val.int8_array_value ();
-          jbyteArray_ref bv (jni_env, jni_env->NewByteArray (m.length ()));
-          jni_env->SetByteArrayRegion (jbyteArray (bv), 0, m.length (),
+          jbyteArray_ref bv (jni_env, jni_env->NewByteArray (m.numel ()));
+          jni_env->SetByteArrayRegion (jbyteArray (bv), 0, m.numel (),
                                        reinterpret_cast <jbyte *> (m.fortran_vec ()));
           jmethodID mID = jni_env->GetMethodID (mcls, "<init>", "([B[I)V");
           jobj = jni_env->NewObject (jclass (mcls), mID, jbyteArray (bv), jintArray (iv));
@@ -1405,8 +1404,8 @@
       else if (val.is_uint8_type ())
         {
           uint8NDArray m = val.uint8_array_value ();
-          jbyteArray_ref bv (jni_env, jni_env->NewByteArray (m.length ()));
-          jni_env->SetByteArrayRegion (jbyteArray (bv), 0, m.length (),
+          jbyteArray_ref bv (jni_env, jni_env->NewByteArray (m.numel ()));
+          jni_env->SetByteArrayRegion (jbyteArray (bv), 0, m.numel (),
                                        reinterpret_cast<jbyte *> (m.fortran_vec ()));
           jmethodID mID = jni_env->GetMethodID (mcls, "<init>", "([B[I)V");
           jobj = jni_env->NewObject (jclass (mcls), mID, jbyteArray (bv), jintArray (iv));
@@ -1415,8 +1414,8 @@
       else if (val.is_int32_type ())
         {
           int32NDArray m = val.int32_array_value ();
-          jintArray_ref v (jni_env, jni_env->NewIntArray (m.length ()));
-          jni_env->SetIntArrayRegion (jintArray (v), 0, m.length (),
+          jintArray_ref v (jni_env, jni_env->NewIntArray (m.numel ()));
+          jni_env->SetIntArrayRegion (jintArray (v), 0, m.numel (),
                                       reinterpret_cast<jint *> (m.fortran_vec ()));
           jmethodID mID = jni_env->GetMethodID (mcls, "<init>", "([I[I)V");
           jobj = jni_env->NewObject (jclass (mcls), mID, jintArray (v), jintArray (iv));
@@ -1552,8 +1551,6 @@
     varargin(i) = box (env, env->GetObjectArrayElement (argin, i), 0);
 
   varargout = feval (fname, varargin, nargout);
-  if (error_state)
-    return false;
 
   jobjectArray_ref out_objs (env, argout), out_clss (env);
   out_objs.detach ();
@@ -1582,38 +1579,31 @@
         {
           jobject_ref jobj (env, env->GetObjectArrayElement (args, i));
           oct_args(i) = box (env, jobj, 0);
-
-          if (error_state)
-            break;
         }
 
-      if (! error_state)
+      BEGIN_INTERRUPT_WITH_EXCEPTIONS;
+
+      if (val.is_function_handle ())
+        {
+          octave_function *fcn = val.function_value ();
+          feval (fcn, oct_args);
+        }
+      else if (val.is_cell () && val.length () > 0
+               && (val.rows () == 1 || val.columns () == 1)
+               && val.cell_value()(0).is_function_handle ())
         {
-          BEGIN_INTERRUPT_WITH_EXCEPTIONS;
-
-          if (val.is_function_handle ())
-            {
-              octave_function *fcn = val.function_value ();
-              feval (fcn, oct_args);
-            }
-          else if (val.is_cell () && val.length () > 0
-                   && (val.rows () == 1 || val.columns () == 1)
-                   && val.cell_value()(0).is_function_handle ())
-            {
-              Cell c = val.cell_value ();
-              octave_function *fcn = c(0).function_value ();
-
-              for (int i=1; i<c.length (); i++)
-                oct_args(len+i-1) = c(i);
-
-              if (! error_state)
-                feval (fcn, oct_args);
-            }
-          else
-            error ("trying to invoke non-invocable object");
-
-          END_INTERRUPT_WITH_EXCEPTIONS;
+          Cell c = val.cell_value ();
+          octave_function *fcn = c(0).function_value ();
+
+          for (int i=1; i<c.numel (); i++)
+            oct_args(len+i-1) = c(i);
+
+          feval (fcn, oct_args);
         }
+      else
+        error ("trying to invoke non-invocable object");
+
+      END_INTERRUPT_WITH_EXCEPTIONS;
     }
 }
 
@@ -1737,11 +1727,9 @@
           ovl(1) = (idx.front ())(0);
           ovl(2) = rhs;
           feval ("__java_set__", ovl, 0);
-          if (! error_state)
-            {
-              count++;
-              retval = octave_value (this);
-            }
+
+          count++;
+          retval = octave_value (this);
         }
       else if (type.length () > 2 && type[1] == '(')
         {
@@ -1750,33 +1738,25 @@
           new_idx.push_back (*it++);
           new_idx.push_back (*it++);
           octave_value_list u = subsref (type.substr (0, 2), new_idx, 1);
-          if (! error_state)
-            {
-              std::list<octave_value_list> next_idx (idx);
-              next_idx.erase (next_idx.begin ());
-              next_idx.erase (next_idx.begin ());
-              u(0).subsasgn (type.substr (2), next_idx, rhs);
-              if (! error_state)
-                {
-                  count++;
-                  retval = octave_value (this);
-                }
-            }
+
+          std::list<octave_value_list> next_idx (idx);
+          next_idx.erase (next_idx.begin ());
+          next_idx.erase (next_idx.begin ());
+          u(0).subsasgn (type.substr (2), next_idx, rhs);
+
+          count++;
+          retval = octave_value (this);
         }
       else if (type[1] == '.')
         {
           octave_value_list u = subsref (type.substr (0, 1), idx, 1);
-          if (! error_state)
-            {
-              std::list<octave_value_list> next_idx (idx);
-              next_idx.erase (next_idx.begin ());
-              u(0).subsasgn (type.substr (1), next_idx, rhs);
-              if (! error_state)
-                {
-                  count++;
-                  retval = octave_value (this);
-                }
-            }
+
+          std::list<octave_value_list> next_idx (idx);
+          next_idx.erase (next_idx.begin ());
+          u(0).subsasgn (type.substr (1), next_idx, rhs);
+
+          count++;
+          retval = octave_value (this);
         }
       else
         error ("invalid indexing/assignment on Java object");
@@ -1786,11 +1766,9 @@
       if (current_env)
         {
           set_array_elements (current_env, to_java (), idx.front (), rhs);
-          if (! error_state)
-            {
-              count++;
-              retval = octave_value (this);
-            }
+
+          count++;
+          retval = octave_value (this);
         }
       break;
 
@@ -1837,6 +1815,56 @@
   os << "<Java object: " << java_classname << ">";
 }
 
+// FIXME: Need routines to actually save/load java objects through Serialize.
+//        See bug #42112.
+
+bool
+octave_java::save_ascii (std::ostream& /* os */)
+{
+  warning ("save: unable to save java objects, skipping");
+
+  return true;
+}
+
+bool
+octave_java::load_ascii (std::istream& /* is */)
+{
+  // Silently skip over java object that was not saved
+  return true;
+}
+
+bool
+octave_java::save_binary (std::ostream& /* os */, bool& /* save_as_floats */)
+{
+  warning ("save: unable to save java objects, skipping");
+
+  return true;
+}
+
+bool
+octave_java::load_binary (std::istream& /* is */, bool /* swap*/,
+                          oct_mach_info::float_format /* fmt */)
+{
+  // Silently skip over java object that was not saved
+  return true;
+}
+
+bool
+octave_java::save_hdf5 (octave_hdf5_id /* loc_id */, const char * /* name */,
+                        bool /* save_as_floats */)
+{
+  warning ("save: unable to save java objects, skipping");
+
+  return true;
+}
+
+bool
+octave_java::load_hdf5 (octave_hdf5_id /* loc_id */, const char * /* name */)
+{
+  // Silently skip object that was not saved
+  return true;
+}
+
 octave_value
 octave_java::do_javaMethod (JNIEnv* jni_env, const std::string& name,
                             const octave_value_list& args)
@@ -2056,8 +2084,7 @@
 
   initialize_java ();
 
-  if (! error_state)
-    retval = 1;
+  retval = 1;
 
   return retval;
 #else
@@ -2104,38 +2131,36 @@
 @seealso{javaMethod, javaArray}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
 #ifdef HAVE_JAVA
-  octave_value retval;
 
   initialize_java ();
 
-  if (! error_state)
+  JNIEnv *current_env = octave_java::thread_jni_env ();
+
+  if (args.length () == 0)
+    print_usage ();
+
+  if (args(0).is_string ())
     {
-      JNIEnv *current_env = octave_java::thread_jni_env ();
-
-      if (args.length () > 0)
-        {
-          if (args(0).is_string ())
-            {
-              std::string classname = args(0).string_value ();
-
-              octave_value_list tmp;
-              for (int i=1; i<args.length (); i++)
-                tmp(i-1) = args(i);
-              retval = octave_java::do_javaObject (current_env, classname, tmp);
-            }
-          else
-            error ("javaObject: CLASSNAME must be a string");
-        }
-      else
-        print_usage ();
+      std::string classname = args(0).string_value ();
+
+      octave_value_list tmp;
+      for (int i=1; i<args.length (); i++)
+        tmp(i-1) = args(i);
+      retval = octave_java::do_javaObject (current_env, classname, tmp);
     }
+  else
+    error ("javaObject: CLASSNAME must be a string");
+
+#else
+
+  error ("javaObject: Octave was not compiled with Java interface");
+
+#endif
 
   return retval;
-#else
-  error ("javaObject: Octave was not compiled with Java interface");
-  return octave_value ();
-#endif
 }
 
 /*
@@ -2172,50 +2197,48 @@
 @seealso{methods, javaObject}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
 #ifdef HAVE_JAVA
-  octave_value retval;
 
   initialize_java ();
 
-  if (! error_state)
+  JNIEnv *current_env = octave_java::thread_jni_env ();
+
+  if (args.length () < 2)
+    print_usage ();
+
+  if (args(0).is_string ())
     {
-      JNIEnv *current_env = octave_java::thread_jni_env ();
-
-      if (args.length () > 1)
+      std::string methodname = args(0).string_value ();
+
+      octave_value_list tmp;
+      for (int i=2; i<args.length (); i++)
+        tmp(i-2) = args(i);
+
+      if (args(1).is_java ())
         {
-          if (args(0).is_string ())
-            {
-              std::string methodname = args(0).string_value ();
-
-              octave_value_list tmp;
-              for (int i=2; i<args.length (); i++)
-                tmp(i-2) = args(i);
-
-              if (args(1).is_java ())
-                {
-                  octave_java *jobj = TO_JAVA (args(1));
-                  retval = jobj->do_javaMethod (current_env, methodname, tmp);
-                }
-              else if (args(1).is_string ())
-                {
-                  std::string cls = args(1).string_value ();
-                  retval = octave_java::do_javaMethod (current_env, cls, methodname, tmp);
-                }
-              else
-                error ("javaMethod: OBJ must be a Java object or a string");
-            }
-          else
-            error ("javaMethod: METHODNAME must be a string");
+          octave_java *jobj = TO_JAVA (args(1));
+          retval = jobj->do_javaMethod (current_env, methodname, tmp);
+        }
+      else if (args(1).is_string ())
+        {
+          std::string cls = args(1).string_value ();
+          retval = octave_java::do_javaMethod (current_env, cls, methodname, tmp);
         }
       else
-        print_usage ();
+        error ("javaMethod: OBJ must be a Java object or a string");
     }
+  else
+    error ("javaMethod: METHODNAME must be a string");
+
+#else
+
+  error ("javaMethod: Octave was not compiled with Java interface");
+
+#endif
 
   return retval;
-#else
-  error ("javaMethod: Octave was not compiled with Java interface");
-  return octave_value ();
-#endif
 }
 
 /*
@@ -2247,46 +2270,44 @@
 @seealso{__java_set__, javaMethod, javaObject}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
 #ifdef HAVE_JAVA
-  octave_value retval;
 
   initialize_java ();
 
-  if (! error_state)
+  JNIEnv *current_env = octave_java::thread_jni_env ();
+
+  if (args.length () != 2)
+    print_usage ();
+
+  if (args(1).is_string ())
     {
-      JNIEnv *current_env = octave_java::thread_jni_env ();
-
-      if (args.length () == 2)
+      std::string name = args(1).string_value ();
+
+      if (args(0).is_java ())
         {
-          if (args(1).is_string ())
-            {
-              std::string name = args(1).string_value ();
-
-              if (args(0).is_java ())
-                {
-                  octave_java *jobj = TO_JAVA (args(0));
-                  retval = jobj->do_java_get (current_env, name);
-                }
-              else if (args(0).is_string ())
-                {
-                  std::string cls = args(0).string_value ();
-                  retval = octave_java::do_java_get (current_env, cls, name);
-                }
-              else
-                error ("__java_get__: OBJ must be a Java object or a string");
-            }
-          else
-            error ("__java_get__: NAME must be a string");
+          octave_java *jobj = TO_JAVA (args(0));
+          retval = jobj->do_java_get (current_env, name);
+        }
+      else if (args(0).is_string ())
+        {
+          std::string cls = args(0).string_value ();
+          retval = octave_java::do_java_get (current_env, cls, name);
         }
       else
-        print_usage ();
+        error ("__java_get__: OBJ must be a Java object or a string");
     }
+  else
+    error ("__java_get__: NAME must be a string");
+
+#else
+
+  error ("__java_get__: Octave was not compiled with Java interface");
+
+#endif
 
   return retval;
-#else
-  error ("__java_get__: Octave was not compiled with Java interface");
-  return octave_value ();
-#endif
 }
 
 DEFUN (__java_set__, args, ,
@@ -2312,46 +2333,44 @@
 @seealso{__java_get__, javaMethod, javaObject}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
 #ifdef HAVE_JAVA
-  octave_value retval;
 
   initialize_java ();
 
-  if (! error_state)
+  JNIEnv *current_env = octave_java::thread_jni_env ();
+
+  if (args.length () != 3)
+    print_usage ();
+
+  if (args(1).is_string ())
     {
-      JNIEnv *current_env = octave_java::thread_jni_env ();
-
-      if (args.length () == 3)
+      std::string name = args(1).string_value ();
+
+      if (args(0).is_java ())
         {
-          if (args(1).is_string ())
-            {
-              std::string name = args(1).string_value ();
-
-              if (args(0).is_java ())
-                {
-                  octave_java *jobj = TO_JAVA (args(0));
-                  retval = jobj->do_java_set (current_env, name, args(2));
-                }
-              else if (args(0).is_string ())
-                {
-                  std::string cls = args(0).string_value ();
-                  retval = octave_java::do_java_set (current_env, cls, name, args(2));
-                }
-              else
-                error ("__java_set__: OBJ must be a Java object or a string");
-            }
-          else
-            error ("__java_set__: NAME must be a string");
+          octave_java *jobj = TO_JAVA (args(0));
+          retval = jobj->do_java_set (current_env, name, args(2));
+        }
+      else if (args(0).is_string ())
+        {
+          std::string cls = args(0).string_value ();
+          retval = octave_java::do_java_set (current_env, cls, name, args(2));
         }
       else
-        print_usage ();
+        error ("__java_set__: OBJ must be a Java object or a string");
     }
+  else
+    error ("__java_set__: NAME must be a string");
+
+#else
+
+  error ("__java_set__: Octave was not compiled with Java interface");
+
+#endif
 
   return retval;
-#else
-  error ("__java_set__: Octave was not compiled with Java interface");
-  return octave_value ();
-#endif
 }
 
 DEFUN (java2mat, args, ,
@@ -2360,34 +2379,32 @@
 Undocumented internal function.\n\
 @end deftypefn")
 {
+  octave_value_list retval;
+
 #ifdef HAVE_JAVA
-  octave_value_list retval;
 
   initialize_java ();
 
-  if (! error_state)
+  JNIEnv *current_env = octave_java::thread_jni_env ();
+
+  if (args.length () != 1)
+    print_usage ();
+
+  if (args(0).is_java ())
     {
-      JNIEnv *current_env = octave_java::thread_jni_env ();
-
-      if (args.length () == 1)
-        {
-          if (args(0).is_java ())
-            {
-              octave_java *jobj = TO_JAVA (args(0));
-              retval(0) = box_more (current_env, jobj->to_java (), 0);
-            }
-          else
-            retval(0) = args(0);
-        }
-      else
-        print_usage ();
+      octave_java *jobj = TO_JAVA (args(0));
+      retval(0) = box_more (current_env, jobj->to_java (), 0);
     }
+  else
+    retval(0) = args(0);
+
+#else
+
+  error ("java2mat: Octave was not compiled with Java interface");
+
+#endif
 
   return retval;
-#else
-  error ("java2mat: Octave was not compiled with Java interface");
-  return octave_value ();
-#endif
 }
 
 DEFUN (java_matrix_autoconversion, args, nargout,
@@ -2406,12 +2423,18 @@
 @seealso{java_unsigned_autoconversion, debug_java}\n\
 @end deftypefn")
 {
+  octave_value retval;
+
 #ifdef HAVE_JAVA
-  return SET_INTERNAL_VARIABLE (java_matrix_autoconversion);
+
+  retval = SET_INTERNAL_VARIABLE (java_matrix_autoconversion);
 #else
+
   error ("java_matrix_autoconversion: Octave was not compiled with Java interface");
-  return octave_value ();
+
 #endif
+
+  return retval;
 }
 
 DEFUN (java_unsigned_autoconversion, args, nargout,
@@ -2471,14 +2494,10 @@
 @seealso{class, typeinfo, isa, javaObject}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
   if (args.length () != 1)
     print_usage ();
-  else
-    retval = args(0).is_java ();
-
-  return retval;
+
+  return octave_value (args(0).is_java ());
 }
 
 /*
--- a/libinterp/octave-value/ov-java.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-java.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_java_h)
+#if ! defined (octave_ov_java_h)
 #define octave_ov_java_h 1
 
 #include <jni.h>
@@ -157,6 +157,20 @@
 
   void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
 
+  bool save_ascii (std::ostream& os);
+
+  bool load_ascii (std::istream& is);
+
+  bool save_binary (std::ostream& os, bool& save_as_floats);
+
+  bool load_binary (std::istream& is, bool swap,
+                    oct_mach_info::float_format fmt);
+
+  bool save_hdf5 (octave_hdf5_id loc_id, const char *name,
+                  bool save_as_floats);
+
+  bool load_hdf5 (octave_hdf5_id loc_id, const char *name);
+
   octave_value_list
   subsref (const std::string& type,
            const std::list<octave_value_list>& idx, int nargout);
--- a/libinterp/octave-value/ov-lazy-idx.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-lazy-idx.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -27,7 +27,7 @@
 #include "ov-lazy-idx.h"
 #include "ops.h"
 #include "ov-scalar.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-oct-binary.h"
 
 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_lazy_index, "lazy_index", "double");
@@ -106,7 +106,7 @@
   const dim_vector odims = index.orig_dimensions ();
   // index_vector can employ a more efficient sorting algorithm.
   if (mode == ASCENDING && odims.length () == 2
-      && (dim >= 0 && dim <= 1) && odims (1-dim) == 1)
+      && (dim >= 0 && dim <= 1) && odims(1-dim) == 1)
     return index_vector ().sorted ();
   else
     return idx_vector (index.as_array ().sort (dim, mode),
@@ -120,7 +120,7 @@
   const dim_vector odims = index.orig_dimensions ();
   // index_vector can employ a more efficient sorting algorithm.
   if (mode == ASCENDING && odims.length () == 2
-      && (dim >= 0 && dim <= 1) && odims (1-dim) == 1)
+      && (dim >= 0 && dim <= 1) && odims(1-dim) == 1)
     return index_vector ().sorted (sidx);
   else
     return idx_vector (index.as_array ().sort (sidx, dim, mode),
@@ -161,21 +161,21 @@
 
 bool octave_lazy_index::save_ascii (std::ostream& os)
 {
-  return save_ascii_data (os, make_value (), value_save_tag, false, 0);
+  return save_text_data (os, make_value (), value_save_tag, false, 0);
 }
 
 bool octave_lazy_index::load_ascii (std::istream& is)
 {
   bool dummy;
 
-  std::string nm = read_ascii_data (is, std::string (), dummy, value, 0);
+  std::string nm = read_text_data (is, std::string (), dummy, value, 0);
 
   if (nm != value_save_tag)
     error ("lazy_index: corrupted data on load");
   else
     index = value.index_vector ();
 
-  return ! error_state;
+  return true;
 }
 
 
@@ -199,5 +199,5 @@
   else
     index = value.index_vector ();
 
-  return ! error_state;
+  return true;
 }
--- a/libinterp/octave-value/ov-lazy-idx.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-lazy-idx.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_lazy_idx_h)
+#if ! defined (octave_ov_lazy_idx_h)
 #define octave_ov_lazy_idx_h 1
 
 #include "ov-re-mat.h"
--- a/libinterp/octave-value/ov-mex-fcn.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-mex-fcn.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -132,11 +132,8 @@
 {
   octave_value_list retval;
 
-  if (error_state)
-    return retval;
-
   if (args.has_magic_colon ())
-    ::error ("invalid use of colon in function argument list");
+    error ("invalid use of colon in function argument list");
   else
     {
       unwind_protect frame;
@@ -145,18 +142,11 @@
 
       frame.add_fcn (octave_call_stack::pop);
 
-      try
-        {
-          BEGIN_PROFILER_BLOCK (octave_mex_function)
-
-          retval = call_mex (have_fmex, mex_fcn_ptr, args, nargout, this);
+      BEGIN_PROFILER_BLOCK (octave_mex_function)
 
-          END_PROFILER_BLOCK
-        }
-      catch (octave_execution_exception)
-        {
-          gripe_library_execution_error ();
-        }
+        retval = call_mex (have_fmex, mex_fcn_ptr, args, nargout, this);
+
+      END_PROFILER_BLOCK
     }
 
   return retval;
--- a/libinterp/octave-value/ov-mex-fcn.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-mex-fcn.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_mex_fcn_h)
+#if ! defined (octave_ov_mex_fcn_h)
 #define octave_ov_mex_fcn_h 1
 
 #include <string>
--- a/libinterp/octave-value/ov-null-mat.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-null-mat.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -114,16 +114,10 @@
 @seealso{isempty, isindex}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  int nargin = args.length ();
-
-  if (nargin == 1 && args(0).is_defined ())
-    retval = args(0).is_null_value ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_null_value ());
 }
 
 /*
--- a/libinterp/octave-value/ov-null-mat.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-null-mat.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_null_mat_h)
+#if ! defined (octave_ov_null_mat_h)
 #define octave_ov_null_mat_h 1
 
 #include "ov.h"
--- a/libinterp/octave-value/ov-oncleanup.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-oncleanup.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -78,29 +78,26 @@
   frame.protect_var (quit_allowed);
   quit_allowed = false;
 
-  // Clear errors.
-  frame.protect_var (error_state);
-  error_state = 0;
-
   try
     {
       // Run the actual code.
       fcn.do_multi_index_op (0, octave_value_list ());
     }
-  catch (octave_interrupt_exception)
+  catch (const octave_interrupt_exception&)
     {
-      // Swallow the interrupt.
+      recover_from_exception ();
+
       warning ("onCleanup: interrupt occured in cleanup action");
     }
+  catch (const octave_execution_exception&)
+    {
+      throw;
+    }
   catch (...) // Yes, the black hole. We're in a d-tor.
     {
       // This shouldn't happen, in theory.
       error ("onCleanup: internal error: unhandled exception in cleanup action");
     }
-
-  // FIXME: can this happen now?
-  if (error_state)
-    frame.discard_first ();
 }
 
 octave_scalar_map
@@ -111,23 +108,18 @@
   return retval;
 }
 
-static void
-warn_save_load (void)
-{
-  warning ("onCleanup: load and save not supported");
-}
-
 bool
 octave_oncleanup::save_ascii (std::ostream& /* os */)
 {
-  warn_save_load ();
+  warning ("save: unable to save onCleanup variables, skipping");
+
   return true;
 }
 
 bool
 octave_oncleanup::load_ascii (std::istream& /* is */)
 {
-  warn_save_load ();
+  // Silently skip object that was not saved
   return true;
 }
 
@@ -135,7 +127,8 @@
 octave_oncleanup::save_binary (std::ostream& /* os */,
                                bool& /* save_as_floats */)
 {
-  warn_save_load ();
+  warning ("save: unable to save onCleanup variables, skipping");
+
   return true;
 }
 
@@ -143,7 +136,7 @@
 octave_oncleanup::load_binary (std::istream& /* is */, bool /* swap */,
                                oct_mach_info::float_format /* fmt */)
 {
-  warn_save_load ();
+  // Silently skip object that was not saved
   return true;
 }
 
@@ -152,7 +145,8 @@
                              const char * /* name */,
                              bool /* save_as_floats */)
 {
-  warn_save_load ();
+  warning ("save: unable to save onCleanup variables, skipping");
+
   return true;
 }
 
@@ -160,7 +154,7 @@
 octave_oncleanup::load_hdf5 (octave_hdf5_id /* loc_id */,
                              const char * /* name */)
 {
-  warn_save_load ();
+  // Silently skip object that was not saved
   return true;
 }
 
@@ -192,14 +186,10 @@
 For similar functionality @xref{The unwind_protect Statement}.\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = octave_value (new octave_oncleanup (args(0)));
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (new octave_oncleanup (args(0)));
 }
 
 /*
--- a/libinterp/octave-value/ov-oncleanup.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-oncleanup.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,10 +20,6 @@
 
 */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #include <iosfwd>
 
 #include "ov-base.h"
--- a/libinterp/octave-value/ov-perm.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-perm.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -36,7 +36,7 @@
 #include "ops.h"
 #include "pr-output.h"
 
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 
 octave_value
 octave_perm_matrix::subsref (const std::string& type,
@@ -74,8 +74,19 @@
   idx_vector idx0, idx1;
   if (nidx == 2)
     {
-      idx0 = idx(0).index_vector ();
-      idx1 = idx(1).index_vector ();
+      int k = 0;    // index we're processing when index_vector throws
+      try
+        {
+          idx0 = idx(0).index_vector ();
+          k = 1;
+          idx1 = idx(1).index_vector ();
+        }
+      catch (index_exception& e)
+        {
+          // Rethrow to allow more info to be reported later.
+          e.set_pos_if_unset (2, k+1);
+          throw;
+        }
     }
 
   // This hack is to allow constructing permutation matrices using
@@ -83,7 +94,7 @@
   // vectors.
   // Note that, for better consistency, eye(n)(:,:) still converts to a full
   // matrix.
-  if (! error_state && nidx == 2)
+  if (nidx == 2)
     {
       bool left = idx0.is_permutation (matrix.rows ());
       bool right = idx1.is_permutation (matrix.cols ());
@@ -109,8 +120,7 @@
         }
     }
 
-  // if error_state is set, we've already griped.
-  if (! error_state && ! retval.is_defined ())
+  if (! retval.is_defined ())
     {
       if (nidx == 2 && ! resize_ok && idx0.is_scalar () && idx1.is_scalar ())
         retval = matrix.checkelem (idx0(0), idx1(0));
@@ -261,7 +271,7 @@
   os << "# orient: c\n";
 
   Array<octave_idx_type> pvec = matrix.col_perm_vec ();
-  octave_idx_type n = pvec.length ();
+  octave_idx_type n = pvec.numel ();
   ColumnVector tmp (n);
   for (octave_idx_type i = 0; i < n; i++) tmp(i) = pvec(i) + 1;
   os << tmp;
@@ -439,7 +449,7 @@
 {
   octave_base_value *retval = 0;
 
-  if (matrix.nelem () == 1)
+  if (matrix.numel () == 1)
     retval = new octave_scalar (matrix (0, 0));
 
   return retval;
--- a/libinterp/octave-value/ov-perm.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-perm.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_perm_h)
+#if ! defined (octave_ov_perm_h)
 #define octave_ov_perm_h 1
 
 #include "mx-base.h"
--- a/libinterp/octave-value/ov-range.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-range.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -72,7 +72,7 @@
 {
   octave_base_value *retval = 0;
 
-  switch (range.nelem ())
+  switch (range.numel ())
     {
     case 1:
       retval = new octave_scalar (range.base ());
@@ -128,14 +128,23 @@
       octave_value retval;
 
       // The range can handle a single subscript.
-      idx_vector i = idx(0).index_vector ();
-      if (! error_state)
+
+      try
         {
-          if (i.is_scalar () && i(0) < range.nelem ())
+          idx_vector i = idx(0).index_vector ();
+
+          if (i.is_scalar () && i(0) < range.numel ())
             retval = range.elem (i(0));
           else
             retval = range.index (i);
         }
+      catch (index_exception& e)
+        {
+          // More info may be added later before displaying error.
+
+          e.set_pos_if_unset (1, 1);
+          throw;
+        }
 
       return retval;
     }
@@ -173,7 +182,7 @@
 {
   double retval = lo_ieee_nan_value ();
 
-  octave_idx_type nel = range.nelem ();
+  octave_idx_type nel = range.numel ();
 
   if (nel > 0)
     {
@@ -193,7 +202,7 @@
 {
   float retval = lo_ieee_float_nan_value ();
 
-  octave_idx_type nel = range.nelem ();
+  octave_idx_type nel = range.numel ();
 
   if (nel > 0)
     {
@@ -264,7 +273,7 @@
 {
   bool retval = false;
 
-  if (range.nelem () != 0)
+  if (range.numel () != 0)
     {
       // FIXME: this is a potential waste of memory.
 
@@ -283,7 +292,7 @@
 
   Complex retval (tmp, tmp);
 
-  octave_idx_type nel = range.nelem ();
+  octave_idx_type nel = range.numel ();
 
   if (nel > 0)
     {
@@ -305,7 +314,7 @@
 
   FloatComplex retval (tmp, tmp);
 
-  octave_idx_type nel = range.nelem ();
+  octave_idx_type nel = range.numel ();
 
   if (nel > 0)
     {
@@ -370,7 +379,7 @@
 {
   bool retval = false;
 
-  octave_idx_type n = range.nelem ();
+  octave_idx_type n = range.numel ();
 
   indent (os);
 
@@ -392,7 +401,7 @@
 void
 octave_range::short_disp (std::ostream& os) const
 {
-  octave_idx_type len = range.nelem ();
+  octave_idx_type len = range.numel ();
 
   if (len == 0)
     os << "[]";
@@ -434,7 +443,7 @@
   double base = r.base ();
   double limit = r.limit ();
   double inc = r.inc ();
-  octave_idx_type len = r.nelem ();
+  octave_idx_type len = r.numel ();
 
   if (inc != 0)
     os << "# base, limit, increment\n";
@@ -487,7 +496,7 @@
   double lim = r.limit ();
   double inc = r.inc ();
   if (inc == 0)
-    lim = r.nelem ();
+    lim = r.numel ();
 
   os.write (reinterpret_cast<char *> (&bas), 8);
   os.write (reinterpret_cast<char *> (&lim), 8);
@@ -583,13 +592,13 @@
   Range r = range_value ();
   double range_vals[3];
   range_vals[0] = r.base ();
-  range_vals[1] = r.inc () != 0 ? r.limit () : r.nelem ();
+  range_vals[1] = r.inc () != 0 ? r.limit () : r.numel ();
   range_vals[2] = r.inc ();
 
   if (H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, H5P_DEFAULT,
                 range_vals) >= 0)
     {
-      octave_idx_type nel = r.nelem ();
+      octave_idx_type nel = r.numel ();
       retval = hdf5_add_scalar_attr (data_hid, H5T_NATIVE_IDX,
                                      "OCTAVE_RANGE_NELEM", &nel) >= 0;
     }
@@ -693,7 +702,7 @@
 octave_value
 octave_range::fast_elem_extract (octave_idx_type n) const
 {
-  return (n < range.nelem ()) ? octave_value (range.elem (n))
+  return (n < range.numel ()) ? octave_value (range.elem (n))
                               : octave_value ();
 }
 
--- a/libinterp/octave-value/ov-range.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-range.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_range_h)
+#if ! defined (octave_ov_range_h)
 #define octave_ov_range_h 1
 
 #include <cstdlib>
@@ -58,15 +58,15 @@
   octave_range (double base, double limit, double inc)
     : octave_base_value (), range (base, limit, inc), idx_cache ()
   {
-    if (range.nelem () < 0)
-      ::error ("invalid range");
+    if (range.numel () < 0)
+      error ("invalid range");
   }
 
   octave_range (const Range& r)
     : octave_base_value (), range (r), idx_cache ()
   {
-    if (range.nelem () < 0 && range.nelem () != -2)
-      ::error ("invalid range");
+    if (range.numel () < 0 && range.numel () != -2)
+      error ("invalid range");
   }
 
   octave_range (const octave_range& r)
@@ -107,7 +107,7 @@
 
   dim_vector dims (void) const
   {
-    octave_idx_type n = range.nelem ();
+    octave_idx_type n = range.numel ();
     return dim_vector (n > 0, n);
   }
 
--- a/libinterp/octave-value/ov-re-diag.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-re-diag.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -92,11 +92,13 @@
   // vectors.
   if (! resize_ok && idx.length () == 2 && matrix.is_multiple_of_identity (1))
     {
-      idx_vector idx0 = idx(0).index_vector ();
-      idx_vector idx1 = idx(1).index_vector ();
+      int k = 0;        // index we're accesing when index_vector throws
+      try
+        {
+          idx_vector idx0 = idx(0).index_vector ();
+          k = 1;
+          idx_vector idx1 = idx(1).index_vector ();
 
-      if (! error_state)
-        {
           bool left = idx0.is_permutation (matrix.rows ());
           bool right = idx1.is_permutation (matrix.cols ());
 
@@ -117,10 +119,15 @@
                 }
             }
         }
+      catch (index_exception& e)
+        {
+          // Rethrow to allow more info to be reported later.
+          e.set_pos_if_unset (2, k+1);
+          throw;
+        }
     }
 
-  // if error_state is set, we've already griped.
-  if (! error_state && retval.is_undefined ())
+  if (retval.is_undefined ())
     retval = octave_base_diag<DiagMatrix, Matrix>::do_index_op (idx, resize_ok);
 
   return retval;
@@ -228,8 +235,10 @@
   double *re = m.fortran_vec ();
   octave_idx_type len = m.length ();
   read_doubles (is, re, static_cast<save_type> (tmp), len, swap, fmt);
-  if (error_state || ! is)
+
+  if (! is)
     return false;
+
   matrix = m;
 
   return true;
--- a/libinterp/octave-value/ov-re-diag.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-re-diag.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_re_diag_h)
+#if ! defined (octave_ov_re_diag_h)
 #define octave_ov_re_diag_h 1
 
 #include "ov-base.h"
--- a/libinterp/octave-value/ov-re-mat.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-re-mat.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -65,7 +65,7 @@
 #include "variables.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
@@ -95,7 +95,7 @@
 {
   octave_base_value *retval = 0;
 
-  if (matrix.nelem () == 1)
+  if (matrix.numel () == 1)
     retval = new octave_scalar (matrix (0));
 
   return retval;
@@ -440,14 +440,14 @@
       os << "# ndims: " << d.length () << "\n";
 
       for (int i=0; i < d.length (); i++)
-        os << " " << d (i);
+        os << " " << d(i);
 
       os << "\n" << tmp;
     }
   else
     {
       // Keep this case, rather than use generic code above for backward
-      // compatiability. Makes load_ascii much more complex!!
+      // compatibility.  Makes load_ascii much more complex!!
       os << "# rows: " << rows () << "\n"
          << "# columns: " << columns () << "\n";
 
@@ -639,8 +639,10 @@
       double *re = m.fortran_vec ();
       read_doubles (is, re, static_cast<save_type> (tmp), dv.numel (),
                     swap, fmt);
-      if (error_state || ! is)
+
+      if (! is)
         return false;
+
       matrix = m;
     }
   else
@@ -657,8 +659,10 @@
       double *re = m.fortran_vec ();
       octave_idx_type len = nr * nc;
       read_doubles (is, re, static_cast<save_type> (tmp), len, swap, fmt);
-      if (error_state || ! is)
+
+      if (! is)
         return false;
+
       matrix = m;
     }
   return true;
@@ -685,7 +689,7 @@
 
   // Octave uses column-major, while HDF5 uses row-major ordering
   for (int i = 0; i < rank; i++)
-    hdims[i] = dv (rank-i-1);
+    hdims[i] = dv(rank-i-1);
 
   space_hid = H5Screate_simple (rank, hdims, 0);
 
@@ -964,7 +968,7 @@
     case umap_xtoascii:
       {
         octave_value str_conv = convert_to_str (true, true);
-        return error_state ? octave_value () : str_conv.map (umap);
+        return str_conv.map (umap);
       }
 
     default:
@@ -983,50 +987,48 @@
   // inside their own scopes, and we don't declare retval here to
   // avoid a shadowed declaration warning.
 
-  if (args.length () == 1)
+  if (args.length () != 1)
+    print_usage ();
+
+  if (args(0).is_perm_matrix ())
     {
-      if (args(0).is_perm_matrix ())
-        {
-          OCTAVE_TYPE_CONV_BODY3 (double, octave_perm_matrix, octave_scalar);
-        }
-      else if (args(0).is_diag_matrix ())
+      OCTAVE_TYPE_CONV_BODY3 (double, octave_perm_matrix, octave_scalar);
+    }
+  else if (args(0).is_diag_matrix ())
+    {
+      if (args(0).is_complex_type ())
         {
-          if (args(0).is_complex_type ())
-            {
-              OCTAVE_TYPE_CONV_BODY3 (double, octave_complex_diag_matrix,
-                                      octave_complex);
-            }
-          else
-            {
-              OCTAVE_TYPE_CONV_BODY3 (double, octave_diag_matrix,
-                                      octave_scalar);
-            }
-        }
-      else if (args(0).is_sparse_type ())
-        {
-          if (args(0).is_complex_type ())
-            {
-              OCTAVE_TYPE_CONV_BODY3 (double, octave_sparse_complex_matrix,
-                                      octave_complex);
-            }
-          else
-            {
-              OCTAVE_TYPE_CONV_BODY3 (double, octave_sparse_matrix,
-                                      octave_scalar);
-            }
-        }
-      else if (args(0).is_complex_type ())
-        {
-          OCTAVE_TYPE_CONV_BODY3 (double, octave_complex_matrix,
+          OCTAVE_TYPE_CONV_BODY3 (double, octave_complex_diag_matrix,
                                   octave_complex);
         }
       else
         {
-          OCTAVE_TYPE_CONV_BODY3 (double, octave_matrix, octave_scalar);
+          OCTAVE_TYPE_CONV_BODY3 (double, octave_diag_matrix,
+                                  octave_scalar);
         }
     }
+  else if (args(0).is_sparse_type ())
+    {
+      if (args(0).is_complex_type ())
+        {
+          OCTAVE_TYPE_CONV_BODY3 (double, octave_sparse_complex_matrix,
+                                  octave_complex);
+        }
+      else
+        {
+          OCTAVE_TYPE_CONV_BODY3 (double, octave_sparse_matrix,
+                                  octave_scalar);
+        }
+    }
+  else if (args(0).is_complex_type ())
+    {
+      OCTAVE_TYPE_CONV_BODY3 (double, octave_complex_matrix,
+                              octave_complex);
+    }
   else
-    print_usage ();
+    {
+      OCTAVE_TYPE_CONV_BODY3 (double, octave_matrix, octave_scalar);
+    }
 
   return octave_value ();
 }
--- a/libinterp/octave-value/ov-re-mat.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-re-mat.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_re_mat_h)
+#if ! defined (octave_ov_re_mat_h)
 #define octave_ov_re_mat_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-re-sparse.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-re-sparse.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -61,8 +61,8 @@
     return idx_vector (array_value ());
   else
     {
-      std::string nm = type_name ();
-      error ("%s type invalid as index value", nm.c_str ());
+      std::string nm = "<" + type_name () + ">";
+      gripe_invalid_index (nm.c_str ());
       return idx_vector ();
     }
 }
@@ -387,7 +387,7 @@
 
   read_doubles (is, m.xdata (), static_cast<save_type> (ctmp), nz, swap, fmt);
 
-  if (error_state || ! is)
+  if (! is)
     return false;
 
   if (! m.indices_ok ())
--- a/libinterp/octave-value/ov-re-sparse.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-re-sparse.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_re_sparse_h)
+#if ! defined (octave_ov_re_sparse_h)
 #define octave_ov_re_sparse_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-scalar.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-scalar.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -49,7 +49,7 @@
 #include "xpow.h"
 #include "ops.h"
 
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-hdf5.h"
 
 template class octave_base_scalar<double>;
@@ -192,7 +192,8 @@
 
   double dtmp;
   read_doubles (is, &dtmp, static_cast<save_type> (tmp), 1, swap, fmt);
-  if (error_state || ! is)
+
+  if (! is)
     return false;
 
   scalar = dtmp;
@@ -373,7 +374,7 @@
     case umap_xtoascii:
       {
         octave_value str_conv = convert_to_str (true, true);
-        return error_state ? octave_value () : str_conv.map (umap);
+        return str_conv.map (umap);
       }
 
     default:
--- a/libinterp/octave-value/ov-scalar.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-scalar.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_scalar_h)
+#if ! defined (octave_ov_scalar_h)
 #define octave_ov_scalar_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-str-mat.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-str-mat.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -41,7 +41,7 @@
 #include "gripes.h"
 #include "ls-ascii-helper.h"
 #include "ls-hdf5.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-utils.h"
 #include "oct-obj.h"
 #include "oct-hdf5.h"
@@ -68,13 +68,10 @@
 
   NDArray nda = v.array_value (true);
 
-  if (! error_state)
-    {
-      if (nda.numel () == 1)
-        retval = new octave_scalar (nda(0));
-      else
-        retval = new octave_matrix (nda);
-    }
+  if (nda.numel () == 1)
+    retval = new octave_scalar (nda(0));
+  else
+    retval = new octave_matrix (nda);
 
   return retval;
 }
@@ -94,46 +91,59 @@
 
   octave_idx_type len = idx.length ();
 
-  switch (len)
-    {
-    case 0:
-      retval = octave_value (matrix, type);
-      break;
+  // If we catch an indexing error in index_vector, we flag an error in
+  // index k.  Ensure it is the right value befor each idx_vector call.
+  // Same variable as used in the for loop in the default case.
+
+  octave_idx_type k = 0;
 
-    case 1:
-      {
-        idx_vector i = idx (0).index_vector ();
+  try
+    {
+      switch (len)
+        {
+        case 0:
+          retval = octave_value (matrix, type);
+          break;
 
-        if (! error_state)
-          retval = octave_value (charNDArray (matrix.index (i, resize_ok)),
-                                 type);
-      }
-      break;
+        case 1:
+          {
+            idx_vector i = idx (0).index_vector ();
+
+            retval = octave_value (charNDArray (matrix.index (i, resize_ok)),
+                                   type);
+          }
+          break;
 
-    case 2:
-      {
-        idx_vector i = idx (0).index_vector ();
-        idx_vector j = idx (1).index_vector ();
+        case 2:
+          {
+            idx_vector i = idx (0).index_vector ();
+            k = 1;
+            idx_vector j = idx (1).index_vector ();
 
-        if (! error_state)
-          retval = octave_value (charNDArray (matrix.index (i, j, resize_ok)),
-                                 type);
-      }
-      break;
+            retval = octave_value (charNDArray (matrix.index (i, j, resize_ok)),
+                                   type);
+          }
+          break;
+
+        default:
+          {
+            Array<idx_vector> idx_vec (dim_vector (len, 1));
 
-    default:
-      {
-        Array<idx_vector> idx_vec (dim_vector (len, 1));
-
-        for (octave_idx_type i = 0; i < len; i++)
-          idx_vec(i) = idx(i).index_vector ();
+            for (k = 0; k < len; k++)
+              idx_vec(k) = idx(k).index_vector ();
 
-        if (! error_state)
-          retval =
-            octave_value (charNDArray (matrix.index (idx_vec, resize_ok)),
-                          type);
-      }
-      break;
+            retval =
+              octave_value (charNDArray (matrix.index (idx_vec, resize_ok)),
+                            type);
+          }
+          break;
+        }
+    }
+  catch (index_exception& e)
+    {
+      // Rethrow to allow more info to be reported later.
+      e.set_pos_if_unset (len, k+1);
+      throw;
     }
 
   return retval;
@@ -292,7 +302,7 @@
       charNDArray tmp = char_array_value ();
       os << "# ndims: " << d.length () << "\n";
       for (int i=0; i < d.length (); i++)
-        os << " " << d (i);
+        os << " " << d(i);
       os << "\n";
       os.write (tmp.fortran_vec (), d.numel ());
       os << "\n";
@@ -300,7 +310,7 @@
   else
     {
       // Keep this case, rather than use generic code above for
-      // backward compatiability. Makes load_ascii much more complex!!
+      // backward compatibility.  Makes load_ascii much more complex!!
       charMatrix chm = char_matrix_value ();
       octave_idx_type elements = chm.rows ();
       os << "# elements: " << elements << "\n";
@@ -427,8 +437,7 @@
                     }
                 }
 
-              if (! error_state)
-                matrix = chm;
+              matrix = chm;
             }
           else
             {
@@ -442,7 +451,7 @@
 
           if (len >= 0)
             {
-              // This is cruft for backward compatiability,
+              // This is cruft for backward compatibility,
               // but relatively harmless.
 
               // Use this instead of a C-style character buffer so
@@ -539,8 +548,9 @@
       char *tmp = m.fortran_vec ();
       is.read (tmp, dv.numel ());
 
-      if (error_state || ! is)
+      if (! is)
         return false;
+
       matrix = m;
     }
   else
@@ -592,7 +602,7 @@
 
   // Octave uses column-major, while HDF5 uses row-major ordering
   for (int i = 0; i < rank; i++)
-    hdims[i] = dv (rank-i-1);
+    hdims[i] = dv(rank-i-1);
 
   space_hid = H5Screate_simple (rank, hdims, 0);
   if (space_hid < 0)
@@ -697,7 +707,7 @@
     }
   else
     {
-      // This is cruft for backward compatiability and easy data
+      // This is cruft for backward compatibility and easy data
       // importation
       if (rank == 0) //FIXME: Does rank==0 even exist for strings in HDF5?
         {
--- a/libinterp/octave-value/ov-str-mat.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-str-mat.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_str_mat_h)
+#if ! defined (octave_ov_str_mat_h)
 #define octave_ov_str_mat_h 1
 
 #include <cstdlib>
@@ -129,6 +129,8 @@
 
   std::string string_value (bool force = false) const;
 
+  std::string xstring_value (void) const { return string_value (); }
+
   Array<std::string> cellstr_value (void) const;
 
   octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
--- a/libinterp/octave-value/ov-struct.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-struct.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -42,7 +42,7 @@
 #include "oct-locbuf.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-oct-binary.h"
 #include "ls-hdf5.h"
 #include "ls-utils.h"
@@ -91,14 +91,6 @@
   return retval;
 }
 
-#if 0
-static void
-gripe_invalid_index1 (void)
-{
-  error ("invalid index for structure array");
-}
-#endif
-
 static void
 gripe_invalid_index_for_assignment (void)
 {
@@ -112,12 +104,6 @@
 }
 
 static void
-gripe_failed_assignment (void)
-{
-  error ("assignment to structure element failed");
-}
-
-static void
 maybe_warn_invalid_field_name (const std::string& key, const char *who)
 {
   if (! valid_identifier (key))
@@ -153,17 +139,14 @@
 
             const Cell tmp = dotref (key_idx);
 
-            if (! error_state)
-              {
-                const Cell t = tmp.index (idx.front ());
-
-                retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true);
-
-                // We handled two index elements, so tell
-                // next_subsref to skip both of them.
-
-                skip++;
-              }
+            const Cell t = tmp.index (idx.front ());
+
+            retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true);
+
+            // We handled two index elements, so tell
+            // next_subsref to skip both of them.
+
+            skip++;
           }
         else
           retval(0) = do_index_op (idx.front ());
@@ -176,7 +159,7 @@
           {
             const Cell t = dotref (idx.front ());
 
-            retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true);
+            retval(0) = (t.numel () == 1) ? t(0) : octave_value (t, true);
           }
       }
       break;
@@ -219,17 +202,14 @@
 
             const Cell tmp = dotref (key_idx, auto_add);
 
-            if (! error_state)
-              {
-                const Cell t = tmp.index (idx.front (), auto_add);
-
-                retval = (t.length () == 1) ? t(0) : octave_value (t, true);
-
-                // We handled two index elements, so tell
-                // next_subsref to skip both of them.
-
-                skip++;
-              }
+            const Cell t = tmp.index (idx.front (), auto_add);
+
+            retval = (t.numel () == 1) ? t(0) : octave_value (t, true);
+
+            // We handled two index elements, so tell
+            // next_subsref to skip both of them.
+
+            skip++;
           }
         else
           retval = do_index_op (idx.front (), auto_add);
@@ -242,7 +222,7 @@
           {
             const Cell t = dotref (idx.front (), auto_add);
 
-            retval = (t.length () == 1) ? t(0) : octave_value (t, true);
+            retval = (t.numel () == 1) ? t(0) : octave_value (t, true);
           }
       }
       break;
@@ -324,9 +304,6 @@
 
                 maybe_warn_invalid_field_name (key, "subsasgn");
 
-                if (error_state)
-                  return retval;
-
                 std::list<octave_value_list> next_idx (idx);
 
                 // We handled two index elements, so subsasgn to
@@ -343,37 +320,36 @@
                   {
                     map.contents (pkey).make_unique ();
                     tmpc = map.contents (pkey).index (idx.front (), true);
+                    // See bug #35841, assigning to struct with trailing
+                    // singleton dimensions.
+                    if (tmpc.is_empty ())
+                      tmpc = Cell (1,1);
                   }
 
                 // FIXME: better code reuse?
                 //        cf. octave_cell::subsasgn and the case below.
-                if (! error_state)
+                if (tmpc.numel () == 1)
                   {
-                    if (tmpc.numel () == 1)
+                    octave_value& tmp = tmpc(0);
+
+                    bool orig_undefined = tmp.is_undefined ();
+
+                    if (orig_undefined || tmp.is_zero_by_zero ())
                       {
-                        octave_value& tmp = tmpc(0);
-
-                        bool orig_undefined = tmp.is_undefined ();
-
-                        if (orig_undefined || tmp.is_zero_by_zero ())
-                          {
-                            tmp = octave_value::empty_conv (next_type, rhs);
-                            tmp.make_unique (); // probably a no-op.
-                          }
-                        else
-                          // optimization: ignore the copy
-                          // still stored inside our map.
-                          tmp.make_unique (1);
-
-                        if (! error_state)
-                          t_rhs =
-                            (orig_undefined
-                               ? tmp.undef_subsasgn (next_type, next_idx, rhs)
-                               : tmp.subsasgn (next_type, next_idx, rhs));
+                        tmp = octave_value::empty_conv (next_type, rhs);
+                        tmp.make_unique (); // probably a no-op.
                       }
                     else
-                      gripe_indexed_cs_list ();
+                      // optimization: ignore the copy
+                      // still stored inside our map.
+                      tmp.make_unique (1);
+
+                      t_rhs =(orig_undefined
+                              ? tmp.undef_subsasgn (next_type, next_idx, rhs)
+                              : tmp.subsasgn (next_type, next_idx, rhs));
                   }
+                else
+                  gripe_indexed_cs_list ();
               }
             else
               gripe_invalid_index_for_assignment ();
@@ -390,9 +366,6 @@
 
             maybe_warn_invalid_field_name (key, "subsasgn");
 
-            if (error_state)
-              return retval;
-
             std::list<octave_value_list> next_idx (idx);
 
             next_idx.erase (next_idx.begin ());
@@ -408,32 +381,29 @@
               }
 
             // FIXME: better code reuse?
-            if (! error_state)
+
+            if (tmpc.numel () == 1)
               {
-                if (tmpc.numel () == 1)
+                octave_value& tmp = tmpc(0);
+
+                bool orig_undefined = tmp.is_undefined ();
+
+                if (orig_undefined || tmp.is_zero_by_zero ())
                   {
-                    octave_value& tmp = tmpc(0);
-
-                    bool orig_undefined = tmp.is_undefined ();
-
-                    if (orig_undefined || tmp.is_zero_by_zero ())
-                      {
-                        tmp = octave_value::empty_conv (next_type, rhs);
-                        tmp.make_unique (); // probably a no-op.
-                      }
-                    else
-                      // optimization: ignore the copy
-                      // still stored inside our map.
-                      tmp.make_unique (1);
-
-                    if (! error_state)
-                      t_rhs = (orig_undefined
-                               ? tmp.undef_subsasgn (next_type, next_idx, rhs)
-                               : tmp.subsasgn (next_type, next_idx, rhs));
+                    tmp = octave_value::empty_conv (next_type, rhs);
+                    tmp.make_unique (); // probably a no-op.
                   }
                 else
-                  gripe_indexed_cs_list ();
+                  // optimization: ignore the copy
+                  // still stored inside our map.
+                  tmp.make_unique (1);
+
+                t_rhs = (orig_undefined
+                         ? tmp.undef_subsasgn (next_type, next_idx, rhs)
+                         : tmp.subsasgn (next_type, next_idx, rhs));
               }
+            else
+              gripe_indexed_cs_list ();
           }
           break;
 
@@ -446,125 +416,15 @@
         }
     }
 
-  if (! error_state)
+  switch (type[0])
     {
-      switch (type[0])
-        {
-        case '(':
+    case '(':
+      {
+        if (n > 1 && type[1] == '.')
           {
-            if (n > 1 && type[1] == '.')
-              {
-                std::list<octave_value_list>::const_iterator p = idx.begin ();
-                octave_value_list key_idx = *++p;
-                octave_value_list idxf = idx.front ();
-
-                assert (key_idx.length () == 1);
-
-                std::string key = key_idx(0).string_value ();
-
-                maybe_warn_invalid_field_name (key, "subsasgn");
-
-                if (error_state)
-                  return retval;
-
-                if (! error_state)
-                  {
-                    if (t_rhs.is_cs_list ())
-                      {
-                        Cell tmp_cell = Cell (t_rhs.list_value ());
-
-                        // Inquire the proper shape of the RHS.
-
-                        dim_vector didx = dims ().redim (idxf.length ());
-                        for (octave_idx_type k = 0; k < idxf.length (); k++)
-                          if (! idxf(k).is_magic_colon ())
-                            didx(k) = idxf(k).numel ();
-
-                        if (didx.numel () == tmp_cell.numel ())
-                          tmp_cell = tmp_cell.reshape (didx);
-
-
-                        map.assign (idxf, key, tmp_cell);
-
-                        if (! error_state)
-                          {
-                            count++;
-                            retval = octave_value (this);
-                          }
-                        else
-                          gripe_failed_assignment ();
-                      }
-                    else
-                      {
-                        const octave_map& cmap =
-                          const_cast<const octave_map &> (map);
-                        // cast to const reference, avoid forced key insertion.
-                        if (idxf.all_scalars ()
-                            || cmap.contents (key).index (idxf, true).numel ()
-                               == 1)
-                          {
-                            map.assign (idxf,
-                                        key, Cell (t_rhs.storable_value ()));
-                            if (! error_state)
-                              {
-                                count++;
-                                retval = octave_value (this);
-                              }
-                            else
-                              gripe_failed_assignment ();
-                          }
-                        else if (! error_state)
-                          gripe_nonbraced_cs_list_assignment ();
-                      }
-                  }
-                else
-                  gripe_failed_assignment ();
-              }
-            else
-              {
-                if (t_rhs.is_map () || t_rhs.is_object ())
-                  {
-                    octave_map rhs_map = t_rhs.map_value ();
-
-                    if (! error_state)
-                      {
-                        map.assign (idx.front (), rhs_map);
-
-                        if (! error_state)
-                          {
-                            count++;
-                            retval = octave_value (this);
-                          }
-                        else
-                          gripe_failed_assignment ();
-                      }
-                    else
-                      error ("invalid structure assignment");
-                  }
-                else
-                  {
-                    if (t_rhs.is_null_value ())
-                      {
-                        map.delete_elements (idx.front ());
-
-                        if (! error_state)
-                          {
-                            count++;
-                            retval = octave_value (this);
-                          }
-                        else
-                          gripe_failed_assignment ();
-                      }
-                    else
-                      error ("invalid structure assignment");
-                  }
-              }
-          }
-          break;
-
-        case '.':
-          {
-            octave_value_list key_idx = idx.front ();
+            std::list<octave_value_list>::const_iterator p = idx.begin ();
+            octave_value_list key_idx = *++p;
+            octave_value_list idxf = idx.front ();
 
             assert (key_idx.length () == 1);
 
@@ -572,49 +432,114 @@
 
             maybe_warn_invalid_field_name (key, "subsasgn");
 
-            if (error_state)
-              return retval;
-
             if (t_rhs.is_cs_list ())
               {
                 Cell tmp_cell = Cell (t_rhs.list_value ());
 
-                // The shape of the RHS is irrelevant, we just want
-                // the number of elements to agree and to preserve the
-                // shape of the left hand side of the assignment.
-
-                if (numel () == tmp_cell.numel ())
-                  tmp_cell = tmp_cell.reshape (dims ());
-
-                map.setfield (key, tmp_cell);
+                // Inquire the proper shape of the RHS.
+
+                dim_vector didx = dims ().redim (idxf.length ());
+                for (octave_idx_type k = 0; k < idxf.length (); k++)
+                  if (! idxf(k).is_magic_colon ())
+                    didx(k) = idxf(k).numel ();
+
+                if (didx.numel () == tmp_cell.numel ())
+                  tmp_cell = tmp_cell.reshape (didx);
+
+
+                map.assign (idxf, key, tmp_cell);
+
+                count++;
+                retval = octave_value (this);
               }
             else
               {
-                Cell tmp_cell(1, 1);
-                tmp_cell(0) = t_rhs.storable_value ();
-                map.setfield (key, tmp_cell);
+                const octave_map& cmap =
+                  const_cast<const octave_map &> (map);
+                // cast to const reference, avoid forced key insertion.
+                if (idxf.all_scalars ()
+                    || cmap.contents (key).index (idxf, true).numel ()
+                    <= 1)
+                  {
+                    map.assign (idxf,
+                                key, Cell (t_rhs.storable_value ()));
+
+                    count++;
+                    retval = octave_value (this);
+                  }
+                else
+                  gripe_nonbraced_cs_list_assignment ();
               }
-
-            if (! error_state)
+          }
+        else
+          {
+            if (t_rhs.is_map () || t_rhs.is_object ())
               {
+                octave_map rhs_map = t_rhs.xmap_value ("invalid structure assignment");
+
+                map.assign (idx.front (), rhs_map);
+
                 count++;
                 retval = octave_value (this);
               }
             else
-              gripe_failed_assignment ();
+              {
+                if (t_rhs.is_null_value ())
+                  {
+                    map.delete_elements (idx.front ());
+
+                    count++;
+                    retval = octave_value (this);
+                  }
+                else
+                  error ("invalid structure assignment");
+              }
           }
-          break;
-
-        case '{':
-          gripe_invalid_index_type (type_name (), type[0]);
-          break;
-
-        default:
-          panic_impossible ();
-        }
+      }
+      break;
+
+    case '.':
+      {
+        octave_value_list key_idx = idx.front ();
+
+        assert (key_idx.length () == 1);
+
+        std::string key = key_idx(0).string_value ();
+
+        maybe_warn_invalid_field_name (key, "subsasgn");
+
+        if (t_rhs.is_cs_list ())
+          {
+            Cell tmp_cell = Cell (t_rhs.list_value ());
+
+            // The shape of the RHS is irrelevant, we just want
+            // the number of elements to agree and to preserve the
+            // shape of the left hand side of the assignment.
+
+            if (numel () == tmp_cell.numel ())
+              tmp_cell = tmp_cell.reshape (dims ());
+
+            map.setfield (key, tmp_cell);
+          }
+        else
+          {
+            Cell tmp_cell(1, 1);
+            tmp_cell(0) = t_rhs.storable_value ();
+            map.setfield (key, tmp_cell);
+          }
+
+        count++;
+        retval = octave_value (this);
+      }
+      break;
+
+    case '{':
+      gripe_invalid_index_type (type_name (), type[0]);
+      break;
+
+    default:
+      panic_impossible ();
     }
-  else
-    gripe_failed_assignment ();
 
   retval.maybe_mutate ();
 
@@ -679,7 +604,7 @@
 
       string_vector key_list = map.fieldnames ();
 
-      for (octave_idx_type i = 0; i < key_list.length (); i++)
+      for (octave_idx_type i = 0; i < key_list.numel (); i++)
         {
           std::string key = key_list[i];
 
@@ -735,7 +660,7 @@
 static bool
 scalar (const dim_vector& dims)
 {
-  return dims.length () == 2 && dims (0) == 1 && dims (1) == 1;
+  return dims.length () == 2 && dims(0) == 1 && dims(1) == 1;
 }
 
 
@@ -751,7 +676,7 @@
   os << "# ndims: " << dv.length () << "\n";
 
   for (int i = 0; i < dv.length (); i++)
-    os << " " << dv (i);
+    os << " " << dv(i);
   os << "\n";
 
   os << "# length: " << nf << "\n";
@@ -766,7 +691,7 @@
 
       octave_value val = map.contents (key);
 
-      bool b = save_ascii_data (os, val, key, false, 0);
+      bool b = save_text_data (os, val, key, false, 0);
 
       if (! b)
         return ! os.fail ();
@@ -820,18 +745,12 @@
 
               // recurse to read cell elements
               std::string nm
-                = read_ascii_data (is, std::string (), dummy, t2, j);
+                = read_text_data (is, std::string (), dummy, t2, j);
 
               if (!is)
                 break;
 
-              Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2);
-
-              if (error_state)
-                {
-                  error ("load: internal error loading struct elements");
-                  return false;
-                }
+              Cell tcell = t2.is_cell () ? t2.xcell_value ("load: internal error loading struct elements") : Cell (t2);
 
               m.setfield (nm, tcell);
             }
@@ -953,13 +872,7 @@
           if (!is)
             break;
 
-          Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2);
-
-          if (error_state)
-            {
-              error ("load: internal error loading struct elements");
-              return false;
-            }
+          Cell tcell = t2.is_cell () ? t2.xcell_value ("load: internal error loading struct elements") : Cell (t2);
 
           m.setfield (nm, tcell);
         }
@@ -1056,13 +969,7 @@
     {
       octave_value t2 = dsub.tc;
 
-      Cell tcell = t2.is_cell () ? t2.cell_value () : Cell (t2);
-
-      if (error_state)
-        {
-          error ("load: internal error loading struct elements");
-          return false;
-        }
+      Cell tcell = t2.is_cell () ? t2.xcell_value ("load: internal error loading struct elements") : Cell (t2);
 
       m.setfield (dsub.name, tcell);
 
@@ -1156,9 +1063,6 @@
 
   maybe_warn_invalid_field_name (nm, "subsref");
 
-  if (error_state)
-    return retval;
-
   retval = map.getfield (nm);
 
   if (! auto_add && retval.is_undefined ())
@@ -1283,9 +1187,6 @@
 
       maybe_warn_invalid_field_name (key, "subsasgn");
 
-      if (error_state)
-        return retval;
-
       if (n > 1)
         {
           std::list<octave_value_list> next_idx (idx);
@@ -1302,30 +1203,23 @@
               tmp = map.contents (pkey);
             }
 
-          if (! error_state)
+          bool orig_undefined = tmp.is_undefined ();
+
+          if (orig_undefined || tmp.is_zero_by_zero ())
             {
-              bool orig_undefined = tmp.is_undefined ();
-
-              if (orig_undefined || tmp.is_zero_by_zero ())
-                {
-                  tmp = octave_value::empty_conv (next_type, rhs);
-                  tmp.make_unique (); // probably a no-op.
-                }
-              else
-                // optimization: ignore the copy still stored inside our map.
-                tmp.make_unique (1);
-
-              if (! error_state)
-                t_rhs = (orig_undefined
-                         ? tmp.undef_subsasgn (next_type, next_idx, rhs)
-                         : tmp.subsasgn (next_type, next_idx, rhs));
+              tmp = octave_value::empty_conv (next_type, rhs);
+              tmp.make_unique (); // probably a no-op.
             }
+          else
+            // optimization: ignore the copy still stored inside our map.
+            tmp.make_unique (1);
+
+          t_rhs = (orig_undefined
+                   ? tmp.undef_subsasgn (next_type, next_idx, rhs)
+                   : tmp.subsasgn (next_type, next_idx, rhs));
         }
 
-      if (! error_state)
-        map.setfield (key, t_rhs.storable_value ());
-      else
-        gripe_failed_assignment ();
+      map.setfield (key, t_rhs.storable_value ());
 
       count++;
       retval = this;
@@ -1400,7 +1294,7 @@
 
       string_vector key_list = map.fieldnames ();
 
-      for (octave_idx_type i = 0; i < key_list.length (); i++)
+      for (octave_idx_type i = 0; i < key_list.numel (); i++)
         {
           std::string key = key_list[i];
 
@@ -1461,7 +1355,7 @@
   os << "# ndims: " << dv.length () << "\n";
 
   for (int i = 0; i < dv.length (); i++)
-    os << " " << dv (i);
+    os << " " << dv(i);
   os << "\n";
 
   os << "# length: " << nf << "\n";
@@ -1476,7 +1370,7 @@
 
       octave_value val = map.contents (key);
 
-      bool b = save_ascii_data (os, val, key, false, 0);
+      bool b = save_text_data (os, val, key, false, 0);
 
       if (! b)
         return ! os.fail ();
@@ -1504,17 +1398,11 @@
 
               // recurse to read cell elements
               std::string nm
-                = read_ascii_data (is, std::string (), dummy, t2, j);
+                = read_text_data (is, std::string (), dummy, t2, j);
 
               if (!is)
                 break;
 
-              if (error_state)
-                {
-                  error ("load: internal error loading struct elements");
-                  return false;
-                }
-
               m.setfield (nm, t2);
             }
 
@@ -1599,12 +1487,6 @@
           if (!is)
             break;
 
-          if (error_state)
-            {
-              error ("load: internal error loading struct elements");
-              return false;
-            }
-
           m.setfield (nm, t2);
         }
 
@@ -1701,12 +1583,6 @@
     {
       octave_value t2 = dsub.tc;
 
-      if (error_state)
-        {
-          error ("load: internal error loading struct elements");
-          return false;
-        }
-
       m.setfield (dsub.name, t2);
 
     }
@@ -1864,10 +1740,9 @@
 
       if (nargin == 2)
         {
-          if (args(1).is_cellstr ())
-            retval = octave_map (args(0).dims (), args(1).cellstr_value ());
-          else
-            error ("struct: expecting cell array of field names as second argument");
+          Array<std::string> cstr = args(1).xcellstr_value ("struct: second argument should be a cell array of field names");
+
+          retval = octave_map (args(0).dims (), cstr);
         }
       else
         retval = octave_map (args(0).dims ());
@@ -1881,7 +1756,7 @@
     {
       if (! args(i).is_string () || i + 1 >= nargin)
         {
-          error ("struct: expecting alternating \"field\", VALUE pairs");
+          error ("struct: additional arguments must occur as \"field\", VALUE pairs");
           return retval;
         }
     }
@@ -1925,14 +1800,8 @@
 
       std::string key (args(i).string_value ());
 
-      if (error_state)
-        return retval;
-
       maybe_warn_invalid_field_name (key, "struct");
 
-      if (error_state)
-        return retval;
-
       // Value may be v, { v }, or { v1, v2, ... }
       // In the first two cases, we need to create a cell array of
       // the appropriate dimensions filled with v.  In the last case,
@@ -1943,9 +1812,6 @@
         {
           const Cell c (args(i+1).cell_value ());
 
-          if (error_state)
-            return retval;
-
           if (scalar (c.dims ()))
             map.setfield (key, Cell (dims, c(0)));
           else
@@ -1953,9 +1819,6 @@
         }
       else
         map.setfield (key, Cell (dims, args(i+1)));
-
-      if (error_state)
-        return retval;
     }
 
   return octave_value (map);
@@ -1977,8 +1840,8 @@
 %!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')
+%!error <arguments must occur as "field", VALUE pairs> struct (1,2,3,4)
+%!fail ('struct ("1",2,"3")', 'struct: additional arguments must occur as "field", VALUE pairs')
 */
 
 DEFUN (isstruct, args, ,
@@ -1988,14 +1851,10 @@
 @seealso{ismatrix, iscell, isa}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_map ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_map ());
 }
 
 DEFUN (__fieldnames__, args, ,
@@ -2017,7 +1876,7 @@
 
   string_vector keys = m.fieldnames ();
 
-  if (keys.length () == 0)
+  if (keys.numel () == 0)
     retval = Cell (0, 1);
   else
     retval = Cell (keys);
@@ -2039,49 +1898,45 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 2)
+  if (args.length () != 2)
+    print_usage ();
+
+  retval = false;
+
+  if (args(0).is_map ())
     {
-      retval = false;
-
-      if (args(0).is_map ())
+      octave_map m = args(0).map_value ();
+
+      // FIXME: should this work for all types that can do
+      // structure reference operations?
+
+      if (args(1).is_string ())
         {
-          octave_map m = args(0).map_value ();
-
-          // FIXME: should this work for all types that can do
-          // structure reference operations?
-
-          if (args(1).is_string ())
+          std::string key = args(1).string_value ();
+
+          retval = m.isfield (key);
+        }
+      else if (args(1).is_cell ())
+        {
+          Cell c = args(1).cell_value ();
+          boolNDArray bm (c.dims ());
+          octave_idx_type n = bm.numel ();
+
+          for (octave_idx_type i = 0; i < n; i++)
             {
-              std::string key = args(1).string_value ();
-
-              retval = m.isfield (key);
+              if (c(i).is_string ())
+                {
+                  std::string key = c(i).string_value ();
+
+                  bm(i) = m.isfield (key);
+                }
+              else
+                bm(i) = false;
             }
-          else if (args(1).is_cell ())
-            {
-              Cell c = args(1).cell_value ();
-              boolNDArray bm (c.dims ());
-              octave_idx_type n = bm.numel ();
-
-              for (octave_idx_type i = 0; i < n; i++)
-                {
-                  if (c(i).is_string ())
-                    {
-                      std::string key = c(i).string_value ();
-
-                      bm(i) = m.isfield (key);
-                    }
-                  else
-                    bm(i) = false;
-                }
-
-              retval = bm;
-            }
+
+          retval = bm;
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -2095,14 +1950,13 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 1 && args(0).is_map ())
-    {
-      retval = static_cast<double> (args(0).nfields ());
-    }
+  if (args.length () != 1)
+    print_usage ();
+
+  if (args(0).is_map ())
+    retval = static_cast<double> (args(0).nfields ());
   else
-    print_usage ();
+    error ("numfields: argument must be a struct");
 
   return retval;
 }
@@ -2151,88 +2005,81 @@
 
   int nargin = args.length ();
 
-  if (nargin == 2 || nargin == 3)
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
+
+  if (! args(0).is_cell ())
+    {
+      error ("cell2struct: argument CELL must be of type cell");
+      return retval;
+    }
+
+  if (! (args(1).is_cellstr () || args(1).is_char_matrix ()))
     {
-      if (! args(0).is_cell ())
+      error ("cell2struct: FIELDS must be a cell array of strings or a character matrix");
+      return retval;
+    }
+
+  const Cell vals = args(0).cell_value ();
+  const Array<std::string> fields = args(1).cellstr_value ();
+
+  octave_idx_type ext = 0;
+
+  int dim = 0;
+
+  if (nargin == 3)
+    {
+      if (args(2).is_real_scalar ())
+        dim = nargin == 2 ? 0 : args(2).int_value () - 1;
+      else
         {
-          error ("cell2struct: argument CELL must be of type cell");
-          return retval;
-        }
-
-      if (! (args(1).is_cellstr () || args(1).is_char_matrix ()))
-        {
-          error ("cell2struct: FIELDS must be a cell array of strings or a character matrix");
+          error ("cell2struct: DIM must be a real scalar");
           return retval;
         }
-
-      const Cell vals = args(0).cell_value ();
-      const Array<std::string> fields = args(1).cellstr_value ();
-
-      octave_idx_type ext = 0;
-
-      int dim = 0;
-
-      if (nargin == 3)
-        {
-          if (args(2).is_real_scalar ())
-            {
-              dim = nargin == 2 ? 0 : args(2).int_value () - 1;
-
-              if (error_state)
-                return retval;
-            }
-          else
-            {
-              error ("cell2struct: DIM must be a real scalar");
-              return retval;
-            }
-        }
-
-      if (dim < 0)
-        {
-          error ("cell2struct: DIM must be a valid dimension");
-          return retval;
-        }
-
-      ext = vals.ndims () > dim ? vals.dims ()(dim) : 1;
-
-      if (ext != fields.numel ())
-        {
-          error ("cell2struct: number of FIELDS does not match dimension");
-          return retval;
-        }
-
-      int nd = std::max (dim+1, vals.ndims ());
-      // result dimensions.
-      dim_vector rdv = vals.dims ().redim (nd);
-
-      assert (ext == rdv(dim));
-      if (nd == 2)
-        {
-          rdv(0) = rdv(1-dim);
-          rdv(1) = 1;
-        }
-      else
-        {
-          for (int i =  dim + 1; i < nd; i++)
-            rdv(i-1) = rdv(i);
-
-          rdv.resize (nd-1);
-        }
-
-      octave_map map (rdv);
-      Array<idx_vector> ia (dim_vector (nd, 1), idx_vector::colon);
-
-      for (octave_idx_type i = 0; i < ext; i++)
-        {
-          ia(dim) = i;
-          map.setfield (fields(i), vals.index (ia).reshape (rdv));
-        }
-
-      retval = map;
+    }
+
+  if (dim < 0)
+    {
+      error ("cell2struct: DIM must be a valid dimension");
+      return retval;
+    }
+
+  ext = vals.ndims () > dim ? vals.dims ()(dim) : 1;
+
+  if (ext != fields.numel ())
+    {
+      error ("cell2struct: number of FIELDS does not match dimension");
+      return retval;
+    }
+
+  int nd = std::max (dim+1, vals.ndims ());
+  // result dimensions.
+  dim_vector rdv = vals.dims ().redim (nd);
+
+  assert (ext == rdv(dim));
+  if (nd == 2)
+    {
+      rdv(0) = rdv(1-dim);
+      rdv(1) = 1;
     }
   else
-    print_usage ();
+    {
+      for (int i =  dim + 1; i < nd; i++)
+        rdv(i-1) = rdv(i);
+
+      rdv.resize (nd-1);
+    }
+
+  octave_map map (rdv);
+  Array<idx_vector> ia (dim_vector (nd, 1), idx_vector::colon);
+
+  for (octave_idx_type i = 0; i < ext; i++)
+    {
+      ia(dim) = i;
+      map.setfield (fields(i), vals.index (ia).reshape (rdv));
+    }
+
+  retval = map;
 
   return retval;
 }
@@ -2253,9 +2100,10 @@
 %!assert (cell2struct ({}, {"f"}, 3), struct ("f", {}));
 */
 
-
-// So we can call Fcellstr directly.
-extern octave_value_list Fcellstr (const octave_value_list& args, int);
+// FIXME: we should be including builtin-defun-decls.h but doing that
+// currently exposes a problem with dependencies in the the build system.
+extern OCTINTERP_API octave_value_list
+Fcellstr (const octave_value_list& = octave_value_list (), int = 0);
 
 DEFUN (rmfield, args, ,
        "-*- texinfo -*-\n\
@@ -2271,39 +2119,26 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 2)
+  if (args.length () != 2)
+    print_usage ();
+
+  octave_map m = args(0).xmap_value ("rmfield: first argument must be a struct");
+
+  octave_value_list fval = Fcellstr (args(1), 1);
+
+  Cell fcell = fval(0).cell_value ();
+
+  for (int i = 0; i < fcell.numel (); i++)
     {
-      octave_map m = args(0).map_value ();
-
-      octave_value_list fval = Fcellstr (args(1), 1);
-
-      if (! error_state)
-        {
-          Cell fcell = fval(0).cell_value ();
-
-          for (int i = 0; i < fcell.numel (); i++)
-            {
-              std::string key = fcell(i).string_value ();
-
-              if (m.isfield (key))
-                m.rmfield (key);
-              else
-                {
-                  error ("rmfield: structure does not contain field %s",
-                         key.c_str ());
-
-                  break;
-                }
-            }
-
-          if (! error_state)
-            retval = m;
-        }
+      std::string key = fcell(i).string_value ();
+
+      if (m.isfield (key))
+        m.rmfield (key);
+      else
+        error ("rmfield: structure does not contain field %s", key.c_str ());
     }
-  else
-    print_usage ();
+
+  retval = m;
 
   return retval;
 }
--- a/libinterp/octave-value/ov-struct.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-struct.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_struct_h)
+#if ! defined (octave_ov_struct_h)
 #define octave_ov_struct_h 1
 
 #include <cstdlib>
--- a/libinterp/octave-value/ov-type-conv.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-type-conv.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_type_conv_h)
+#if ! defined (octave_ov_type_conv_h)
 #define octave_ov_type_conv_h 1
 
 static
@@ -78,28 +78,24 @@
  \
   octave_value retval; \
  \
-  int nargin = args.length (); \
+  if (args.length () != 1) \
+    print_usage (); \
  \
-  if (nargin == 1) \
-    { \
-      const octave_value arg = args(0); \
+  const octave_value arg = args(0); \
  \
-      int t_result = MATRIX_RESULT_T::static_type_id (); \
+  int t_result = MATRIX_RESULT_T::static_type_id (); \
  \
-      retval = octave_type_conv_body (arg, #NAME, t_result); \
-      if (retval.is_undefined ()) \
-        { \
-          std::string arg_tname = arg.type_name (); \
+  retval = octave_type_conv_body (arg, #NAME, t_result); \
+  if (retval.is_undefined ()) \
+    { \
+      std::string arg_tname = arg.type_name (); \
  \
-          std::string result_tname = arg.numel () == 1 \
-            ? SCALAR_RESULT_T::static_type_name () \
-            : MATRIX_RESULT_T::static_type_name (); \
+      std::string result_tname = arg.numel () == 1 \
+        ? SCALAR_RESULT_T::static_type_name () \
+        : MATRIX_RESULT_T::static_type_name (); \
  \
-          gripe_invalid_conversion (arg_tname, result_tname); \
-        } \
+      gripe_invalid_conversion (arg_tname, result_tname); \
     } \
-  else \
-    print_usage (); \
  \
   return retval
 
--- a/libinterp/octave-value/ov-typeinfo.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-typeinfo.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -52,7 +52,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create value type info object!");
+      error ("unable to create value type info object!");
 
       retval = false;
     }
@@ -193,7 +193,7 @@
     if (t_name == types (i))
       return i;
 
-  int len = types.length ();
+  int len = types.numel ();
 
   if (i == len)
     {
@@ -625,12 +625,13 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 0)
     retval = Cell (octave_value_typeinfo::installed_type_names ());
-  else if (nargin == 1)
+  else
     retval = args(0).type_name ();
-  else
-    print_usage ();
 
   return retval;
 }
--- a/libinterp/octave-value/ov-typeinfo.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-typeinfo.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_typeinfo_h)
+#if ! defined (octave_ov_typeinfo_h)
 #define octave_ov_typeinfo_h 1
 
 #include <string>
--- a/libinterp/octave-value/ov-uint16.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-uint16.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -52,7 +52,7 @@
 #include "variables.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
--- a/libinterp/octave-value/ov-uint16.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-uint16.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_uint16_h)
+#if ! defined (octave_ov_uint16_h)
 #define octave_ov_uint16_h 1
 
 #define OCTAVE_INT_T octave_uint16
--- a/libinterp/octave-value/ov-uint32.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-uint32.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -52,7 +52,7 @@
 #include "variables.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
--- a/libinterp/octave-value/ov-uint32.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-uint32.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_uint32_h)
+#if ! defined (octave_ov_uint32_h)
 #define octave_ov_uint32_h 1
 
 #define OCTAVE_INT_T octave_uint32
--- a/libinterp/octave-value/ov-uint64.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-uint64.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -52,7 +52,7 @@
 #include "variables.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
--- a/libinterp/octave-value/ov-uint64.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-uint64.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_uint64_h)
+#if ! defined (octave_ov_uint64_h)
 #define octave_ov_uint64_h 1
 
 #define OCTAVE_INT_T octave_uint64
--- a/libinterp/octave-value/ov-uint8.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-uint8.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -52,7 +52,7 @@
 #include "variables.h"
 
 #include "byte-swap.h"
-#include "ls-oct-ascii.h"
+#include "ls-oct-text.h"
 #include "ls-utils.h"
 #include "ls-hdf5.h"
 
--- a/libinterp/octave-value/ov-uint8.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-uint8.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_uint8_h)
+#if ! defined (octave_ov_uint8_h)
 #define octave_ov_uint8_h 1
 
 #define OCTAVE_INT_T octave_uint8
--- a/libinterp/octave-value/ov-usr-fcn.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-usr-fcn.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -117,7 +117,7 @@
 {
   octave_value_list retval;
 
-  ::error ("invalid use of script %s in index expression", file_name.c_str ());
+  error ("invalid use of script %s in index expression", file_name.c_str ());
 
   return retval;
 }
@@ -130,43 +130,40 @@
 
   unwind_protect frame;
 
-  if (! error_state)
+  if (args.length () == 0 && nargout == 0)
     {
-      if (args.length () == 0 && nargout == 0)
+      if (cmd_list)
         {
-          if (cmd_list)
-            {
-              frame.protect_var (call_depth);
-              call_depth++;
+          frame.protect_var (call_depth);
+          call_depth++;
 
-              if (call_depth < Vmax_recursion_depth)
-                {
-                  octave_call_stack::push (this);
+          if (call_depth < Vmax_recursion_depth)
+            {
+              octave_call_stack::push (this);
 
-                  frame.add_fcn (octave_call_stack::pop);
+              frame.add_fcn (octave_call_stack::pop);
 
-                  frame.protect_var (tree_evaluator::statement_context);
-                  tree_evaluator::statement_context = tree_evaluator::script;
+              frame.protect_var (tree_evaluator::statement_context);
+              tree_evaluator::statement_context = tree_evaluator::script;
 
-                  BEGIN_PROFILER_BLOCK (octave_user_script)
+              BEGIN_PROFILER_BLOCK (octave_user_script)
 
-                  cmd_list->accept (*current_evaluator);
+                cmd_list->accept (*current_evaluator);
 
-                  END_PROFILER_BLOCK
+              END_PROFILER_BLOCK
 
-                  if (tree_return_command::returning)
-                    tree_return_command::returning = 0;
+                if (tree_return_command::returning)
+                  tree_return_command::returning = 0;
 
-                  if (tree_break_command::breaking)
-                    tree_break_command::breaking--;
-                }
-              else
-                ::error ("max_recursion_depth exceeded");
+              if (tree_break_command::breaking)
+                tree_break_command::breaking--;
             }
+          else
+            error ("max_recursion_depth exceeded");
         }
-      else
-        error ("invalid call to script %s", file_name.c_str ());
     }
+  else
+    error ("invalid call to script %s", file_name.c_str ());
 
   return retval;
 }
@@ -476,9 +473,6 @@
 {
   octave_value_list retval;
 
-  if (error_state)
-    return retval;
-
   if (! cmd_list)
     return retval;
 
@@ -505,8 +499,6 @@
     return retval;
 #endif
 
-  int nargin = args.length ();
-
   unwind_protect frame;
 
   frame.protect_var (call_depth);
@@ -514,7 +506,7 @@
 
   if (call_depth >= Vmax_recursion_depth)
     {
-      ::error ("max_recursion_depth exceeded");
+      error ("max_recursion_depth exceeded");
       return retval;
     }
 
@@ -536,11 +528,7 @@
   string_vector arg_names = args.name_tags ();
 
   if (param_list && ! param_list->varargs_only ())
-    {
-      param_list->define_from_arg_vector (args);
-      if (error_state)
-        return retval;
-    }
+    param_list->define_from_arg_vector (args);
 
   // For classdef constructor, pre-populate the output arguments
   // with the pre-initialized object instance, extracted above.
@@ -548,15 +536,11 @@
   if (is_classdef_constructor ())
     {
       if (ret_list)
-        {
-          ret_list->define_from_arg_vector (ret_args);
-          if (error_state)
-            return retval;
-        }
+        ret_list->define_from_arg_vector (ret_args);
       else
         {
-          ::error ("%s: invalid classdef constructor, no output argument defined",
-                   dispatch_class ().c_str ());
+          error ("%s: invalid classdef constructor, no output argument defined",
+                 dispatch_class ().c_str ());
           return retval;
         }
     }
@@ -590,8 +574,8 @@
       frame.add_fcn (symbol_table::clear_variables);
     }
 
-  bind_automatic_vars (arg_names, nargin, nargout, all_va_args (args),
-                       lvalue_list);
+  bind_automatic_vars (arg_names, args.length (), nargout,
+                       all_va_args (args), lvalue_list);
 
   frame.add_method (this, &octave_user_function::restore_warning_states);
 
@@ -636,9 +620,6 @@
   if (tree_break_command::breaking)
     tree_break_command::breaking--;
 
-  if (error_state)
-    return retval;
-
   // Copy return values out.
 
   if (ret_list && ! is_special_expr ())
@@ -652,16 +633,10 @@
           octave_value varargout_varval = symbol_table::varval ("varargout");
 
           if (varargout_varval.is_defined ())
-            {
-              varargout = varargout_varval.cell_value ();
-
-              if (error_state)
-                error ("expecting varargout to be a cell array object");
-            }
+            varargout = varargout_varval.xcell_value ("varargout must be a cell array object");
         }
 
-      if (! error_state)
-        retval = ret_list->convert_to_const_vector (nargout, varargout);
+      retval = ret_list->convert_to_const_vector (nargout, varargout);
     }
 
   return retval;
@@ -803,11 +778,8 @@
 
   if (val.is_defined ())
     {
-      // Don't use the usual approach of attempting to extract a value
-      // and then checking error_state since this code might be
-      // executing when error_state is already set.  But do fail
-      // spectacularly if .saved_warning_states. is not an octave_map
-      // (or octave_scalar_map) object.
+      // Fail spectacularly if .saved_warning_states. is not an
+      // octave_map (or octave_scalar_map) object.
 
       if (! val.is_map ())
         panic_impossible ();
@@ -857,6 +829,9 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 1)
     {
       octave_value func = args(0);
@@ -895,15 +870,13 @@
       else
         error ("nargin: FCN must be a string or function handle");
     }
-  else if (nargin == 0)
+  else
     {
       retval = symbol_table::varval (".nargin.");
 
       if (retval.is_undefined ())
         retval = 0;
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -967,6 +940,9 @@
 
   int nargin = args.length ();
 
+  if (nargin > 1)
+    print_usage ();
+
   if (nargin == 1)
     {
       octave_value func = args(0);
@@ -1026,7 +1002,7 @@
       else
         error ("nargout: FCN must be a string or function handle");
     }
-  else if (nargin == 0)
+  else
     {
       if (! symbol_table::at_top_level ())
         {
@@ -1038,8 +1014,6 @@
       else
         error ("nargout: invalid call at top level");
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1102,52 +1076,39 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
+  if (args.length () != 1)
+    print_usage ();
 
-  if (nargin == 1)
+  if (! symbol_table::at_top_level ())
     {
-      if (! symbol_table::at_top_level ())
-        {
-          int nargout1 = symbol_table::varval (".nargout.").int_value ();
-          if (error_state)
-            {
-              error ("isargout: internal error");
-              return retval;
-            }
+      int nargout1 = symbol_table::varval (".nargout.").int_value ();
 
-          Matrix ignored;
-          octave_value tmp = symbol_table::varval (".ignored.");
-          if (tmp.is_defined ())
-            ignored = tmp.matrix_value ();
+      Matrix ignored;
+      octave_value tmp = symbol_table::varval (".ignored.");
+      if (tmp.is_defined ())
+        ignored = tmp.matrix_value ();
 
-          if (args(0).is_scalar_type ())
-            {
-              double k = args(0).double_value ();
-              if (! error_state)
-                retval = isargout1 (nargout1, ignored, k);
-            }
-          else if (args(0).is_numeric_type ())
-            {
-              const NDArray ka = args(0).array_value ();
-              if (! error_state)
-                {
-                  boolNDArray r (ka.dims ());
-                  for (octave_idx_type i = 0;
-                       i < ka.numel () && ! error_state;
-                       i++)
-                    r(i) = isargout1 (nargout1, ignored, ka(i));
+      if (args(0).is_scalar_type ())
+        {
+          double k = args(0).double_value ();
 
-                  retval = r;
-                }
-            }
-          else
-            gripe_wrong_type_arg ("isargout", args(0));
+          retval = isargout1 (nargout1, ignored, k);
+        }
+      else if (args(0).is_numeric_type ())
+        {
+          const NDArray ka = args(0).array_value ();
+
+          boolNDArray r (ka.dims ());
+          for (octave_idx_type i = 0; i < ka.numel (); i++)
+            r(i) = isargout1 (nargout1, ignored, ka(i));
+
+          retval = r;
         }
       else
-        error ("isargout: invalid call at top level");
+        gripe_wrong_type_arg ("isargout", args(0));
     }
   else
-    print_usage ();
+    error ("isargout: invalid call at top level");
 
   return retval;
 }
--- a/libinterp/octave-value/ov-usr-fcn.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov-usr-fcn.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ov_usr_fcn_h)
+#if ! defined (octave_ov_usr_fcn_h)
 #define octave_ov_usr_fcn_h 1
 
 #include <ctime>
--- a/libinterp/octave-value/ov.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -1318,7 +1318,7 @@
                             const std::list<octave_value_list>& idx,
                             size_t skip)
 {
-  if (! error_state && idx.size () > skip)
+  if (idx.size () > skip)
     {
       std::list<octave_value_list> new_idx (idx);
       for (size_t i = 0; i < skip; i++)
@@ -1334,7 +1334,7 @@
                             const std::list<octave_value_list>& idx,
                             size_t skip)
 {
-  if (! error_state && idx.size () > skip)
+  if (idx.size () > skip)
     {
       std::list<octave_value_list> new_idx (idx);
       for (size_t i = 0; i < skip; i++)
@@ -1351,7 +1351,7 @@
                             const std::list<octave_lvalue> *lvalue_list,
                             size_t skip)
 {
-  if (! error_state && idx.size () > skip)
+  if (idx.size () > skip)
     {
       std::list<octave_value_list> new_idx (idx);
       for (size_t i = 0; i < skip; i++)
@@ -1367,7 +1367,7 @@
                             const std::list<octave_value_list>& idx,
                             size_t skip)
 {
-  if (! error_state && idx.size () > skip)
+  if (idx.size () > skip)
     {
       std::list<octave_value_list> new_idx (idx);
       for (size_t i = 0; i < skip; i++)
@@ -1391,25 +1391,6 @@
   return rep->do_multi_index_op (nargout, idx, lvalue_list);
 }
 
-#if 0
-static void
-gripe_assign_failed (const std::string& on, const std::string& tn1,
-                     const std::string& tn2)
-{
-  error ("assignment failed for '%s %s %s'",
-         tn1.c_str (), on.c_str (), tn2.c_str ());
-}
-#endif
-
-static void
-gripe_assign_failed_or_no_method (const std::string& on,
-                                  const std::string& tn1,
-                                  const std::string& tn2)
-{
-  error ("assignment failed, or no method for '%s %s %s'",
-         tn1.c_str (), on.c_str (), tn2.c_str ());
-}
-
 octave_value
 octave_value::subsasgn (const std::string& type,
                         const std::list<octave_value_list>& idx,
@@ -1443,28 +1424,15 @@
         {
           octave_value t = subsref (type, idx);
 
-          if (! error_state)
-            {
-              binary_op binop = op_eq_to_binary_op (op);
-
-              if (! error_state)
-                t_rhs = do_binary_op (binop, t, rhs);
-            }
+          binary_op binop = op_eq_to_binary_op (op);
+
+          t_rhs = do_binary_op (binop, t, rhs);
         }
       else
         error ("in computed assignment A(index) OP= X, A must be defined first");
     }
 
-  if (! error_state)
-    {
-      octave_value tmp = subsasgn (type, idx, t_rhs);
-
-      if (error_state)
-        gripe_assign_failed_or_no_method (assign_op_as_string (op_asn_eq),
-                                          type_name (), rhs.type_name ());
-      else
-        *this = tmp;
-    }
+  *this = subsasgn (type, idx, t_rhs);
 
   return *this;
 }
@@ -1490,29 +1458,18 @@
 
       if (f)
         {
-          try
-            {
-              f (*rep, octave_value_list (), *rhs.rep);
-              // Usually unnecessary, but may be needed (complex arrays).
-              maybe_mutate ();
-            }
-          catch (octave_execution_exception)
-            {
-              gripe_library_execution_error ();
-            }
+          f (*rep, octave_value_list (), *rhs.rep);
+          // Usually unnecessary, but may be needed (complex arrays).
+          maybe_mutate ();
         }
       else
         {
 
           binary_op binop = op_eq_to_binary_op (op);
 
-          if (! error_state)
-            {
-              octave_value t = do_binary_op (binop, *this, rhs);
-
-              if (! error_state)
-                operator = (t);
-            }
+          octave_value t = do_binary_op (binop, *this, rhs);
+
+          operator = (t);
         }
     }
   else
@@ -1555,19 +1512,13 @@
       octave_value tmp = do_binary_op (octave_value::op_eq, *this, test);
 
       // Empty array also means a match.
-      if (! error_state && tmp.is_defined ())
+      if (tmp.is_defined ())
         retval = tmp.is_true () || tmp.is_empty ();
     }
 
   return retval;
 }
 
-Cell
-octave_value::cell_value (void) const
-{
-  return rep->cell_value ();
-}
-
 // Define the idx_type_value function here instead of in ov.h to avoid
 // needing definitions for the SIZEOF_X macros in ov.h.
 
@@ -1581,6 +1532,12 @@
 #endif
 }
 
+Cell
+octave_value::cell_value (void) const
+{
+  return rep->cell_value ();
+}
+
 octave_map
 octave_value::map_value (void) const
 {
@@ -1692,12 +1649,9 @@
 {
   Array<double> retval = array_value (force_string_conv);
 
-  if (error_state)
-    return retval;
-  else
-    return retval.reshape (make_vector_dims (retval.dims (),
-                                             force_vector_conversion,
-                                             type_name (), "real vector"));
+  return retval.reshape (make_vector_dims (retval.dims (),
+                                           force_vector_conversion,
+                                           type_name (), "real vector"));
 }
 
 template <class T>
@@ -1714,7 +1668,7 @@
 }
 
 Array<int>
-octave_value::int_vector_value (bool force_string_conv, bool require_int,
+octave_value::int_vector_value (bool require_int, bool force_string_conv,
                                 bool force_vector_conversion) const
 {
   Array<int> retval;
@@ -1743,36 +1697,30 @@
   else
     {
       const NDArray a = array_value (force_string_conv);
-      if (! error_state)
+
+      if (require_int)
         {
-          if (require_int)
+          retval.resize (a.dims ());
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             {
-              retval.resize (a.dims ());
-              for (octave_idx_type i = 0; i < a.numel (); i++)
+              double ai = a.elem (i);
+              int v = static_cast<int> (ai);
+              if (ai == v)
+                retval.xelem (i) = v;
+              else
                 {
-                  double ai = a.elem (i);
-                  int v = static_cast<int> (ai);
-                  if (ai == v)
-                    retval.xelem (i) = v;
-                  else
-                    {
-                      error_with_cfn ("conversion to integer value failed");
-                      break;
-                    }
+                  error_with_cfn ("conversion to integer value failed");
+                  break;
                 }
             }
-          else
-            retval = Array<int> (a);
         }
+      else
+        retval = Array<int> (a);
     }
 
-
-  if (error_state)
-    return retval;
-  else
-    return retval.reshape (make_vector_dims (retval.dims (),
-                                             force_vector_conversion,
-                                             type_name (), "integer vector"));
+  return retval.reshape (make_vector_dims (retval.dims (),
+                                           force_vector_conversion,
+                                           type_name (), "integer vector"));
 }
 
 template <class T>
@@ -1819,36 +1767,30 @@
   else
     {
       const NDArray a = array_value (force_string_conv);
-      if (! error_state)
+
+      if (require_int)
         {
-          if (require_int)
+          retval.resize (a.dims ());
+          for (octave_idx_type i = 0; i < a.numel (); i++)
             {
-              retval.resize (a.dims ());
-              for (octave_idx_type i = 0; i < a.numel (); i++)
+              double ai = a.elem (i);
+              octave_idx_type v = static_cast<octave_idx_type> (ai);
+              if (ai == v)
+                retval.xelem (i) = v;
+              else
                 {
-                  double ai = a.elem (i);
-                  octave_idx_type v = static_cast<octave_idx_type> (ai);
-                  if (ai == v)
-                    retval.xelem (i) = v;
-                  else
-                    {
-                      error_with_cfn ("conversion to integer value failed");
-                      break;
-                    }
+                  error_with_cfn ("conversion to integer value failed");
+                  break;
                 }
             }
-          else
-            retval = Array<octave_idx_type> (a);
         }
+      else
+        retval = Array<octave_idx_type> (a);
     }
 
-
-  if (error_state)
-    return retval;
-  else
-    return retval.reshape (make_vector_dims (retval.dims (),
-                                             force_vector_conversion,
-                                             type_name (), "integer vector"));
+  return retval.reshape (make_vector_dims (retval.dims (),
+                                           force_vector_conversion,
+                                           type_name (), "integer vector"));
 }
 
 Array<Complex>
@@ -1857,12 +1799,9 @@
 {
   Array<Complex> retval = complex_array_value (force_string_conv);
 
-  if (error_state)
-    return retval;
-  else
-    return retval.reshape (make_vector_dims (retval.dims (),
-                                             force_vector_conversion,
-                                             type_name (), "complex vector"));
+  return retval.reshape (make_vector_dims (retval.dims (),
+                                           force_vector_conversion,
+                                           type_name (), "complex vector"));
 }
 
 FloatColumnVector
@@ -1904,12 +1843,9 @@
 {
   Array<float> retval = float_array_value (force_string_conv);
 
-  if (error_state)
-    return retval;
-  else
-    return retval.reshape (make_vector_dims (retval.dims (),
-                                             force_vector_conversion,
-                                             type_name (), "real vector"));
+  return retval.reshape (make_vector_dims (retval.dims (),
+                                           force_vector_conversion,
+                                           type_name (), "real vector"));
 }
 
 Array<FloatComplex>
@@ -1918,14 +1854,163 @@
 {
   Array<FloatComplex> retval = float_complex_array_value (force_string_conv);
 
-  if (error_state)
-    return retval;
-  else
-    return retval.reshape (make_vector_dims (retval.dims (),
-                                             force_vector_conversion,
-                                             type_name (), "complex vector"));
+  return retval.reshape (make_vector_dims (retval.dims (),
+                                           force_vector_conversion,
+                                           type_name (), "complex vector"));
 }
 
+// NAME can't always be "x ## FCN" because some of the original
+// value extraction functions perform implicit type conversions that we
+// wish to avoid for these functions.
+
+#define XVALUE_EXTRACTOR(TYPE, NAME, FCN) \
+  TYPE \
+  octave_value::NAME (const char *fmt, ...) const \
+  { \
+    TYPE retval; \
+ \
+    try \
+      { \
+        retval = FCN (); \
+      } \
+    catch (octave_execution_exception& e) \
+      { \
+        if (fmt) \
+          { \
+            va_list args; \
+            va_start (args, fmt); \
+            verror (e, fmt, args); \
+            va_end (args); \
+          } \
+ \
+        throw e; \
+      } \
+ \
+    return retval; \
+  }
+
+XVALUE_EXTRACTOR (short int, xshort_value, short_value)
+
+XVALUE_EXTRACTOR (unsigned short int, xushort_value, ushort_value)
+
+XVALUE_EXTRACTOR (int, xint_value, int_value)
+
+XVALUE_EXTRACTOR (unsigned int, xuint_value, uint_value)
+
+XVALUE_EXTRACTOR (int, xnint_value, nint_value)
+
+XVALUE_EXTRACTOR (long int, xlong_value, long_value)
+
+XVALUE_EXTRACTOR (unsigned long int, xulong_value, ulong_value)
+
+XVALUE_EXTRACTOR (int64_t, xint64_value, int64_value)
+
+XVALUE_EXTRACTOR (uint64_t, xuint64_value, uint64_value)
+
+XVALUE_EXTRACTOR (octave_idx_type, xidx_type_value, idx_type_value)
+
+XVALUE_EXTRACTOR (double, xdouble_value, double_value)
+XVALUE_EXTRACTOR (float, xfloat_value, float_value)
+
+XVALUE_EXTRACTOR (double, xscalar_value, scalar_value)
+XVALUE_EXTRACTOR (float, xfloat_scalar_value, float_scalar_value)
+
+XVALUE_EXTRACTOR (Matrix, xmatrix_value, matrix_value)
+XVALUE_EXTRACTOR (FloatMatrix, xfloat_matrix_value, float_matrix_value)
+
+XVALUE_EXTRACTOR (NDArray, xarray_value, array_value)
+XVALUE_EXTRACTOR (FloatNDArray, xfloat_array_value, float_array_value)
+
+XVALUE_EXTRACTOR (Complex, xcomplex_value, complex_value)
+XVALUE_EXTRACTOR (FloatComplex, xfloat_complex_value, float_complex_value)
+
+XVALUE_EXTRACTOR (ComplexMatrix, xcomplex_matrix_value, complex_matrix_value)
+XVALUE_EXTRACTOR (FloatComplexMatrix, xfloat_complex_matrix_value, float_complex_matrix_value)
+
+XVALUE_EXTRACTOR (ComplexNDArray, xcomplex_array_value, complex_array_value)
+XVALUE_EXTRACTOR (FloatComplexNDArray, xfloat_complex_array_value, float_complex_array_value)
+
+XVALUE_EXTRACTOR (bool, xbool_value, bool_value)
+XVALUE_EXTRACTOR (boolMatrix, xbool_matrix_value, bool_matrix_value)
+XVALUE_EXTRACTOR (boolNDArray, xbool_array_value, bool_array_value)
+
+XVALUE_EXTRACTOR (charMatrix, xchar_matrix_value, char_matrix_value)
+XVALUE_EXTRACTOR (charNDArray, xchar_array_value, char_array_value)
+
+XVALUE_EXTRACTOR (SparseMatrix, xsparse_matrix_value, sparse_matrix_value)
+XVALUE_EXTRACTOR (SparseComplexMatrix, xsparse_complex_matrix_value, sparse_complex_matrix_value)
+XVALUE_EXTRACTOR (SparseBoolMatrix, xsparse_bool_matrix_value, sparse_bool_matrix_value)
+
+XVALUE_EXTRACTOR (DiagMatrix, xdiag_matrix_value, diag_matrix_value)
+XVALUE_EXTRACTOR (FloatDiagMatrix, xfloat_diag_matrix_value, float_diag_matrix_value)
+XVALUE_EXTRACTOR (ComplexDiagMatrix, xcomplex_diag_matrix_value, complex_diag_matrix_value)
+XVALUE_EXTRACTOR (FloatComplexDiagMatrix, xfloat_complex_diag_matrix_value, float_complex_diag_matrix_value)
+
+XVALUE_EXTRACTOR (PermMatrix, xperm_matrix_value, perm_matrix_value)
+
+XVALUE_EXTRACTOR (octave_int8, xint8_scalar_value, int8_scalar_value)
+XVALUE_EXTRACTOR (octave_int16, xint16_scalar_value, int16_scalar_value)
+XVALUE_EXTRACTOR (octave_int32, xint32_scalar_value, int32_scalar_value)
+XVALUE_EXTRACTOR (octave_int64, xint64_scalar_value, int64_scalar_value)
+
+XVALUE_EXTRACTOR (octave_uint8, xuint8_scalar_value, uint8_scalar_value)
+XVALUE_EXTRACTOR (octave_uint16, xuint16_scalar_value, uint16_scalar_value)
+XVALUE_EXTRACTOR (octave_uint32, xuint32_scalar_value, uint32_scalar_value)
+XVALUE_EXTRACTOR (octave_uint64, xuint64_scalar_value, uint64_scalar_value)
+
+XVALUE_EXTRACTOR (int8NDArray, xint8_array_value, int8_array_value)
+XVALUE_EXTRACTOR (int16NDArray, xint16_array_value, int16_array_value)
+XVALUE_EXTRACTOR (int32NDArray, xint32_array_value, int32_array_value)
+XVALUE_EXTRACTOR (int64NDArray, xint64_array_value, int64_array_value)
+
+XVALUE_EXTRACTOR (uint8NDArray, xuint8_array_value, uint8_array_value)
+XVALUE_EXTRACTOR (uint16NDArray, xuint16_array_value, uint16_array_value)
+XVALUE_EXTRACTOR (uint32NDArray, xuint32_array_value, uint32_array_value)
+XVALUE_EXTRACTOR (uint64NDArray, xuint64_array_value, uint64_array_value)
+
+XVALUE_EXTRACTOR (std::string, xstring_value, rep->xstring_value)
+XVALUE_EXTRACTOR (string_vector, xall_strings, all_strings)
+
+XVALUE_EXTRACTOR (Cell, xcell_value, cell_value)
+XVALUE_EXTRACTOR (Array<std::string>, xcellstr_value, cellstr_value)
+
+XVALUE_EXTRACTOR (Range, xrange_value, range_value)
+
+XVALUE_EXTRACTOR (octave_map, xmap_value, map_value)
+XVALUE_EXTRACTOR (octave_scalar_map, xscalar_map_value, scalar_map_value)
+
+XVALUE_EXTRACTOR (ColumnVector, xcolumn_vector_value, column_vector_value)
+XVALUE_EXTRACTOR (ComplexColumnVector, xcomplex_column_vector_value, complex_column_vector_value)
+
+XVALUE_EXTRACTOR (RowVector, xrow_vector_value, row_vector_value)
+XVALUE_EXTRACTOR (ComplexRowVector, xcomplex_row_vector_value, complex_row_vector_value)
+
+XVALUE_EXTRACTOR (FloatColumnVector, xfloat_column_vector_value, float_column_vector_value)
+XVALUE_EXTRACTOR (FloatComplexColumnVector, xfloat_complex_column_vector_value, float_complex_column_vector_value)
+
+XVALUE_EXTRACTOR (FloatRowVector, xfloat_row_vector_value, float_row_vector_value)
+XVALUE_EXTRACTOR (FloatComplexRowVector, xfloat_complex_row_vector_value, float_complex_row_vector_value)
+
+XVALUE_EXTRACTOR (Array<int>, xint_vector_value, int_vector_value)
+XVALUE_EXTRACTOR (Array<octave_idx_type>, xoctave_idx_type_vector_value, octave_idx_type_vector_value)
+
+XVALUE_EXTRACTOR (Array<double>, xvector_value, vector_value)
+XVALUE_EXTRACTOR (Array<Complex>, xcomplex_vector_value, complex_vector_value)
+
+XVALUE_EXTRACTOR (Array<float>, xfloat_vector_value, float_vector_value)
+XVALUE_EXTRACTOR (Array<FloatComplex>, xfloat_complex_vector_value, float_complex_vector_value)
+
+XVALUE_EXTRACTOR (octave_function *, xfunction_value, function_value)
+XVALUE_EXTRACTOR (octave_user_function *, xuser_function_value, user_function_value)
+XVALUE_EXTRACTOR (octave_user_script *, xuser_script_value, user_script_value)
+XVALUE_EXTRACTOR (octave_user_code *, xuser_code_value, user_code_value)
+XVALUE_EXTRACTOR (octave_fcn_handle *, xfcn_handle_value, fcn_handle_value)
+XVALUE_EXTRACTOR (octave_fcn_inline *, xfcn_inline_value, fcn_inline_value)
+
+XVALUE_EXTRACTOR (octave_value_list, xlist_value, list_value)
+
+#undef XVALUE_EXTRACTOR
+
 octave_value
 octave_value::storable_value (void) const
 {
@@ -1993,14 +2078,7 @@
 
       if (f)
         {
-          try
-            {
-              retval = f (v1, v2);
-            }
-          catch (octave_execution_exception)
-            {
-              gripe_library_execution_error ();
-            }
+          retval = f (v1, v2);
         }
       else
         gripe_binary_op (octave_value::binary_op_as_string (op),
@@ -2015,16 +2093,7 @@
         = octave_value_typeinfo::lookup_binary_op (op, t1, t2);
 
       if (f)
-        {
-          try
-            {
-              retval = f (*v1.rep, *v2.rep);
-            }
-          catch (octave_execution_exception)
-            {
-              gripe_library_execution_error ();
-            }
-        }
+        retval = f (*v1.rep, *v2.rep);
       else
         {
           octave_value tv1;
@@ -2143,16 +2212,7 @@
                   f = octave_value_typeinfo::lookup_binary_op (op, t1, t2);
 
                   if (f)
-                    {
-                      try
-                        {
-                          retval = f (*tv1.rep, *tv2.rep);
-                        }
-                      catch (octave_execution_exception)
-                        {
-                          gripe_library_execution_error ();
-                        }
-                    }
+                    retval = f (*tv1.rep, *tv2.rep);
                   else
                     gripe_binary_op (octave_value::binary_op_as_string (op),
                                      v1.type_name (), v2.type_name ());
@@ -2251,16 +2311,7 @@
         = octave_value_typeinfo::lookup_binary_class_op (op);
 
       if (f)
-        {
-          try
-            {
-              retval = f (v1, v2);
-            }
-          catch (octave_execution_exception)
-            {
-              gripe_library_execution_error ();
-            }
-        }
+        retval = f (v1, v2);
       else
         retval = decompose_binary_op (op, v1, v2);
     }
@@ -2270,16 +2321,7 @@
         = octave_value_typeinfo::lookup_binary_op (op, t1, t2);
 
       if (f)
-        {
-          try
-            {
-              retval = f (*v1.rep, *v2.rep);
-            }
-          catch (octave_execution_exception)
-            {
-              gripe_library_execution_error ();
-            }
-        }
+        retval = f (*v1.rep, *v2.rep);
       else
         retval = decompose_binary_op (op, v1, v2);
     }
@@ -2316,16 +2358,7 @@
     = octave_value_typeinfo::lookup_cat_op (t1, t2);
 
   if (f)
-    {
-      try
-        {
-          retval = f (*v1.rep, *v2.rep, ra_idx);
-        }
-      catch (octave_execution_exception)
-        {
-          gripe_library_execution_error ();
-        }
-    }
+    retval = f (*v1.rep, *v2.rep, ra_idx);
   else
     {
       octave_value tv1;
@@ -2435,30 +2468,35 @@
       bool result_is_str = (base.is_string () && limit.is_string ());
       bool dq_str = (base.is_dq_string () || limit.is_dq_string ());
 
-      Matrix m_base = base.matrix_value (true);
-
-      if (error_state)
+      Matrix m_base, m_limit, m_increment;
+
+      try
         {
-          error ("invalid base value in colon expression");
-          return retval;
+          m_base = base.matrix_value (true);
         }
-
-      Matrix m_limit = limit.matrix_value (true);
-
-      if (error_state)
+      catch (octave_execution_exception& e)
+        {
+          error (e, "invalid base value in colon expression");
+        }
+
+      try
         {
-          error ("invalid limit value in colon expression");
-          return retval;
+          m_limit = limit.matrix_value (true);
+        }
+      catch (octave_execution_exception& e)
+        {
+          error (e, "invalid limit value in colon expression");
         }
 
-      Matrix m_increment = (increment.is_defined ()
-                            ? increment.matrix_value (true)
-                            : Matrix (1, 1, 1.0));
-
-      if (error_state)
+      try
         {
-          error ("invalid increment value in colon expression");
-          return retval;
+          m_increment = (increment.is_defined ()
+                         ? increment.matrix_value (true)
+                         : Matrix (1, 1, 1.0));
+        }
+      catch (octave_execution_exception& e)
+        {
+          error (e, "invalid increment value in colon expression");
         }
 
       bool base_empty = m_base.is_empty ();
@@ -2521,16 +2559,7 @@
         = octave_value_typeinfo::lookup_unary_class_op (op);
 
       if (f)
-        {
-          try
-            {
-              retval = f (v);
-            }
-          catch (octave_execution_exception)
-            {
-              gripe_library_execution_error ();
-            }
-        }
+        retval = f (v);
       else
         gripe_unary_op (octave_value::unary_op_as_string (op),
                         v.class_name ());
@@ -2544,16 +2573,7 @@
         = octave_value_typeinfo::lookup_unary_op (op, t);
 
       if (f)
-        {
-          try
-            {
-              retval = f (*v.rep);
-            }
-          catch (octave_execution_exception)
-            {
-              gripe_library_execution_error ();
-            }
-        }
+        retval = f (*v.rep);
       else
         {
           octave_value tv;
@@ -2615,14 +2635,7 @@
         {
           make_unique ();
 
-          try
-            {
-              f (*rep);
-            }
-          catch (octave_execution_exception)
-            {
-              gripe_library_execution_error ();
-            }
+          f (*rep);
         }
       else
         {
@@ -2643,14 +2656,7 @@
 
                   if (f)
                     {
-                      try
-                        {
-                          f (*rep);
-                        }
-                      catch (octave_execution_exception)
-                        {
-                          gripe_library_execution_error ();
-                        }
+                      f (*rep);
 
                       if (old_rep && --old_rep->count == 0)
                         delete old_rep;
@@ -2690,16 +2696,7 @@
         f = octave_value_typeinfo::lookup_non_const_unary_op (op, t);
 
       if (f)
-        {
-          try
-            {
-              f (*rep);
-            }
-          catch (octave_execution_exception)
-            {
-              gripe_library_execution_error ();
-            }
-        }
+        f (*rep);
       else
         *this = do_unary_op (op, *this);
     }
@@ -2930,14 +2927,10 @@
 @seealso{whos}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).byte_size ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).byte_size ());
 }
 
 /*
@@ -2951,10 +2944,9 @@
                    std::string& type_string,
                    std::list<octave_value_list>& idx)
 {
-  const octave_map m = arg.map_value ();
-
-  if (! error_state
-      && m.nfields () == 2 && m.contains ("type") && m.contains ("subs"))
+  const octave_map m = arg.xmap_value ("%s: second argument must be a structure with fields 'type' and 'subs'", name);
+
+  if (m.nfields () == 2 && m.contains ("type") && m.contains ("subs"))
     {
       octave_idx_type nel = m.numel ();
 
@@ -2969,24 +2961,17 @@
 
       for (int k = 0; k < nel; k++)
         {
-          if (type(k).is_string ())
-            {
-              std::string item = type(k).string_value ();
-              if (item == "{}")
-                type_string[k] = '{';
-              else if (item == "()")
-                type_string[k] = '(';
-              else if (item == ".")
-                type_string[k] = '.';
-              else
-                {
-                  error ("%s: invalid indexing type '%s'", name, item.c_str ());
-                  return;
-                }
-            }
+          std::string item = type(k).xstring_value ("%s: type(%d) must be a string", name, k+1);
+
+          if (item == "{}")
+            type_string[k] = '{';
+          else if (item == "()")
+            type_string[k] = '(';
+          else if (item == ".")
+            type_string[k] = '.';
           else
             {
-              error ("%s: type(%d) must be a string", name, k+1);
+              error ("%s: invalid indexing type '%s'", name, item.c_str ());
               return;
             }
 
@@ -2998,7 +2983,7 @@
             {
               Cell subs_cell = subs(k).cell_value ();
 
-              for (int n = 0; n < subs_cell.length (); n++)
+              for (int n = 0; n < subs_cell.numel (); n++)
                 {
                   if (subs_cell(n).is_string ()
                       && subs_cell(n).string_value () == ":")
@@ -3059,25 +3044,20 @@
 {
   octave_value_list retval;
 
-  if (args.length () == 2)
-    {
-      std::string type;
-      std::list<octave_value_list> idx;
-
-      decode_subscripts ("subsref", args(1), type, idx);
-
-      if (! error_state)
-        {
-          octave_value arg0 = args(0);
-
-          if (type.empty ())
-            retval = arg0;
-          else
-            retval = arg0.subsref (type, idx, nargout);
-        }
-    }
+  if (args.length () != 2)
+    print_usage ();
+
+  std::string type;
+  std::list<octave_value_list> idx;
+
+  decode_subscripts ("subsref", args(1), type, idx);
+
+  octave_value arg0 = args(0);
+
+  if (type.empty ())
+    retval = arg0;
   else
-    print_usage ();
+    retval = arg0.subsref (type, idx, nargout);
 
   return retval;
 }
@@ -3117,34 +3097,28 @@
 {
   octave_value retval;
 
-  if (args.length () == 3)
+  if (args.length () != 3)
+    print_usage ();
+
+  std::string type;
+  std::list<octave_value_list> idx;
+
+  decode_subscripts ("subsasgn", args(1), type, idx);
+
+  if (type.empty ())
     {
-      std::string type;
-      std::list<octave_value_list> idx;
-
-      decode_subscripts ("subsasgn", args(1), type, idx);
-
-      if (! error_state)
-        {
-          if (type.empty ())
-            {
-              // Regularize a null matrix if stored into a variable.
-
-              retval = args(2).storable_value ();
-            }
-          else
-            {
-              octave_value arg0 = args(0);
-
-              arg0.make_unique ();
-
-              if (! error_state)
-                retval= arg0.subsasgn (type, idx, args(2));
-            }
-        }
+      // Regularize a null matrix if stored into a variable.
+
+      retval = args(2).storable_value ();
     }
   else
-    print_usage ();
+    {
+      octave_value arg0 = args(0);
+
+      arg0.make_unique ();
+
+      retval= arg0.subsasgn (type, idx, args(2));
+    }
 
   return retval;
 }
@@ -3223,14 +3197,10 @@
 @seealso{is_dq_string, ischar}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_sq_string ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_sq_string ());
 }
 
 /*
@@ -3250,14 +3220,10 @@
 @seealso{is_sq_string, ischar}\n\
 @end deftypefn")
 {
-  octave_value retval;
-
-  if (args.length () == 1)
-    retval = args(0).is_dq_string ();
-  else
+  if (args.length () != 1)
     print_usage ();
 
-  return retval;
+  return octave_value (args(0).is_dq_string ());
 }
 
 /*
--- a/libinterp/octave-value/ov.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave-value/ov.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ov_h)
+#if ! defined (octave_ov_h)
 #define octave_ov_h 1
 
 #include <cstdlib>
@@ -483,8 +483,8 @@
   octave_idx_type numel (void) const
   { return rep->numel (); }
 
-  octave_idx_type capacity (void) const
-  { return rep->capacity (); }
+  GCC_ATTR_DEPRECATED octave_idx_type capacity (void) const
+  { return rep->numel (); }
 
   size_t byte_size (void) const
   { return rep->byte_size (); }
@@ -768,8 +768,6 @@
   float float_scalar_value (bool frc_str_conv = false) const
   { return rep->float_scalar_value (frc_str_conv); }
 
-  Cell cell_value (void) const;
-
   Matrix matrix_value (bool frc_str_conv = false) const
   { return rep->matrix_value (frc_str_conv); }
 
@@ -891,11 +889,13 @@
   uint64NDArray uint64_array_value (void) const
   { return rep->uint64_array_value (); }
 
+  std::string string_value (bool force = false) const
+  { return rep->string_value (force); }
+
   string_vector all_strings (bool pad = false) const
   { return rep->all_strings (pad); }
 
-  std::string string_value (bool force = false) const
-  { return rep->string_value (force); }
+  Cell cell_value (void) const;
 
   Array<std::string> cellstr_value (void) const
   { return rep->cellstr_value (); }
@@ -994,6 +994,176 @@
   float_complex_vector_value (bool frc_str_conv = false,
                               bool frc_vec_conv = false) const;
 
+  // Extract values of specific types without any implicit type
+  // conversions.  Throw an error if an object is the wrong type for
+  // the requested value extraction.
+  //
+  // These functions are intended to provide a simple way to extract
+  // values of specific types and display error messages that are more
+  // meaningful than the generic "error: wrong type argument 'cell'"
+  // message.
+
+  short int xshort_value (const char *fmt, ...) const;
+
+  unsigned short int xushort_value (const char *fmt, ...) const;
+
+  int xint_value (const char *fmt, ...) const;
+
+  unsigned int xuint_value (const char *fmt, ...) const;
+
+  int xnint_value (const char *fmt, ...) const;
+
+  long int xlong_value (const char *fmt, ...) const;
+
+  unsigned long int xulong_value (const char *fmt, ...) const;
+
+  int64_t xint64_value (const char *fmt, ...) const;
+
+  uint64_t xuint64_value (const char *fmt, ...) const;
+
+  octave_idx_type xidx_type_value (const char *fmt, ...) const;
+
+  double xdouble_value (const char *fmt, ...) const;
+
+  float xfloat_value (const char *fmt, ...) const;
+
+  double xscalar_value (const char *fmt, ...) const;
+
+  float xfloat_scalar_value (const char *fmt, ...) const;
+
+  Matrix xmatrix_value (const char *fmt, ...) const;
+
+  FloatMatrix xfloat_matrix_value (const char *fmt, ...) const;
+
+  NDArray xarray_value (const char *fmt, ...) const;
+
+  FloatNDArray xfloat_array_value (const char *fmt, ...) const;
+
+  Complex xcomplex_value (const char *fmt, ...) const;
+
+  FloatComplex xfloat_complex_value (const char *fmt, ...) const;
+
+  ComplexMatrix xcomplex_matrix_value (const char *fmt, ...) const;
+
+  FloatComplexMatrix xfloat_complex_matrix_value (const char *fmt, ...) const;
+
+  ComplexNDArray xcomplex_array_value (const char *fmt, ...) const;
+
+  FloatComplexNDArray xfloat_complex_array_value (const char *fmt, ...) const;
+
+  bool xbool_value (const char *fmt, ...) const;
+
+  boolMatrix xbool_matrix_value (const char *fmt, ...) const;
+
+  boolNDArray xbool_array_value (const char *fmt, ...) const;
+
+  charMatrix xchar_matrix_value (const char *fmt, ...) const;
+
+  charNDArray xchar_array_value (const char *fmt, ...) const;
+
+  SparseMatrix xsparse_matrix_value (const char *fmt, ...) const;
+
+  SparseComplexMatrix xsparse_complex_matrix_value (const char *fmt, ...) const;
+
+  SparseBoolMatrix xsparse_bool_matrix_value (const char *fmt, ...) const;
+
+  DiagMatrix xdiag_matrix_value (const char *fmt, ...) const;
+
+  FloatDiagMatrix xfloat_diag_matrix_value (const char *fmt, ...) const;
+
+  ComplexDiagMatrix xcomplex_diag_matrix_value (const char *fmt, ...) const;
+
+  FloatComplexDiagMatrix xfloat_complex_diag_matrix_value (const char *fmt, ...) const;
+
+  PermMatrix xperm_matrix_value (const char *fmt, ...) const;
+
+  octave_int8 xint8_scalar_value (const char *fmt, ...) const;
+
+  octave_int16 xint16_scalar_value (const char *fmt, ...) const;
+
+  octave_int32 xint32_scalar_value (const char *fmt, ...) const;
+
+  octave_int64 xint64_scalar_value (const char *fmt, ...) const;
+
+  octave_uint8 xuint8_scalar_value (const char *fmt, ...) const;
+
+  octave_uint16 xuint16_scalar_value (const char *fmt, ...) const;
+
+  octave_uint32 xuint32_scalar_value (const char *fmt, ...) const;
+
+  octave_uint64 xuint64_scalar_value (const char *fmt, ...) const;
+
+  int8NDArray xint8_array_value (const char *fmt, ...) const;
+
+  int16NDArray xint16_array_value (const char *fmt, ...) const;
+
+  int32NDArray xint32_array_value (const char *fmt, ...) const;
+
+  int64NDArray xint64_array_value (const char *fmt, ...) const;
+
+  uint8NDArray xuint8_array_value (const char *fmt, ...) const;
+
+  uint16NDArray xuint16_array_value (const char *fmt, ...) const;
+
+  uint32NDArray xuint32_array_value (const char *fmt, ...) const;
+
+  uint64NDArray xuint64_array_value (const char *fmt, ...) const;
+
+  std::string xstring_value (const char *fmt, ...) const;
+
+  string_vector xall_strings (const char *fmt, ...) const;
+
+  Cell xcell_value (const char *fmt, ...) const;
+
+  Array<std::string> xcellstr_value (const char *fmt, ...) const;
+
+  Range xrange_value (const char *fmt, ...) const;
+
+  octave_map xmap_value (const char *fmt, ...) const;
+
+  octave_scalar_map xscalar_map_value (const char *fmt, ...) const;
+
+  ColumnVector xcolumn_vector_value (const char *fmt, ...) const;
+
+  ComplexColumnVector
+  xcomplex_column_vector_value (const char *fmt, ...) const;
+
+  RowVector xrow_vector_value (const char *fmt, ...) const;
+
+  ComplexRowVector xcomplex_row_vector_value (const char *fmt, ...) const;
+
+  FloatColumnVector xfloat_column_vector_value (const char *fmt, ...) const;
+
+  FloatComplexColumnVector
+  xfloat_complex_column_vector_value (const char *fmt, ...) const;
+
+  FloatRowVector xfloat_row_vector_value (const char *fmt, ...) const;
+
+  FloatComplexRowVector
+  xfloat_complex_row_vector_value (const char *fmt, ...) const;
+
+  Array<int> xint_vector_value (const char *fmt, ...) const;
+
+  Array<octave_idx_type>
+  xoctave_idx_type_vector_value (const char *fmt, ...) const;
+
+  Array<double> xvector_value (const char *fmt, ...) const;
+
+  Array<Complex> xcomplex_vector_value (const char *fmt, ...) const;
+
+  Array<float> xfloat_vector_value (const char *fmt, ...) const;
+
+  Array<FloatComplex> xfloat_complex_vector_value (const char *fmt, ...) const;
+
+  octave_function *xfunction_value (const char *fmt, ...) const;
+  octave_user_function *xuser_function_value (const char *fmt, ...) const;
+  octave_user_script *xuser_script_value (const char *fmt, ...) const;
+  octave_user_code *xuser_code_value (const char *fmt, ...) const;
+  octave_fcn_handle *xfcn_handle_value (const char *fmt, ...) const;
+  octave_fcn_inline *xfcn_inline_value (const char *fmt, ...) const;
+
+  octave_value_list xlist_value (const char *fmt, ...) const;
+
   // Possibly economize a lazy-indexed value.
 
   void maybe_economize (void)
@@ -1360,12 +1530,6 @@
 
 extern OCTINTERP_API void install_types (void);
 
-// This will eventually go away, but for now it can be used to
-// simplify the transition to the new octave_value class hierarchy,
-// which uses octave_base_value instead of octave_value for the type
-// of octave_value::rep.
-#define OV_REP_TYPE octave_base_value
-
 // Templated value extractors.
 template<class Value>
 inline Value octave_value_extract (const octave_value&)
--- a/libinterp/octave.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -279,16 +279,19 @@
     {
       source_file (file_name, context, verbose, require_file, warn_for);
     }
-  catch (octave_interrupt_exception)
+  catch (const octave_interrupt_exception&)
     {
       recover_from_exception ();
+
       octave_stdout << "\n";
+
       if (quitting_gracefully)
         clean_up_and_exit (exit_status);
     }
-  catch (octave_execution_exception)
+  catch (const octave_execution_exception&)
     {
       recover_from_exception ();
+
       gripe_safe_source_exception (file_name, "unhandled execution exception");
     }
 }
@@ -394,16 +397,19 @@
     {
       eval_string (code, false, parse_status, 0);
     }
-  catch (octave_interrupt_exception)
+  catch (const octave_interrupt_exception&)
     {
       recover_from_exception ();
+
       octave_stdout << "\n";
+
       if (quitting_gracefully)
         clean_up_and_exit (exit_status);
     }
-  catch (octave_execution_exception)
+  catch (const octave_execution_exception&)
     {
       recover_from_exception ();
+
       std::cerr << "error: unhandled execution exception -- eval failed"
                 << std::endl;
     }
@@ -857,13 +863,24 @@
   // Execute any code specified with --eval 'CODE'
   if (! code_to_eval.empty ())
     {
-      int parse_status = execute_eval_option_code (code_to_eval);
+      int parse_status = 0;
+
+      try
+        {
+          parse_status = execute_eval_option_code (code_to_eval);
+        }
+      catch (const octave_execution_exception&)
+        {
+          recover_from_exception ();
+
+          parse_status = 1;
+        }
 
       if (! persist)
         {
           quitting_gracefully = true;
 
-          clean_up_and_exit (parse_status || error_state ? 1 : 0);
+          clean_up_and_exit (parse_status);
         }
     }
 
@@ -878,15 +895,26 @@
       // If we are running an executable script (#! /bin/octave) then
       // we should only see the args passed to the script.
 
-      intern_argv (remaining_args, octave_cmdline_argv+last_arg_idx);
+      exit_status = 0;
+
+      try
+        {
+          intern_argv (remaining_args, octave_cmdline_argv+last_arg_idx);
 
-      execute_command_line_file (octave_cmdline_argv[last_arg_idx]);
+          execute_command_line_file (octave_cmdline_argv[last_arg_idx]);
+        }
+      catch (const octave_execution_exception&)
+        {
+          recover_from_exception ();
+
+          exit_status = 1;
+        }
 
       if (! persist)
         {
           quitting_gracefully = true;
 
-          clean_up_and_exit (error_state ? 1 : 0);
+          clean_up_and_exit (exit_status);
         }
     }
 
--- a/libinterp/octave.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/octave.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_octave_h)
+#if ! defined (octave_octave_h)
 #define octave_octave_h 1
 
 #ifdef  __cplusplus
--- a/libinterp/operators/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,145 +1,142 @@
-EXTRA_DIST += operators/module.mk
-
-OPERATORS_SRC = \
-  operators/op-b-b.cc \
-  operators/op-b-bm.cc \
-  operators/op-b-sbm.cc \
-  operators/op-bm-b.cc \
-  operators/op-bm-bm.cc \
-  operators/op-bm-sbm.cc \
-  operators/op-cdm-cdm.cc \
-  operators/op-cdm-cm.cc \
-  operators/op-cdm-cs.cc \
-  operators/op-cdm-dm.cc \
-  operators/op-cdm-m.cc \
-  operators/op-cdm-s.cc \
-  operators/op-cell.cc \
-  operators/op-chm.cc \
-  operators/op-class.cc \
-  operators/op-cm-cdm.cc \
-  operators/op-cm-cm.cc \
-  operators/op-cm-cs.cc \
-  operators/op-cm-dm.cc \
-  operators/op-cm-m.cc \
-  operators/op-cm-pm.cc \
-  operators/op-cm-s.cc \
-  operators/op-cm-scm.cc \
-  operators/op-cm-sm.cc \
-  operators/op-cs-cm.cc \
-  operators/op-cs-cs.cc \
-  operators/op-cs-m.cc \
-  operators/op-cs-s.cc \
-  operators/op-cs-scm.cc \
-  operators/op-cs-sm.cc \
-  operators/op-dm-cdm.cc \
-  operators/op-dm-cm.cc \
-  operators/op-dm-cs.cc \
-  operators/op-dm-dm.cc \
-  operators/op-dm-m.cc \
-  operators/op-dm-s.cc \
-  operators/op-dm-scm.cc \
-  operators/op-dm-sm.cc \
-  operators/op-double-conv.cc \
-  operators/op-fcdm-fcdm.cc \
-  operators/op-fcdm-fcm.cc \
-  operators/op-fcdm-fcs.cc \
-  operators/op-fcdm-fdm.cc \
-  operators/op-fcdm-fm.cc \
-  operators/op-fcdm-fs.cc \
-  operators/op-fcm-fcdm.cc \
-  operators/op-fcm-fcm.cc \
-  operators/op-fcm-fcs.cc \
-  operators/op-fcm-fdm.cc \
-  operators/op-fcm-fm.cc \
-  operators/op-fcm-fs.cc \
-  operators/op-fcm-pm.cc \
-  operators/op-fcn.cc \
-  operators/op-fcs-fcm.cc \
-  operators/op-fcs-fcs.cc \
-  operators/op-fcs-fm.cc \
-  operators/op-fcs-fs.cc \
-  operators/op-fdm-fcdm.cc \
-  operators/op-fdm-fcm.cc \
-  operators/op-fdm-fcs.cc \
-  operators/op-fdm-fdm.cc \
-  operators/op-fdm-fm.cc \
-  operators/op-fdm-fs.cc \
-  operators/op-float-conv.cc \
-  operators/op-fm-fcdm.cc \
-  operators/op-fm-fcm.cc \
-  operators/op-fm-fcs.cc \
-  operators/op-fm-fdm.cc \
-  operators/op-fm-fm.cc \
-  operators/op-fm-fs.cc \
-  operators/op-fm-pm.cc \
-  operators/op-fs-fcm.cc \
-  operators/op-fs-fcs.cc \
-  operators/op-fs-fm.cc \
-  operators/op-fs-fs.cc \
-  operators/op-i16-i16.cc \
-  operators/op-i32-i32.cc \
-  operators/op-i64-i64.cc \
-  operators/op-i8-i8.cc \
-  operators/op-int-concat.cc \
-  operators/op-int-conv.cc \
-  operators/op-m-cdm.cc \
-  operators/op-m-cm.cc \
-  operators/op-m-cs.cc \
-  operators/op-m-dm.cc \
-  operators/op-m-m.cc \
-  operators/op-m-pm.cc \
-  operators/op-m-s.cc \
-  operators/op-m-scm.cc \
-  operators/op-m-sm.cc \
-  operators/op-pm-cm.cc \
-  operators/op-pm-fcm.cc \
-  operators/op-pm-fm.cc \
-  operators/op-pm-m.cc \
-  operators/op-pm-pm.cc \
-  operators/op-pm-scm.cc \
-  operators/op-pm-sm.cc \
-  operators/op-range.cc \
-  operators/op-s-cm.cc \
-  operators/op-s-cs.cc \
-  operators/op-s-m.cc \
-  operators/op-s-s.cc \
-  operators/op-s-scm.cc \
-  operators/op-s-sm.cc \
-  operators/op-sbm-b.cc \
-  operators/op-sbm-bm.cc \
-  operators/op-sbm-sbm.cc \
-  operators/op-scm-cm.cc \
-  operators/op-scm-cs.cc \
-  operators/op-scm-m.cc \
-  operators/op-scm-s.cc \
-  operators/op-scm-scm.cc \
-  operators/op-scm-sm.cc \
-  operators/op-sm-cm.cc \
-  operators/op-sm-cs.cc \
-  operators/op-sm-m.cc \
-  operators/op-sm-s.cc \
-  operators/op-sm-scm.cc \
-  operators/op-sm-sm.cc \
-  operators/op-str-m.cc \
-  operators/op-str-s.cc \
-  operators/op-str-str.cc \
-  operators/op-struct.cc \
-  operators/op-ui16-ui16.cc \
-  operators/op-ui32-ui32.cc \
-  operators/op-ui64-ui64.cc \
-  operators/op-ui8-ui8.cc
+LIBINTERP_OPERATORS_SRC = \
+  libinterp/operators/op-b-b.cc \
+  libinterp/operators/op-b-bm.cc \
+  libinterp/operators/op-b-sbm.cc \
+  libinterp/operators/op-bm-b.cc \
+  libinterp/operators/op-bm-bm.cc \
+  libinterp/operators/op-bm-sbm.cc \
+  libinterp/operators/op-cdm-cdm.cc \
+  libinterp/operators/op-cdm-cm.cc \
+  libinterp/operators/op-cdm-cs.cc \
+  libinterp/operators/op-cdm-dm.cc \
+  libinterp/operators/op-cdm-m.cc \
+  libinterp/operators/op-cdm-s.cc \
+  libinterp/operators/op-cell.cc \
+  libinterp/operators/op-chm.cc \
+  libinterp/operators/op-class.cc \
+  libinterp/operators/op-cm-cdm.cc \
+  libinterp/operators/op-cm-cm.cc \
+  libinterp/operators/op-cm-cs.cc \
+  libinterp/operators/op-cm-dm.cc \
+  libinterp/operators/op-cm-m.cc \
+  libinterp/operators/op-cm-pm.cc \
+  libinterp/operators/op-cm-s.cc \
+  libinterp/operators/op-cm-scm.cc \
+  libinterp/operators/op-cm-sm.cc \
+  libinterp/operators/op-cs-cm.cc \
+  libinterp/operators/op-cs-cs.cc \
+  libinterp/operators/op-cs-m.cc \
+  libinterp/operators/op-cs-s.cc \
+  libinterp/operators/op-cs-scm.cc \
+  libinterp/operators/op-cs-sm.cc \
+  libinterp/operators/op-dm-cdm.cc \
+  libinterp/operators/op-dm-cm.cc \
+  libinterp/operators/op-dm-cs.cc \
+  libinterp/operators/op-dm-dm.cc \
+  libinterp/operators/op-dm-m.cc \
+  libinterp/operators/op-dm-s.cc \
+  libinterp/operators/op-dm-scm.cc \
+  libinterp/operators/op-dm-sm.cc \
+  libinterp/operators/op-double-conv.cc \
+  libinterp/operators/op-fcdm-fcdm.cc \
+  libinterp/operators/op-fcdm-fcm.cc \
+  libinterp/operators/op-fcdm-fcs.cc \
+  libinterp/operators/op-fcdm-fdm.cc \
+  libinterp/operators/op-fcdm-fm.cc \
+  libinterp/operators/op-fcdm-fs.cc \
+  libinterp/operators/op-fcm-fcdm.cc \
+  libinterp/operators/op-fcm-fcm.cc \
+  libinterp/operators/op-fcm-fcs.cc \
+  libinterp/operators/op-fcm-fdm.cc \
+  libinterp/operators/op-fcm-fm.cc \
+  libinterp/operators/op-fcm-fs.cc \
+  libinterp/operators/op-fcm-pm.cc \
+  libinterp/operators/op-fcn.cc \
+  libinterp/operators/op-fcs-fcm.cc \
+  libinterp/operators/op-fcs-fcs.cc \
+  libinterp/operators/op-fcs-fm.cc \
+  libinterp/operators/op-fcs-fs.cc \
+  libinterp/operators/op-fdm-fcdm.cc \
+  libinterp/operators/op-fdm-fcm.cc \
+  libinterp/operators/op-fdm-fcs.cc \
+  libinterp/operators/op-fdm-fdm.cc \
+  libinterp/operators/op-fdm-fm.cc \
+  libinterp/operators/op-fdm-fs.cc \
+  libinterp/operators/op-float-conv.cc \
+  libinterp/operators/op-fm-fcdm.cc \
+  libinterp/operators/op-fm-fcm.cc \
+  libinterp/operators/op-fm-fcs.cc \
+  libinterp/operators/op-fm-fdm.cc \
+  libinterp/operators/op-fm-fm.cc \
+  libinterp/operators/op-fm-fs.cc \
+  libinterp/operators/op-fm-pm.cc \
+  libinterp/operators/op-fs-fcm.cc \
+  libinterp/operators/op-fs-fcs.cc \
+  libinterp/operators/op-fs-fm.cc \
+  libinterp/operators/op-fs-fs.cc \
+  libinterp/operators/op-i16-i16.cc \
+  libinterp/operators/op-i32-i32.cc \
+  libinterp/operators/op-i64-i64.cc \
+  libinterp/operators/op-i8-i8.cc \
+  libinterp/operators/op-int-concat.cc \
+  libinterp/operators/op-int-conv.cc \
+  libinterp/operators/op-m-cdm.cc \
+  libinterp/operators/op-m-cm.cc \
+  libinterp/operators/op-m-cs.cc \
+  libinterp/operators/op-m-dm.cc \
+  libinterp/operators/op-m-m.cc \
+  libinterp/operators/op-m-pm.cc \
+  libinterp/operators/op-m-s.cc \
+  libinterp/operators/op-m-scm.cc \
+  libinterp/operators/op-m-sm.cc \
+  libinterp/operators/op-pm-cm.cc \
+  libinterp/operators/op-pm-fcm.cc \
+  libinterp/operators/op-pm-fm.cc \
+  libinterp/operators/op-pm-m.cc \
+  libinterp/operators/op-pm-pm.cc \
+  libinterp/operators/op-pm-scm.cc \
+  libinterp/operators/op-pm-sm.cc \
+  libinterp/operators/op-range.cc \
+  libinterp/operators/op-s-cm.cc \
+  libinterp/operators/op-s-cs.cc \
+  libinterp/operators/op-s-m.cc \
+  libinterp/operators/op-s-s.cc \
+  libinterp/operators/op-s-scm.cc \
+  libinterp/operators/op-s-sm.cc \
+  libinterp/operators/op-sbm-b.cc \
+  libinterp/operators/op-sbm-bm.cc \
+  libinterp/operators/op-sbm-sbm.cc \
+  libinterp/operators/op-scm-cm.cc \
+  libinterp/operators/op-scm-cs.cc \
+  libinterp/operators/op-scm-m.cc \
+  libinterp/operators/op-scm-s.cc \
+  libinterp/operators/op-scm-scm.cc \
+  libinterp/operators/op-scm-sm.cc \
+  libinterp/operators/op-sm-cm.cc \
+  libinterp/operators/op-sm-cs.cc \
+  libinterp/operators/op-sm-m.cc \
+  libinterp/operators/op-sm-s.cc \
+  libinterp/operators/op-sm-scm.cc \
+  libinterp/operators/op-sm-sm.cc \
+  libinterp/operators/op-str-m.cc \
+  libinterp/operators/op-str-s.cc \
+  libinterp/operators/op-str-str.cc \
+  libinterp/operators/op-struct.cc \
+  libinterp/operators/op-ui16-ui16.cc \
+  libinterp/operators/op-ui32-ui32.cc \
+  libinterp/operators/op-ui64-ui64.cc \
+  libinterp/operators/op-ui8-ui8.cc
 
 ## These look like included header files to Autotools build process
-OPERATORS_INC = \
-  operators/op-dm-template.cc \
-  operators/op-dms-template.cc \
-  operators/op-int.h \
-  operators/op-pm-template.cc \
-  operators/ops.h
+LIBINTERP_OPERATORS_INC = \
+  libinterp/operators/op-dm-template.cc \
+  libinterp/operators/op-dms-template.cc \
+  libinterp/operators/op-int.h \
+  libinterp/operators/op-pm-template.cc \
+  libinterp/operators/ops.h
 
 ## Special rules for sources which must be built before rest of compilation.
-operators/ops.cc: $(OPERATORS_SRC) mkops
+libinterp/operators/ops.cc: $(LIBINTERP_OPERATORS_SRC) libinterp/mkops
 	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mkops $(OPERATORS_SRC) > $@-t && \
+	$(srcdir)/libinterp/mkops $(LIBINTERP_OPERATORS_SRC) > $@-t && \
 	mv $@-t $@
-
--- a/libinterp/operators/op-bm-b.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-bm-b.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -76,8 +76,7 @@
 
   boolNDArray v2 = a2.bool_array_value (true);
 
-  if (! error_state)
-    v1.assign (idx, v2);
+  v1.assign (idx, v2);
 
   return octave_value ();
 }
--- a/libinterp/operators/op-bm-bm.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-bm-bm.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -61,12 +61,9 @@
   CAST_UNOP_ARG (const octave_bool_matrix&);
 
   if (v.ndims () > 2)
-    {
-      error ("transpose not defined for N-d objects");
-      return octave_value ();
-    }
-  else
-    return octave_value (v.bool_matrix_value ().transpose ());
+    error ("transpose not defined for N-d objects");
+
+  return octave_value (v.bool_matrix_value ().transpose ());
 }
 
 // bool matrix by bool matrix ops.
@@ -120,8 +117,7 @@
 
   boolNDArray v2 = a2.bool_array_value (true);
 
-  if (! error_state)
-    v1.assign (idx, v2);
+  v1.assign (idx, v2);
 
   return octave_value ();
 }
--- a/libinterp/operators/op-cell.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-cell.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -41,12 +41,9 @@
   CAST_UNOP_ARG (const octave_cell&);
 
   if (v.ndims () > 2)
-    {
-      error ("transpose not defined for N-d objects");
-      return octave_value ();
-    }
-  else
-    return octave_value (Cell (v.cell_value ().transpose ()));
+    error ("transpose not defined for N-d objects");
+
+  return octave_value (Cell (v.cell_value ().transpose ()));
 }
 
 DEFCATOP_FN (c_c, cell, cell, concat)
--- a/libinterp/operators/op-class.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-class.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -48,20 +48,18 @@
  \
     octave_value meth = symbol_table::find_method (#name, class_name); \
  \
-    if (meth.is_defined ()) \
-      { \
-        octave_value_list args; \
+    if (meth.is_undefined ()) \
+      error ("%s method not defined for %s class", #name, \
+             class_name.c_str ()); \
  \
-        args(0) = a; \
+    octave_value_list args; \
  \
-        octave_value_list tmp = feval (meth.function_value (), args, 1); \
+    args(0) = a; \
  \
-        if (tmp.length () > 0) \
-          retval = tmp(0); \
-      } \
-    else \
-      error ("%s method not defined for %s class", \
-             #name, class_name.c_str ()); \
+    octave_value_list tmp = feval (meth.function_value (), args, 1); \
+ \
+    if (tmp.length () > 0) \
+      retval = tmp(0); \
  \
     return retval; \
   }
@@ -85,21 +83,19 @@
  \
     octave_value meth = symbol_table::find_method (#name, dispatch_type); \
  \
-    if (meth.is_defined ()) \
-      { \
-        octave_value_list args; \
+    if (meth.is_undefined ()) \
+      error ("%s method not defined for %s class", #name, \
+             dispatch_type.c_str ()); \
  \
-        args(1) = a2; \
-        args(0) = a1; \
+    octave_value_list args; \
  \
-        octave_value_list tmp = feval (meth.function_value (), args, 1); \
+    args(1) = a2; \
+    args(0) = a1; \
  \
-        if (tmp.length () > 0) \
-          retval = tmp(0); \
-      } \
-    else \
-      error ("%s method not defined for %s class", \
-             #name, dispatch_type.c_str ()); \
+    octave_value_list tmp = feval (meth.function_value (), args, 1); \
+ \
+    if (tmp.length () > 0) \
+      retval = tmp(0); \
  \
     return retval; \
   }
--- a/libinterp/operators/op-cm-cm.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-cm-cm.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -46,12 +46,9 @@
   CAST_UNOP_ARG (const octave_complex_matrix&);
 
   if (v.ndims () > 2)
-    {
-      error ("transpose not defined for N-d objects");
-      return octave_value ();
-    }
-  else
-    return octave_value (v.complex_matrix_value ().transpose ());
+    error ("transpose not defined for N-d objects");
+
+  return octave_value (v.complex_matrix_value ().transpose ());
 }
 
 DEFUNOP (hermitian, complex_matrix)
@@ -59,12 +56,9 @@
   CAST_UNOP_ARG (const octave_complex_matrix&);
 
   if (v.ndims () > 2)
-    {
-      error ("complex-conjugate transpose not defined for N-d objects");
-      return octave_value ();
-    }
-  else
-    return octave_value (v.complex_matrix_value ().hermitian ());
+    error ("complex-conjugate transpose not defined for N-d objects");
+
+  return octave_value (v.complex_matrix_value ().hermitian ());
 }
 
 DEFNCUNOP_METHOD (incr, complex_matrix, increment)
--- a/libinterp/operators/op-fcm-fcm.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-fcm-fcm.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -46,12 +46,9 @@
   CAST_UNOP_ARG (const octave_float_complex_matrix&);
 
   if (v.ndims () > 2)
-    {
-      error ("transpose not defined for N-d objects");
-      return octave_value ();
-    }
-  else
-    return octave_value (v.float_complex_matrix_value ().transpose ());
+    error ("transpose not defined for N-d objects");
+
+  return octave_value (v.float_complex_matrix_value ().transpose ());
 }
 
 DEFUNOP (hermitian, float_complex_matrix)
@@ -59,12 +56,9 @@
   CAST_UNOP_ARG (const octave_float_complex_matrix&);
 
   if (v.ndims () > 2)
-    {
-      error ("complex-conjugate transpose not defined for N-d objects");
-      return octave_value ();
-    }
-  else
-    return octave_value (v.float_complex_matrix_value ().hermitian ());
+    error ("complex-conjugate transpose not defined for N-d objects");
+
+  return octave_value (v.float_complex_matrix_value ().hermitian ());
 }
 
 DEFNCUNOP_METHOD (incr, float_complex_matrix, increment)
--- a/libinterp/operators/op-fm-fm.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-fm-fm.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -46,12 +46,9 @@
   CAST_UNOP_ARG (const octave_float_matrix&);
 
   if (v.ndims () > 2)
-    {
-      error ("transpose not defined for N-d objects");
-      return octave_value ();
-    }
-  else
-    return octave_value (v.float_matrix_value ().transpose ());
+    error ("transpose not defined for N-d objects");
+
+  return octave_value (v.float_matrix_value ().transpose ());
 }
 
 DEFNCUNOP_METHOD (incr, float_matrix, increment)
--- a/libinterp/operators/op-int.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-int.h	Thu Dec 10 12:50:06 2015 -0800
@@ -370,7 +370,7 @@
   elem_xpow (const octave_ ## T1& a, const T2 ## NDArray& b) \
   { \
     T2 ## NDArray result (b.dims ()); \
-    for (int i = 0; i < b.length (); i++) \
+    for (int i = 0; i < b.numel (); i++) \
       { \
         OCTAVE_QUIT; \
         result (i) = pow (a, b(i)); \
@@ -382,7 +382,7 @@
   elem_xpow (const octave_ ## T1& a, const NDArray& b) \
   { \
     T1 ## NDArray result (b.dims ()); \
-    for (int i = 0; i < b.length (); i++) \
+    for (int i = 0; i < b.numel (); i++) \
       { \
         OCTAVE_QUIT; \
         result (i) = pow (a, b(i)); \
@@ -394,7 +394,7 @@
   elem_xpow (double a, const T2 ## NDArray& b) \
   { \
     T2 ## NDArray result (b.dims ()); \
-    for (int i = 0; i < b.length (); i++) \
+    for (int i = 0; i < b.numel (); i++) \
       { \
         OCTAVE_QUIT; \
         result (i) = pow (a, b(i)); \
@@ -406,7 +406,7 @@
   elem_xpow (const octave_ ## T1& a, const FloatNDArray& b) \
   { \
     T1 ## NDArray result (b.dims ()); \
-    for (int i = 0; i < b.length (); i++) \
+    for (int i = 0; i < b.numel (); i++) \
       { \
         OCTAVE_QUIT; \
         result (i) = powf (a, b(i)); \
@@ -418,7 +418,7 @@
   elem_xpow (float a, const T2 ## NDArray& b) \
   { \
     T2 ## NDArray result (b.dims ()); \
-    for (int i = 0; i < b.length (); i++) \
+    for (int i = 0; i < b.numel (); i++) \
       { \
         OCTAVE_QUIT; \
         result (i) = powf (a, b(i)); \
@@ -536,7 +536,7 @@
 octave_value elem_xpow (T1 ## NDArray a, octave_ ## T2  b) \
 { \
   T1 ## NDArray result (a.dims ()); \
-  for (int i = 0; i < a.length (); i++) \
+  for (int i = 0; i < a.numel (); i++) \
     { \
       OCTAVE_QUIT; \
       result (i) = pow (a(i), b);               \
@@ -547,7 +547,7 @@
 octave_value elem_xpow (T1 ## NDArray a, double  b) \
 { \
   T1 ## NDArray result (a.dims ()); \
-  for (int i = 0; i < a.length (); i++) \
+  for (int i = 0; i < a.numel (); i++) \
     { \
       OCTAVE_QUIT; \
       result (i) = pow (a(i), b);               \
@@ -558,7 +558,7 @@
 octave_value elem_xpow (NDArray a, octave_ ## T2  b) \
 { \
   T2 ## NDArray result (a.dims ()); \
-  for (int i = 0; i < a.length (); i++) \
+  for (int i = 0; i < a.numel (); i++) \
     { \
       OCTAVE_QUIT; \
       result (i) = pow (a(i), b);               \
@@ -569,7 +569,7 @@
 octave_value elem_xpow (T1 ## NDArray a, float  b) \
 { \
   T1 ## NDArray result (a.dims ()); \
-  for (int i = 0; i < a.length (); i++) \
+  for (int i = 0; i < a.numel (); i++) \
     { \
       OCTAVE_QUIT; \
       result (i) = powf (a(i), b);              \
@@ -580,7 +580,7 @@
 octave_value elem_xpow (FloatNDArray a, octave_ ## T2  b) \
 { \
   T2 ## NDArray result (a.dims ()); \
-  for (int i = 0; i < a.length (); i++) \
+  for (int i = 0; i < a.numel (); i++) \
     { \
       OCTAVE_QUIT; \
       result (i) = powf (a(i), b);              \
@@ -715,7 +715,7 @@
           } \
       } \
     T1 ## NDArray result (a_dims); \
-    for (int i = 0; i < a.length (); i++) \
+    for (int i = 0; i < a.numel (); i++) \
       { \
         OCTAVE_QUIT; \
         result (i) = pow (a(i), b(i)); \
@@ -741,7 +741,7 @@
           } \
       } \
     T1 ## NDArray result (a_dims); \
-    for (int i = 0; i < a.length (); i++) \
+    for (int i = 0; i < a.numel (); i++) \
       { \
         OCTAVE_QUIT; \
         result (i) = pow (a(i), b(i)); \
@@ -767,7 +767,7 @@
           } \
       } \
     T2 ## NDArray result (a_dims); \
-    for (int i = 0; i < a.length (); i++) \
+    for (int i = 0; i < a.numel (); i++) \
       { \
         OCTAVE_QUIT; \
         result (i) = pow (a(i), b(i)); \
@@ -793,7 +793,7 @@
           } \
       } \
     T1 ## NDArray result (a_dims); \
-    for (int i = 0; i < a.length (); i++) \
+    for (int i = 0; i < a.numel (); i++) \
       { \
         OCTAVE_QUIT; \
         result (i) = powf (a(i), b(i)); \
@@ -819,7 +819,7 @@
           } \
       } \
     T2 ## NDArray result (a_dims); \
-    for (int i = 0; i < a.length (); i++) \
+    for (int i = 0; i < a.numel (); i++) \
       { \
         OCTAVE_QUIT; \
         result (i) = powf (a(i), b(i)); \
--- a/libinterp/operators/op-m-m.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-m-m.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -46,12 +46,9 @@
   CAST_UNOP_ARG (const octave_matrix&);
 
   if (v.ndims () > 2)
-    {
-      error ("transpose not defined for N-d objects");
-      return octave_value ();
-    }
-  else
-    return octave_value (v.matrix_value ().transpose ());
+    error ("transpose not defined for N-d objects");
+
+  return octave_value (v.matrix_value ().transpose ());
 }
 
 DEFNCUNOP_METHOD (incr, matrix, increment)
--- a/libinterp/operators/op-sbm-b.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-sbm-b.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -97,8 +97,7 @@
 
   SparseBoolMatrix v2 (1, 1, a2.bool_value ());
 
-  if (! error_state)
-    v1.assign (idx, v2);
+  v1.assign (idx, v2);
 
   return octave_value ();
 }
--- a/libinterp/operators/op-sbm-bm.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-sbm-bm.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -103,8 +103,7 @@
 
   SparseBoolMatrix v2 (a2.bool_array_value ());
 
-  if (! error_state)
-    v1.assign (idx, v2);
+  v1.assign (idx, v2);
 
   return octave_value ();
 }
--- a/libinterp/operators/op-str-m.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-str-m.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -40,8 +40,7 @@
     = v2.convert_to_str_internal (false, false,
                                   a1.is_sq_string () ? '\'' : '"');
 
-  if (! error_state)
-    v1.assign (idx, tmp.char_array_value ());
+  v1.assign (idx, tmp.char_array_value ());
 
   return octave_value ();
 }
--- a/libinterp/operators/op-str-s.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-str-s.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -40,8 +40,7 @@
     = v2.convert_to_str_internal (false, false,
                                   a1.is_sq_string () ? '\'' : '"');
 
-  if (! error_state)
-    v1.assign (idx, tmp.char_array_value ());
+  v1.assign (idx, tmp.char_array_value ());
 
   return octave_value ();
 }
--- a/libinterp/operators/op-str-str.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-str-str.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -39,13 +39,10 @@
   CAST_UNOP_ARG (const octave_char_matrix_str&);
 
   if (v.ndims () > 2)
-    {
-      error ("transpose not defined for N-d objects");
-      return octave_value ();
-    }
-  else
-    return octave_value (v.char_matrix_value ().transpose (),
-                         a.is_sq_string () ? '\'' : '"');
+    error ("transpose not defined for N-d objects");
+
+  return octave_value (v.char_matrix_value ().transpose (),
+                       a.is_sq_string () ? '\'' : '"');
 }
 
 // string by string ops.
--- a/libinterp/operators/op-struct.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/op-struct.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -39,12 +39,9 @@
   CAST_UNOP_ARG (const octave_struct&);
 
   if (v.ndims () > 2)
-    {
-      error ("transpose not defined for N-d objects");
-      return octave_value ();
-    }
-  else
-    return octave_value (v.map_value ().transpose ());
+    error ("transpose not defined for N-d objects");
+
+  return octave_value (v.map_value ().transpose ());
 }
 
 DEFUNOP (scalar_transpose, scalar_struct)
@@ -63,30 +60,30 @@
 oct_catop_struct_matrix (octave_base_value& a1, const octave_base_value& a2,
                          const Array<octave_idx_type>&)
 {
-  octave_value retval;
   CAST_BINOP_ARGS (const octave_struct&, const octave_matrix&);
+
   NDArray tmp = v2.array_value ();
   dim_vector dv = tmp.dims ();
-  if (dv.all_zero ())
-    retval = octave_value (v1.map_value ());
-  else
+
+  if (! dv.all_zero ())
     error ("invalid concatenation of structure with matrix");
-  return retval;
+
+  return octave_value (v1.map_value ());
 }
 
 static octave_value
 oct_catop_matrix_struct (octave_base_value& a1, const octave_base_value& a2,
                          const Array<octave_idx_type>&)
 {
-  octave_value retval;
   CAST_BINOP_ARGS (const octave_matrix&, const octave_struct&);
+
   NDArray tmp = v1.array_value ();
   dim_vector dv = tmp.dims ();
-  if (dv.all_zero ())
-    retval = octave_value (v2.map_value ());
-  else
+
+  if (! dv.all_zero ())
     error ("invalid concatenation of structure with matrix");
-  return retval;
+
+  return octave_value (v2.map_value ());
 }
 
 void
--- a/libinterp/operators/ops.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/operators/ops.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_ops_h)
+#if ! defined (octave_ops_h)
 #define octave_ops_h 1
 
 #include "Array-util.h"
--- a/libinterp/options-usage.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/options-usage.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_options_usage_h)
+#if ! defined (octave_options_usage_h)
 #define octave_options_usage_h 1
 
 #include <iosfwd>
--- a/libinterp/parse-tree/lex.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/lex.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_lex_h)
+#if ! defined (octave_lex_h)
 #define octave_lex_h 1
 
 #include <deque>
--- a/libinterp/parse-tree/lex.ll	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/lex.ll	Thu Dec 10 12:50:06 2015 -0800
@@ -24,7 +24,7 @@
 We are using the pure parser interface and the reentrant lexer
 interface but the Octave parser and lexer are NOT properly
 reentrant because both still use many global variables.  It should be
-safe to create a parser object and call it while anotehr parser
+safe to create a parser object and call it while another parser
 object is active (to parse a callback function while the main
 interactive parser is waiting for input, for example) if you take
 care to properly save and restore (typically with an unwind_protect
@@ -64,6 +64,7 @@
 
 #include <cctype>
 #include <cstring>
+#include <stdint.h>
 
 #include <iostream>
 #include <set>
@@ -320,14 +321,18 @@
 %}
 
 D       [0-9]
+D_      [0-9_]
 S       [ \t]
 NL      ((\n)|(\r)|(\r\n))
 Im      [iIjJ]
 CCHAR   [#%]
 IDENT   ([_$a-zA-Z][_$a-zA-Z0-9]*)
 FQIDENT ({IDENT}(\.{IDENT})*)
-EXPON   ([DdEe][+-]?{D}+)
-NUMBER  (({D}+\.?{D}*{EXPON}?)|(\.{D}+{EXPON}?)|(0[xX][0-9a-fA-F]+))
+EXPON   ([DdEe][+-]?{D}{D_}*)
+NUMBIN  (0[bB][01_]+)
+NUMHEX  (0[xX][0-9a-fA-F][0-9a-fA-F_]*)
+NUMREAL (({D}{D_}*\.?{D_}*{EXPON}?)|(\.{D}{D_}*{EXPON}?))
+NUMBER  ({NUMREAL}|{NUMHEX}|{NUMBIN})
 
 ANY_EXCEPT_NL [^\r\n]
 ANY_INCLUDING_NL (.|{NL})
@@ -335,7 +340,7 @@
 %%
 
 %{
-// Make script and function files start with a bogus token. This makes
+// Make script and function files start with an invalid token. This makes
 // the parser go down a special path.
 %}
 
@@ -1124,9 +1129,9 @@
 // the constant.
 %}
 
-{D}+/\.[\*/\\^\'] |
+{D}{D_}*/\.[\*/\\^\'] |
 {NUMBER} {
-    curr_lexer->lexer_debug ("{D}+/\\.[\\*/\\\\^\\']|{NUMBER}");
+    curr_lexer->lexer_debug ("{D}{D_}*/\\.[\\*/\\\\^\\']|{NUMBER}");
 
     if (curr_lexer->previous_token_may_be_command ()
         &&  curr_lexer->space_follows_previous_token ())
@@ -1907,16 +1912,14 @@
 {
   octave_value retval;
 
-  int argc = args.length () + 1;
-
-  string_vector argv = args.make_argv ("iskeyword");
-
-  if (error_state)
-    return retval;
-
-  if (argc == 1)
+  int nargin = args.length ();
+
+  if (nargin > 1)
+    print_usage ();
+
+  if (nargin == 0)
     {
-      // Neither set and get are keywords.  See the note in the
+      // Neither set nor get are keywords.  See the note in the
       // is_keyword function for additional details.
 
       string_vector lst (TOTAL_KEYWORDS);
@@ -1925,22 +1928,21 @@
 
       for (int i = 0; i < TOTAL_KEYWORDS; i++)
         {
-          std::string tmp = wordlist[i].name;
-
-          if (! (tmp == "set" || tmp == "get"))
-            lst[j++] = tmp;
+          std::string kword = wordlist[i].name;
+
+          if (kword != "set" && kword != "get")
+            lst[j++] = kword;
         }
 
       lst.resize (j);
 
       retval = Cell (lst.sort ());
     }
-  else if (argc == 2)
+  else
     {
-      retval = is_keyword (argv[1]);
+      std::string name = args(0).xstring_value ("iskeyword: NAME must be a string");
+      retval = is_keyword (name);
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -1950,6 +1952,11 @@
 %!assert (iskeyword ("for"))
 %!assert (iskeyword ("fort"), false)
 %!assert (iskeyword ("fft"), false)
+%!assert (iskeyword ("get"), false)
+%!assert (iskeyword ("set"), false)
+
+%!error iskeyword ("A", "B")
+%!error <NAME must be a string> iskeyword (1)
 
 */
 
@@ -2660,6 +2667,12 @@
 }
 
 static inline bool
+looks_like_bin (const char *s, int len)
+{
+  return (len > 2 && s[0] == '0' && (s[1] == 'b' || s[1] == 'B'));
+}
+
+static inline bool
 looks_like_hex (const char *s, int len)
 {
   return (len > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X'));
@@ -2673,28 +2686,50 @@
 
   char *yytxt = flex_yytext ();
 
-  if (looks_like_hex (yytxt, strlen (yytxt)))
+  // Strip any underscores
+  char *tmptxt = strsave (yytxt);
+  char *rptr = tmptxt;
+  char *wptr = tmptxt;
+  while (*rptr)
+  {
+    *wptr = *rptr++;
+     wptr += (*wptr != '_');
+  }
+  *wptr = '\0';
+
+  if (looks_like_hex (tmptxt, strlen (tmptxt)))
     {
       unsigned long ival;
 
-      nread = sscanf (yytxt, "%lx", &ival);
+      nread = sscanf (tmptxt, "%lx", &ival);
 
       value = static_cast<double> (ival);
     }
+  else if (looks_like_bin (tmptxt, strlen (tmptxt)))
+    {
+      uint64_t ivalue = 0;
+
+      for (int i = 0; i < strlen (tmptxt); i++)
+        {
+          ivalue <<= 1;
+          ivalue += static_cast<uint64_t> (tmptxt[i] == '1');
+        }
+
+      value = static_cast<double> (ivalue);
+      nread = 1;  // Just to pass the assert stmt below
+    }
   else
     {
-      char *tmp = strsave (yytxt);
-
-      char *idx = strpbrk (tmp, "Dd");
+      char *idx = strpbrk (tmptxt, "Dd");
 
       if (idx)
         *idx = 'e';
 
-      nread = sscanf (tmp, "%lf", &value);
-
-      delete [] tmp;
+      nread = sscanf (tmptxt, "%lf", &value);
     }
 
+  delete [] tmptxt;
+
   // If yytext doesn't contain a valid number, we are in deep doo doo.
 
   assert (nread == 1);
--- a/libinterp/parse-tree/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,81 +1,76 @@
-EXTRA_DIST += \
-  parse-tree/module.mk \
-  parse-tree/oct-parse.in.yy \
-  parse-tree/octave.gperf
-
 PARSER_INC = \
-  parse-tree/lex.h \
-  parse-tree/parse.h
+  libinterp/parse-tree/lex.h \
+  libinterp/parse-tree/parse.h
 
 PARSER_SRC = \
-  parse-tree/lex.ll \
-  parse-tree/oct-parse.yy
+  libinterp/parse-tree/lex.ll \
+  libinterp/parse-tree/oct-parse.yy
 
 PARSE_TREE_INC = \
-  parse-tree/pt-all.h \
-  parse-tree/pt-arg-list.h \
-  parse-tree/pt-array-list.h \
-  parse-tree/pt-assign.h \
-  parse-tree/pt-binop.h \
-  parse-tree/pt-bp.h \
-  parse-tree/pt-cbinop.h \
-  parse-tree/pt-cell.h \
-  parse-tree/pt-check.h \
-  parse-tree/pt-classdef.h \
-  parse-tree/pt-cmd.h \
-  parse-tree/pt-colon.h \
-  parse-tree/pt-const.h \
-  parse-tree/pt-decl.h \
-  parse-tree/pt-eval.h \
-  parse-tree/pt-except.h \
-  parse-tree/pt-exp.h \
-  parse-tree/pt-fcn-handle.h \
-  parse-tree/pt-funcall.h \
-  parse-tree/pt-id.h \
-  parse-tree/pt-idx.h \
-  parse-tree/pt-jump.h \
-  parse-tree/pt-loop.h \
-  parse-tree/pt-mat.h \
-  parse-tree/pt-misc.h \
-  parse-tree/pt-pr-code.h \
-  parse-tree/pt-select.h \
-  parse-tree/pt-stmt.h \
-  parse-tree/pt-unop.h \
-  parse-tree/pt-walk.h \
-  parse-tree/pt.h \
-  parse-tree/token.h
+  libinterp/parse-tree/pt-all.h \
+  libinterp/parse-tree/pt-arg-list.h \
+  libinterp/parse-tree/pt-array-list.h \
+  libinterp/parse-tree/pt-assign.h \
+  libinterp/parse-tree/pt-binop.h \
+  libinterp/parse-tree/pt-bp.h \
+  libinterp/parse-tree/pt-cbinop.h \
+  libinterp/parse-tree/pt-cell.h \
+  libinterp/parse-tree/pt-check.h \
+  libinterp/parse-tree/pt-classdef.h \
+  libinterp/parse-tree/pt-cmd.h \
+  libinterp/parse-tree/pt-colon.h \
+  libinterp/parse-tree/pt-const.h \
+  libinterp/parse-tree/pt-decl.h \
+  libinterp/parse-tree/pt-eval.h \
+  libinterp/parse-tree/pt-except.h \
+  libinterp/parse-tree/pt-exp.h \
+  libinterp/parse-tree/pt-fcn-handle.h \
+  libinterp/parse-tree/pt-funcall.h \
+  libinterp/parse-tree/pt-id.h \
+  libinterp/parse-tree/pt-idx.h \
+  libinterp/parse-tree/pt-jump.h \
+  libinterp/parse-tree/pt-loop.h \
+  libinterp/parse-tree/pt-mat.h \
+  libinterp/parse-tree/pt-misc.h \
+  libinterp/parse-tree/pt-pr-code.h \
+  libinterp/parse-tree/pt-select.h \
+  libinterp/parse-tree/pt-stmt.h \
+  libinterp/parse-tree/pt-unop.h \
+  libinterp/parse-tree/pt-walk.h \
+  libinterp/parse-tree/pt.h \
+  libinterp/parse-tree/token.h
 
 PARSE_TREE_SRC = \
-  parse-tree/pt-arg-list.cc \
-  parse-tree/pt-array-list.cc \
-  parse-tree/pt-assign.cc \
-  parse-tree/pt-binop.cc \
-  parse-tree/pt-bp.cc \
-  parse-tree/pt-cbinop.cc \
-  parse-tree/pt-cell.cc \
-  parse-tree/pt-check.cc \
-  parse-tree/pt-classdef.cc \
-  parse-tree/pt-cmd.cc \
-  parse-tree/pt-colon.cc \
-  parse-tree/pt-const.cc \
-  parse-tree/pt-decl.cc \
-  parse-tree/pt-eval.cc \
-  parse-tree/pt-except.cc \
-  parse-tree/pt-exp.cc \
-  parse-tree/pt-fcn-handle.cc \
-  parse-tree/pt-funcall.cc \
-  parse-tree/pt-id.cc \
-  parse-tree/pt-idx.cc \
-  parse-tree/pt-jump.cc \
-  parse-tree/pt-loop.cc \
-  parse-tree/pt-mat.cc \
-  parse-tree/pt-misc.cc \
-  parse-tree/pt-pr-code.cc \
-  parse-tree/pt-select.cc \
-  parse-tree/pt-stmt.cc \
-  parse-tree/pt-unop.cc \
-  parse-tree/pt.cc \
-  parse-tree/token.cc
+  libinterp/parse-tree/pt-arg-list.cc \
+  libinterp/parse-tree/pt-array-list.cc \
+  libinterp/parse-tree/pt-assign.cc \
+  libinterp/parse-tree/pt-binop.cc \
+  libinterp/parse-tree/pt-bp.cc \
+  libinterp/parse-tree/pt-cbinop.cc \
+  libinterp/parse-tree/pt-cell.cc \
+  libinterp/parse-tree/pt-check.cc \
+  libinterp/parse-tree/pt-classdef.cc \
+  libinterp/parse-tree/pt-cmd.cc \
+  libinterp/parse-tree/pt-colon.cc \
+  libinterp/parse-tree/pt-const.cc \
+  libinterp/parse-tree/pt-decl.cc \
+  libinterp/parse-tree/pt-eval.cc \
+  libinterp/parse-tree/pt-except.cc \
+  libinterp/parse-tree/pt-exp.cc \
+  libinterp/parse-tree/pt-fcn-handle.cc \
+  libinterp/parse-tree/pt-funcall.cc \
+  libinterp/parse-tree/pt-id.cc \
+  libinterp/parse-tree/pt-idx.cc \
+  libinterp/parse-tree/pt-jump.cc \
+  libinterp/parse-tree/pt-loop.cc \
+  libinterp/parse-tree/pt-mat.cc \
+  libinterp/parse-tree/pt-misc.cc \
+  libinterp/parse-tree/pt-pr-code.cc \
+  libinterp/parse-tree/pt-select.cc \
+  libinterp/parse-tree/pt-stmt.cc \
+  libinterp/parse-tree/pt-unop.cc \
+  libinterp/parse-tree/pt.cc \
+  libinterp/parse-tree/token.cc
 
 ## Special rules for sources which must be built before rest of compilation.
 
@@ -83,26 +78,39 @@
 ## is missing but sed is not, the exit status of the pipeline
 ## will still be success and we will end up creating an empty
 ## oct-gperf.h file.
-parse-tree/oct-gperf.h: parse-tree/octave.gperf
+libinterp/parse-tree/oct-gperf.h: libinterp/parse-tree/octave.gperf
 	$(AM_V_GEN)rm -f $@-t $@t1 $@ && \
 	$(GPERF) -t -C -D -G -L C++ -Z octave_kw_hash $< > $@-t1 && \
 	$(SED) 's,lookup\[,gperf_lookup[,' < $@-t1 > $@-t && \
 	mv $@-t $@ && \
 	rm -f $@-t1
 
-parse-tree/oct-parse.h: parse-tree/oct-parse.cc
+libinterp/parse-tree/oct-parse.h: libinterp/parse-tree/oct-parse.cc
 
-parse-tree/oct-parse.yy: parse-tree/oct-parse.in.yy
+libinterp/parse-tree/oct-parse.yy: libinterp/parse-tree/oct-parse.in.yy
 	$(AM_V_GEN)$(call subst-bison-api-decls,octave_)
 
 noinst_LTLIBRARIES += \
-  parse-tree/libparse-tree.la \
-  parse-tree/libparser.la
+  libinterp/parse-tree/libparse-tree.la \
+  libinterp/parse-tree/libparser.la
+
+libinterp_parse_tree_libparse_tree_la_SOURCES = $(PARSE_TREE_SRC)
+
+libinterp_parse_tree_libparse_tree_la_CPPFLAGS = $(libinterp_liboctinterp_la_CPPFLAGS)
+
+libinterp_parse_tree_libparse_tree_la_CFLAGS = $(AM_CFLAGS)	\
+$(WARN_CFLAGS)
+
+libinterp_parse_tree_libparse_tree_la_CXXFLAGS = $(AM_CXXFLAGS) $(WARN_CXXFLAGS)
 
-parse_tree_libparse_tree_la_SOURCES = $(PARSE_TREE_SRC)
-parse_tree_libparse_tree_la_CPPFLAGS = $(liboctinterp_la_CPPFLAGS)
+libinterp_parse_tree_libparser_la_SOURCES = $(PARSER_SRC)
+
+libinterp_parse_tree_libparser_la_CPPFLAGS = $(libinterp_liboctinterp_la_CPPFLAGS)
 
-parse_tree_libparser_la_SOURCES = $(PARSER_SRC)
-parse_tree_libparser_la_CPPFLAGS = $(liboctinterp_la_CPPFLAGS)
-parse_tree_libparser_la_CXXFLAGS = \
+libinterp_parse_tree_libparser_la_CXXFLAGS = \
   $(filter-out -Wold-style-cast, $(AM_CXXFLAGS))
+
+libinterp_EXTRA_DIST += \
+  libinterp/parse-tree/oct-parse.in.yy \
+  libinterp/parse-tree/octave.gperf
+
--- a/libinterp/parse-tree/oct-parse.in.yy	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/oct-parse.in.yy	Thu Dec 10 12:50:06 2015 -0800
@@ -2246,9 +2246,6 @@
 
   unwind_protect frame;
 
-  frame.protect_var (error_state);
-  frame.protect_var (warning_state);
-
   frame.protect_var (discard_error_messages);
   frame.protect_var (discard_warning_messages);
 
@@ -2266,10 +2263,10 @@
           if (base->is_constant () && limit->is_constant ()
               && (! incr || (incr && incr->is_constant ())))
             {
-              octave_value tmp = e->rvalue1 ();
-
-              if (! (error_state || warning_state))
+              try
                 {
+                  octave_value tmp = e->rvalue1 ();
+
                   tree_constant *tc_retval
                     = new tree_constant (tmp, base->line (), base->column ());
 
@@ -2285,6 +2282,10 @@
 
                   retval = tc_retval;
                 }
+              catch (const octave_execution_exception&)
+                {
+                  recover_from_exception ();
+                }
             }
         }
       else
@@ -3135,7 +3136,7 @@
   {
     // FIXME -- should lexer.fcn_file_name already be
     // preprocessed when we get here?  It seems to only be a
-    // problem with relative file names.
+    // problem with relative filenames.
 
     std::string nm = lexer.fcn_file_name;
 
@@ -3148,7 +3149,7 @@
       {
         warning_with_id
           ("Octave:function-name-clash",
-           "function name '%s' does not agree with function file name '%s'",
+           "function name '%s' does not agree with function filename '%s'",
            id_name.c_str (), lexer.fcn_file_full_name.c_str ());
 
         id_name = nm;
@@ -3361,7 +3362,7 @@
     nm = lexer.fcn_file_name.substr (pos+1);
 
   if (nm != cls_name)
-    bison_error ("invalid classdef definition, the class name must match the file name");
+    bison_error ("invalid classdef definition, the class name must match the filename");
   else if (end_token_ok (end_tok, token::classdef_end))
     {
       octave_comment_list *tc = lexer.comment_buf.get_comment ();
@@ -3799,9 +3800,6 @@
 
   unwind_protect frame;
 
-  frame.protect_var (error_state);
-  frame.protect_var (warning_state);
-
   frame.protect_var (discard_error_messages);
   frame.protect_var (discard_warning_messages);
 
@@ -3810,10 +3808,10 @@
 
   if (array_list->all_elements_are_constant ())
     {
-      octave_value tmp = array_list->rvalue1 ();
-
-      if (! (error_state || warning_state))
+      try
         {
+          octave_value tmp = array_list->rvalue1 ();
+
           tree_constant *tc_retval
             = new tree_constant (tmp, array_list->line (),
                                  array_list->column ());
@@ -3830,6 +3828,10 @@
 
           retval = tc_retval;
         }
+      catch (const octave_execution_exception&)
+        {
+          recover_from_exception ();
+        }
     }
 
   return retval;
@@ -4316,7 +4318,7 @@
 @deftypefnx {Built-in Function} {} autoload (@dots{}, \"remove\")\n\
 Define @var{function} to autoload from @var{file}.\n\
 \n\
-The second argument, @var{file}, should be an absolute file name or a file\n\
+The second argument, @var{file}, should be an absolute filename or a file\n\
 name in the same directory as the function or script from which the autoload\n\
 command was run.  @var{file} @emph{should not} depend on the Octave load\n\
 path.\n\
@@ -4353,6 +4355,9 @@
 
   int nargin = args.length ();
 
+  if (nargin == 1 || nargin > 3)
+    print_usage ();
+
   if (nargin == 0)
     {
       Cell func_names (dim_vector (autoload_map.size (), 1));
@@ -4375,59 +4380,54 @@
 
       retval = m;
     }
-  else if (nargin == 2 || nargin == 3)
+  else
     {
       string_vector argv = args.make_argv ("autoload");
 
-      if (! error_state)
+      std::string nm = argv[2];
+
+      if (! octave_env::absolute_pathname (nm))
         {
-          std::string nm = argv[2];
-
-          if (! octave_env::absolute_pathname (nm))
+          octave_user_code *fcn = octave_call_stack::caller_user_code ();
+
+          bool found = false;
+
+          if (fcn)
             {
-              octave_user_code *fcn = octave_call_stack::caller_user_code ();
-
-              bool found = false;
-
-              if (fcn)
+              std::string fname = fcn->fcn_file_name ();
+
+              if (! fname.empty ())
                 {
-                  std::string fname = fcn->fcn_file_name ();
-
-                  if (! fname.empty ())
+                  fname = octave_env::make_absolute (fname);
+                  fname = fname.substr (0, fname.find_last_of (file_ops::dir_sep_str ()) + 1);
+
+                  file_stat fs (fname + nm);
+
+                  if (fs.exists ())
                     {
-                      fname = octave_env::make_absolute (fname);
-                      fname = fname.substr (0, fname.find_last_of (file_ops::dir_sep_str ()) + 1);
-
-                      file_stat fs (fname + nm);
-
-                      if (fs.exists ())
-                        {
-                          nm = fname + nm;
-                          found = true;
-                        }
+                      nm = fname + nm;
+                      found = true;
                     }
                 }
-              if (! found)
-                warning_with_id ("Octave:autoload-relative-file-name",
-                                 "autoload: '%s' is not an absolute file name",
-                                 nm.c_str ());
             }
-          if (nargin == 2)
-            autoload_map[argv[1]] = nm;
-          else if (nargin == 3)
-            {
-              if (argv[3].compare ("remove") != 0)
-                error_with_id ("Octave:invalid-input-arg",
-                               "autoload: third argument can only be 'remove'");
-
-              // Remove function from symbol table and autoload map.
-              symbol_table::clear_dld_function (argv[1]);
-              autoload_map.erase (argv[1]);
-            }
+          if (! found)
+            warning_with_id ("Octave:autoload-relative-file-name",
+                             "autoload: '%s' is not an absolute filename",
+                             nm.c_str ());
+        }
+      if (nargin == 2)
+        autoload_map[argv[1]] = nm;
+      else if (nargin == 3)
+        {
+          if (argv[3].compare ("remove") != 0)
+            error_with_id ("Octave:invalid-input-arg",
+                           "autoload: third argument can only be 'remove'");
+
+          // Remove function from symbol table and autoload map.
+          symbol_table::clear_dld_function (argv[1]);
+          autoload_map.erase (argv[1]);
         }
     }
-  else
-    print_usage ();
 
   return retval;
 }
@@ -4499,40 +4499,38 @@
       else
         error ("source: context must be \"caller\" or \"base\"");
 
-      if (! error_state)
-        frame.add_fcn (octave_call_stack::pop);
+      frame.add_fcn (octave_call_stack::pop);
     }
 
-  if (! error_state)
+  octave_function *fcn = 0;
+
+  try
     {
-      octave_function *fcn = parse_fcn_file (file_full_name, file_name,
-                                             "", "", require_file, true,
-                                             false, false, warn_for);
-
-      if (! error_state)
+      fcn = parse_fcn_file (file_full_name, file_name, "", "",
+                            require_file, true, false, false, warn_for);
+    }
+  catch (octave_execution_exception& e)
+    {
+      error (e, "source: error sourcing file '%s'", file_full_name.c_str ());
+    }
+
+  if (fcn && fcn->is_user_script ())
+    {
+      octave_value_list args;
+
+      if (verbose)
         {
-          if (fcn && fcn->is_user_script ())
-            {
-              octave_value_list args;
-
-              if (verbose)
-                {
-                  std::cout << "executing commands from " << file_full_name << " ... ";
-                  reading_startup_message_printed = true;
-                  std::cout.flush ();
-                }
-
-              fcn->do_multi_index_op (0, args);
-
-              if (verbose)
-                std::cout << "done." << std::endl;
-
-              delete fcn;
-            }
+          std::cout << "executing commands from " << file_full_name << " ... ";
+          reading_startup_message_printed = true;
+          std::cout.flush ();
         }
-      else
-        error ("source: error sourcing file '%s'",
-               file_full_name.c_str ());
+
+      fcn->do_multi_index_op (0, args);
+
+      if (verbose)
+        std::cout << "done." << std::endl;
+
+      delete fcn;
     }
 }
 
@@ -4546,10 +4544,10 @@
 When called from outside an m-file return the empty string.\n\
 \n\
 Given the argument @qcode{\"fullpath\"}, include the directory part of the\n\
-file name, but not the extension.\n\
+filename, but not the extension.\n\
 \n\
 Given the argument @qcode{\"fullpathext\"}, include the directory part of\n\
-the file name and the extension.\n\
+the filename and the extension.\n\
 @end deftypefn")
 {
   octave_value retval;
@@ -4557,23 +4555,12 @@
   int nargin = args.length ();
 
   if (nargin > 1)
-    {
-      print_usage ();
-      return retval;
-    }
+    print_usage ();
 
   std::string arg;
 
   if (nargin == 1)
-    {
-      arg = args(0).string_value ();
-
-      if (error_state)
-        {
-          error ("mfilename: expecting argument to be a character string");
-          return retval;
-        }
-    }
+    arg = args(0).xstring_value ("mfilename: expecting argument to be a character string");
 
   std::string fname;
 
@@ -4622,28 +4609,18 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
-    {
-      std::string file_name = args(0).string_value ();
-
-      if (! error_state)
-        {
-          std::string context;
-
-          if (nargin == 2)
-            context = args(1).string_value ();
-
-          if (! error_state)
-            source_file (file_name, context);
-          else
-            error ("source: expecting context to be character string");
-        }
-      else
-        error ("source: expecting file name as argument");
-    }
-  else
+  if (nargin < 1 || nargin > 2)
     print_usage ();
 
+  std::string file_name = args(0).xstring_value ("source: expecting filename as argument");
+
+  std::string context;
+
+  if (nargin == 2)
+    context = args(1).xstring_value ("source: expecting context to be character string");
+
+  source_file (file_name, context);
+
   return retval;
 }
 
@@ -4663,9 +4640,14 @@
     retval = fcn.do_multi_index_op (nargout, args);
   else
     {
-      maybe_missing_function_hook (name);
-      if (! error_state)
-        error ("feval: function '%s' not found", name.c_str ());
+      try
+        {
+          maybe_missing_function_hook (name);
+        }
+      catch (octave_execution_exception& e)
+        {
+          error (e, "feval: function '%s' not found", name.c_str ());
+        }
     }
 
   return retval;
@@ -4700,9 +4682,7 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
-
-  if (nargin > 0)
+  if (args.length () > 0)
     {
       octave_value f_arg = args(0);
 
@@ -4710,12 +4690,9 @@
         {
           std::string name = f_arg.string_value ();
 
-          if (! error_state)
-            {
-              octave_value_list tmp_args = get_feval_args (args);
-
-              retval = feval (name, tmp_args, nargout);
-            }
+          octave_value_list tmp_args = get_feval_args (args);
+
+          retval = feval (name, tmp_args, nargout);
         }
       else if (f_arg.is_function_handle ()
                || f_arg.is_anonymous_function ()
@@ -4772,16 +4749,10 @@
 instead.\n\
 @end deftypefn")
 {
-  octave_value_list retval;
-
-  int nargin = args.length ();
-
-  if (nargin > 0)
-    retval = feval (args, nargout);
-  else
+  if (args.length () == 0)
     print_usage ();
 
-  return retval;
+  return feval (args, nargout);
 }
 
 DEFUN (builtin, args, nargout,
@@ -4812,27 +4783,17 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
-
-  if (nargin > 0)
-    {
-      const std::string name (args(0).string_value ());
-
-      if (! error_state)
-        {
-          octave_value fcn = symbol_table::builtin_find (name);
-
-          if (fcn.is_defined ())
-            retval = feval (fcn.function_value (), args.splice (0, 1),
-                            nargout);
-          else
-            error ("builtin: lookup for symbol '%s' failed", name.c_str ());
-        }
-      else
-        error ("builtin: function name (F) must be a string");
-    }
+  if (args.length () == 0)
+    print_usage ();
+
+  const std::string name (args(0).xstring_value ("builtin: function name (F) must be a string"));
+
+  octave_value fcn = symbol_table::builtin_find (name);
+
+  if (fcn.is_defined ())
+    retval = feval (fcn.function_value (), args.splice (0, 1), nargout);
   else
-    print_usage ();
+    error ("builtin: lookup for symbol '%s' failed", name.c_str ());
 
   return retval;
 }
@@ -4880,7 +4841,7 @@
 
                   retval = expr->rvalue (nargout);
 
-                  if (do_bind_ans && ! (error_state || retval.empty ()))
+                  if (do_bind_ans && ! retval.empty ())
                     bind_ans (retval(0), expr->print_result ());
 
                   if (nargout == 0)
@@ -4891,8 +4852,7 @@
               else
                 error ("eval: invalid use of statement list");
 
-              if (error_state
-                  || tree_return_command::returning
+              if (tree_return_command::returning
                   || tree_break_command::breaking
                   || tree_continue_command::continuing)
                 break;
@@ -4923,13 +4883,7 @@
 eval_string (const octave_value& arg, bool silent, int& parse_status,
              int nargout)
 {
-  std::string s = arg.string_value ();
-
-  if (error_state)
-    {
-      error ("eval: expecting std::string argument");
-      return octave_value (-1);
-    }
+  std::string s = arg.xstring_value ("eval: expecting std::string argument");
 
   return eval_string (s, silent, parse_status, nargout);
 }
@@ -4987,40 +4941,56 @@
 
   int nargin = args.length ();
 
-  if (nargin > 0)
+  if (nargin == 0)
+    print_usage ();
+
+  unwind_protect frame;
+
+  if (nargin > 1)
+    {
+      frame.protect_var (buffer_error_messages);
+      buffer_error_messages++;
+    }
+
+  int parse_status = 0;
+
+  bool execution_error = false;
+
+  octave_value_list tmp;
+
+  try
     {
-      unwind_protect frame;
-
-      if (nargin > 1)
-        {
-          frame.protect_var (buffer_error_messages);
-          buffer_error_messages++;
-        }
-
-      int parse_status = 0;
-
-      octave_value_list tmp = eval_string (args(0), nargout > 0,
-                                           parse_status, nargout);
-
-      if (nargin > 1 && (parse_status != 0 || error_state))
-        {
-          error_state = 0;
-
-          // Set up for letting the user print any messages from
-          // errors that occurred in the first part of this eval().
-
-          buffer_error_messages--;
-
-          tmp = eval_string (args(1), nargout > 0, parse_status, nargout);
-
-          if (nargout > 0)
-            retval = tmp;
-        }
-      else if (nargout > 0)
+      tmp = eval_string (args(0), nargout > 0, parse_status, nargout);
+    }
+  catch (const octave_execution_exception&)
+    {
+      recover_from_exception ();
+
+      execution_error = true;
+    }
+
+  if (nargin > 1 && (parse_status != 0 || execution_error))
+    {
+      // Set up for letting the user print any messages from
+      // errors that occurred in the first part of this eval().
+
+      buffer_error_messages--;
+
+      tmp = eval_string (args(1), nargout > 0, parse_status, nargout);
+
+      if (nargout > 0)
         retval = tmp;
     }
   else
-    print_usage ();
+    {
+      if (nargout > 0)
+        retval = tmp;
+
+      // FIXME: we should really be rethrowing whatever exception occurred,
+      // not just throwing an execution exception.
+      if (execution_error)
+        octave_throw_execution_exception ();
+    }
 
   return retval;
 }
@@ -5073,45 +5043,28 @@
 {
   octave_value_list retval;
 
-  int nargin = args.length ();
-
-  if (nargin == 3)
-    {
-      std::string context = args(0).string_value ();
-
-      if (! error_state)
-        {
-          unwind_protect frame;
-
-          if (context == "caller")
-            octave_call_stack::goto_caller_frame ();
-          else if (context == "base")
-            octave_call_stack::goto_base_frame ();
-          else
-            error ("assignin: CONTEXT must be \"caller\" or \"base\"");
-
-          if (! error_state)
-            {
-              frame.add_fcn (octave_call_stack::pop);
-
-              std::string nm = args(1).string_value ();
-
-              if (! error_state)
-                {
-                  if (valid_identifier (nm))
-                    symbol_table::assign (nm, args(2));
-                  else
-                    error ("assignin: invalid variable name in argument VARNAME");
-                }
-              else
-                error ("assignin: VARNAME must be a string");
-            }
-        }
-      else
-        error ("assignin: CONTEXT must be a string");
-    }
+  if (args.length () != 3)
+    print_usage ();
+
+  std::string context = args(0).xstring_value ("assignin: CONTEXT must be a string");
+
+  unwind_protect frame;
+
+  if (context == "caller")
+    octave_call_stack::goto_caller_frame ();
+  else if (context == "base")
+    octave_call_stack::goto_base_frame ();
   else
-    print_usage ();
+    error ("assignin: CONTEXT must be \"caller\" or \"base\"");
+
+  frame.add_fcn (octave_call_stack::pop);
+
+  std::string nm = args(1).xstring_value ("assignin: VARNAME must be a string");
+
+  if (valid_identifier (nm))
+    symbol_table::assign (nm, args(2));
+  else
+    error ("assignin: invalid variable name in argument VARNAME");
 
   return retval;
 }
@@ -5129,60 +5082,69 @@
 
   int nargin = args.length ();
 
-  if (nargin > 1)
+  if (nargin < 2)
+    print_usage ();
+
+  std::string context = args(0).xstring_value ("evalin: CONTEXT must be a string");
+
+  unwind_protect frame;
+
+  if (context == "caller")
+    octave_call_stack::goto_caller_frame ();
+  else if (context == "base")
+    octave_call_stack::goto_base_frame ();
+  else
+    error ("evalin: CONTEXT must be \"caller\" or \"base\"");
+
+  frame.add_fcn (octave_call_stack::pop);
+
+  if (nargin > 2)
     {
-      std::string context = args(0).string_value ();
-
-      if (! error_state)
-        {
-          unwind_protect frame;
-
-          if (context == "caller")
-            octave_call_stack::goto_caller_frame ();
-          else if (context == "base")
-            octave_call_stack::goto_base_frame ();
-          else
-            error ("evalin: CONTEXT must be \"caller\" or \"base\"");
-
-          if (! error_state)
-            {
-              frame.add_fcn (octave_call_stack::pop);
-
-              if (nargin > 2)
-                {
-                  frame.protect_var (buffer_error_messages);
-                  buffer_error_messages++;
-                }
-
-              int parse_status = 0;
-
-              octave_value_list tmp = eval_string (args(1), nargout > 0,
-                                                   parse_status, nargout);
-
-              if (nargout > 0)
-                retval = tmp;
-
-              if (nargin > 2 && (parse_status != 0 || error_state))
-                {
-                  error_state = 0;
-
-                  // Set up for letting the user print any messages from
-                  // errors that occurred in the first part of this eval().
-
-                  buffer_error_messages--;
-
-                  tmp = eval_string (args(2), nargout > 0,
-                                     parse_status, nargout);
-
-                  retval = (nargout > 0) ? tmp : octave_value_list ();
-                }
-            }
-        }
-      else
-        error ("evalin: CONTEXT must be a string");
+      frame.protect_var (buffer_error_messages);
+      buffer_error_messages++;
+    }
+
+  int parse_status = 0;
+
+  bool execution_error = false;
+
+  octave_value_list tmp;
+
+  try
+    {
+      tmp = eval_string (args(1), nargout > 0,
+                         parse_status, nargout);
+    }
+  catch (const octave_execution_exception&)
+    {
+      recover_from_exception ();
+
+      execution_error = true;
+    }
+
+  if (nargin > 2 && (parse_status != 0 || execution_error))
+    {
+      // Set up for letting the user print any messages from
+      // errors that occurred in the first part of this eval().
+
+      buffer_error_messages--;
+
+      tmp = eval_string (args(2), nargout > 0,
+                         parse_status, nargout);
+
+      retval = (nargout > 0) ? tmp : octave_value_list ();
     }
   else
-    print_usage ();
+    {
+      if (nargout > 0)
+        retval = tmp;
+
+      // FIXME: we should really be rethrowing whatever
+      // exception occurred, not just throwing an
+      // execution exception.
+      if (execution_error)
+        octave_throw_execution_exception ();
+    }
 
   return retval;
 }
@@ -5218,43 +5180,36 @@
 
   int nargin = args.length ();
 
-  if (nargin == 1 || nargin == 2)
+  if (nargin < 1 || nargin > 2)
+    print_usage ();
+
+  std::string file = args(0).xstring_value ("__parse_file__: expecting filename as argument");
+
+  std::string full_file = octave_env::make_absolute (file);
+
+  size_t file_len = file.length ();
+
+  if ((file_len > 4 && file.substr (file_len-4) == ".oct")
+      || (file_len > 4 && file.substr (file_len-4) == ".mex")
+      || (file_len > 2 && file.substr (file_len-2) == ".m"))
     {
-      std::string file = args(0).string_value ();
-
-      std::string full_file = octave_env::make_absolute (file);
-
-      size_t file_len = file.length ();
-
-      if ((file_len > 4 && file.substr (file_len-4) == ".oct")
-          || (file_len > 4 && file.substr (file_len-4) == ".mex")
-          || (file_len > 2 && file.substr (file_len-2) == ".m"))
-        {
-          file = octave_env::base_pathname (file);
-          file = file.substr (0, file.find_last_of ('.'));
-
-          size_t pos = file.find_last_of (file_ops::dir_sep_str ());
-          if (pos != std::string::npos)
-            file = file.substr (pos+1);
-        }
-
-      if (! error_state)
-        {
-          if (nargin == 2)
-            octave_stdout << "parsing " << full_file << std::endl;
-
-          octave_function *fcn = parse_fcn_file (full_file, file, "", "",
-                                                 true, false, false,
-                                                 false, "__parse_file__");
-
-          if (fcn)
-            delete fcn;
-        }
-      else
-        error ("__parse_file__: expecting file name as argument");
+      file = octave_env::base_pathname (file);
+      file = file.substr (0, file.find_last_of ('.'));
+
+      size_t pos = file.find_last_of (file_ops::dir_sep_str ());
+      if (pos != std::string::npos)
+        file = file.substr (pos+1);
     }
-  else
-    print_usage ();
+
+  if (nargin == 2)
+    octave_stdout << "parsing " << full_file << std::endl;
+
+  octave_function *fcn = parse_fcn_file (full_file, file, "", "",
+                                         true, false, false,
+                                         false, "__parse_file__");
+
+  if (fcn)
+    delete fcn;
 
   return retval;
 }
--- a/libinterp/parse-tree/parse.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/parse.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_parse_h)
+#if ! defined (octave_parse_h)
 #define octave_parse_h 1
 
 #include <cstdio>
--- a/libinterp/parse-tree/pt-all.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-all.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_all_h)
+#if ! defined (octave_pt_all_h)
 #define octave_pt_all_h 1
 
 #include "pt.h"
--- a/libinterp/parse-tree/pt-arg-list.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-arg-list.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -195,7 +195,7 @@
         retval = 1;
     }
   else
-    ::error ("invalid use of end");
+    error ("invalid use of end");
 
   return retval;
 }
@@ -242,19 +242,10 @@
         {
           octave_value tmp = elt->rvalue1 ();
 
-          if (error_state)
-            {
-              ::error ("evaluating argument list element number %d", k+1);
-              args.clear ();
-              break;
-            }
-          else
-            {
-              if (tmp.is_cs_list ())
-                args.push_back (tmp.list_value ());
-              else if (tmp.is_defined ())
-                args.push_back (tmp);
-            }
+          if (tmp.is_cs_list ())
+            args.push_back (tmp.list_value ());
+          else if (tmp.is_defined ())
+            args.push_back (tmp);
         }
       else
         {
--- a/libinterp/parse-tree/pt-arg-list.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-arg-list.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_arg_list_h)
+#if ! defined (octave_pt_arg_list_h)
 #define octave_pt_arg_list_h 1
 
 #include <list>
--- a/libinterp/parse-tree/pt-array-list.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-array-list.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_array_list_h)
+#if ! defined (octave_pt_array_list_h)
 #define octave_pt_array_list_h 1
 
 #include "base-list.h"
--- a/libinterp/parse-tree/pt-assign.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-assign.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -62,14 +62,10 @@
 octave_value_list
 tree_simple_assignment::rvalue (int nargout)
 {
-  octave_value_list retval;
-
   if (nargout > 1)
     error ("invalid number of output arguments for expression X = RHS");
-  else
-    retval = rvalue1 (nargout);
 
-  return retval;
+  return rvalue1 (nargout);
 }
 
 octave_value
@@ -77,72 +73,60 @@
 {
   octave_value retval;
 
-  if (error_state)
-    return retval;
-
   if (rhs)
     {
       octave_value rhs_val = rhs->rvalue1 ();
 
-      if (! error_state)
+      if (rhs_val.is_undefined ())
+        error ("value on right hand side of assignment is undefined");
+
+      if (rhs_val.is_cs_list ())
         {
-          if (rhs_val.is_undefined ())
-            {
-              error ("value on right hand side of assignment is undefined");
-              return retval;
-            }
-          else
-            {
-              if (rhs_val.is_cs_list ())
-                {
-                  const octave_value_list lst = rhs_val.list_value ();
+          const octave_value_list lst = rhs_val.list_value ();
 
-                  if (! lst.empty ())
-                    rhs_val = lst(0);
-                  else
-                    {
-                      error ("invalid number of elements on RHS of assignment");
-                      return retval;
-                    }
-                }
+          if (! lst.empty ())
+            rhs_val = lst(0);
+          else
+            error ("invalid number of elements on RHS of assignment");
+        }
 
-              octave_lvalue ult = lhs->lvalue ();
+      try
+        {
+          octave_lvalue ult = lhs->lvalue ();
 
-              if (ult.numel () != 1)
-                gripe_nonbraced_cs_list_assignment ();
+          if (ult.numel () != 1)
+            gripe_nonbraced_cs_list_assignment ();
+
+          ult.assign (etype, rhs_val);
 
-              if (! error_state)
-                {
-                  ult.assign (etype, rhs_val);
+          if (etype == octave_value::op_asn_eq)
+            retval = rhs_val;
+          else
+            retval = ult.value ();
 
-                  if (! error_state)
-                    {
-                      if (etype == octave_value::op_asn_eq)
-                        retval = rhs_val;
-                      else
-                        retval = ult.value ();
+          if (print_result ()
+              && tree_evaluator::statement_printing_enabled ())
+            {
+              // We clear any index here so that we can
+              // get the new value of the referenced
+              // object below, instead of the indexed
+              // value (which should be the same as the
+              // right hand side value).
 
-                      if (print_result ()
-                          && tree_evaluator::statement_printing_enabled ())
-                        {
-                          // We clear any index here so that we can
-                          // get the new value of the referenced
-                          // object below, instead of the indexed
-                          // value (which should be the same as the
-                          // right hand side value).
+              ult.clear_index ();
+
+              octave_value lhs_val = ult.value ();
 
-                          ult.clear_index ();
-
-                          octave_value lhs_val = ult.value ();
-
-                          if (! error_state)
-                            lhs_val.print_with_name (octave_stdout,
-                                                     lhs->name ());
-                        }
-                    }
-                }
+              lhs_val.print_with_name (octave_stdout,
+                                       lhs->name ());
             }
         }
+      catch (index_exception& e)
+        {
+          e.set_var (lhs->name ());
+          std::string msg = e.message ();
+          error_with_id (e.err_id (), msg.c_str ());
+        }
     }
 
   return retval;
@@ -211,16 +195,10 @@
 {
   octave_value_list retval;
 
-  if (error_state)
-    return retval;
-
   if (rhs)
     {
       std::list<octave_lvalue> lvalue_list = lhs->lvalue_list ();
 
-      if (error_state)
-        return retval;
-
       octave_idx_type n_out = 0;
 
       for (std::list<octave_lvalue>::const_iterator p = lvalue_list.begin ();
@@ -235,9 +213,6 @@
                                          ? rhs_val1(0).list_value ()
                                          : rhs_val1);
 
-      if (error_state)
-        return retval;
-
       octave_idx_type k = 0;
 
       octave_idx_type n = rhs_val.length ();
@@ -260,6 +235,33 @@
 
           if (nel != 1)
             {
+              // Huge kluge so that wrapper scripts with lines like
+              //
+              //   [varargout{1:nargout}] = fcn (args);
+              //
+              // Will work the same as calling fcn directly when nargout
+              // is 0 and fcn produces more than one output even when
+              // nargout is 0.  This only works if varargout has not yet
+              // been defined.  See also bug #43813.
+
+              if (lvalue_list.size () == 1 && nel == 0 && n > 0
+                  && ! ult.is_black_hole () && ult.is_undefined ()
+                  && ult.index_type () == "{" && ult.index_is_empty ())
+                {
+                  // Convert undefined lvalue with empty index to a cell
+                  // array with a single value and indexed by 1 to
+                  // handle a single output.
+
+                  nel = 1;
+
+                  ult.define (Cell (1, 1));
+
+                  ult.clear_index ();
+                  std::list<octave_value_list> idx;
+                  idx.push_back (octave_value_list (octave_value (1)));
+                  ult.set_index ("{", idx);
+                }
+
               if (k + nel <= n)
                 {
                   // This won't do a copy.
@@ -268,12 +270,9 @@
                   ult.assign (octave_value::op_asn_eq,
                               octave_value (ovl, true));
 
-                  if (! error_state)
-                    {
-                      retval_list.push_back (ovl);
+                  retval_list.push_back (ovl);
 
-                      k += nel;
-                    }
+                  k += nel;
                 }
               else
                 error ("some elements undefined in return list");
@@ -289,7 +288,7 @@
                       k++;
                       continue;
                     }
-                  else if (! error_state)
+                  else
                     {
                       retval_list.push_back (rhs_val(k));
 
@@ -323,10 +322,8 @@
                 }
             }
 
-          if (error_state)
-            break;
-          else if (print_result ()
-                   && tree_evaluator::statement_printing_enabled ())
+          if (print_result ()
+              && tree_evaluator::statement_printing_enabled ())
             {
               // We clear any index here so that we can get
               // the new value of the referenced object below,
@@ -337,19 +334,12 @@
 
               octave_value lhs_val = ult.value ();
 
-              if (! error_state)
-                lhs_val.print_with_name (octave_stdout,
-                                         lhs_elt->name ());
+              lhs_val.print_with_name (octave_stdout, lhs_elt->name ());
             }
-
-          if (error_state)
-            break;
-
         }
 
       // Concatenate return values.
       retval = retval_list;
-
     }
 
   return retval;
--- a/libinterp/parse-tree/pt-assign.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-assign.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_assign_h)
+#if ! defined (octave_pt_assign_h)
 #define octave_pt_assign_h 1
 
 #include <iosfwd>
--- a/libinterp/parse-tree/pt-binop.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-binop.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -69,9 +69,6 @@
 {
   octave_value retval;
 
-  if (error_state)
-    return retval;
-
   if (Vdo_braindead_shortcircuit_evaluation
       && eligible_for_braindead_shortcircuit)
     {
@@ -79,48 +76,40 @@
         {
           octave_value a = op_lhs->rvalue1 ();
 
-          if (! error_state)
+          if (a.ndims () == 2 && a.rows () == 1 && a.columns () == 1)
             {
-              if (a.ndims () == 2 && a.rows () == 1 && a.columns () == 1)
+              bool result = false;
+
+              bool a_true = a.is_true ();
+
+              if (a_true)
                 {
-                  bool result = false;
-
-                  bool a_true = a.is_true ();
-
-                  if (! error_state)
+                  if (etype == octave_value::op_el_or)
                     {
-                      if (a_true)
-                        {
-                          if (etype == octave_value::op_el_or)
-                            {
-                              matlab_style_short_circuit_warning ("|");
-                              result = true;
-                              goto done;
-                            }
-                        }
-                      else
-                        {
-                          if (etype == octave_value::op_el_and)
-                            {
-                              matlab_style_short_circuit_warning ("&");
-                              goto done;
-                            }
-                        }
-
-                      if (op_rhs)
-                        {
-                          octave_value b = op_rhs->rvalue1 ();
-
-                          if (! error_state)
-                            result = b.is_true ();
-                        }
-
-                    done:
-
-                      if (! error_state)
-                        return octave_value (result);
+                      matlab_style_short_circuit_warning ("|");
+                      result = true;
+                      goto done;
                     }
                 }
+              else
+                {
+                  if (etype == octave_value::op_el_and)
+                    {
+                      matlab_style_short_circuit_warning ("&");
+                      goto done;
+                    }
+                }
+
+              if (op_rhs)
+                {
+                  octave_value b = op_rhs->rvalue1 ();
+
+                  result = b.is_true ();
+                }
+
+            done:
+
+              return octave_value (result);
             }
         }
     }
@@ -129,11 +118,11 @@
     {
       octave_value a = op_lhs->rvalue1 ();
 
-      if (! error_state && a.is_defined () && op_rhs)
+      if (a.is_defined () && op_rhs)
         {
           octave_value b = op_rhs->rvalue1 ();
 
-          if (! error_state && b.is_defined ())
+          if (b.is_defined ())
             {
               BEGIN_PROFILER_BLOCK (tree_binary_expression)
 
@@ -145,9 +134,6 @@
 
               retval = ::do_binary_op (etype, a, b);
 
-              if (error_state)
-                retval = octave_value ();
-
               END_PROFILER_BLOCK
             }
         }
@@ -203,9 +189,6 @@
 {
   octave_value retval;
 
-  if (error_state)
-    return retval;
-
   bool result = false;
 
   // This evaluation is not caught by the profiler, since we can't find
@@ -217,40 +200,32 @@
     {
       octave_value a = op_lhs->rvalue1 ();
 
-      if (! error_state)
+      bool a_true = a.is_true ();
+
+      if (a_true)
         {
-          bool a_true = a.is_true ();
-
-          if (! error_state)
+          if (etype == bool_or)
             {
-              if (a_true)
-                {
-                  if (etype == bool_or)
-                    {
-                      result = true;
-                      goto done;
-                    }
-                }
-              else
-                {
-                  if (etype == bool_and)
-                    goto done;
-                }
-
-              if (op_rhs)
-                {
-                  octave_value b = op_rhs->rvalue1 ();
-
-                  if (! error_state)
-                    result = b.is_true ();
-                }
-
-            done:
-
-              if (! error_state)
-                retval = octave_value (result);
+              result = true;
+              goto done;
             }
         }
+      else
+        {
+          if (etype == bool_and)
+            goto done;
+        }
+
+      if (op_rhs)
+        {
+          octave_value b = op_rhs->rvalue1 ();
+
+          result = b.is_true ();
+        }
+
+    done:
+
+      retval = octave_value (result);
     }
 
   return retval;
--- a/libinterp/parse-tree/pt-binop.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-binop.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_binop_h)
+#if ! defined (octave_pt_binop_h)
 #define octave_pt_binop_h 1
 
 #include <string>
--- a/libinterp/parse-tree/pt-bp.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-bp.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_bp_h)
+#if ! defined (octave_pt_bp_h)
 #define octave_pt_bp_h 1
 
 #include "input.h"
--- a/libinterp/parse-tree/pt-cbinop.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-cbinop.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -51,24 +51,16 @@
 {
   octave_value retval;
 
-  if (error_state)
-    return retval;
-
   if (op_lhs)
     {
       octave_value a = op_lhs->rvalue1 ();
 
-      if (! error_state && a.is_defined () && op_rhs)
+      if (a.is_defined () && op_rhs)
         {
           octave_value b = op_rhs->rvalue1 ();
 
-          if (! error_state && b.is_defined ())
-            {
-              retval = ::do_binary_op (etype, a, b);
-
-              if (error_state)
-                retval = octave_value ();
-            }
+          if (b.is_defined ())
+            retval = ::do_binary_op (etype, a, b);
         }
     }
 
--- a/libinterp/parse-tree/pt-cbinop.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-cbinop.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_cbinop_h)
+#if ! defined (octave_pt_cbinop_h)
 #define octave_pt_cbinop_h 1
 
 #include <string>
--- a/libinterp/parse-tree/pt-cell.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-cell.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -70,10 +70,7 @@
               if (this_nc == 0)
                 continue;  // blank line
               else
-                {
-                  ::error ("number of columns must match");
-                  return retval;
-                }
+                error ("number of columns must match");
             }
         }
 
@@ -93,14 +90,10 @@
 octave_value_list
 tree_cell::rvalue (int nargout)
 {
-  octave_value_list retval;
-
   if (nargout > 1)
     error ("invalid number of output arguments for cell array");
-  else
-    retval = rvalue1 (nargout);
 
-  return retval;
+  return rvalue1 (nargout);
 }
 
 tree_expression *
--- a/libinterp/parse-tree/pt-cell.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-cell.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_cell_h)
+#if ! defined (octave_pt_cell_h)
 #define octave_pt_cell_h 1
 
 #include <iosfwd>
--- a/libinterp/parse-tree/pt-check.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-check.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_check_h)
+#if ! defined (octave_pt_check_h)
 #define octave_pt_check_h 1
 
 #include "pt-walk.h"
--- a/libinterp/parse-tree/pt-classdef.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-classdef.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_tree_classdef_h)
+#if ! defined (octave_tree_classdef_h)
 #define octave_tree_classdef_h 1
 
 class octave_value;
--- a/libinterp/parse-tree/pt-cmd.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-cmd.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_cmd_h)
+#if ! defined (octave_pt_cmd_h)
 #define octave_pt_cmd_h 1
 
 #include <string>
--- a/libinterp/parse-tree/pt-colon.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-colon.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -44,17 +44,15 @@
       if (op_limit)
         {
           if (op_increment)
-            ::error ("invalid colon expression");
-          else
-            {
-              // Stupid syntax:
-              //
-              // base : limit
-              // base : increment : limit
+            error ("invalid colon expression");
 
-              op_increment = op_limit;
-              op_limit = t;
-            }
+          // Stupid syntax:
+          //
+          // base : limit
+          // base : increment : limit
+
+          op_increment = op_limit;
+          op_limit = t;
         }
       else
         op_limit = t;
@@ -62,7 +60,7 @@
       retval = this;
     }
   else
-    ::error ("invalid colon expression");
+    error ("invalid colon expression");
 
   return retval;
 }
@@ -70,14 +68,10 @@
 octave_value_list
 tree_colon_expression::rvalue (int nargout)
 {
-  octave_value_list retval;
-
   if (nargout > 1)
     error ("invalid number of output arguments for colon expression");
-  else
-    retval = rvalue1 (nargout);
 
-  return retval;
+  return rvalue1 (nargout);
 }
 
 octave_value
@@ -85,73 +79,51 @@
 {
   octave_value retval;
 
-  if (error_state || ! op_base || ! op_limit)
+  if (! op_base || ! op_limit)
     return retval;
 
   octave_value ov_base = op_base->rvalue1 ();
 
-  if (error_state || ov_base.is_undefined ())
-    eval_error ("invalid base value in colon expression");
-  else
-    {
-      octave_value ov_limit = op_limit->rvalue1 ();
+  octave_value ov_limit = op_limit->rvalue1 ();
 
-      if (error_state || ov_limit.is_undefined ())
-        eval_error ("invalid limit value in colon expression");
-      else if (ov_base.is_object () || ov_limit.is_object ())
-        {
-          octave_value_list tmp1;
-
-          if (op_increment)
-            {
-              octave_value ov_increment = op_increment->rvalue1 ();
+  if (ov_base.is_object () || ov_limit.is_object ())
+    {
+      octave_value_list tmp1;
 
-              if (error_state || ov_increment.is_undefined ())
-                eval_error ("invalid increment value in colon expression");
-              else
-                {
-                  tmp1(2) = ov_limit;
-                  tmp1(1) = ov_increment;
-                  tmp1(0) = ov_base;
-                }
-            }
-          else
-            {
-              tmp1(1) = ov_limit;
-              tmp1(0) = ov_base;
-            }
+      if (op_increment)
+        {
+          octave_value ov_increment = op_increment->rvalue1 ();
 
-          if (!error_state)
-            {
-              octave_value fcn = symbol_table::find_function ("colon", tmp1);
-
-              if (fcn.is_defined ())
-                {
-                  octave_value_list tmp2 = fcn.do_multi_index_op (1, tmp1);
-
-                  if (! error_state)
-                    retval = tmp2 (0);
-                }
-              else
-                ::error ("can not find overloaded colon function");
-            }
+          tmp1(2) = ov_limit;
+          tmp1(1) = ov_increment;
+          tmp1(0) = ov_base;
         }
       else
         {
-          octave_value ov_increment = 1.0;
+          tmp1(1) = ov_limit;
+          tmp1(0) = ov_base;
+        }
 
-          if (op_increment)
-            {
-              ov_increment = op_increment->rvalue1 ();
+      octave_value fcn = symbol_table::find_function ("colon", tmp1);
+
+      if (fcn.is_defined ())
+        {
+          octave_value_list tmp2 = fcn.do_multi_index_op (1, tmp1);
 
-              if (error_state || ov_increment.is_undefined ())
-                eval_error ("invalid increment value in colon expression");
-            }
+          retval = tmp2 (0);
+        }
+      else
+        error ("can not find overloaded colon function");
+    }
+  else
+    {
+      octave_value ov_increment = 1.0;
 
-          if (! error_state)
-            retval = do_colon_op (ov_base, ov_increment, ov_limit,
-                                  is_for_cmd_expr ());
-        }
+      if (op_increment)
+        ov_increment = op_increment->rvalue1 ();
+
+      retval = do_colon_op (ov_base, ov_increment, ov_limit,
+                            is_for_cmd_expr ());
     }
 
   return retval;
@@ -160,7 +132,7 @@
 void
 tree_colon_expression::eval_error (const std::string& s) const
 {
-  ::error ("%s", s.c_str ());
+  error ("%s", s.c_str ());
 }
 
 int
--- a/libinterp/parse-tree/pt-colon.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-colon.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_colon_h)
+#if ! defined (octave_pt_colon_h)
 #define octave_tree_colon 1
 
 #include <string>
--- a/libinterp/parse-tree/pt-const.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-const.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_const_h)
+#if ! defined (octave_pt_const_h)
 #define octave_pt_const_h 1
 
 #include <iosfwd>
--- a/libinterp/parse-tree/pt-decl.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-decl.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -56,12 +56,9 @@
 
       octave_value init_val = expr->rvalue1 ();
 
-      if (! error_state)
-        {
-          ult.assign (octave_value::op_asn_eq, init_val);
+      ult.assign (octave_value::op_asn_eq, init_val);
 
-          retval = true;
-        }
+      retval = true;
     }
 
   return retval;
--- a/libinterp/parse-tree/pt-decl.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-decl.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_decl_h)
+#if ! defined (octave_pt_decl_h)
 #define octave_pt_decl_h 1
 
 class tree_expression;
--- a/libinterp/parse-tree/pt-eval.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-eval.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -42,6 +42,7 @@
 #include "pt-all.h"
 #include "pt-eval.h"
 #include "symtab.h"
+#include "toplev.h"
 #include "unwind-prot.h"
 
 //FIXME: This should be part of tree_evaluator
@@ -95,15 +96,12 @@
 void
 tree_evaluator::visit_break_command (tree_break_command& cmd)
 {
-  if (! error_state)
-    {
-      if (debug_mode)
-        do_breakpoint (cmd.is_breakpoint ());
+  if (debug_mode)
+    do_breakpoint (cmd.is_breakpoint ());
 
-      if (statement_context == function || statement_context == script
-          || in_loop_command)
-        tree_break_command::breaking = 1;
-    }
+  if (statement_context == function || statement_context == script
+      || in_loop_command)
+    tree_break_command::breaking = 1;
 }
 
 void
@@ -115,15 +113,12 @@
 void
 tree_evaluator::visit_continue_command (tree_continue_command& cmd)
 {
-  if (! error_state)
-    {
-      if (debug_mode)
-        do_breakpoint (cmd.is_breakpoint ());
+  if (debug_mode)
+    do_breakpoint (cmd.is_breakpoint ());
 
-      if (statement_context == function || statement_context == script
-          || in_loop_command)
-        tree_continue_command::continuing = 1;
-    }
+  if (statement_context == function || statement_context == script
+      || in_loop_command)
+    tree_continue_command::continuing = 1;
 }
 
 void
@@ -150,23 +145,20 @@
     {
       id->mark_global ();
 
-      if (! error_state)
-        {
-          octave_lvalue ult = id->lvalue ();
+      octave_lvalue ult = id->lvalue ();
 
-          if (ult.is_undefined ())
-            {
-              tree_expression *expr = elt.expression ();
+      if (ult.is_undefined ())
+        {
+          tree_expression *expr = elt.expression ();
 
-              octave_value init_val;
+          octave_value init_val;
 
-              if (expr)
-                init_val = expr->rvalue1 ();
-              else
-                init_val = Matrix ();
+          if (expr)
+            init_val = expr->rvalue1 ();
+          else
+            init_val = Matrix ();
 
-              ult.assign (octave_value::op_asn_eq, init_val);
-            }
+          ult.assign (octave_value::op_asn_eq, init_val);
         }
     }
 }
@@ -210,9 +202,6 @@
           tree_decl_elt *elt = *p;
 
           fcn (*elt);
-
-          if (error_state)
-            break;
         }
     }
 }
@@ -253,12 +242,9 @@
 
       octave_value init_val = expr->rvalue1 ();
 
-      if (! error_state)
-        {
-          ult.assign (octave_value::op_asn_eq, init_val);
+      ult.assign (octave_value::op_asn_eq, init_val);
 
-          retval = true;
-        }
+      retval = true;
     }
 
   return retval;
@@ -282,8 +268,7 @@
   if (tree_continue_command::continuing)
     tree_continue_command::continuing--;
 
-  bool quit = (error_state
-               || tree_return_command::returning
+  bool quit = (tree_return_command::returning
                || tree_break_command::breaking
                || tree_continue_command::continuing);
 
@@ -296,9 +281,6 @@
 void
 tree_evaluator::visit_simple_for_command (tree_simple_for_command& cmd)
 {
-  if (error_state)
-    return;
-
   if (debug_mode)
     do_breakpoint (cmd.is_breakpoint ());
 
@@ -320,110 +302,100 @@
     return;
 #endif
 
-  if (error_state || rhs.is_undefined ())
+  if (rhs.is_undefined ())
     return;
 
-  {
-    tree_expression *lhs = cmd.left_hand_side ();
+  tree_expression *lhs = cmd.left_hand_side ();
 
-    octave_lvalue ult = lhs->lvalue ();
+  octave_lvalue ult = lhs->lvalue ();
 
-    if (error_state)
-      return;
+  tree_statement_list *loop_body = cmd.body ();
 
-    tree_statement_list *loop_body = cmd.body ();
+  if (rhs.is_range ())
+    {
+      Range rng = rhs.range_value ();
 
-    if (rhs.is_range ())
-      {
-        Range rng = rhs.range_value ();
-
-        octave_idx_type steps = rng.nelem ();
+      octave_idx_type steps = rng.numel ();
 
-        for (octave_idx_type i = 0; i < steps; i++)
-          {
-            octave_value val (rng.elem (i));
+      for (octave_idx_type i = 0; i < steps; i++)
+        {
+          octave_value val (rng.elem (i));
 
-            ult.assign (octave_value::op_asn_eq, val);
+          ult.assign (octave_value::op_asn_eq, val);
+
+          if (loop_body)
+            loop_body->accept (*this);
 
-            if (! error_state && loop_body)
-              loop_body->accept (*this);
+          if (quit_loop_now ())
+            break;
+        }
+    }
+  else if (rhs.is_scalar_type ())
+    {
+      ult.assign (octave_value::op_asn_eq, rhs);
 
-            if (quit_loop_now ())
-              break;
-          }
-      }
-    else if (rhs.is_scalar_type ())
-      {
-        ult.assign (octave_value::op_asn_eq, rhs);
+      if (loop_body)
+        loop_body->accept (*this);
 
-        if (! error_state && loop_body)
-          loop_body->accept (*this);
+      // Maybe decrement break and continue states.
+      quit_loop_now ();
+    }
+  else if (rhs.is_matrix_type () || rhs.is_cell () || rhs.is_string ()
+           || rhs.is_map ())
+    {
+      // A matrix or cell is reshaped to 2 dimensions and iterated by
+      // columns.
 
-        // Maybe decrement break and continue states.
-        quit_loop_now ();
-      }
-    else if (rhs.is_matrix_type () || rhs.is_cell () || rhs.is_string ()
-             || rhs.is_map ())
-      {
-        // A matrix or cell is reshaped to 2 dimensions and iterated by
-        // columns.
-
-        dim_vector dv = rhs.dims ().redim (2);
+      dim_vector dv = rhs.dims ().redim (2);
 
-        octave_idx_type nrows = dv(0);
-        octave_idx_type steps = dv(1);
+      octave_idx_type nrows = dv(0);
+      octave_idx_type steps = dv(1);
 
-        if (steps > 0)
-          {
-            octave_value arg = rhs;
-            if (rhs.ndims () > 2)
-              arg = arg.reshape (dv);
+      if (steps > 0)
+        {
+          octave_value arg = rhs;
+          if (rhs.ndims () > 2)
+            arg = arg.reshape (dv);
 
-            // for row vectors, use single index to speed things up.
-            octave_value_list idx;
-            octave_idx_type iidx;
-            if (nrows == 1)
-              {
-                idx.resize (1);
-                iidx = 0;
-              }
-            else
-              {
-                idx.resize (2);
-                idx(0) = octave_value::magic_colon_t;
-                iidx = 1;
-              }
+          // for row vectors, use single index to speed things up.
+          octave_value_list idx;
+          octave_idx_type iidx;
+          if (nrows == 1)
+            {
+              idx.resize (1);
+              iidx = 0;
+            }
+          else
+            {
+              idx.resize (2);
+              idx(0) = octave_value::magic_colon_t;
+              iidx = 1;
+            }
 
-            for (octave_idx_type i = 1; i <= steps; i++)
-              {
-                // do_index_op expects one-based indices.
-                idx(iidx) = i;
-                octave_value val = arg.do_index_op (idx);
+          for (octave_idx_type i = 1; i <= steps; i++)
+            {
+              // do_index_op expects one-based indices.
+              idx(iidx) = i;
+              octave_value val = arg.do_index_op (idx);
 
-                ult.assign (octave_value::op_asn_eq, val);
-
-                if (! error_state && loop_body)
-                  loop_body->accept (*this);
+              ult.assign (octave_value::op_asn_eq, val);
 
-                if (quit_loop_now ())
-                  break;
-              }
-          }
-      }
-    else
-      {
-        ::error ("invalid type in for loop expression near line %d, column %d",
-                 cmd.line (), cmd.column ());
-      }
-  }
+              if (loop_body)
+                loop_body->accept (*this);
+
+              if (quit_loop_now ())
+                break;
+            }
+        }
+    }
+  else
+    error ("invalid type in for loop expression near line %d, column %d",
+           cmd.line (), cmd.column ());
 }
 
 void
 tree_evaluator::visit_complex_for_command (tree_complex_for_command& cmd)
 {
-  if (error_state)
-    return;
-
   if (debug_mode)
     do_breakpoint (cmd.is_breakpoint ());
 
@@ -437,7 +409,7 @@
 
   octave_value rhs = expr->rvalue1 ();
 
-  if (error_state || rhs.is_undefined ())
+  if (rhs.is_undefined ())
     return;
 
   if (rhs.is_map ())
@@ -479,7 +451,7 @@
           val_ref.assign (octave_value::op_asn_eq, val);
           key_ref.assign (octave_value::op_asn_eq, key);
 
-          if (! error_state && loop_body)
+          if (loop_body)
             loop_body->accept (*this);
 
           if (quit_loop_now ())
@@ -572,13 +544,10 @@
 
       if (tic->is_else_clause () || expr->is_logically_true ("if"))
         {
-          if (! error_state)
-            {
-              tree_statement_list *stmt_lst = tic->commands ();
+          tree_statement_list *stmt_lst = tic->commands ();
 
-              if (stmt_lst)
-                stmt_lst->accept (*this);
-            }
+          if (stmt_lst)
+            stmt_lst->accept (*this);
 
           break;
         }
@@ -655,24 +624,21 @@
 void
 tree_evaluator::visit_return_command (tree_return_command& cmd)
 {
-  if (! error_state)
-    {
-      if (debug_mode)
-        do_breakpoint (cmd.is_breakpoint ());
+  if (debug_mode)
+    do_breakpoint (cmd.is_breakpoint ());
 
-      // Act like dbcont.
+  // Act like dbcont.
 
-      if (Vdebugging
-          && octave_call_stack::current_frame () == current_frame)
-        {
-          Vdebugging = false;
+  if (Vdebugging
+      && octave_call_stack::current_frame () == current_frame)
+    {
+      Vdebugging = false;
 
-          reset_debug_state ();
-        }
-      else if (statement_context == function || statement_context == script
-               || in_loop_command)
-        tree_return_command::returning = 1;
+      reset_debug_state ();
     }
+  else if (statement_context == function || statement_context == script
+           || in_loop_command)
+    tree_return_command::returning = 1;
 }
 
 void
@@ -743,7 +709,7 @@
 
               octave_value tmp_result = expr->rvalue1 (0);
 
-              if (do_bind_ans && ! (error_state || tmp_result.is_undefined ()))
+              if (do_bind_ans && tmp_result.is_defined ())
                 bind_ans (tmp_result, expr->print_result ()
                           && statement_printing_enabled ());
 
@@ -751,19 +717,12 @@
               //                result_values(0) = tmp_result;
             }
         }
-      catch (octave_execution_exception)
-        {
-          gripe_library_execution_error ();
-        }
-      catch (std::bad_alloc)
+      catch (const std::bad_alloc&)
         {
-          // FIXME: We want to use error_with_id here so that we set
-          // the error state, give users control over this error
-          // message, and so that we set the error_state appropriately
-          // so we'll get stack trace info when appropriate.  But
-          // error_with_id will require some memory allocations.  Is
-          // there anything we can do to make those more likely to
-          // succeed?
+          // FIXME: We want to use error_with_id here so that give users
+          // control over this error message but error_with_id will
+          // require some memory allocations.  Is there anything we can
+          // do to make those more likely to succeed?
 
           error_with_id ("Octave:bad-alloc",
                          "out of memory or dimension too large for Octave's index type");
@@ -776,9 +735,6 @@
 {
   static octave_value_list empty_list;
 
-  if (error_state)
-    return;
-
   tree_statement_list::iterator p = lst.begin ();
 
   if (p != lst.end ())
@@ -793,9 +749,6 @@
 
               elt->accept (*this);
 
-              if (error_state)
-                break;
-
               if (tree_break_command::breaking
                   || tree_continue_command::continuing)
                 break;
@@ -855,7 +808,7 @@
 
       tree_switch_case_list *lst = cmd.case_list ();
 
-      if (! error_state && lst)
+      if (lst)
         {
           for (tree_switch_case_list::iterator p = lst->begin ();
                p != lst->end (); p++)
@@ -864,9 +817,6 @@
 
               if (t->is_default_case () || t->label_matches (val))
                 {
-                  if (error_state)
-                    break;
-
                   tree_statement_list *stmt_lst = t->commands ();
 
                   if (stmt_lst)
@@ -878,8 +828,8 @@
         }
     }
   else
-    ::error ("missing value in switch command near line %d, column %d",
-             cmd.line (), cmd.column ());
+    error ("missing value in switch command near line %d, column %d",
+           cmd.line (), cmd.column ());
 }
 
 void
@@ -902,15 +852,24 @@
 
   tree_statement_list *try_code = cmd.body ();
 
+  bool execution_error = false;
+
   if (try_code)
     {
-      try_code->accept (*this);
+      try
+        {
+          try_code->accept (*this);
+        }
+      catch (const octave_execution_exception&)
+        {
+          recover_from_exception ();
+
+          execution_error = true;
+        }
     }
 
-  if (error_state)
+  if (execution_error)
     {
-      error_state = 0;
-
       if (catch_code)
         {
           // Set up for letting the user print any messages from errors that
@@ -923,21 +882,15 @@
 
           if (expr_id)
             {
+              ult = expr_id->lvalue ();
 
               octave_scalar_map err;
 
-              ult = expr_id->lvalue ();
-
-              if (error_state)
-                return;
-
               err.assign ("message", last_error_message ());
               err.assign ("identifier", last_error_id ());
               err.assign ("stack", last_error_stack ());
 
-              if (! error_state)
-                ult.assign (octave_value::op_asn_eq, err);
-
+              ult.assign (octave_value::op_asn_eq, err);
             }
 
           if (catch_code)
@@ -954,14 +907,6 @@
   frame.protect_var (octave_interrupt_state);
   octave_interrupt_state = 0;
 
-  // We want to run the cleanup code without error_state being set,
-  // but we need to restore its value, so that any errors encountered
-  // in the first part of the unwind_protect are not completely
-  // ignored.
-
-  frame.protect_var (error_state);
-  error_state = 0;
-
   // We want to preserve the last location info for possible
   // backtracking.
   frame.add_fcn (octave_call_stack::set_line,
@@ -980,8 +925,24 @@
   frame.protect_var (tree_break_command::breaking);
   tree_break_command::breaking = 0;
 
-  if (list)
-    list->accept (*this);
+  try
+    {
+      if (list)
+        list->accept (*this);
+    }
+  catch (const octave_execution_exception&)
+    {
+      recover_from_exception ();
+
+      if (tree_break_command::breaking || tree_return_command::returning)
+        frame.discard (2);
+      else
+        frame.run (2);
+
+      frame.discard (2);
+
+      throw;
+    }
 
   // The unwind_protects are popped off the stack in the reverse of
   // the order they are pushed on.
@@ -994,13 +955,13 @@
   //
   //   function foo ()
   //     unwind_protect
-  //       stderr << "1: this should always be executed\n";
+  //       fprintf (stderr, "1: this should always be executed\n");
   //       break;
-  //       stderr << "1: this should never be executed\n";
+  //       fprintf (stderr, "1: this should never be executed\n");
   //     unwind_protect_cleanup
-  //       stderr << "2: this should always be executed\n";
+  //       fprintf (stderr, "2: this should always be executed\n");
   //       return;
-  //       stderr << "2: this should never be executed\n";
+  //       fprintf (stderr, "2: this should never be executed\n");
   //     end_unwind_protect
   //   endfunction
   //
@@ -1011,24 +972,9 @@
   // whatever they were when the cleanup block was entered.
 
   if (tree_break_command::breaking || tree_return_command::returning)
-    {
-      frame.discard (2);
-    }
-  else
-    {
-      frame.run (2);
-    }
-
-  // We don't want to ignore errors that occur in the cleanup code, so
-  // if an error is encountered there, leave error_state alone.
-  // Otherwise, set it back to what it was before.
-
-  if (error_state)
     frame.discard (2);
   else
     frame.run (2);
-
-  frame.run ();
 }
 
 void
@@ -1044,17 +990,25 @@
         {
           unwind_protect_code->accept (*this);
         }
-      catch (...)
+      catch (const octave_execution_exception&)
         {
-          // Run the cleanup code on exceptions, so that it is run even in case
-          // of interrupt or out-of-memory.
+          // FIXME: Maybe we should be able to temporarily set the
+          // interpreter's exception handling state to something "safe"
+          // while the cleanup block runs instead of just resetting it
+          // here?
+          recover_from_exception ();
+
+          // Run the cleanup code on exceptions, so that it is run even
+          // in case of interrupt or out-of-memory.
           do_unwind_protect_cleanup_code (cleanup_code);
-          // FIXME: should error_state be checked here?
-          // We want to rethrow the exception, even if error_state is set, so
-          // that interrupts continue.
+
+          // If an error occurs inside the cleanup code, a new
+          // exception will be thrown instead of the original.
           throw;
         }
 
+      // Also execute the unwind_protect_cleanump code if the
+      // unwind_protect block runs without error.
       do_unwind_protect_cleanup_code (cleanup_code);
     }
 }
@@ -1062,9 +1016,6 @@
 void
 tree_evaluator::visit_while_command (tree_while_command& cmd)
 {
-  if (error_state)
-    return;
-
 #if HAVE_LLVM
   if (tree_jit::execute (cmd))
     return;
@@ -1091,12 +1042,7 @@
           tree_statement_list *loop_body = cmd.body ();
 
           if (loop_body)
-            {
-              loop_body->accept (*this);
-
-              if (error_state)
-                return;
-            }
+            loop_body->accept (*this);
 
           if (quit_loop_now ())
             break;
@@ -1109,9 +1055,6 @@
 void
 tree_evaluator::visit_do_until_command (tree_do_until_command& cmd)
 {
-  if (error_state)
-    return;
-
 #if HAVE_LLVM
   if (tree_jit::execute (cmd))
     return;
@@ -1133,12 +1076,7 @@
       tree_statement_list *loop_body = cmd.body ();
 
       if (loop_body)
-        {
-          loop_body->accept (*this);
-
-          if (error_state)
-            return;
-        }
+        loop_body->accept (*this);
 
       if (quit_loop_now ())
         break;
--- a/libinterp/parse-tree/pt-eval.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-eval.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_eval_h)
+#if ! defined (octave_pt_eval_h)
 #define octave_pt_eval_h 1
 
 #include <stack>
--- a/libinterp/parse-tree/pt-except.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-except.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_except_h)
+#if ! defined (octave_pt_except_h)
 #define octave_pt_except_h 1
 
 class tree_statement_list;
--- a/libinterp/parse-tree/pt-exp.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-exp.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -42,14 +42,11 @@
 
   octave_value t1 = rvalue1 ();
 
-  if (! error_state)
-    {
-      if (t1.is_defined ())
-        return t1.is_true ();
-      else
-        ::error ("%s: undefined value used in conditional expression",
-                 warn_for);
-    }
+  if (t1.is_defined ())
+    return t1.is_true ();
+  else
+    error ("%s: undefined value used in conditional expression",
+           warn_for);
 
   return expr_value;
 }
@@ -57,14 +54,14 @@
 octave_value
 tree_expression::rvalue1 (int)
 {
-  ::error ("invalid rvalue function called in expression");
+  error ("invalid rvalue function called in expression");
   return octave_value ();
 }
 
 octave_value_list
 tree_expression::rvalue (int)
 {
-  ::error ("invalid rvalue function called in expression");
+  error ("invalid rvalue function called in expression");
   return octave_value_list ();
 }
 
@@ -77,7 +74,7 @@
 octave_lvalue
 tree_expression::lvalue (void)
 {
-  ::error ("invalid lvalue function called in expression");
+  error ("invalid lvalue function called in expression");
   return octave_lvalue ();
 }
 
--- a/libinterp/parse-tree/pt-exp.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-exp.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_exp_h)
+#if ! defined (octave_pt_exp_h)
 #define octave_pt_exp_h 1
 
 #include <string>
--- a/libinterp/parse-tree/pt-fcn-handle.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-fcn-handle.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_fcn_handle_h)
+#if ! defined (octave_pt_fcn_handle_h)
 #define octave_fcn_handle_h 1
 
 #include <iosfwd>
--- a/libinterp/parse-tree/pt-funcall.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-funcall.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_tree_funcall_h)
+#if ! defined (octave_tree_funcall_h)
 #define octave_tree_funcall_h 1
 
 #include "ov.h"
--- a/libinterp/parse-tree/pt-id.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-id.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -46,16 +46,14 @@
   int c = column ();
 
   maybe_missing_function_hook (name ());
-  if (error_state)
-    return;
 
   if (l == -1 && c == -1)
-    ::error_with_id ("Octave:undefined-function",
-                     "'%s' undefined", name ().c_str ());
+    error_with_id ("Octave:undefined-function",
+                   "'%s' undefined", name ().c_str ());
   else
-    ::error_with_id ("Octave:undefined-function",
-                     "'%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
@@ -64,9 +62,6 @@
 {
   octave_value_list retval;
 
-  if (error_state)
-    return retval;
-
   octave_value val = sym->find ();
 
   if (val.is_defined ())
--- a/libinterp/parse-tree/pt-id.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-id.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_id_h)
+#if ! defined (octave_pt_id_h)
 #define octave_pt_id_h 1
 
 #include <iosfwd>
@@ -66,7 +66,7 @@
 
   bool is_defined (void) { return sym->is_defined (); }
 
-  virtual bool is_variable (void) { return sym->is_variable (); }
+  virtual bool is_variable (void) const { return sym->is_variable (); }
 
   virtual bool is_black_hole (void) { return false; }
 
@@ -118,8 +118,8 @@
 
   void static_workspace_error (void)
   {
-    ::error ("can not add variable \"%s\" to a static workspace",
-             name ().c_str ());
+    error ("can not add variable \"%s\" to a static workspace",
+           name ().c_str ());
   }
 
   tree_identifier *dup (symbol_table::scope_id scope,
@@ -152,7 +152,7 @@
 
   std::string name (void) const { return "~"; }
 
-  bool is_variable (void) { return false; }
+  bool is_variable (void) const { return false; }
 
   bool is_black_hole (void) { return true; }
 
--- a/libinterp/parse-tree/pt-idx.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-idx.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -157,19 +157,16 @@
   if (args)
     arg_values = args->convert_to_const_vector ();
 
-  if (! error_state)
-    {
-      int n = arg_values.length ();
+  int n = arg_values.length ();
 
-      if (n > 0)
-        {
-          arg_values.stash_name_tags (arg_nm);
+  if (n > 0)
+    {
+      arg_values.stash_name_tags (arg_nm);
 
-          retval.resize (dim_vector (1, n));
+      retval.resize (dim_vector (1, n));
 
-          for (int i = 0; i < n; i++)
-            retval(0,i) = arg_values(i);
-        }
+      for (int i = 0; i < n; i++)
+        retval(0,i) = arg_values(i);
     }
 
   return retval;
@@ -189,13 +186,10 @@
         retval = args->convert_to_const_vector (object);
     }
 
-  if (! error_state)
-    {
-      octave_idx_type n = retval.length ();
+  octave_idx_type n = retval.length ();
 
-      if (n > 0)
-        retval.stash_name_tags (arg_nm);
-    }
+  if (n > 0)
+    retval.stash_name_tags (arg_nm);
 
   return retval;
 }
@@ -215,13 +209,7 @@
         {
           octave_value t = df->rvalue1 ();
 
-          if (! error_state)
-            {
-              if (t.is_string () && t.rows () == 1)
-                fn = t.string_value ();
-              else
-                error ("dynamic structure field names must be strings");
-            }
+          fn = t.xstring_value ("dynamic structure field names must be strings");
         }
       else
         panic_impossible ();
@@ -264,9 +252,6 @@
           panic_impossible ();
         }
 
-      if (error_state)
-        return m;
-
       p_args++;
       p_arg_nm++;
       p_dyn_field++;
@@ -284,15 +269,27 @@
   return tree_index_expression::rvalue (nargout, 0);
 }
 
+// Final step of processing an indexing error.  Add the name of the
+// variable being indexed, if any, then issue an error.  (Will this also
+// be needed by pt-lvalue, which calls subsref?)
+
+static void
+final_index_error (index_exception& e, const tree_expression *expr)
+{
+  if (expr->is_identifier ()
+      && dynamic_cast<const tree_identifier *> (expr)->is_variable ())
+    e.set_var (expr->name ());
+
+  std::string msg = e.message ();
+  error_with_id (e.err_id (), msg.c_str ());
+}
+
 octave_value_list
 tree_index_expression::rvalue (int nargout,
                                const std::list<octave_lvalue> *lvalue_list)
 {
   octave_value_list retval;
 
-  if (error_state)
-    return retval;
-
   octave_value first_expr_val;
 
   octave_value_list first_args;
@@ -316,55 +313,54 @@
               first_args = al -> convert_to_const_vector ();
               first_args.stash_name_tags (anm);
 
-              if (! error_state)
-                first_expr_val = id->do_lookup  (first_args);
+              first_expr_val = id->do_lookup  (first_args);
             }
         }
     }
 
-  if (! error_state)
-    {
-      if (first_expr_val.is_undefined ())
-        first_expr_val = expr->rvalue1 ();
+  if (first_expr_val.is_undefined ())
+    first_expr_val = expr->rvalue1 ();
 
-      octave_value tmp = first_expr_val;
-      octave_idx_type tmpi = 0;
+  octave_value tmp = first_expr_val;
+  octave_idx_type tmpi = 0;
 
-      std::list<octave_value_list> idx;
+  std::list<octave_value_list> idx;
+
+  int n = args.size ();
 
-      int n = args.size ();
-
-      std::list<tree_argument_list *>::iterator p_args = args.begin ();
-      std::list<string_vector>::iterator p_arg_nm = arg_nm.begin ();
-      std::list<tree_expression *>::iterator p_dyn_field = dyn_field.begin ();
+  std::list<tree_argument_list *>::iterator p_args = args.begin ();
+  std::list<string_vector>::iterator p_arg_nm = arg_nm.begin ();
+  std::list<tree_expression *>::iterator p_dyn_field = dyn_field.begin ();
 
-      for (int i = 0; i < n; i++)
+  for (int i = 0; i < n; i++)
+    {
+      if (i > 0)
         {
-          if (i > 0)
-            {
-              tree_argument_list *al = *p_args;
+          tree_argument_list *al = *p_args;
 
-              // In Matlab, () can only be followed by . In Octave, we do not
-              // enforce this for rvalue expressions, but we'll split the
-              // evaluation at this point. This will, hopefully, allow Octave's
-              // looser rules apply smoothly for Matlab overloaded subsref
-              // codes.
-              bool force_split = type[i-1] == '(' && type[i] != '.';
+          // In Matlab, () can only be followed by . In Octave, we do not
+          // enforce this for rvalue expressions, but we'll split the
+          // evaluation at this point. This will, hopefully, allow Octave's
+          // looser rules apply smoothly for Matlab overloaded subsref
+          // codes.
+          bool force_split = type[i-1] == '(' && type[i] != '.';
 
-              if (force_split || (al && al->has_magic_end ()))
+          if (force_split || (al && al->has_magic_end ()))
+            {
+              // (we have force_split, or) we have an expression like
+              //
+              //   x{end}.a(end)
+              //
+              // and we are looking at the argument list that
+              // contains the second (or third, etc.) "end" token,
+              // so we must evaluate everything up to the point of
+              // that argument list so we can pass the appropriate
+              // value to the built-in end function.
+
+              try
                 {
-                  // We have an expression like
-                  //
-                  //   x{end}.a(end)
-                  //
-                  // and we are looking at the argument list that
-                  // contains the second (or third, etc.) "end" token,
-                  // so we must evaluate everything up to the point of
-                  // that argument list so we can pass the appropriate
-                  // value to the built-in end function.
-
                   octave_value_list tmp_list
-                    = tmp.subsref (type.substr (tmpi, i - tmpi), idx, nargout);
+                    =tmp.subsref (type.substr (tmpi, i-tmpi), idx, nargout);
 
                   tmp = tmp_list.length () ? tmp_list(0) : octave_value ();
                   tmpi = i;
@@ -373,9 +369,6 @@
                   if (tmp.is_cs_list ())
                     gripe_indexed_cs_list ();
 
-                  if (error_state)
-                    break;
-
                   if (tmp.is_function ())
                     {
                       octave_function *fcn = tmp.function_value (true);
@@ -390,68 +383,70 @@
 
                           if (tmp.is_cs_list ())
                             gripe_indexed_cs_list ();
-
-                          if (error_state)
-                            break;
                         }
                     }
                 }
-            }
-
-          switch (type[i])
-            {
-            case '(':
-              if (have_args)
+              catch (index_exception& e)  // problems with index range, type etc.
                 {
-                  idx.push_back (first_args);
-                  have_args = false;
+                  final_index_error (e, expr);
                 }
-              else
-                idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp));
-              break;
-
-            case '{':
-              idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp));
-              break;
-
-            case '.':
-              idx.push_back (octave_value (get_struct_index (p_arg_nm,
-                                                             p_dyn_field)));
-              break;
-
-            default:
-              panic_impossible ();
             }
-
-          if (error_state)
-            break;
-
-          p_args++;
-          p_arg_nm++;
-          p_dyn_field++;
         }
 
-      if (! error_state)
+      switch (type[i])
         {
-          retval = tmp.subsref (type.substr (tmpi, n - tmpi), idx, nargout,
-                                lvalue_list);
+        case '(':
+          if (have_args)
+            {
+              idx.push_back (first_args);
+              have_args = false;
+            }
+          else
+            idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp));
+          break;
 
-          octave_value val = retval.length () ? retval(0) : octave_value ();
+        case '{':
+          idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp));
+          break;
 
-          if (! error_state && val.is_function ())
-            {
-              octave_function *fcn = val.function_value (true);
+        case '.':
+          idx.push_back (octave_value (get_struct_index (p_arg_nm,
+                                                         p_dyn_field)));
+          break;
+
+        default:
+          panic_impossible ();
+        }
 
-              if (fcn)
-                {
-                  octave_value_list empty_args;
+      p_args++;
+      p_arg_nm++;
+      p_dyn_field++;
+    }
+
+  try
+    {
+      retval = tmp.subsref (type.substr (tmpi, n - tmpi), idx, nargout,
+                            lvalue_list);
+    }
+  catch (index_exception& e)    // problems with range, invalid index type etc.
+    {
+      final_index_error (e, expr);
+    }
 
-                  retval = (lvalue_list
-                            ? val.do_multi_index_op (nargout, empty_args,
-                                                     lvalue_list)
-                            : val.do_multi_index_op (nargout, empty_args));
-                }
-            }
+  octave_value val = retval.length () ? retval(0) : octave_value ();
+
+  if (val.is_function ())
+    {
+      octave_function *fcn = val.function_value (true);
+
+      if (fcn)
+        {
+          octave_value_list empty_args;
+
+          retval = (lvalue_list
+                    ? val.do_multi_index_op (nargout, empty_args,
+                                             lvalue_list)
+                    : val.do_multi_index_op (nargout, empty_args));
         }
     }
 
@@ -487,151 +482,139 @@
 
   retval = expr->lvalue ();
 
-  if (! error_state)
-    {
-      octave_value tmp = retval.value ();
+  octave_value tmp = retval.value ();
+
+  octave_idx_type tmpi = 0;
+  std::list<octave_value_list> tmpidx;
 
-      octave_idx_type tmpi = 0;
-      std::list<octave_value_list> tmpidx;
-
-      for (int i = 0; i < n; i++)
+  for (int i = 0; i < n; i++)
+    {
+      if (retval.numel () != 1)
+        gripe_indexed_cs_list ();
+      else if (tmpi < i)
         {
-          if (retval.numel () != 1)
-            gripe_indexed_cs_list ();
-          else if (tmpi < i)
+          try
             {
-              tmp = tmp.subsref (type.substr (tmpi, i - tmpi), tmpidx, true);
-              tmpidx.clear ();
+              tmp = tmp.subsref (type.substr (tmpi, i-tmpi), tmpidx, true);
+            }
+          catch (index_exception& e)  // problems with range, invalid type etc.
+            {
+              final_index_error (e, expr);
             }
-
-          if (error_state)
-            break;
+          tmpidx.clear ();
+        }
 
-          switch (type[i])
-            {
-            case '(':
+      switch (type[i])
+        {
+        case '(':
+          {
+            octave_value_list tidx
+              = make_value_list (*p_args, *p_arg_nm, &tmp, false);
+
+            idx.push_back (tidx);
+
+            if (i < n - 1)
               {
-                octave_value_list tidx
-                  = make_value_list (*p_args, *p_arg_nm, &tmp, false);
-
-                idx.push_back (tidx);
-
-                if (i < n - 1)
+                if (type[i+1] == '.')
                   {
-                    if (type[i+1] == '.')
-                      {
-                        tmpidx.push_back (tidx);
-                        tmpi = i+1;
-                      }
-                    else
-                      error ("() must be followed by . or close the index chain");
+                    tmpidx.push_back (tidx);
+                    tmpi = i+1;
                   }
+                else
+                  error ("() must be followed by . or close the index chain");
               }
-              break;
+          }
+          break;
+
+        case '{':
+          {
+            octave_value_list tidx
+              = make_value_list (*p_args, *p_arg_nm, &tmp, false);
 
-            case '{':
+            if (tmp.is_undefined ())
+              {
+                if (tidx.has_magic_colon ())
+                  gripe_invalid_inquiry_subscript ();
+                else
+                  tmp = Cell ();
+              }
+            else if (tmp.is_zero_by_zero ()
+                     && (tmp.is_matrix_type () || tmp.is_string ()))
               {
-                octave_value_list tidx
-                  = make_value_list (*p_args, *p_arg_nm, &tmp, false);
+                tmp = Cell ();
+              }
+
+            retval.numel (tmp.numel (tidx));
+
+            idx.push_back (tidx);
+            tmpidx.push_back (tidx);
+            tmpi = i;
+          }
+          break;
 
+        case '.':
+          {
+            octave_value tidx = get_struct_index (p_arg_nm, p_dyn_field);
+
+            bool autoconv = (tmp.is_zero_by_zero ()
+                             && (tmp.is_matrix_type () || tmp.is_string ()
+                                 || tmp.is_cell ()));
+
+            if (i > 0 && type[i-1] == '(')
+              {
+                octave_value_list pidx = idx.back ();
+
+                // Use octave_map, not octave_scalar_map so that the
+                // dimensions are 0x0, not 1x1.
                 if (tmp.is_undefined ())
                   {
-                    if (tidx.has_magic_colon ())
+                    if (pidx.has_magic_colon ())
                       gripe_invalid_inquiry_subscript ();
                     else
-                      tmp = Cell ();
+                      tmp = octave_map ();
                   }
-                else if (tmp.is_zero_by_zero ()
-                         && (tmp.is_matrix_type () || tmp.is_string ()))
-                  {
-                    tmp = Cell ();
-                  }
-
-                retval.numel (tmp.numel (tidx));
+                else if (autoconv)
+                  tmp = octave_map ();
 
-                if (error_state)
-                  break;
-
-                idx.push_back (tidx);
-                tmpidx.push_back (tidx);
-                tmpi = i;
-              }
-              break;
-
-            case '.':
-              {
-                octave_value tidx = get_struct_index (p_arg_nm, p_dyn_field);
-                if (error_state)
-                  break;
+                retval.numel (tmp.numel (pidx));
 
-                bool autoconv = (tmp.is_zero_by_zero ()
-                                 && (tmp.is_matrix_type () || tmp.is_string ()
-                                     || tmp.is_cell ()));
-
-                if (i > 0 && type[i-1] == '(')
+                tmpi = i-1;
+                tmpidx.push_back (tidx);
+              }
+            else
+              {
+                if (tmp.is_undefined () || autoconv)
                   {
-                    octave_value_list pidx = idx.back ();
-
-                    // Use octave_map, not octave_scalar_map so that the
-                    // dimensions are 0x0, not 1x1.
-                    if (tmp.is_undefined ())
-                      {
-                        if (pidx.has_magic_colon ())
-                          gripe_invalid_inquiry_subscript ();
-                        else
-                          tmp = octave_map ();
-                      }
-                    else if (autoconv)
-                      tmp = octave_map ();
-
-                    retval.numel (tmp.numel (pidx));
-
-                    tmpi = i-1;
-                    tmpidx.push_back (tidx);
+                    tmpi = i+1;
+                    tmp = octave_value ();
                   }
                 else
                   {
-                    if (tmp.is_undefined () || autoconv)
-                      {
-                        tmpi = i+1;
-                        tmp = octave_value ();
-                      }
-                    else
-                      {
-                        retval.numel (tmp.numel (octave_value_list ()));
+                    retval.numel (tmp.numel (octave_value_list ()));
 
-                        tmpi = i;
-                        tmpidx.push_back (tidx);
-                      }
+                    tmpi = i;
+                    tmpidx.push_back (tidx);
                   }
-
-                if (error_state)
-                  break;
+              }
 
-                idx.push_back (tidx);
-              }
-              break;
-
-            default:
-              panic_impossible ();
-            }
+            idx.push_back (tidx);
+          }
+          break;
 
-          if (idx.back ().empty ())
-            error ("invalid empty index list");
-
-          if (error_state)
-            break;
-
-          p_args++;
-          p_arg_nm++;
-          p_dyn_field++;
+        default:
+          panic_impossible ();
         }
 
-      if (! error_state)
-        retval.set_index (type, idx);
+      if (idx.back ().empty ())
+        error ("invalid empty index list");
 
+      p_args++;
+      p_arg_nm++;
+      p_dyn_field++;
     }
 
+  retval.set_index (type, idx);
+
   return retval;
 }
 
--- a/libinterp/parse-tree/pt-idx.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-idx.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_idx_h)
+#if ! defined (octave_pt_idx_h)
 #define octave_pt_idx_h 1
 
 #include <list>
--- a/libinterp/parse-tree/pt-jump.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-jump.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_jump_h)
+#if ! defined (octave_pt_jump_h)
 #define octave_pt_jump_h 1
 
 class tree_walker;
--- a/libinterp/parse-tree/pt-loop.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-loop.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_loop_h)
+#if ! defined (octave_pt_loop_h)
 #define octave_pt_loop_h 1
 
 class octave_value;
--- a/libinterp/parse-tree/pt-mat.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-mat.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -274,9 +274,13 @@
 }
 
 static void
+eval_error (const char *msg, const dim_vector& x,
+            const dim_vector& y) GCC_ATTR_NORETURN;
+
+static void
 eval_error (const char *msg, const dim_vector& x, const dim_vector& y)
 {
-  ::error ("%s (%s vs %s)", msg, x.str ().c_str (), y.str ().c_str ());
+  error ("%s (%s vs %s)", msg, x.str ().c_str (), y.str ().c_str ());
 }
 
 void
@@ -360,9 +364,9 @@
 
       octave_value tmp = elt->rvalue1 ();
 
-      if (error_state || tmp.is_undefined ())
+      if (tmp.is_undefined ())
         {
-          ok = ! error_state;
+          ok = true;
           return;
         }
       else
@@ -388,35 +392,29 @@
 
   first_elem = true;
 
-  if (! error_state)
+  for (iterator p = begin (); p != end (); p++)
     {
-      for (iterator p = begin (); p != end (); p++)
-        {
-          octave_quit ();
+      octave_quit ();
+
+      octave_value val = *p;
 
-          octave_value val = *p;
+      dim_vector this_elt_dv = val.dims ();
 
-          dim_vector this_elt_dv = val.dims ();
+      if (! this_elt_dv.zero_by_zero ())
+        {
+          all_mt = false;
 
-          if (! this_elt_dv.zero_by_zero ())
+          if (first_elem)
             {
-              all_mt = false;
-
-              if (first_elem)
-                {
-                  first_elem = false;
-                  dv = this_elt_dv;
-                }
-              else if ((! any_class) && (! dv.hvcat (this_elt_dv, 1)))
-                {
-                  eval_error ("horizontal dimensions mismatch", dv, this_elt_dv);
-                  break;
-                }
+              first_elem = false;
+              dv = this_elt_dv;
             }
+          else if ((! any_class) && (! dv.hvcat (this_elt_dv, 1)))
+            eval_error ("horizontal dimensions mismatch", dv, this_elt_dv);
         }
     }
 
-  ok = ! error_state;
+  ok = true;
 }
 
 void
@@ -456,11 +454,7 @@
                   dv = this_elt_dv;
                 }
               else if (! dv.hvcat (this_elt_dv, 1))
-                {
-                  eval_error ("horizontal dimensions mismatch",
-                              dv, this_elt_dv);
-                  break;
-                }
+                eval_error ("horizontal dimensions mismatch", dv, this_elt_dv);
             }
         }
     }
@@ -606,73 +600,63 @@
         break;
     }
 
-  if (! error_state)
+  if (any_cell && ! any_class && ! first_elem_is_struct)
     {
-      if (any_cell && ! any_class && ! first_elem_is_struct)
-        {
-          for (iterator q = begin (); q != end (); q++)
-            {
-              octave_quit ();
-
-              q->cellify ();
-            }
-        }
-
-      first_elem = true;
-
       for (iterator q = begin (); q != end (); q++)
         {
           octave_quit ();
 
-          tm_row_const elt = *q;
-
-          octave_idx_type this_elt_nr = elt.rows ();
-          octave_idx_type this_elt_nc = elt.cols ();
-
-          std::string this_elt_class_nm = elt.class_name ();
-          class_nm = get_concat_class (class_nm, this_elt_class_nm);
-
-          dim_vector this_elt_dv = elt.dims ();
-
-          all_mt = false;
-
-          if (first_elem)
-            {
-              first_elem = false;
-
-              dv = this_elt_dv;
-            }
-          else if (all_str && dv.length () == 2
-                   && this_elt_dv.length () == 2)
-            {
-              // FIXME: this is Octave's specialty. Character matrices allow
-              // rows of unequal length.
-              if (this_elt_nc > cols ())
-                dv(1) = this_elt_nc;
-              dv(0) += this_elt_nr;
-            }
-          else if ((!any_class) && (!dv.hvcat (this_elt_dv, 0)))
-            {
-              eval_error ("vertical dimensions mismatch", dv, this_elt_dv);
-              return;
-            }
+          q->cellify ();
         }
     }
 
-  ok = ! error_state;
+  first_elem = true;
+
+  for (iterator q = begin (); q != end (); q++)
+    {
+      octave_quit ();
+
+      tm_row_const elt = *q;
+
+      octave_idx_type this_elt_nr = elt.rows ();
+      octave_idx_type this_elt_nc = elt.cols ();
+
+      std::string this_elt_class_nm = elt.class_name ();
+      class_nm = get_concat_class (class_nm, this_elt_class_nm);
+
+      dim_vector this_elt_dv = elt.dims ();
+
+      all_mt = false;
+
+      if (first_elem)
+        {
+          first_elem = false;
+
+          dv = this_elt_dv;
+        }
+      else if (all_str && dv.length () == 2
+               && this_elt_dv.length () == 2)
+        {
+          // FIXME: this is Octave's specialty. Character matrices allow
+          // rows of unequal length.
+          if (this_elt_nc > cols ())
+            dv(1) = this_elt_nc;
+          dv(0) += this_elt_nr;
+        }
+      else if ((!any_class) && (!dv.hvcat (this_elt_dv, 0)))
+        eval_error ("vertical dimensions mismatch", dv, this_elt_dv);
+    }
+
+  ok = true;
 }
 
 octave_value_list
 tree_matrix::rvalue (int nargout)
 {
-  octave_value_list retval;
-
   if (nargout > 1)
     error ("invalid number of output arguments for matrix list");
-  else
-    retval = rvalue1 (nargout);
 
-  return retval;
+  return rvalue1 (nargout);
 }
 
 void
@@ -707,20 +691,13 @@
           TYPE ra = octave_value_extract<TYPE> (*q);
 
           // Skip empty arrays to allow looser rules.
-          if (! error_state)
-            {
-              if (! ra.is_empty ())
-                {
-                  result.insert (ra, r, c);
 
-                  if (! error_state)
-                    c += ra.columns ();
-                  else
-                    return;
-                }
+          if (! ra.is_empty ())
+            {
+              result.insert (ra, r, c);
+
+              c += ra.columns ();
             }
-          else
-            return;
         }
 
       r += row.rows ();
@@ -752,8 +729,7 @@
           result.clear (dv);
           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++)
+          for (tm_row_const::iterator q = row.begin (); q != row.end (); q++)
             result(i++) = octave_value_extract<T> (*q);
 
           return;
@@ -763,9 +739,7 @@
       octave_idx_type i = 0;
       OCTAVE_LOCAL_BUFFER (Array<T>, array_list, ncols);
 
-      for (tm_row_const::iterator q = row.begin ();
-           q != row.end () && ! error_state;
-           q++)
+      for (tm_row_const::iterator q = row.begin (); q != row.end (); q++)
         {
           octave_quit ();
 
@@ -773,8 +747,7 @@
           i++;
         }
 
-      if (! error_state)
-        result = Array<T>::cat (-2, ncols, array_list);
+      result = Array<T>::cat (-2, ncols, array_list);
     }
   else
     {
@@ -808,9 +781,7 @@
       octave_idx_type i = 0;
       OCTAVE_LOCAL_BUFFER (Sparse<T>, sparse_list, ncols);
 
-      for (tm_row_const::iterator q = row.begin ();
-           q != row.end () && ! error_state;
-           q++)
+      for (tm_row_const::iterator q = row.begin (); q != row.end (); q++)
         {
           octave_quit ();
 
@@ -848,9 +819,7 @@
       octave_idx_type i = 0;
       OCTAVE_LOCAL_BUFFER (MAP, map_list, ncols);
 
-      for (tm_row_const::iterator q = row.begin ();
-           q != row.end () && ! error_state;
-           q++)
+      for (tm_row_const::iterator q = row.begin (); q != row.end (); q++)
         {
           octave_quit ();
 
@@ -921,13 +890,10 @@
         }
     }
 
-  if (! error_state)
-    {
-      if (rows.length () == 1)
-        retval = rows(0);
-      else
-        retval = do_class_concat (rows, "vertcat", 0);
-    }
+  if (rows.length () == 1)
+    retval = rows(0);
+  else
+    retval = do_class_concat (rows, "vertcat", 0);
 
   return retval;
 }
@@ -1095,53 +1061,46 @@
                 ctmp = ctmp.resize (dim_vector (0,0)).resize (dv);
             }
 
-          if (! error_state)
-            {
-              // Now, extract the values from the individual elements and
-              // insert them in the result matrix.
+          // Now, extract the values from the individual elements and
+          // insert them in the result matrix.
+
+          int dv_len = dv.length ();
+          octave_idx_type ntmp = dv_len > 1 ? dv_len : 2;
+          Array<octave_idx_type> ra_idx (dim_vector (ntmp, 1), 0);
 
-              int dv_len = dv.length ();
-              octave_idx_type ntmp = dv_len > 1 ? dv_len : 2;
-              Array<octave_idx_type> ra_idx (dim_vector (ntmp, 1), 0);
+          for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++)
+            {
+              octave_quit ();
 
-              for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++)
+              tm_row_const row = *p;
+
+              for (tm_row_const::iterator q = row.begin ();
+                   q != row.end ();
+                   q++)
                 {
                   octave_quit ();
 
-                  tm_row_const row = *p;
-
-                  for (tm_row_const::iterator q = row.begin ();
-                       q != row.end ();
-                       q++)
-                    {
-                      octave_quit ();
-
-                      octave_value elt = *q;
+                  octave_value elt = *q;
 
-                      if (elt.is_empty ())
-                        continue;
-
-                      ctmp = do_cat_op (ctmp, elt, ra_idx);
+                  if (elt.is_empty ())
+                    continue;
 
-                      if (error_state)
-                        goto done;
+                  ctmp = do_cat_op (ctmp, elt, ra_idx);
 
-                      ra_idx (1) += elt.columns ();
-                    }
-
-                  ra_idx (0) += row.rows ();
-                  ra_idx (1) = 0;
+                  ra_idx (1) += elt.columns ();
                 }
 
-              retval = ctmp;
+              ra_idx (0) += row.rows ();
+              ra_idx (1) = 0;
+            }
 
-              if (frc_str_conv && ! retval.is_string ())
-                retval = retval.convert_to_str ();
-            }
+          retval = ctmp;
+
+          if (frc_str_conv && ! retval.is_string ())
+            retval = retval.convert_to_str ();
         }
     }
 
-done:
   return retval;
 }
 
--- a/libinterp/parse-tree/pt-mat.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-mat.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_mat_h)
+#if ! defined (octave_pt_mat_h)
 #define octave_pt_mat_h 1
 
 #include <iosfwd>
--- a/libinterp/parse-tree/pt-misc.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-misc.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -81,41 +81,34 @@
                 error ("invalid use of ~ in output list");
             }
           else if (dict.find (name) != dict.end ())
-            {
-              retval = false;
-              error ("'%s' appears more than once in parameter list",
-                     name.c_str ());
-              break;
-            }
+            error ("'%s' appears more than once in parameter list",
+                   name.c_str ());
           else
             dict.insert (name);
         }
     }
 
-  if (! error_state)
-    {
-      std::string va_type = (type == in ? "varargin" : "varargout");
+  std::string va_type = (type == in ? "varargin" : "varargout");
 
-      size_t len = length ();
+  size_t len = length ();
 
-      if (len > 0)
-        {
-          tree_decl_elt *elt = back ();
+  if (len > 0)
+    {
+      tree_decl_elt *elt = back ();
 
-          tree_identifier *id = elt->ident ();
+      tree_identifier *id = elt->ident ();
 
-          if (id && id->name () == va_type)
-            {
-              if (len == 1)
-                mark_varargs_only ();
-              else
-                mark_varargs ();
+      if (id && id->name () == va_type)
+        {
+          if (len == 1)
+            mark_varargs_only ();
+          else
+            mark_varargs ();
 
-              iterator p = end ();
-              --p;
-              delete *p;
-              erase (p);
-            }
+          iterator p = end ();
+          --p;
+          delete *p;
+          erase (p);
         }
     }
 
@@ -182,8 +175,6 @@
 void
 tree_parameter_list::define_from_arg_vector (const octave_value_list& args)
 {
-  int nargin = args.length ();
-
   int expected_nargin = length ();
 
   iterator p = begin ();
@@ -194,15 +185,12 @@
 
       octave_lvalue ref = elt->lvalue ();
 
-      if (i < nargin)
+      if (i < args.length ())
         {
           if (args(i).is_defined () && args(i).is_magic_colon ())
             {
               if (! elt->eval ())
-                {
-                  ::error ("no default value for argument %d\n", i+1);
-                  return;
-                }
+                error ("no default value for argument %d", i+1);
             }
           else
             ref.define (args(i));
--- a/libinterp/parse-tree/pt-misc.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-misc.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_misc_h)
+#if ! defined (octave_pt_misc_h)
 #define octave_pt_misc_h 1
 
 class Cell;
--- a/libinterp/parse-tree/pt-pr-code.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-pr-code.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -329,7 +329,7 @@
 
       cmd_list->accept (*this);
 
-      decrement_indent_level ();
+      // endfunction will decrement the indent level.
     }
 
   visit_octave_user_function_trailer (fcn);
@@ -600,7 +600,7 @@
         case '.':
           {
             string_vector nm = *p_arg_names;
-            assert (nm.length () == 1);
+            assert (nm.numel () == 1);
             os << "." << nm(0);
           }
           break;
@@ -719,6 +719,9 @@
 void
 tree_print_code::visit_no_op_command (tree_no_op_command& cmd)
 {
+  if (cmd.is_end_of_fcn_or_script () && curr_print_indent_level > 1)
+    decrement_indent_level ();
+
   indent ();
 
   os << cmd.original_command ();
@@ -873,13 +876,7 @@
     {
       cmd->accept (*this);
 
-      if (! stmt.print_result ())
-        {
-          os << ";";
-          newline (" ");
-        }
-      else
-        newline ();
+      newline ();
     }
   else
     {
--- a/libinterp/parse-tree/pt-pr-code.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-pr-code.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_pr_code_h)
+#if ! defined (octave_pt_pr_code_h)
 #define octave_pt_pr_code_h 1
 
 #include <stack>
--- a/libinterp/parse-tree/pt-select.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-select.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -123,7 +123,7 @@
 {
   octave_value label_value = label->rvalue1 ();
 
-  if (! error_state && label_value.is_defined ())
+  if (label_value.is_defined ())
     {
       if (label_value.is_cell ())
         {
@@ -135,22 +135,13 @@
                 {
                   bool match = val.is_equal (cell(i,j));
 
-                  if (error_state)
-                    return false;
-                  else if (match)
+                  if (match)
                     return true;
                 }
             }
         }
       else
-        {
-          bool match = val.is_equal (label_value);
-
-          if (error_state)
-            return false;
-          else
-            return match;
-        }
+        return val.is_equal (label_value);
     }
 
   return false;
--- a/libinterp/parse-tree/pt-select.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-select.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_select_h)
+#if ! defined (octave_pt_select_h)
 #define octave_pt_select_h 1
 
 class expression;
--- a/libinterp/parse-tree/pt-stmt.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-stmt.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_stmt_h)
+#if ! defined (octave_pt_stmt_h)
 #define octave_pt_stmt_h 1
 
 class octave_value_list;
--- a/libinterp/parse-tree/pt-unop.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-unop.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -62,34 +62,27 @@
 {
   octave_value retval;
 
-  if (error_state)
-    return retval;
-
   if (op)
     {
       if (etype == octave_value::op_incr || etype == octave_value::op_decr)
         {
           octave_lvalue ref = op->lvalue ();
 
-          if (! error_state)
-            {
-              BEGIN_PROFILER_BLOCK (tree_prefix_expression)
+          BEGIN_PROFILER_BLOCK (tree_prefix_expression)
 
-              ref.do_unary_op (etype);
+          ref.do_unary_op (etype);
 
-              if (! error_state)
-                retval = ref.value ();
+          retval = ref.value ();
 
-              END_PROFILER_BLOCK
-            }
+          END_PROFILER_BLOCK
         }
       else
         {
           octave_value val = op->rvalue1 ();
 
-          if (! error_state && val.is_defined ())
+          if (val.is_defined ())
             {
-              BEGIN_PROFILER_BLOCK (tree_prefix_expression)
+               BEGIN_PROFILER_BLOCK (tree_prefix_expression)
 
               // Attempt to do the operation in-place if it is unshared
               // (a temporary expression).
@@ -98,9 +91,6 @@
               else
                 retval = ::do_unary_op (etype, val);
 
-              if (error_state)
-                retval = octave_value ();
-
               END_PROFILER_BLOCK
             }
         }
@@ -149,39 +139,30 @@
 {
   octave_value retval;
 
-  if (error_state)
-    return retval;
-
   if (op)
     {
       if (etype == octave_value::op_incr || etype == octave_value::op_decr)
         {
           octave_lvalue ref = op->lvalue ();
 
-          if (! error_state)
-            {
-              retval = ref.value ();
+          retval = ref.value ();
+
+          BEGIN_PROFILER_BLOCK (tree_postfix_expression)
 
-              BEGIN_PROFILER_BLOCK (tree_postfix_expression)
+          ref.do_unary_op (etype);
 
-              ref.do_unary_op (etype);
-
-              END_PROFILER_BLOCK
-            }
+          END_PROFILER_BLOCK
         }
       else
         {
           octave_value val = op->rvalue1 ();
 
-          if (! error_state && val.is_defined ())
+          if (val.is_defined ())
             {
               BEGIN_PROFILER_BLOCK (tree_postfix_expression)
 
               retval = ::do_unary_op (etype, val);
 
-              if (error_state)
-                retval = octave_value ();
-
               END_PROFILER_BLOCK
             }
         }
--- a/libinterp/parse-tree/pt-unop.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-unop.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_unop_h)
+#if ! defined (octave_pt_unop_h)
 #define octave_pt_unop_h 1
 
 #include <string>
--- a/libinterp/parse-tree/pt-walk.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt-walk.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_walk_h)
+#if ! defined (octave_pt_walk_h)
 #define octave_pt_walk_h 1
 
 class tree_anon_fcn_handle;
--- a/libinterp/parse-tree/pt.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/pt.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pt_h)
+#if ! defined (octave_pt_h)
 #define octave_pt_h 1
 
 #include <string>
--- a/libinterp/parse-tree/token.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/parse-tree/token.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_token_h)
+#if ! defined (octave_token_h)
 #define octave_token_h 1
 
 #include <string>
--- a/libinterp/template-inst/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/template-inst/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,6 +1,4 @@
-EXTRA_DIST += template-inst/module.mk
-
 TEMPLATE_INST_SRC = \
-  template-inst/Array-os.cc \
-  template-inst/Array-tc.cc \
-  template-inst/Array-jit.cc
+  libinterp/template-inst/Array-os.cc \
+  libinterp/template-inst/Array-tc.cc \
+  libinterp/template-inst/Array-jit.cc
--- a/libinterp/version.in.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/libinterp/version.in.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_version_h)
+#if ! defined (octave_version_h)
 #define octave_version_h 1
 
 #define OCTAVE_VERSION %OCTAVE_VERSION%
--- a/liboctave/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +0,0 @@
-# Makefile for Octave's liboctave directory
-#
-# Copyright (C) 1993-2015 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 $(top_srcdir)/build-aux/common.mk
-
-## Search local directories before those specified by the user.
-AM_CPPFLAGS = \
-  -I$(srcdir)/array \
-  -I$(srcdir)/cruft/misc \
-  -Inumeric -I$(srcdir)/numeric \
-  -Ioperators -I$(srcdir)/operators \
-  -I$(srcdir)/system \
-  -I$(srcdir)/util \
-  -I$(top_builddir)/libgnu -I$(top_srcdir)/libgnu
-
-AM_CFLAGS += $(WARN_CFLAGS)
-
-AM_CXXFLAGS += $(WARN_CXXFLAGS)
-
-octlib_LTLIBRARIES = liboctave.la
-
-EXTRA_DIST =
-
-DISTCLEANFILES =
-
-BUILT_INCS = \
-  operators/mx-ops.h \
-  $(OPT_INC) \
-  $(MX_OP_INC) \
-  $(VX_OP_INC) \
-  $(SMX_OP_INC)
-
-BUILT_SOURCES = $(BUILT_INCS)
-
-octinclude_HEADERS = \
-  $(ARRAY_INC) \
-  $(CRUFT_INC) \
-  $(NUMERIC_INC) \
-  $(OPERATORS_INC) \
-  $(SYSTEM_INC) \
-  $(UTIL_INC) \
-  $(OTHER_INC) \
-  $(TEMPLATE_SRC)
-
-nodist_octinclude_HEADERS = \
-  $(BUILT_INCS)
-
-noinst_LTLIBRARIES =
-
-## C++ files that are #included, not compiled
-OTHER_INC =
-
-## C++ files with templates that are #included, not compiled
-TEMPLATE_SRC =
-
-## A list of all files that could include tests
-
-liboctave_la_LIBADD =
-
-include array/module.mk
-include cruft/module.mk
-include numeric/module.mk
-include operators/module.mk
-include system/module.mk
-include util/module.mk
-
-## liboctave merely collects a bunch of compiled convenience libraries.
-## It has no source code itself.
-liboctave_la_SOURCES =
-
-liboctave_la_CPPFLAGS = @OCTAVE_DLL_DEFS@ @CRUFT_DLL_DEFS@ $(AM_CPPFLAGS)
-
-include link-deps.mk
-
-# Dummy C++ source to force C++ linking.
-nodist_EXTRA_liboctave_la_SOURCES = dummy.cc
-
-liboctave_la_LIBADD += \
-  $(top_builddir)/libgnu/libgnu.la \
-  $(LIBOCTAVE_LINK_DEPS)
-
-# Increment these as needed and according to the rules in the libtool manual:
-liboctave_current = 3
-liboctave_revision = 0
-liboctave_age = 0
-
-liboctave_version_info = $(liboctave_current):$(liboctave_revision):$(liboctave_age)
-
-liboctave_la_LDFLAGS = \
-  -version-info $(liboctave_version_info) \
-  $(NO_UNDEFINED_LDFLAG) \
-  @XTRA_CRUFT_SH_LDFLAGS@ \
-  -bindir $(bindir) \
-  $(LIBOCTAVE_LINK_OPTS)
-
-## Rules to build test files
-
-LIBOCTAVE_TST_SRC = \
-  $(array_libarray_la_SOURCES) \
-  $(numeric_libnumeric_la_SOURCES) \
-  $(system_libsystem_la_SOURCES) \
-  $(util_libutil_la_SOURCES) \
-  $(TEMPLATE_SRC)
-
-TST_FILES_SRC := $(shell $(top_srcdir)/build-aux/find-files-with-tests.sh "$(srcdir)" $(LIBOCTAVE_TST_SRC))
-
-TST_FILES := $(addsuffix -tst,$(TST_FILES_SRC))
-
-liboctavetestsdir := $(octtestsdir)/liboctave
-
-nobase_liboctavetests_DATA = $(TST_FILES)
-
-DISTCLEANFILES += \
-  $(BUILT_INCS) \
-  $(TST_FILES)
-
--- a/liboctave/array/Array-util.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/Array-util.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -36,7 +36,7 @@
 {
   bool retval = true;
 
-  int n = ra_idx.length ();
+  int n = ra_idx.numel ();
 
   if (n == dimensions.length ())
     {
@@ -61,7 +61,7 @@
 {
   ra_idx(start_dimension)++;
 
-  int n = ra_idx.length () - 1;
+  int n = ra_idx.numel () - 1;
   int nda = dimensions.length ();
 
   for (int i = start_dimension; i < n; i++)
@@ -81,7 +81,7 @@
 {
   octave_idx_type retval (-1);
 
-  int n = idx.length ();
+  int n = idx.numel ();
 
   if (n > 0)
     {
@@ -89,7 +89,7 @@
 
       while (--n >= 0)
         {
-          retval *= dims (n);
+          retval *= dims(n);
 
           retval += idx(n);
         }
@@ -102,9 +102,9 @@
 {
   octave_idx_type retval = 0;
 
-  for (octave_idx_type i = 0; i < ra_idx.length (); i++)
+  for (octave_idx_type i = 0; i < ra_idx.numel (); i++)
     {
-      if (ra_idx (i) == 1)
+      if (ra_idx(i) == 1)
         retval++;
     }
 
@@ -124,9 +124,9 @@
     }
   else
     {
-      for (int i = 0; i < n; i ++)
+      for (int i = 0; i < n; i++)
         {
-          if (dim (i) != 1)
+          if (dim(i) != 1)
             {
               retval = false;
 
@@ -147,8 +147,8 @@
     m = 2;
   else
     {
-      for (int i = 0; i < n; i ++)
-        if (dim (i) > 1)
+      for (int i = 0; i < n; i++)
+        if (dim(i) > 1)
           m++;
         else if (dim(i) < 1)
           m += 2;
@@ -162,7 +162,7 @@
 {
   bool retval = false;
 
-  for (octave_idx_type i = 0; i < arr.length (); i++)
+  for (octave_idx_type i = 0; i < arr.numel (); i++)
     {
       if (arr (i) == 1)
         {
@@ -178,9 +178,9 @@
 compute_index (octave_idx_type n, const dim_vector& dims)
 {
   if (n < 0)
-    gripe_invalid_index ();
+    gripe_invalid_index (n, 1, 1);
   if (n >= dims.numel ())
-    gripe_index_out_of_range (1, 1, n+1, dims.numel ());
+    gripe_index_out_of_range (1, 1, n+1, dims.numel (), dims);
 
   return n;
 }
@@ -188,12 +188,14 @@
 octave_idx_type
 compute_index (octave_idx_type i, octave_idx_type j, const dim_vector& dims)
 {
-  if (i < 0 || j < 0)
-    gripe_invalid_index ();
+  if (i < 0)
+    gripe_invalid_index (i, 2, 1);
+  else if (j < 0)
+    gripe_invalid_index (j, 2, 2);
   if (i >= dims(0))
-    gripe_index_out_of_range (2, 1, i+1, dims(0));
+    gripe_index_out_of_range (2, 1, i+1, dims(0), dims);
   if (j >= dims.numel (1))
-    gripe_index_out_of_range (2, 2, j+1, dims.numel (1));
+    gripe_index_out_of_range (2, 2, j+1, dims.numel (1), dims);
 
   return j*dims(0) + i;
 }
@@ -202,14 +204,18 @@
 compute_index (octave_idx_type i, octave_idx_type j, octave_idx_type k,
                const dim_vector& dims)
 {
-  if (i < 0 || j < 0 || k < 0)
-    gripe_invalid_index ();
+  if (i < 0)
+    gripe_invalid_index (i, 3, 1);
+  else if (j < 0)
+    gripe_invalid_index (j, 3, 2);
+  else if (k < 0)
+    gripe_invalid_index (k, 3, 3);
   if (i >= dims(0))
-    gripe_index_out_of_range (3, 1, i+1, dims(0));
+    gripe_index_out_of_range (3, 1, i+1, dims(0), dims);
   if (j >= dims(1))
-    gripe_index_out_of_range (3, 2, j+1, dims(1));
+    gripe_index_out_of_range (3, 2, j+1, dims(1), dims);
   if (k >= dims.numel (2))
-    gripe_index_out_of_range (3, 3, k+1, dims.numel (2));
+    gripe_index_out_of_range (3, 3, k+1, dims.numel (2), dims);
 
   return (k*dims(1) + j)*dims(0) + i;
 }
@@ -217,14 +223,14 @@
 octave_idx_type
 compute_index (const Array<octave_idx_type>& ra_idx, const dim_vector& dims)
 {
-  int nd = ra_idx.length ();
+  int nd = ra_idx.numel ();
   const dim_vector dv = dims.redim (nd);
   for (int d = 0; d < nd; d++)
     {
       if (ra_idx(d) < 0)
-        gripe_invalid_index ();
+        gripe_invalid_index (ra_idx(d), nd, d+1);
       if (ra_idx(d) >= dv(d))
-        gripe_index_out_of_range (nd, d+1, ra_idx(d)+1, dv(d));
+        gripe_index_out_of_range (nd, d+1, ra_idx(d)+1, dv(d), dims);
     }
 
   return dv.compute_index (ra_idx.data ());
@@ -235,7 +241,7 @@
 {
   Array<octave_idx_type> retval (a.dims ());
 
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     retval(i) = a(i).elem (0);
 
   return retval;
@@ -257,7 +263,7 @@
 {
   dim_vector retval;
 
-  int n = ra_idx.length ();
+  int n = ra_idx.numel ();
 
   assert (n == dimensions.length ());
 
@@ -298,7 +304,7 @@
 {
   bool retval = true;
 
-  octave_idx_type n = ra_idx.length ();
+  octave_idx_type n = ra_idx.numel ();
 
   for (octave_idx_type i = 0; i < n; i++)
     {
@@ -317,7 +323,7 @@
 {
   bool retval = false;
 
-  octave_idx_type n = ra_idx.length ();
+  octave_idx_type n = ra_idx.numel ();
 
   for (octave_idx_type i = 0; i < n; i++)
     {
@@ -337,7 +343,7 @@
 {
   bool retval = true;
 
-  octave_idx_type idx_n = ra_idx.length ();
+  octave_idx_type idx_n = ra_idx.numel ();
 
   int n = frozen_lengths.length ();
 
@@ -360,7 +366,7 @@
 {
   bool retval = true;
 
-  for (octave_idx_type i = 0; i < arr.length (); i++)
+  for (octave_idx_type i = 0; i < arr.numel (); i++)
     {
       if (arr(i) != 1)
         {
@@ -376,7 +382,7 @@
 get_elt_idx (const Array<idx_vector>& ra_idx,
              const Array<octave_idx_type>& result_idx)
 {
-  octave_idx_type n = ra_idx.length ();
+  octave_idx_type n = ra_idx.numel ();
 
   Array<octave_idx_type> retval (dim_vector (n, 1));
 
@@ -423,7 +429,7 @@
 dim_vector
 zero_dims_inquire (const Array<idx_vector>& ia, const dim_vector& rhdv)
 {
-  int ial = ia.length ();
+  int ial = ia.numel ();
   int rhdvl = rhdv.length ();
   dim_vector rdv = dim_vector::alloc (ial);
   bool *scalar = new bool [ial];
@@ -530,7 +536,7 @@
 sub2ind (const dim_vector& dv, const Array<idx_vector>& idxa)
 {
   idx_vector retval;
-  octave_idx_type len = idxa.length ();
+  octave_idx_type len = idxa.numel ();
 
   if (len >= 1)
     {
@@ -540,18 +546,31 @@
 
       for (octave_idx_type i = 0; i < len; i++)
         {
-          idx_vector idx = idxa(i);
-          octave_idx_type n = dvx(i);
+          try
+            {
+              idx_vector idx = idxa(i);
+              octave_idx_type n = dvx(i);
+
+              all_ranges = all_ranges && idx.is_range ();
+              if (clen < 0)
+                clen = idx.length (n);
+              else if (clen != idx.length (n))
+                current_liboctave_error_handler ("sub2ind: lengths of indices must match");
 
-          all_ranges = all_ranges && idx.is_range ();
-          if (clen < 0)
-            clen = idx.length (n);
-          else if (clen != idx.length (n))
-            current_liboctave_error_handler ("sub2ind: lengths of indices must match");
+              if (idx.extent (n) > n)
+                  gripe_index_out_of_range (len, i+1, idx.extent (n), n);
+            }
+          catch (index_exception& e)
+            {
+              e.set_pos_if_unset (len, i+1);
+              e.set_var ();
+              std::string msg = e.message ();
+              (*current_liboctave_error_with_id_handler)
+                (e.err_id (), msg.c_str ());
+            }
+        }
+      // idxa known to be valid. Shouldn't need to catch index_exception below here.
 
-          if (idx.extent (n) > n)
-            current_liboctave_error_handler ("sub2ind: index out of range");
-        }
 
       if (len == 1)
         retval = idxa(0);
@@ -560,7 +579,7 @@
           // All scalars case - the result is a scalar.
           octave_idx_type idx = idxa(len-1)(0);
           for (octave_idx_type i = len - 2; i >= 0; i--)
-            idx = idx * dvx(i) + idxa(i)(0);
+            idx = dvx(i) * idx + idxa(i)(0);
           retval = idx_vector (idx);
         }
       else if (all_ranges && clen != 0)
@@ -572,8 +591,8 @@
             {
               octave_idx_type xstart = idxa(i)(0);
               octave_idx_type xstep = idxa(i)(1) - xstart;
-              start = start * dvx(i) + xstart;
-              step = step * dvx(i) + xstep;
+              start = dvx(i) * start + xstart;
+              step = dvx(i) * step + xstep;
             }
           retval = idx_vector::make_range (start, step, clen);
         }
--- a/liboctave/array/Array-util.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/Array-util.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_Array_util_h)
+#if ! defined (octave_Array_util_h)
 #define octave_Array_util_h 1
 
 #include "Array.h"
--- a/liboctave/array/Array.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/Array.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -72,7 +72,7 @@
   if (rep->count > 1)
     {
       --rep->count;
-      rep = new ArrayRep (length (), val);
+      rep = new ArrayRep (numel (), val);
       slice_data = rep->data;
     }
   else
@@ -190,9 +190,9 @@
 {
   // Do checks directly to avoid recomputing slice_len.
   if (n < 0)
-    gripe_invalid_index ();
+    gripe_invalid_index (n);
   if (n >= slice_len)
-    gripe_index_out_of_range (1, 1, n+1, slice_len);
+    gripe_index_out_of_range (1, 1, n+1, slice_len, dimensions);
 
   return elem (n);
 }
@@ -224,9 +224,9 @@
 {
   // Do checks directly to avoid recomputing slice_len.
   if (n < 0)
-    gripe_invalid_index ();
+    gripe_invalid_index (n);
   if (n >= slice_len)
-    gripe_index_out_of_range (1, 1, n+1, slice_len);
+    gripe_index_out_of_range (1, 1, n+1, slice_len, dimensions);
 
   return elem (n);
 }
@@ -260,7 +260,7 @@
   octave_idx_type r = dimensions(0);
 #ifdef BOUNDS_CHECKING
   if (k < 0 || k > dimensions.numel (1))
-    gripe_index_out_of_range (2, 2, k+1, dimensions.numel (1));
+    gripe_index_out_of_range (2, 2, k+1, dimensions.numel (1), dimensions);
 #endif
 
   return Array<T> (*this, dim_vector (r, 1), k*r, k*r + r);
@@ -275,7 +275,7 @@
   octave_idx_type p = r*c;
 #ifdef BOUNDS_CHECKING
   if (k < 0 || k > dimensions.numel (2))
-    gripe_index_out_of_range (3, 3, k+1, dimensions.numel (2));
+    gripe_index_out_of_range (3, 3, k+1, dimensions.numel (2), dimensions);
 #endif
 
   return Array<T> (*this, dim_vector (r, c), k*p, k*p + p);
@@ -287,9 +287,9 @@
 {
 #ifdef BOUNDS_CHECKING
   if (lo < 0)
-    gripe_index_out_of_range (1, 1, lo+1, numel ());
+    gripe_index_out_of_range (1, 1, lo+1, numel (), dimensions);
   if (up > numel ())
-    gripe_index_out_of_range (1, 1, up, numel ());
+    gripe_index_out_of_range (1, 1, up, numel (), dimensions);
 #endif
   if (up < lo) up = lo;
   return Array<T> (*this, dim_vector (up - lo, 1), lo, up);
@@ -313,7 +313,7 @@
     : n (dv.length ()), top (0), dim (new octave_idx_type [2*n]),
       stride (dim + n), use_blk (false)
   {
-    assert (n == perm.length ());
+    assert (n == perm.numel ());
 
     // Get cumulative dimensions.
     OCTAVE_LOCAL_BUFFER (octave_idx_type, cdim, n+1);
@@ -446,7 +446,7 @@
 
   dim_vector dv = dims ();
 
-  int perm_vec_len = perm_vec_arg.length ();
+  int perm_vec_len = perm_vec_arg.numel ();
 
   if (perm_vec_len < dv.length ())
     (*current_liboctave_error_handler)
@@ -532,7 +532,7 @@
 
 public:
   rec_index_helper (const dim_vector& dv, const Array<idx_vector>& ia)
-    : n (ia.length ()), top (0), dim (new octave_idx_type [2*n]),
+    : n (ia.numel ()), top (0), dim (new octave_idx_type [2*n]),
       cdim (dim + n), idx (new idx_vector [n])
   {
     assert (n > 0 && (dv.length () == std::max (n, 2)));
@@ -726,7 +726,7 @@
   else
     {
       if (i.extent (n) != n)
-        gripe_index_out_of_range (1, 1, i.extent (n), n); // throws
+        gripe_index_out_of_range (1, 1, i.extent (n), n, dimensions); // throws
 
       // FIXME: this is the only place where orig_dimensions are used.
       dim_vector rd = i.orig_dimensions ();
@@ -793,9 +793,9 @@
   else
     {
       if (i.extent (r) != r)
-        gripe_index_out_of_range (2, 1, i.extent (r), r); // throws
+        gripe_index_out_of_range (2, 1, i.extent (r), r, dimensions); // throws
       if (j.extent (c) != c)
-        gripe_index_out_of_range (2, 2, j.extent (c), c); // throws
+        gripe_index_out_of_range (2, 2, j.extent (c), c, dimensions); // throws
 
       octave_idx_type n = numel ();
       octave_idx_type il = i.length (r);
@@ -837,7 +837,7 @@
 Array<T>
 Array<T>::index (const Array<idx_vector>& ia) const
 {
-  int ial = ia.length ();
+  int ial = ia.numel ();
   Array<T> retval;
 
   // FIXME: is this dispatching necessary?
@@ -855,7 +855,7 @@
       for (int i = 0; i < ial; i++)
         {
           if (ia(i).extent (dv(i)) != dv(i))
-            gripe_index_out_of_range (ial, i+1, ia(i).extent (dv(i)), dv(i)); // throws
+            gripe_index_out_of_range (ial, i+1, ia(i).extent (dv(i)), dv(i), dimensions); // throws
 
           all_colons = all_colons && ia(i).is_colon ();
         }
@@ -1112,10 +1112,10 @@
   Array<T> tmp = *this;
   if (resize_ok)
     {
-      int ial = ia.length ();
+      int ial = ia.numel ();
       dim_vector dv = dimensions.redim (ial);
       dim_vector dvx = dim_vector::alloc (ial);
-      for (int i = 0; i < ial; i++) dvx(i) = ia(i).extent (dv (i));
+      for (int i = 0; i < ial; i++) dvx(i) = ia(i).extent (dv(i));
       if (! (dvx == dv))
         {
           bool all_scalars = true;
@@ -1180,9 +1180,10 @@
         }
     }
   else
-    gripe_invalid_assignment_size ();
+    gripe_nonconformant ("=", dim_vector(i.length(n),1), rhs.dims());
 }
 
+// Assignment to a 2-dimensional array
 template <class T>
 void
 Array<T>::assign (const idx_vector& i, const idx_vector& j,
@@ -1281,16 +1282,18 @@
             }
         }
     }
-  else
-    gripe_assignment_dimension_mismatch ();
+  // any empty RHS can be assigned to an empty LHS
+  else if ((il != 0 && jl != 0) || (rhdv(0) != 0 && rhdv(1) != 0))
+    gripe_nonconformant ("=", il, jl, rhs.dim1 (), rhs.dim2 ());
 }
 
+// Assignment to a multi-dimensional array
 template <class T>
 void
 Array<T>::assign (const Array<idx_vector>& ia,
                   const Array<T>& rhs, const T& rfv)
 {
-  int ial = ia.length ();
+  int ial = ia.numel ();
 
   // FIXME: is this dispatching necessary / desirable?
   if (ial == 1)
@@ -1384,10 +1387,30 @@
             }
         }
       else
-        gripe_assignment_dimension_mismatch ();
+        {
+          // dimension mismatch, unless LHS and RHS both empty
+          bool lhsempty, rhsempty;
+          lhsempty = rhsempty = false;
+          for (int i = 0; i < ial; i++)
+            {
+              octave_idx_type l = ia(i).length (rdv(i));
+              lhsempty = lhsempty || (l == 0);
+              rhsempty = rhsempty || (rhdv(j++) == 0);
+            }
+          if (! lhsempty || ! rhsempty)
+            gripe_nonconformant ("=", dv, rhdv);
+        }
     }
 }
 
+/*
+%!shared a
+%! a = [1 2; 3 4];
+%!error <op1 is 1x2, op2 is 1x3> a(1,:) = [1 2 3]
+%!error <op1 is 2x1, op2 is 1x3> a(:,1) = [1 2 3]
+%!error <op1 is 2x2, op2 is 2x1> a(1:2,2:3) = [1;2]
+*/
+
 template <class T>
 void
 Array<T>::delete_elements (const idx_vector& i)
@@ -1439,7 +1462,7 @@
       return;
     }
 
-  octave_idx_type n = dimensions (dim);
+  octave_idx_type n = dimensions(dim);
   if (i.is_colon ())
     {
       *this = Array<T> ();
@@ -1492,7 +1515,7 @@
 void
 Array<T>::delete_elements (const Array<idx_vector>& ia)
 {
-  int ial = ia.length ();
+  int ial = ia.numel ();
 
   if (ial == 1)
     delete_elements (ia(0));
@@ -1590,11 +1613,11 @@
 Array<T>&
 Array<T>::insert (const Array<T>& a, const Array<octave_idx_type>& ra_idx)
 {
-  octave_idx_type n = ra_idx.length ();
+  octave_idx_type n = ra_idx.numel ();
   Array<idx_vector> idx (dim_vector (n, 1));
   const dim_vector dva = a.dims ().redim (n);
   for (octave_idx_type k = 0; k < n; k++)
-    idx(k) = idx_vector (ra_idx (k), ra_idx (k) + dva(k));
+    idx(k) = idx_vector (ra_idx(k), ra_idx(k) + dva(k));
 
   assign (idx, a);
 
@@ -1776,7 +1799,7 @@
 
   dim_vector dv = m.dims ();
 
-  if (m.length () < 1)
+  if (m.numel () < 1)
     return m;
 
   if (dim >= dv.length ())
@@ -1897,7 +1920,7 @@
 
   dim_vector dv = m.dims ();
 
-  if (m.length () < 1)
+  if (m.numel () < 1)
     {
       sidx = Array<octave_idx_type> (dv);
       return m;
@@ -2231,7 +2254,7 @@
 Array<T>::nnz (void) const
 {
   const T *src = data ();
-  octave_idx_type nel = nelem ();
+  octave_idx_type nel = numel ();
   octave_idx_type retval = 0;
   const T zero = T ();
   for (octave_idx_type i = 0; i < nel; i++)
@@ -2247,7 +2270,7 @@
 {
   Array<octave_idx_type> retval;
   const T *src = data ();
-  octave_idx_type nel = nelem ();
+  octave_idx_type nel = numel ();
   const T zero = T ();
   if (n < 0 || n >= nel)
     {
@@ -2317,7 +2340,7 @@
       || (rows () == 0 && dims ().numel (1) == 0))
     retval.dimensions = dim_vector ();
   else if (rows () == 1 && ndims () == 2)
-    retval.dimensions = dim_vector (1, retval.length ());
+    retval.dimensions = dim_vector (1, retval.numel ());
 
   return retval;
 }
@@ -2533,8 +2556,8 @@
     (*current_liboctave_error_handler) ("Matrix must be 2-dimensional");
   else
     {
-      octave_idx_type nnr = dv (0);
-      octave_idx_type nnc = dv (1);
+      octave_idx_type nnr = dv(0);
+      octave_idx_type nnc = dv(1);
 
       if (nnr == 0 && nnc == 0)
         ; // do nothing for empty matrix
--- a/liboctave/array/Array.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/Array.h	Thu Dec 10 12:50:06 2015 -0800
@@ -23,7 +23,7 @@
 
 */
 
-#if !defined (octave_Array_h)
+#if ! defined (octave_Array_h)
 #define octave_Array_h 1
 
 #include <cassert>
@@ -88,7 +88,7 @@
 
     ~ArrayRep (void) { delete [] data; }
 
-    octave_idx_type length (void) const { return len; }
+    octave_idx_type numel (void) const { return len; }
 
   private:
 
@@ -203,7 +203,7 @@
   template <class U>
   Array (const Array<U>& a)
     : dimensions (a.dims ()),
-      rep (new typename Array<T>::ArrayRep (a.data (), a.length ())),
+      rep (new typename Array<T>::ArrayRep (a.data (), a.numel ())),
       slice_data (rep->data), slice_len (rep->len)
   { }
 
@@ -252,11 +252,13 @@
   // Number of elements in the array. These are all synonyms.
   //@{
   //! Number of elements in the array.
-  //! Synonymous with length(), nelem(), and numel().
-  octave_idx_type capacity (void) const { return slice_len; }
+  //! Synonymous with numel().
+  //! @note This method is deprecated in favour of numel().
+  GCC_ATTR_DEPRECATED octave_idx_type capacity (void) const { return numel (); }
 
   //! Number of elements in the array.
-  /*! Synonymous with capacity(), nelem(), and numel().
+  /*! Synonymous with numel().
+      @note This method is deprecated in favour of numel().
 
       @note
       This is @em not the same as @c %length() at the Octave interpreter.
@@ -264,15 +266,15 @@
       length of the greatest dimension.  This method returns the total
       number of elements.
    */
-  octave_idx_type length (void) const { return capacity (); }
+  GCC_ATTR_DEPRECATED octave_idx_type length (void) const { return numel (); }
 
   //! Number of elements in the array.
-  //! Synonymous with capacity(), length(), and numel().
-  octave_idx_type nelem (void) const { return capacity (); }
+  //! Synonymous with numel().
+  //! @note This method is deprecated in favour of numel().
+  GCC_ATTR_DEPRECATED octave_idx_type nelem (void) const { return numel (); }
 
   //! Number of elements in the array.
-  //! Synonymous with capacity(), length(), and nelem().
-  octave_idx_type numel (void) const { return nelem (); }
+  octave_idx_type numel (void) const { return slice_len; }
   //@}
 
   //! Return the array as a column vector.
@@ -346,7 +348,7 @@
 
   octave_idx_type compute_index_unchecked (const Array<octave_idx_type>& ra_idx)
   const
-  { return dimensions.compute_index (ra_idx.data (), ra_idx.length ()); }
+  { return dimensions.compute_index (ra_idx.data (), ra_idx.numel ()); }
 
   // No checking, even for multiple references, ever.
 
@@ -658,7 +660,7 @@
   Array<U>
   map (F fcn) const
   {
-    octave_idx_type len = length ();
+    octave_idx_type len = numel ();
 
     const T *m = data ();
 
@@ -701,7 +703,7 @@
   template <class F, bool zero>
   bool test (F fcn) const
   {
-    return any_all_test<F, T, zero> (fcn, data (), length ());
+    return any_all_test<F, T, zero> (fcn, data (), numel ());
   }
 
   //@{
--- a/liboctave/array/CColVector.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/CColVector.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -60,8 +60,8 @@
 bool
 ComplexColumnVector::operator == (const ComplexColumnVector& a) const
 {
-  octave_idx_type len = length ();
-  if (len != a.length ())
+  octave_idx_type len = numel ();
+  if (len != a.numel ())
     return 0;
   return mx_inline_equal (len, data (), a.data ());
 }
@@ -77,9 +77,9 @@
 ComplexColumnVector&
 ComplexColumnVector::insert (const ColumnVector& a, octave_idx_type r)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
-  if (r < 0 || r + a_len > length ())
+  if (r < 0 || r + a_len > numel ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -99,9 +99,9 @@
 ComplexColumnVector&
 ComplexColumnVector::insert (const ComplexColumnVector& a, octave_idx_type r)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
-  if (r < 0 || r + a_len > length ())
+  if (r < 0 || r + a_len > numel ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -121,7 +121,7 @@
 ComplexColumnVector&
 ComplexColumnVector::fill (double val)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -137,7 +137,7 @@
 ComplexColumnVector&
 ComplexColumnVector::fill (const Complex& val)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -154,7 +154,7 @@
 ComplexColumnVector&
 ComplexColumnVector::fill (double val, octave_idx_type r1, octave_idx_type r2)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len)
     {
@@ -179,7 +179,7 @@
 ComplexColumnVector::fill (const Complex& val,
                            octave_idx_type r1, octave_idx_type r2)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len)
     {
@@ -203,9 +203,9 @@
 ComplexColumnVector
 ComplexColumnVector::stack (const ColumnVector& a) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   octave_idx_type nr_insert = len;
-  ComplexColumnVector retval (len + a.length ());
+  ComplexColumnVector retval (len + a.numel ());
   retval.insert (*this, 0);
   retval.insert (a, nr_insert);
   return retval;
@@ -214,9 +214,9 @@
 ComplexColumnVector
 ComplexColumnVector::stack (const ComplexColumnVector& a) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   octave_idx_type nr_insert = len;
-  ComplexColumnVector retval (len + a.length ());
+  ComplexColumnVector retval (len + a.numel ());
   retval.insert (*this, 0);
   retval.insert (a, nr_insert);
   return retval;
@@ -279,9 +279,9 @@
 ComplexColumnVector&
 ComplexColumnVector::operator += (const ColumnVector& a)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (len != a_len)
     {
@@ -301,9 +301,9 @@
 ComplexColumnVector&
 ComplexColumnVector::operator -= (const ColumnVector& a)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (len != a_len)
     {
@@ -337,7 +337,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.cols ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (nc != a_len)
     gripe_nonconformant ("operator *", nr, nc, a_len, 1);
@@ -382,7 +382,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.cols ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (nc != a_len)
     {
@@ -410,7 +410,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.cols ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (nc != a_len)
     {
@@ -438,7 +438,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.cols ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (nc != a_len)
     {
@@ -465,7 +465,7 @@
 Complex
 ComplexColumnVector::min (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return 0.0;
 
@@ -485,7 +485,7 @@
 Complex
 ComplexColumnVector::max (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return 0.0;
 
@@ -508,7 +508,7 @@
 operator << (std::ostream& os, const ComplexColumnVector& a)
 {
 //  int field_width = os.precision () + 7;
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     os << /* setw (field_width) << */ a.elem (i) << "\n";
   return os;
 }
@@ -516,7 +516,7 @@
 std::istream&
 operator >> (std::istream& is, ComplexColumnVector& a)
 {
-  octave_idx_type len = a.length ();
+  octave_idx_type len = a.numel ();
 
   if (len > 0)
     {
--- a/liboctave/array/CColVector.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/CColVector.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_CColVector_h)
+#if ! defined (octave_CColVector_h)
 #define octave_CColVector_h 1
 
 #include "MArray.h"
--- a/liboctave/array/CDiagMatrix.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/CDiagMatrix.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -110,7 +110,7 @@
 ComplexDiagMatrix::fill (const ColumnVector& a)
 {
   octave_idx_type len = length ();
-  if (a.length () != len)
+  if (a.numel () != len)
     {
       (*current_liboctave_error_handler) ("range error for fill");
       return *this;
@@ -126,7 +126,7 @@
 ComplexDiagMatrix::fill (const ComplexColumnVector& a)
 {
   octave_idx_type len = length ();
-  if (a.length () != len)
+  if (a.numel () != len)
     {
       (*current_liboctave_error_handler) ("range error for fill");
       return *this;
@@ -142,7 +142,7 @@
 ComplexDiagMatrix::fill (const RowVector& a)
 {
   octave_idx_type len = length ();
-  if (a.length () != len)
+  if (a.numel () != len)
     {
       (*current_liboctave_error_handler) ("range error for fill");
       return *this;
@@ -158,7 +158,7 @@
 ComplexDiagMatrix::fill (const ComplexRowVector& a)
 {
   octave_idx_type len = length ();
-  if (a.length () != len)
+  if (a.numel () != len)
     {
       (*current_liboctave_error_handler) ("range error for fill");
       return *this;
@@ -173,7 +173,7 @@
 ComplexDiagMatrix&
 ComplexDiagMatrix::fill (const ColumnVector& a, octave_idx_type beg)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (beg < 0 || beg + a_len >= length ())
     {
       (*current_liboctave_error_handler) ("range error for fill");
@@ -189,7 +189,7 @@
 ComplexDiagMatrix&
 ComplexDiagMatrix::fill (const ComplexColumnVector& a, octave_idx_type beg)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (beg < 0 || beg + a_len >= length ())
     {
       (*current_liboctave_error_handler) ("range error for fill");
@@ -205,7 +205,7 @@
 ComplexDiagMatrix&
 ComplexDiagMatrix::fill (const RowVector& a, octave_idx_type beg)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (beg < 0 || beg + a_len >= length ())
     {
       (*current_liboctave_error_handler) ("range error for fill");
@@ -221,7 +221,7 @@
 ComplexDiagMatrix&
 ComplexDiagMatrix::fill (const ComplexRowVector& a, octave_idx_type beg)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (beg < 0 || beg + a_len >= length ())
     {
       (*current_liboctave_error_handler) ("range error for fill");
--- a/liboctave/array/CDiagMatrix.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/CDiagMatrix.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_CDiagMatrix_h)
+#if ! defined (octave_CDiagMatrix_h)
 #define octave_CDiagMatrix_h 1
 
 #include "MDiagArray2.h"
--- a/liboctave/array/CMatrix.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/CMatrix.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -366,7 +366,7 @@
   if (rows () != a.rows () || cols () != a.cols ())
     return false;
 
-  return mx_inline_equal (length (), data (), a.data ());
+  return mx_inline_equal (numel (), data (), a.data ());
 }
 
 bool
@@ -423,7 +423,7 @@
 ComplexMatrix&
 ComplexMatrix::insert (const RowVector& a, octave_idx_type r, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ())
     {
@@ -446,7 +446,7 @@
 ComplexMatrix::insert (const ColumnVector& a,
                        octave_idx_type r, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ())
     {
@@ -505,7 +505,7 @@
 ComplexMatrix::insert (const ComplexRowVector& a,
                        octave_idx_type r, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
@@ -522,7 +522,7 @@
 ComplexMatrix::insert (const ComplexColumnVector& a,
                        octave_idx_type r, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ())
     {
@@ -693,7 +693,7 @@
     }
 
   octave_idx_type nc_insert = nc;
-  ComplexMatrix retval (nr, nc + a.length ());
+  ComplexMatrix retval (nr, nc + a.numel ());
   retval.insert (*this, 0, 0);
   retval.insert (a, 0, nc_insert);
   return retval;
@@ -704,7 +704,7 @@
 {
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
-  if (nr != a.length ())
+  if (nr != a.numel ())
     {
       (*current_liboctave_error_handler) ("row dimension mismatch for append");
       return *this;
@@ -765,7 +765,7 @@
     }
 
   octave_idx_type nc_insert = nc;
-  ComplexMatrix retval (nr, nc + a.length ());
+  ComplexMatrix retval (nr, nc + a.numel ());
   retval.insert (*this, 0, 0);
   retval.insert (a, 0, nc_insert);
   return retval;
@@ -776,7 +776,7 @@
 {
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
-  if (nr != a.length ())
+  if (nr != a.numel ())
     {
       (*current_liboctave_error_handler) ("row dimension mismatch for append");
       return *this;
@@ -831,7 +831,7 @@
 {
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
-  if (nc != a.length ())
+  if (nc != a.numel ())
     {
       (*current_liboctave_error_handler)
         ("column dimension mismatch for stack");
@@ -858,7 +858,7 @@
     }
 
   octave_idx_type nr_insert = nr;
-  ComplexMatrix retval (nr + a.length (), nc);
+  ComplexMatrix retval (nr + a.numel (), nc);
   retval.insert (*this, 0, 0);
   retval.insert (a, nr_insert, 0);
   return retval;
@@ -907,7 +907,7 @@
 {
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
-  if (nc != a.length ())
+  if (nc != a.numel ())
     {
       (*current_liboctave_error_handler)
         ("column dimension mismatch for stack");
@@ -934,7 +934,7 @@
     }
 
   octave_idx_type nr_insert = nr;
-  ComplexMatrix retval (nr + a.length (), nc);
+  ComplexMatrix retval (nr + a.numel (), nc);
   retval.insert (*this, 0, 0);
   retval.insert (a, nr_insert, 0);
   return retval;
@@ -1131,7 +1131,7 @@
 
       // Calculate the norm of the matrix, for later use.
       double anorm;
-      //if (calc_cond)   // Must always calculate anorm for bug #45577 
+      //if (calc_cond)   // Must always calculate anorm for bug #45577
       anorm = retval.abs ().sum ().row (static_cast<octave_idx_type>(0)).max ();
 
       // Work around bug #45577, LAPACK crashes Octave if norm is NaN
@@ -1196,7 +1196,7 @@
     {
       if (mattype.is_hermitian ())
         {
-          ComplexCHOL chol (*this, info, calc_cond);
+          ComplexCHOL chol (*this, info, true, calc_cond);
           if (info == 0)
             {
               if (calc_cond)
@@ -1232,7 +1232,7 @@
 
   ColumnVector sigma = S.extract_diag ();
 
-  octave_idx_type r = sigma.length () - 1;
+  octave_idx_type r = sigma.numel () - 1;
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
 
@@ -1323,7 +1323,7 @@
 ComplexMatrix
 ComplexMatrix::fourier2d (void) const
 {
-  dim_vector dv(rows (), cols ());
+  dim_vector dv (rows (), cols ());
 
   ComplexMatrix retval (rows (), cols ());
   const Complex *in (data ());
@@ -1337,7 +1337,7 @@
 ComplexMatrix
 ComplexMatrix::ifourier2d (void) const
 {
-  dim_vector dv(rows (), cols ());
+  dim_vector dv (rows (), cols ());
 
   ComplexMatrix retval (rows (), cols ());
   const Complex *in (data ());
@@ -1701,7 +1701,7 @@
 
           // Calculate the norm of the matrix, for later use.
           double anorm = 0;
-          //if (calc_cond)   // Must always calculate anorm for bug #45577 
+          //if (calc_cond)   // Must always calculate anorm for bug #45577
           anorm = xnorm (*this, 1);
 
           // Work around bug #45577, LAPACK crashes Octave if norm is NaN
@@ -2860,7 +2860,7 @@
   octave_idx_type m = rows ();
   octave_idx_type n = cols ();
 
-  if (m != b.length ())
+  if (m != b.numel ())
     (*current_liboctave_error_handler)
       ("matrix dimension mismatch solution of linear equations");
   else if (m == 0 || n == 0 || b.cols () == 0)
@@ -2973,11 +2973,11 @@
 {
   ComplexMatrix retval;
 
-  octave_idx_type len = v.length ();
+  octave_idx_type len = v.numel ();
 
   if (len != 0)
     {
-      octave_idx_type a_len = a.length ();
+      octave_idx_type a_len = a.numel ();
 
       retval = ComplexMatrix (len, a_len);
       Complex *c = retval.fortran_vec ();
@@ -3101,7 +3101,7 @@
 
   Complex *d = fortran_vec (); // Ensures only one reference to my privates!
 
-  mx_inline_add2 (length (), d, a.data ());
+  mx_inline_add2 (numel (), d, a.data ());
   return *this;
 }
 
@@ -3125,7 +3125,7 @@
 
   Complex *d = fortran_vec (); // Ensures only one reference to my privates!
 
-  mx_inline_sub2 (length (), d, a.data ());
+  mx_inline_sub2 (numel (), d, a.data ());
   return *this;
 }
 
@@ -3880,7 +3880,7 @@
   if (nr != b.rows () || nc != b.columns ())
     {
       (*current_liboctave_error_handler)
-        ("two-arg min expecting args of same size");
+        ("two-arg min requires same size arguments");
       return ComplexMatrix ();
     }
 
@@ -3968,7 +3968,7 @@
   if (nr != b.rows () || nc != b.columns ())
     {
       (*current_liboctave_error_handler)
-        ("two-arg max expecting args of same size");
+        ("two-arg max requires same size arguments");
       return ComplexMatrix ();
     }
 
@@ -4015,21 +4015,25 @@
                         octave_idx_type n)
 
 {
-  if (n < 1) n = 1;
-
-  octave_idx_type m = x1.length ();
-
-  if (x2.length () != m)
+  octave_idx_type m = x1.numel ();
+
+  if (x2.numel () != m)
     (*current_liboctave_error_handler)
       ("linspace: vectors must be of equal length");
 
   NoAlias<ComplexMatrix> retval;
 
+  if (n < 1)
+    {
+      retval.clear (m, 0);
+      return retval;
+    }
+
   retval.clear (m, n);
   for (octave_idx_type i = 0; i < m; i++)
     retval(i, 0) = x1(i);
 
-  // The last column is not needed while using delta.
+  // The last column is unused so temporarily store delta there
   Complex *delta = &retval(0, n-1);
   for (octave_idx_type i = 0; i < m; i++)
     delta[i] = (x2(i) - x1(i)) / (n - 1.0);
--- a/liboctave/array/CMatrix.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/CMatrix.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_CMatrix_h)
+#if ! defined (octave_CMatrix_h)
 #define octave_CMatrix_h 1
 
 #include "MArray.h"
--- a/liboctave/array/CNDArray.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/CNDArray.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -69,9 +69,9 @@
   for (int i = 0; i < dim; i++)
     stride *= dv(i);
 
-  octave_idx_type howmany = numel () / dv (dim);
+  octave_idx_type howmany = numel () / dv(dim);
   howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
-  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
+  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride);
   octave_idx_type dist = (stride == 1 ? n : 1);
 
   const Complex *in (fortran_vec ());
@@ -100,9 +100,9 @@
   for (int i = 0; i < dim; i++)
     stride *= dv(i);
 
-  octave_idx_type howmany = numel () / dv (dim);
+  octave_idx_type howmany = numel () / dv(dim);
   howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
-  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
+  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride);
   octave_idx_type dist = (stride == 1 ? n : 1);
 
   const Complex *in (fortran_vec ());
@@ -124,7 +124,7 @@
   if (dv.length () < 2)
     return ComplexNDArray ();
 
-  dim_vector dv2(dv(0), dv(1));
+  dim_vector dv2 (dv(0), dv(1));
   const Complex *in = fortran_vec ();
   ComplexNDArray retval (dv);
   Complex *out = retval.fortran_vec ();
@@ -144,7 +144,7 @@
   if (dv.length () < 2)
     return ComplexNDArray ();
 
-  dim_vector dv2(dv(0), dv(1));
+  dim_vector dv2 (dv(0), dv(1));
   const Complex *in = fortran_vec ();
   ComplexNDArray retval (dv);
   Complex *out = retval.fortran_vec ();
@@ -535,7 +535,7 @@
 bool
 ComplexNDArray::all_integers (double& max_val, double& min_val) const
 {
-  octave_idx_type nel = nelem ();
+  octave_idx_type nel = numel ();
 
   if (nel > 0)
     {
@@ -765,7 +765,7 @@
 
       for (int i = 0; i < n; i++)
         {
-          if (a_ra_idx (i) < 0 || (a_ra_idx (i) + a_dv (i)) > dimensions (i))
+          if (a_ra_idx(i) < 0 || (a_ra_idx(i) + a_dv(i)) > dimensions(i))
             {
               (*current_liboctave_error_handler)
                 ("Array<T>::insert: range error for insert");
@@ -778,14 +778,14 @@
 
       octave_idx_type n_elt = a.numel ();
 
-      // IS make_unique () NECCESSARY HERE??
+      // IS make_unique () NECESSARY HERE?
 
       for (octave_idx_type i = 0; i < n_elt; i++)
         {
           Array<octave_idx_type> ra_idx = a_ra_idx;
 
-          ra_idx.elem (0) = a_ra_idx (0) + r;
-          ra_idx.elem (1) = a_ra_idx (1) + c;
+          ra_idx.elem (0) = a_ra_idx(0) + r;
+          ra_idx.elem (1) = a_ra_idx(1) + c;
 
           elem (ra_idx) = a.elem (a_ra_idx);
 
@@ -846,7 +846,7 @@
 std::ostream&
 operator << (std::ostream& os, const ComplexNDArray& a)
 {
-  octave_idx_type nel = a.nelem ();
+  octave_idx_type nel = a.numel ();
 
   for (octave_idx_type i = 0; i < nel; i++)
     {
@@ -860,7 +860,7 @@
 std::istream&
 operator >> (std::istream& is, ComplexNDArray& a)
 {
-  octave_idx_type nel = a.nelem ();
+  octave_idx_type nel = a.numel ();
 
   if (nel > 0)
     {
--- a/liboctave/array/CNDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/CNDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_CNDArray_h)
+#if ! defined (octave_CNDArray_h)
 #define octave_CNDArray_h 1
 
 #include "MArray.h"
--- a/liboctave/array/CRowVector.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/CRowVector.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -59,8 +59,8 @@
 bool
 ComplexRowVector::operator == (const ComplexRowVector& a) const
 {
-  octave_idx_type len = length ();
-  if (len != a.length ())
+  octave_idx_type len = numel ();
+  if (len != a.numel ())
     return 0;
   return mx_inline_equal (len, data (), a.data ());
 }
@@ -76,9 +76,9 @@
 ComplexRowVector&
 ComplexRowVector::insert (const RowVector& a, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
-  if (c < 0 || c + a_len > length ())
+  if (c < 0 || c + a_len > numel ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -98,9 +98,9 @@
 ComplexRowVector&
 ComplexRowVector::insert (const ComplexRowVector& a, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
-  if (c < 0 || c + a_len > length ())
+  if (c < 0 || c + a_len > numel ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -120,7 +120,7 @@
 ComplexRowVector&
 ComplexRowVector::fill (double val)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -136,7 +136,7 @@
 ComplexRowVector&
 ComplexRowVector::fill (const Complex& val)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -152,7 +152,7 @@
 ComplexRowVector&
 ComplexRowVector::fill (double val, octave_idx_type c1, octave_idx_type c2)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len)
     {
@@ -177,7 +177,7 @@
 ComplexRowVector::fill (const Complex& val,
                         octave_idx_type c1, octave_idx_type c2)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len)
     {
@@ -201,9 +201,9 @@
 ComplexRowVector
 ComplexRowVector::append (const RowVector& a) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   octave_idx_type nc_insert = len;
-  ComplexRowVector retval (len + a.length ());
+  ComplexRowVector retval (len + a.numel ());
   retval.insert (*this, 0);
   retval.insert (a, nc_insert);
   return retval;
@@ -212,9 +212,9 @@
 ComplexRowVector
 ComplexRowVector::append (const ComplexRowVector& a) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   octave_idx_type nc_insert = len;
-  ComplexRowVector retval (len + a.length ());
+  ComplexRowVector retval (len + a.numel ());
   retval.insert (*this, 0);
   retval.insert (a, nc_insert);
   return retval;
@@ -271,9 +271,9 @@
 ComplexRowVector&
 ComplexRowVector::operator += (const RowVector& a)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (len != a_len)
     {
@@ -293,9 +293,9 @@
 ComplexRowVector&
 ComplexRowVector::operator -= (const RowVector& a)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (len != a_len)
     {
@@ -319,7 +319,7 @@
 {
   ComplexRowVector retval;
 
-  octave_idx_type len = v.length ();
+  octave_idx_type len = v.numel ();
 
   octave_idx_type a_nr = a.rows ();
   octave_idx_type a_nc = a.cols ();
@@ -361,7 +361,7 @@
 Complex
 ComplexRowVector::min (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return Complex (0.0);
 
@@ -381,7 +381,7 @@
 Complex
 ComplexRowVector::max (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return Complex (0.0);
 
@@ -404,7 +404,7 @@
 operator << (std::ostream& os, const ComplexRowVector& a)
 {
 //  int field_width = os.precision () + 7;
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     os << " " /* setw (field_width) */ << a.elem (i);
   return os;
 }
@@ -412,7 +412,7 @@
 std::istream&
 operator >> (std::istream& is, ComplexRowVector& a)
 {
-  octave_idx_type len = a.length ();
+  octave_idx_type len = a.numel ();
 
   if (len > 0)
     {
@@ -445,9 +445,9 @@
 {
   Complex retval (0.0, 0.0);
 
-  octave_idx_type len = v.length ();
+  octave_idx_type len = v.numel ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (len != a_len)
     gripe_nonconformant ("operator *", len, a_len);
@@ -462,14 +462,19 @@
 ComplexRowVector
 linspace (const Complex& x1, const Complex& x2, octave_idx_type n)
 {
-  if (n < 1) n = 1;
+  NoAlias<ComplexRowVector> retval;
 
-  NoAlias<ComplexRowVector> retval (n);
+  if (n < 1)
+    return retval;
+  else
+    retval.clear (n);
+
+  retval(0) = x1;
 
   Complex delta = (x2 - x1) / (n - 1.0);
-  retval(0) = x1;
   for (octave_idx_type i = 1; i < n-1; i++)
     retval(i) = x1 + static_cast<double> (i)*delta;
+
   retval(n-1) = x2;
 
   return retval;
--- a/liboctave/array/CRowVector.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/CRowVector.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_CRowVector_h)
+#if ! defined (octave_CRowVector_h)
 #define octave_CRowVector_h 1
 
 #include "MArray.h"
--- a/liboctave/array/CSparse.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/CSparse.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_CSparse_h)
+#if ! defined (octave_CSparse_h)
 #define octave_CSparse_h 1
 
 #include "dMatrix.h"
@@ -34,7 +34,6 @@
 
 #include "DET.h"
 #include "MSparse.h"
-#include "MSparse-defs.h"
 
 #include "Sparse-op-decls.h"
 
--- a/liboctave/array/DiagArray2.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/DiagArray2.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -42,7 +42,7 @@
   : Array<T> (a.as_column ()), d1 (r), d2 (c)
 {
   octave_idx_type rcmin = std::min (r, c);
-  if (rcmin != a.length ())
+  if (rcmin != a.numel ())
     Array<T>::resize (dim_vector (rcmin, 1));
 }
 
@@ -126,13 +126,13 @@
 
   if (r < 0 || r >= dim1 ())
     {
-      gripe_index_out_of_range (2, 1, r+1, dim1 ());
+      gripe_index_out_of_range (2, 1, r+1, dim1 (), dims ());
       ok = false;
     }
 
   if (c < 0 || c >= dim2 ())
     {
-      gripe_index_out_of_range (2, 2, c+1, dim2 ());
+      gripe_index_out_of_range (2, 2, c+1, dim2 (), dims ());
       ok = false;
     }
 
--- a/liboctave/array/DiagArray2.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/DiagArray2.h	Thu Dec 10 12:50:06 2015 -0800
@@ -23,7 +23,7 @@
 
 */
 
-#if !defined (octave_DiagArray2_h)
+#if ! defined (octave_DiagArray2_h)
 #define octave_DiagArray2_h 1
 
 #include <cassert>
@@ -87,9 +87,9 @@
   octave_idx_type cols (void) const { return dim2 (); }
   octave_idx_type columns (void) const { return dim2 (); }
 
-  octave_idx_type diag_length (void) const { return Array<T>::length (); }
+  octave_idx_type diag_length (void) const { return Array<T>::numel (); }
   // FIXME: a dangerous ambiguity?
-  octave_idx_type length (void) const { return Array<T>::length (); }
+  octave_idx_type length (void) const { return Array<T>::numel (); }
   octave_idx_type nelem (void) const { return dim1 () * dim2 (); }
   octave_idx_type numel (void) const { return nelem (); }
 
--- a/liboctave/array/MArray-decl.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/MArray-decl.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_MArray_decl_h)
+#if ! defined (octave_MArray_decl_h)
 #define octave_MArray_decl_h 1
 
 // A macro that can be used to declare and instantiate OP= operators.
--- a/liboctave/array/MArray-defs.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/MArray-defs.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_MArray_defs_h)
+#if ! defined (octave_MArray_defs_h)
 #define octave_MArray_defs_h 1
 
 #include "mx-inlines.cc"
--- a/liboctave/array/MArray.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/MArray.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -56,7 +56,7 @@
 void
 MArray<T>::idx_add (const idx_vector& idx, T val)
 {
-  octave_idx_type n = this->length ();
+  octave_idx_type n = this->numel ();
   octave_idx_type ext = idx.extent (n);
   if (ext > n)
     {
@@ -74,7 +74,7 @@
 void
 MArray<T>::idx_add (const idx_vector& idx, const MArray<T>& vals)
 {
-  octave_idx_type n = this->length ();
+  octave_idx_type n = this->numel ();
   octave_idx_type ext = idx.extent (n);
   if (ext > n)
     {
@@ -84,7 +84,7 @@
 
   octave_quit ();
 
-  octave_idx_type len = std::min (idx.length (n), vals.length ());
+  octave_idx_type len = std::min (idx.length (n), vals.numel ());
   idx.loop (len, _idxadda_helper<T> (this->fortran_vec (), vals.data ()));
 }
 
@@ -103,7 +103,7 @@
 void
 MArray<T>::idx_min (const idx_vector& idx, const MArray<T>& vals)
 {
-  octave_idx_type n = this->length ();
+  octave_idx_type n = this->numel ();
   octave_idx_type ext = idx.extent (n);
   if (ext > n)
     {
@@ -113,7 +113,7 @@
 
   octave_quit ();
 
-  octave_idx_type len = std::min (idx.length (n), vals.length ());
+  octave_idx_type len = std::min (idx.length (n), vals.numel ());
   idx.loop (len, _idxbinop_helper<T, xmin> (this->fortran_vec (),
                                             vals.data ()));
 }
@@ -122,7 +122,7 @@
 void
 MArray<T>::idx_max (const idx_vector& idx, const MArray<T>& vals)
 {
-  octave_idx_type n = this->length ();
+  octave_idx_type n = this->numel ();
   octave_idx_type ext = idx.extent (n);
   if (ext > n)
     {
@@ -132,7 +132,7 @@
 
   octave_quit ();
 
-  octave_idx_type len = std::min (idx.length (n), vals.length ());
+  octave_idx_type len = std::min (idx.length (n), vals.numel ());
   idx.loop (len, _idxbinop_helper<T, xmax> (this->fortran_vec (),
                                             vals.data ()));
 }
@@ -153,7 +153,7 @@
   dim_vector ddv = Array<T>::dims ().redim (nd);
   dim_vector sdv = vals.dims ().redim (nd);
 
-  octave_idx_type ext = idx.extent (ddv (dim));
+  octave_idx_type ext = idx.extent (ddv(dim));
 
   if (ext > ddv(dim))
     {
--- a/liboctave/array/MArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/MArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 */
 
-#if !defined (octave_MArray_h)
+#if ! defined (octave_MArray_h)
 #define octave_MArray_h 1
 
 #include "Array.h"
--- a/liboctave/array/MDiagArray2.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/MDiagArray2.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 */
 
-#if !defined (octave_MDiagArray2_h)
+#if ! defined (octave_MDiagArray2_h)
 #define octave_MDiagArray2_h 1
 
 #include "DiagArray2.h"
--- a/liboctave/array/MSparse-C.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/MSparse-C.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -28,7 +28,6 @@
 #include "oct-cmplx.h"
 
 #include "MSparse.h"
-#include "MSparse.cc"
 
 template class OCTAVE_API MSparse<Complex>;
 
--- a/liboctave/array/MSparse-d.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/MSparse-d.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -26,7 +26,6 @@
 #endif
 
 #include "MSparse.h"
-#include "MSparse.cc"
 
 template class OCTAVE_API MSparse<double>;
 
--- a/liboctave/array/MSparse-defs.h	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,213 +0,0 @@
-/*
-
-Copyright (C) 2004-2015 David Bateman
-Copyright (C) 1998-2004 Andy Adler
-
-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_MSparse_defs_h)
-#define octave_MSparse_defs_h 1
-
-// Nothing like a little CPP abuse to brighten everyone's day.
-
-// A macro that can be used to declare and instantiate OP= operators.
-#define SPARSE_OP_ASSIGN_DECL(A_T, E_T, OP, PFX, API, LTGT, RHS_T) \
-  PFX API A_T<E_T>& \
-  operator OP LTGT (A_T<E_T>&, const RHS_T&)
-
-// All the OP= operators that we care about.
-#define SPARSE_OP_ASSIGN_DECLS(A_T, E_T, PFX, API, LTGT, RHS_T) \
-  SPARSE_OP_ASSIGN_DECL (A_T, E_T, +=, PFX, API, LTGT, RHS_T); \
-  SPARSE_OP_ASSIGN_DECL (A_T, E_T, -=, PFX, API, LTGT, RHS_T);
-
-// Generate forward declarations for OP= operators.
-#define SPARSE_OP_ASSIGN_FWD_DECLS(A_T, RHS_T, API) \
-  SPARSE_OP_ASSIGN_DECLS (A_T, T, template <typename T>, API, , RHS_T)
-
-// Generate friend declarations for the OP= operators.
-#define SPARSE_OP_ASSIGN_FRIENDS(A_T, RHS_T, API) \
-  SPARSE_OP_ASSIGN_DECLS (A_T, T, friend, API, <>, RHS_T)
-
-// Instantiate the OP= operators.
-#define SPARSE_OP_ASSIGN_DEFS(A_T, E_T, RHS_T, API) \
-  SPARSE_OP_ASSIGN_DECLS (A_T, E_T, template, API, , RHS_T)
-
-// A function that can be used to forward OP= operations from derived
-// classes back to us.
-#define SPARSE_OP_ASSIGN_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
-  inline R \
-  F (X_T& x, const Y_T& y) \
-  { \
-    return R (F (C_X (x), C_Y (y))); \
-  }
-
-// All the OP= operators that we care about forwarding.
-#define SPARSE_OP_ASSIGN_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \
-  SPARSE_OP_ASSIGN_FWD_FCN (R, operator +=, T, C_X, X_T, C_Y, Y_T) \
-  SPARSE_OP_ASSIGN_FWD_FCN (R, operator -=, T, C_X, X_T, C_Y, Y_T)
-
-// A macro that can be used to declare and instantiate unary operators.
-#define SPARSE_UNOP(A_T, E_T, F, PFX, API, LTGT) \
-  PFX API A_T<E_T> \
-  F LTGT (const A_T<E_T>&)
-
-// All the unary operators that we care about.
-#define SPARSE_UNOP_DECLS(A_T, E_T, PFX, API, LTGT) \
-  SPARSE_UNOP (A_T, E_T, operator +, PFX, API, LTGT); \
-  SPARSE_UNOP (A_T, E_T, operator -, PFX, API, LTGT);
-
-// Generate forward declarations for unary operators.
-#define SPARSE_UNOP_FWD_DECLS(A_T, API) \
-  SPARSE_UNOP_DECLS (A_T, T, template <typename T>, API, )
-
-// Generate friend declarations for the unary operators.
-#define SPARSE_UNOP_FRIENDS(A_T, API) \
-  SPARSE_UNOP_DECLS (A_T, T, friend, API, <>)
-
-// Instantiate the unary operators.
-#define SPARSE_UNOP_DEFS(A_T, E_T, API) \
-  SPARSE_UNOP_DECLS (A_T, E_T, template, API, )
-
-// A function that can be used to forward unary operations from derived
-// classes back to us.
-#define SPARSE_UNOP_FWD_FCN(R, F, T, C_X, X_T) \
-  inline R \
-  F (const X_T& x) \
-  { \
-    return R (F (C_X (x))); \
-  }
-
-// All the unary operators that we care about forwarding.
-#define SPARSE_UNOP_FWD_DEFS(R, T, C_X, X_T) \
-  SPARSE_UNOP_FWD_FCN (R, operator +, T, C_X, X_T) \
-  SPARSE_UNOP_FWD_FCN (R, operator -, T, C_X, X_T)
-
-// A macro that can be used to declare and instantiate binary operators.
-#define SPARSE_BINOP_DECL(A_T, E_T, F, PFX, API, LTGT, X_T, Y_T) \
-  PFX API A_T<E_T> \
-  F LTGT (const X_T&, const Y_T&)
-
-// All the binary operators that we care about.  We have two
-// sets of macros since the MArray OP MArray operations use functions
-// (product and quotient) instead of operators (*, /).
-#define SPARSE_BINOP_DECLS(A_T, F_T, E_T, PFX, API, LTGT, X_T, Y_T)      \
-  SPARSE_BINOP_DECL (F_T, E_T, operator +, PFX, API, LTGT, X_T, Y_T); \
-  SPARSE_BINOP_DECL (F_T, E_T, operator -, PFX, API, LTGT, X_T, Y_T); \
-  SPARSE_BINOP_DECL (A_T, E_T, operator *, PFX, API, LTGT, X_T, Y_T); \
-  SPARSE_BINOP_DECL (A_T, E_T, operator /, PFX, API, LTGT, X_T, Y_T);
-
-#define SPARSE_AA_BINOP_DECLS(A_T, E_T, PFX, API, LTGT) \
-  SPARSE_BINOP_DECL (A_T, E_T, operator +, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \
-  SPARSE_BINOP_DECL (A_T, E_T, operator -, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \
-  SPARSE_BINOP_DECL (A_T, E_T, quotient,   PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \
-  SPARSE_BINOP_DECL (A_T, E_T, product,    PFX, API, LTGT, A_T<E_T>, A_T<E_T>);
-
-// Generate forward declarations for binary operators.
-#define SPARSE_BINOP_FWD_DECLS(A_T, F_T, API) \
-  SPARSE_BINOP_DECLS (A_T, F_T, T, template <typename T>, API, , A_T<T>, T)     \
-  SPARSE_BINOP_DECLS (A_T, F_T, T, template <typename T>, API, , T, A_T<T>) \
-  SPARSE_AA_BINOP_DECLS (A_T, T, template <typename T>, API, )
-
-// Generate friend declarations for the binary operators.
-#define SPARSE_BINOP_FRIENDS(A_T, F_T, API)                  \
-  SPARSE_BINOP_DECLS (A_T, F_T, T, friend, API, <>, A_T<T>, T)  \
-  SPARSE_BINOP_DECLS (A_T, F_T, T, friend, API, <>, T, A_T<T>)  \
-  SPARSE_AA_BINOP_DECLS (A_T, T, friend, API, <>)
-
-// Instantiate the binary operators.
-#define SPARSE_BINOP_DEFS(A_T, F_T, E_T, API) \
-  SPARSE_BINOP_DECLS (A_T, F_T, E_T, template, API, , A_T<E_T>, E_T)    \
-  SPARSE_BINOP_DECLS (A_T, F_T, E_T, template, API, , E_T, A_T<E_T>)    \
-  SPARSE_AA_BINOP_DECLS (A_T, E_T, template, API, )
-
-// A function that can be used to forward binary operations from derived
-// classes back to us.
-#define SPARSE_BINOP_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
-  inline R \
-  F (const X_T& x, const Y_T& y) \
-  { \
-    return R (F (C_X (x), C_Y (y))); \
-  }
-
-// The binary operators that we care about forwarding.  We have two
-// sets of macros since the MSparse OP MSparse operations use functions
-// (product and quotient) instead of operators (*, /).
-#define SPARSE_BINOP_FWD_DEFS(R, F, T, C_X, X_T, C_Y, Y_T)     \
-  SPARSE_BINOP_FWD_FCN (F, operator +, T, C_X, X_T, C_Y, Y_T) \
-  SPARSE_BINOP_FWD_FCN (F, operator -, T, C_X, X_T, C_Y, Y_T) \
-  SPARSE_BINOP_FWD_FCN (R, operator *, T, C_X, X_T, C_Y, Y_T) \
-  SPARSE_BINOP_FWD_FCN (R, operator /, T, C_X, X_T, C_Y, Y_T)
-
-#define SPARSE_AA_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \
-  SPARSE_BINOP_FWD_FCN (R, operator +, T, C_X, X_T, C_Y, Y_T) \
-  SPARSE_BINOP_FWD_FCN (R, operator -, T, C_X, X_T, C_Y, Y_T) \
-  SPARSE_BINOP_FWD_FCN (R, product,    T, C_X, X_T, C_Y, Y_T) \
-  SPARSE_BINOP_FWD_FCN (R, quotient,   T, C_X, X_T, C_Y, Y_T)
-
-// Forward declarations for the MSparse operators.
-#define SPARSE_OPS_FORWARD_DECLS(A_T, F_T, API) \
-  template <class T> \
-  class A_T; \
- \
-  /* SPARSE_OP_ASSIGN_FWD_DECLS (A_T, T) */ \
-  SPARSE_OP_ASSIGN_FWD_DECLS (A_T, A_T<T>, API) \
-  SPARSE_UNOP_FWD_DECLS (A_T, API) \
-  SPARSE_BINOP_FWD_DECLS (A_T, F_T, API)
-
-// Friend declarations for the MSparse operators.
-#define SPARSE_OPS_FRIEND_DECLS(A_T, F_T, API)  \
-  /* SPARSE_OP_ASSIGN_FRIENDS (A_T, T) */ \
-  SPARSE_OP_ASSIGN_FRIENDS (A_T, A_T<T>, API) \
-  SPARSE_UNOP_FRIENDS (A_T, API) \
-    SPARSE_BINOP_FRIENDS (A_T, F_T, API)
-
-// The following macros are for external use.
-
-// Instantiate all the MSparse friends for MSparse element type T.
-#define INSTANTIATE_SPARSE_FRIENDS(T, API) \
-  /* SPARSE_OP_ASSIGN_DEFS (MSparse, T, T) */ \
-  SPARSE_OP_ASSIGN_DEFS (MSparse, T, MSparse<T>, API) \
-  SPARSE_UNOP_DEFS (MSparse, T, API) \
-  SPARSE_BINOP_DEFS (MSparse, MArray, T, API)
-
-// Define all the MSparse forwarding functions for return type R and
-// MSparse element type T
-#define SPARSE_FORWARD_DEFS(B, R, F, T)         \
-  /* SPARSE_OP_ASSIGN_FWD_DEFS  */ \
-  /* (R, T, dynamic_cast<B<T>&>, R, , T) */     \
- \
-  SPARSE_OP_ASSIGN_FWD_DEFS \
-    (R, T, \
-     dynamic_cast<B<T>&>, R, dynamic_cast<const B<T>&>, R) \
- \
-  SPARSE_UNOP_FWD_DEFS \
-    (R, T, dynamic_cast<const B<T>&>, R) \
- \
-  SPARSE_BINOP_FWD_DEFS \
-    (R, F, T, dynamic_cast<const B<T>&>, R, , T) \
- \
-  SPARSE_BINOP_FWD_DEFS \
-    (R, F, T, , T, dynamic_cast<const B<T>&>, R)        \
- \
-  SPARSE_AA_BINOP_FWD_DEFS \
-    (R, T, dynamic_cast<const B<T>&>, R, dynamic_cast<const B<T>&>, R)
-
-// Now we have all the definitions we need.
-
-#endif
--- a/liboctave/array/MSparse.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/MSparse.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -21,20 +21,6 @@
 
 */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <functional>
-
-#include "quit.h"
-#include "lo-error.h"
-#include "MArray.h"
-#include "Array-util.h"
-
-#include "MSparse.h"
-#include "MSparse-defs.h"
-
 // sparse array with math ops.
 
 // Element by element MSparse by MSparse ops.
--- a/liboctave/array/MSparse.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/MSparse.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,21 +21,23 @@
 
 */
 
-#if !defined (octave_MSparse_h)
+#if ! defined (octave_MSparse_h)
 #define octave_MSparse_h 1
 
-#include "MArray.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <functional>
 
+#include "quit.h"
+#include "lo-error.h"
 #include "Sparse.h"
+#include "MArray.h"
+#include "Array-util.h"
+
 
 // Two dimensional sparse array with math ops.
-
-// But first, some preprocessor abuse...
-
-#include "MSparse-defs.h"
-
-SPARSE_OPS_FORWARD_DECLS (MSparse, MArray, )
-
 template <class T>
 class
 MSparse : public Sparse<T>
@@ -119,11 +121,100 @@
   MSparse<U>
   map (U (&fcn) (const T&)) const
   { return Sparse<T>::template map<U> (fcn); }
-
-  // Currently, the OPS functions don't need to be friends, but that
-  // may change.
-
-  // SPARSE_OPS_FRIEND_DECLS (MSparse, MArray)
 };
 
+// Include operator templates for MSparse
+#include "MSparse.cc"
+
+// A macro that can be used to declare and instantiate OP= operators.
+#define SPARSE_OP_ASSIGN_DECL(T, OP, API) \
+  template API MSparse<T>& \
+  operator OP (MSparse<T>&, const MSparse<T>&)
+
+// A macro that can be used to declare and instantiate unary operators.
+#define SPARSE_UNOP_DECL(T, OP, API) \
+  template API MSparse<T> \
+  operator OP (const MSparse<T>&)
+
+// A macro that can be used to declare and instantiate binary operators.
+#define SPARSE_BINOP_DECL(A_T, T, F, API, X_T, Y_T) \
+  template API A_T<T> \
+  F (const X_T&, const Y_T&)
+
+// A function that can be used to forward OP= operations from derived
+// classes back to us.
+#define SPARSE_OP_ASSIGN_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
+  inline R \
+  F (X_T& x, const Y_T& y) \
+  { \
+    return R (F (C_X (x), C_Y (y))); \
+  }
+
+// A function that can be used to forward unary operations from derived
+// classes back to us.
+#define SPARSE_UNOP_FWD_FCN(R, F, T, C_X, X_T) \
+  inline R \
+  F (const X_T& x) \
+  { \
+    return R (F (C_X (x))); \
+  }
+
+// A function that can be used to forward binary operations from derived
+// classes back to us.
+#define SPARSE_BINOP_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
+  inline R \
+  F (const X_T& x, const Y_T& y) \
+  { \
+    return R (F (C_X (x), C_Y (y))); \
+  }
+
+// Instantiate all the MSparse friends for MSparse element type T.
+#define INSTANTIATE_SPARSE_FRIENDS(T, API) \
+  SPARSE_OP_ASSIGN_DECL (T, +=, API); \
+  SPARSE_OP_ASSIGN_DECL (T, -=, API); \
+  SPARSE_UNOP_DECL (T, +, API); \
+  SPARSE_UNOP_DECL (T, -, API); \
+  SPARSE_BINOP_DECL (MArray,  T, operator +, API, MSparse<T>, T); \
+  SPARSE_BINOP_DECL (MArray,  T, operator -, API, MSparse<T>, T); \
+  SPARSE_BINOP_DECL (MSparse, T, operator *, API, MSparse<T>, T); \
+  SPARSE_BINOP_DECL (MSparse, T, operator /, API, MSparse<T>, T); \
+  SPARSE_BINOP_DECL (MArray,  T, operator +, API, T, MSparse<T>); \
+  SPARSE_BINOP_DECL (MArray,  T, operator -, API, T, MSparse<T>); \
+  SPARSE_BINOP_DECL (MSparse, T, operator *, API, T, MSparse<T>); \
+  SPARSE_BINOP_DECL (MSparse, T, operator /, API, T, MSparse<T>); \
+  SPARSE_BINOP_DECL (MSparse, T, operator +, API, MSparse<T>, MSparse<T>); \
+  SPARSE_BINOP_DECL (MSparse, T, operator -, API, MSparse<T>, MSparse<T>); \
+  SPARSE_BINOP_DECL (MSparse, T, quotient,   API, MSparse<T>, MSparse<T>); \
+  SPARSE_BINOP_DECL (MSparse, T, product,    API, MSparse<T>, MSparse<T>);
+
+// Define all the MSparse forwarding functions for return type R and
+// MSparse element type T
+#define SPARSE_FORWARD_DEFS(B, R, F, T) \
+  SPARSE_OP_ASSIGN_FWD_FCN \
+    (R, operator +=, T, dynamic_cast<B<T>&>, R, dynamic_cast<const B<T>&>, R) \
+  SPARSE_OP_ASSIGN_FWD_FCN \
+    (R, operator -=, T, dynamic_cast<B<T>&>, R, dynamic_cast<const B<T>&>, R) \
+  SPARSE_UNOP_FWD_FCN (R, operator +, T, dynamic_cast<const B<T>&>, R) \
+  SPARSE_UNOP_FWD_FCN (R, operator -, T, dynamic_cast<const B<T>&>, R) \
+  SPARSE_BINOP_FWD_FCN (F, operator +, T, dynamic_cast<const B<T>&>, R, , T) \
+  SPARSE_BINOP_FWD_FCN (F, operator -, T, dynamic_cast<const B<T>&>, R, , T) \
+  SPARSE_BINOP_FWD_FCN (R, operator *, T, dynamic_cast<const B<T>&>, R, , T) \
+  SPARSE_BINOP_FWD_FCN (R, operator /, T, dynamic_cast<const B<T>&>, R, , T) \
+  SPARSE_BINOP_FWD_FCN (F, operator +, T, , T, dynamic_cast<const B<T>&>, R) \
+  SPARSE_BINOP_FWD_FCN (F, operator -, T, , T, dynamic_cast<const B<T>&>, R) \
+  SPARSE_BINOP_FWD_FCN (R, operator *, T, , T, dynamic_cast<const B<T>&>, R) \
+  SPARSE_BINOP_FWD_FCN (R, operator /, T, , T, dynamic_cast<const B<T>&>, R) \
+  SPARSE_BINOP_FWD_FCN \
+    (R, operator +, T, dynamic_cast<const B<T>&>, R, \
+      dynamic_cast<const B<T>&>, R) \
+  SPARSE_BINOP_FWD_FCN \
+    (R, operator -, T, dynamic_cast<const B<T>&>, R, \
+      dynamic_cast<const B<T>&>, R) \
+  SPARSE_BINOP_FWD_FCN \
+    (R, product,    T, dynamic_cast<const B<T>&>, R, \
+      dynamic_cast<const B<T>&>, R) \
+  SPARSE_BINOP_FWD_FCN \
+    (R, quotient,   T, dynamic_cast<const B<T>&>, R, \
+      dynamic_cast<const B<T>&>, R)
+
 #endif
--- a/liboctave/array/Matrix.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/Matrix.h	Thu Dec 10 12:50:06 2015 -0800
@@ -24,7 +24,7 @@
 // Should probably say something here about why these classes are not
 // represented by some sort of inheritance tree...
 
-#if !defined (octave_Matrix_h)
+#if ! defined (octave_Matrix_h)
 #define octave_Matrix_h 1
 
 #include "mx-base.h"
--- a/liboctave/array/MatrixType.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/MatrixType.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_MatrixType_h)
+#if ! defined (octave_MatrixType_h)
 #define octave_MatrixType_h
 
 class Matrix;
--- a/liboctave/array/PermMatrix.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/PermMatrix.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -41,7 +41,7 @@
 {
   if (check)
     {
-      if (! idx_vector (p).is_permutation (p.length ()))
+      if (! idx_vector (p).is_permutation (p.numel ()))
         {
           gripe_invalid_permutation ();
           Array<octave_idx_type>::operator = (Array<octave_idx_type> ());
@@ -104,7 +104,7 @@
 octave_idx_type
 PermMatrix::checkelem (octave_idx_type i, octave_idx_type j) const
 {
-  octave_idx_type len = Array<octave_idx_type>::length ();
+  octave_idx_type len = Array<octave_idx_type>::numel ();
   if (i < 0 || j < 0 || i > len || j > len)
     {
       (*current_liboctave_error_handler) ("index out of range");
@@ -118,7 +118,7 @@
 PermMatrix
 PermMatrix::transpose (void) const
 {
-  octave_idx_type len = Array<octave_idx_type>::length ();
+  octave_idx_type len = Array<octave_idx_type>::numel ();
 
   PermMatrix retval (len);
 
--- a/liboctave/array/PermMatrix.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/PermMatrix.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_PermMatrix_h)
+#if ! defined (octave_PermMatrix_h)
 #define octave_PermMatrix_h 1
 
 #include "Array.h"
@@ -48,21 +48,21 @@
   PermMatrix (const idx_vector& idx, bool colp, octave_idx_type n = 0);
 
   octave_idx_type dim1 (void) const
-  { return Array<octave_idx_type>::length (); }
+  { return Array<octave_idx_type>::numel (); }
   octave_idx_type dim2 (void) const
-  { return Array<octave_idx_type>::length (); }
+  { return Array<octave_idx_type>::numel (); }
 
   octave_idx_type rows (void) const { return dim1 (); }
   octave_idx_type cols (void) const { return dim2 (); }
   octave_idx_type columns (void) const { return dim2 (); }
 
   octave_idx_type perm_length (void) const
-  { return Array<octave_idx_type>::length (); }
+  { return Array<octave_idx_type>::numel (); }
   // FIXME: a dangerous ambiguity?
   octave_idx_type length (void) const
   { return perm_length (); }
-  octave_idx_type nelem (void) const { return dim1 () * dim2 (); }
-  octave_idx_type numel (void) const { return nelem (); }
+  GCC_ATTR_DEPRECATED octave_idx_type nelem (void) const { return numel (); }
+  octave_idx_type numel (void) const { return dim1 () * dim2 (); }
 
   size_t byte_size (void) const
   { return Array<octave_idx_type>::byte_size (); }
--- a/liboctave/array/Range.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/Range.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -44,37 +44,27 @@
   // or fewer elements only the base needs to be an integer
 
   return (! (xisnan (rng_base) || xisnan (rng_inc))
-          && (NINTbig (rng_base) == rng_base || rng_nelem < 1)
-          && (NINTbig (rng_inc) == rng_inc || rng_nelem <= 1));
+          && (NINTbig (rng_base) == rng_base || rng_numel < 1)
+          && (NINTbig (rng_inc) == rng_inc || rng_numel <= 1));
 }
 
 Matrix
 Range::matrix_value (void) const
 {
-  if (rng_nelem > 0 && cache.nelem () == 0)
+  if (rng_numel > 0 && cache.numel () == 0)
     {
-      cache.resize (1, rng_nelem);
+      cache.resize (1, rng_numel);
+
+      // The first element must always be *exactly* the base.
+      // E.g, -0 would otherwise become +0 in the loop (-0 + 0*increment).
+      cache(0) = rng_base;
+
       double b = rng_base;
       double increment = rng_inc;
-      if (rng_nelem > 0)
-        {
-          // The first element must always be *exactly* the base.
-          // E.g, -0 would otherwise become +0 in the loop (-0 + 0*increment).
-          cache(0) = b;
-          for (octave_idx_type i = 1; i < rng_nelem; i++)
-            cache(i) = b + i * increment;
-        }
+      for (octave_idx_type i = 1; i < rng_numel - 1; i++)
+        cache(i) = b + i * increment;
 
-      // On some machines (x86 with extended precision floating point
-      // arithmetic, for example) it is possible that we can overshoot
-      // the limit by approximately the machine precision even though
-      // we were very careful in our calculation of the number of
-      // elements.  The tests need equality (>= rng_limit or <= rng_limit)
-      // to have expressions like -5:1:-0 result in a -0 endpoint.
-
-      if ((rng_inc > 0 && cache(rng_nelem-1) >= rng_limit)
-          || (rng_inc < 0 && cache(rng_nelem-1) <= rng_limit))
-        cache(rng_nelem-1) = rng_limit;
+      cache(rng_numel - 1) = rng_limit;
     }
 
   return cache;
@@ -83,22 +73,15 @@
 double
 Range::checkelem (octave_idx_type i) const
 {
-  if (i < 0 || i >= rng_nelem)
-    gripe_index_out_of_range (1, 1, i+1, rng_nelem);
+  if (i < 0 || i >= rng_numel)
+    gripe_index_out_of_range (1, 1, i+1, rng_numel);
 
   if (i == 0)
     return rng_base;
-  else if (i < rng_nelem - 1)
+  else if (i < rng_numel - 1)
     return rng_base + i * rng_inc;
   else
-    {
-      double end = rng_base + i * rng_inc;
-      if ((rng_inc > 0 && end >= rng_limit)
-          || (rng_inc < 0 && end <= rng_limit))
-        return rng_limit;
-      else
-        return end;
-    }
+    return rng_limit;
 }
 
 double
@@ -109,17 +92,10 @@
 #else
   if (i == 0)
     return rng_base;
-  else if (i < rng_nelem - 1)
+  else if (i < rng_numel - 1)
     return rng_base + i * rng_inc;
   else
-    {
-      double end = rng_base + i * rng_inc;
-      if ((rng_inc > 0 && end >= rng_limit)
-          || (rng_inc < 0 && end <= rng_limit))
-        return rng_limit;
-      else
-        return end;
-    }
+    return rng_limit;
 #endif
 }
 
@@ -137,13 +113,7 @@
     else if (i < nmax)
       *array++ = base + i * inc;
     else
-      {
-        double end = base + i * inc;
-        if ((inc > 0 && end >= limit) || (inc < 0 && end <= limit))
-          *array++ = limit;
-        else
-          *array++ = end;
-      }
+      *array++ = limit;
   }
 
 private:
@@ -158,11 +128,11 @@
 {
   Array<double> retval;
 
-  octave_idx_type n = rng_nelem;
+  octave_idx_type n = rng_numel;
 
   if (i.is_colon ())
     {
-      retval = matrix_value ().reshape (dim_vector (rng_nelem, 1));
+      retval = matrix_value ().reshape (dim_vector (rng_numel, 1));
     }
   else
     {
@@ -181,28 +151,28 @@
       // idx_vector loop across all values in i,
       // executing __rangeidx_helper (i) for each i
       i.loop (n, __rangeidx_helper (retval.fortran_vec (),
-                                    rng_base, rng_inc, rng_limit, rng_nelem));
+                                    rng_base, rng_inc, rng_limit, rng_numel));
     }
 
   return retval;
 }
 
-// NOTE: max and min only return useful values if nelem > 0.
-//       do_minmax_body() in max.cc avoids calling Range::min/max if nelem == 0.
+// NOTE: max and min only return useful values if numel > 0.
+//       do_minmax_body() in max.cc avoids calling Range::min/max if numel == 0.
 
 double
 Range::min (void) const
 {
   double retval = 0.0;
-  if (rng_nelem > 0)
+  if (rng_numel > 0)
     {
       if (rng_inc > 0)
         retval = rng_base;
       else
         {
-          retval = rng_base + (rng_nelem - 1) * rng_inc;
+          retval = rng_base + (rng_numel - 1) * rng_inc;
 
-          // See the note in the matrix_value method above.
+          // Require '<=' test.  See note in max ().
           if (retval <= rng_limit)
             retval = rng_limit;
         }
@@ -215,13 +185,19 @@
 Range::max (void) const
 {
   double retval = 0.0;
-  if (rng_nelem > 0)
+  if (rng_numel > 0)
     {
       if (rng_inc > 0)
         {
-          retval = rng_base + (rng_nelem - 1) * rng_inc;
+          retval = rng_base + (rng_numel - 1) * rng_inc;
 
-          // See the note in the matrix_value method above.
+          // On some machines (x86 with extended precision floating point
+          // arithmetic, for example) it is possible that we can overshoot the
+          // limit by approximately the machine precision even though we were
+          // very careful in our calculation of the number of elements.
+          // Therefore, we clip the result to the limit if it overshoots.
+          // The test also includes equality (>= rng_limit) to have expressions
+          // such as -5:1:-0 result in a -0 endpoint.
           if (retval >= rng_limit)
             retval = rng_limit;
         }
@@ -234,19 +210,10 @@
 void
 Range::sort_internal (bool ascending)
 {
-  if (ascending && rng_base > rng_limit && rng_inc < 0.0)
+  if ((ascending && rng_base > rng_limit && rng_inc < 0.0)
+      || (! ascending && rng_base < rng_limit && rng_inc > 0.0))
     {
-      double tmp = rng_base;
-      rng_base = min ();
-      rng_limit = tmp;
-      rng_inc = -rng_inc;
-      clear_cache ();
-    }
-  else if (! ascending && rng_base < rng_limit && rng_inc > 0.0)
-    {
-      double tmp = max ();
-      rng_limit = min ();
-      rng_base = tmp;
+      std::swap (rng_base, rng_limit);
       rng_inc = -rng_inc;
       clear_cache ();
     }
@@ -255,7 +222,7 @@
 void
 Range::sort_internal (Array<octave_idx_type>& sidx, bool ascending)
 {
-  octave_idx_type nel = nelem ();
+  octave_idx_type nel = numel ();
 
   sidx.resize (dim_vector (1, nel));
 
@@ -263,20 +230,10 @@
 
   bool reverse = false;
 
-  if (ascending && rng_base > rng_limit && rng_inc < 0.0)
+  if ((ascending && rng_base > rng_limit && rng_inc < 0.0)
+      || (! ascending && rng_base < rng_limit && rng_inc > 0.0))
     {
-      double tmp = rng_base;
-      rng_base = min ();
-      rng_limit = tmp;
-      rng_inc = -rng_inc;
-      clear_cache ();
-      reverse = true;
-    }
-  else if (! ascending && rng_base < rng_limit && rng_inc > 0.0)
-    {
-      double tmp = max ();
-      rng_limit = min ();
-      rng_base = tmp;
+      std::swap (rng_base, rng_limit);
       rng_inc = -rng_inc;
       clear_cache ();
       reverse = true;
@@ -336,9 +293,9 @@
 sortmode
 Range::is_sorted (sortmode mode) const
 {
-  if (rng_nelem > 1 && rng_inc > 0)
+  if (rng_numel > 1 && rng_inc > 0)
     mode = (mode == DESCENDING) ? UNSORTED : ASCENDING;
-  else if (rng_nelem > 1 && rng_inc < 0)
+  else if (rng_numel > 1 && rng_inc < 0)
     mode = (mode == ASCENDING) ? UNSORTED : DESCENDING;
   else
     mode = mode ? mode : ASCENDING;
@@ -346,12 +303,78 @@
   return mode;
 }
 
+void
+Range::set_base (double b)
+{
+  if (rng_base != b)
+    {
+      rng_base = b;
+      rng_numel = numel_internal ();
+
+      double tmplimit = rng_limit;
+
+      if (rng_inc > 0)
+        tmplimit = max ();
+      else
+        tmplimit = min ();
+
+      if (tmplimit != rng_limit)
+        rng_limit = tmplimit;
+
+      clear_cache ();
+    }
+}
+
+void
+Range::set_limit (double l)
+{
+  if (rng_limit != l)
+    {
+      rng_limit = l;
+      rng_numel = numel_internal ();
+
+      double tmplimit = rng_limit;
+
+      if (rng_inc > 0)
+        tmplimit = max ();
+      else
+        tmplimit = min ();
+
+      if (tmplimit != rng_limit)
+        rng_limit = tmplimit;
+
+      clear_cache ();
+    }
+}
+
+void
+Range::set_inc (double i)
+{
+  if (rng_inc != i)
+    {
+      rng_inc = i;
+      rng_numel = numel_internal ();
+
+      double tmplimit = rng_limit;
+
+      if (rng_inc > 0)
+        tmplimit = max ();
+      else
+        tmplimit = min ();
+
+      if (tmplimit != rng_limit)
+        rng_limit = tmplimit;
+
+      clear_cache ();
+    }
+}
+
 std::ostream&
 operator << (std::ostream& os, const Range& a)
 {
   double b = a.base ();
   double increment = a.inc ();
-  octave_idx_type num_elem = a.nelem ();
+  octave_idx_type num_elem = a.numel ();
 
   if (num_elem > 1)
     {
@@ -361,8 +384,8 @@
         os << b + i * increment << " ";
     }
 
-  // Prevent overshoot.  See comment in the matrix_value method above.
-  os << (increment > 0 ? a.max () : a.min ()) << "\n";
+  // Print out exactly the last element, rather than a calculated last element.
+  os << a.rng_limit << "\n";
 
   return os;
 }
@@ -373,12 +396,14 @@
   is >> a.rng_base;
   if (is)
     {
-      is >> a.rng_limit;
+      double tmp_rng_limit;
+      is >> tmp_rng_limit;
+
       if (is)
-        {
-          is >> a.rng_inc;
-          a.rng_nelem = a.nelem_internal ();
-        }
+        is >> a.rng_inc;
+
+      // Clip the rng_limit to the true limit and rebuild numel, clear cache
+      a.set_limit (tmp_rng_limit);
     }
 
   return is;
@@ -387,13 +412,13 @@
 Range
 operator - (const Range& r)
 {
-  return Range (-r.base (), -r.limit (), -r.inc (), r.nelem ());
+  return Range (-r.base (), -r.limit (), -r.inc (), r.numel ());
 }
 
 Range operator + (double x, const Range& r)
 {
-  Range result (x + r.base (), x + r.limit (), r.inc (), r.nelem ());
-  if (result.rng_nelem < 0)
+  Range result (x + r.base (), x + r.limit (), r.inc (), r.numel ());
+  if (result.rng_numel < 0)
     result.cache = x + r.matrix_value ();
 
   return result;
@@ -401,8 +426,8 @@
 
 Range operator + (const Range& r, double x)
 {
-  Range result (r.base () + x, r.limit () + x, r.inc (), r.nelem ());
-  if (result.rng_nelem < 0)
+  Range result (r.base () + x, r.limit () + x, r.inc (), r.numel ());
+  if (result.rng_numel < 0)
     result.cache = r.matrix_value () + x;
 
   return result;
@@ -410,8 +435,8 @@
 
 Range operator - (double x, const Range& r)
 {
-  Range result (x - r.base (), x - r.limit (), -r.inc (), r.nelem ());
-  if (result.rng_nelem < 0)
+  Range result (x - r.base (), x - r.limit (), -r.inc (), r.numel ());
+  if (result.rng_numel < 0)
     result.cache = x - r.matrix_value ();
 
   return result;
@@ -419,8 +444,8 @@
 
 Range operator - (const Range& r, double x)
 {
-  Range result (r.base () - x, r.limit () - x, r.inc (), r.nelem ());
-  if (result.rng_nelem < 0)
+  Range result (r.base () - x, r.limit () - x, r.inc (), r.numel ());
+  if (result.rng_numel < 0)
     result.cache = r.matrix_value () - x;
 
   return result;
@@ -428,8 +453,8 @@
 
 Range operator * (double x, const Range& r)
 {
-  Range result (x * r.base (), x * r.limit (), x * r.inc (), r.nelem ());
-  if (result.rng_nelem < 0)
+  Range result (x * r.base (), x * r.limit (), x * r.inc (), r.numel ());
+  if (result.rng_numel < 0)
     result.cache = x * r.matrix_value ();
 
   return result;
@@ -437,8 +462,8 @@
 
 Range operator * (const Range& r, double x)
 {
-  Range result (r.base () * x, r.limit () * x, r.inc () * x, r.nelem ());
-  if (result.rng_nelem < 0)
+  Range result (r.base () * x, r.limit () * x, r.inc () * x, r.numel ());
+  if (result.rng_numel < 0)
     result.cache = r.matrix_value () * x;
 
   return result;
@@ -524,7 +549,7 @@
 }
 
 octave_idx_type
-Range::nelem_internal (void) const
+Range::numel_internal (void) const
 {
   octave_idx_type retval = -1;
 
--- a/liboctave/array/Range.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/Range.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_Range_h)
+#if ! defined (octave_Range_h)
 #define octave_Range_h 1
 
 #include <iosfwd>
@@ -35,33 +35,71 @@
 public:
 
   Range (void)
-    : rng_base (0), rng_limit (0), rng_inc (0), rng_nelem (0), cache (1, 0) { }
+    : rng_base (0), rng_limit (0), rng_inc (0), rng_numel (0), cache (1, 0) { }
 
   Range (const Range& r)
     : rng_base (r.rng_base), rng_limit (r.rng_limit), rng_inc (r.rng_inc),
-      rng_nelem (r.rng_nelem), cache (r.cache) { }
+      rng_numel (r.rng_numel), cache (r.cache) { }
 
   Range (double b, double l)
     : rng_base (b), rng_limit (l), rng_inc (1),
-      rng_nelem (nelem_internal ()), cache () { }
+      rng_numel (numel_internal ()), cache ()
+  {
+    double tmplimit = rng_limit;
+
+    if (rng_inc > 0)
+      tmplimit = max ();
+    else
+      tmplimit = min ();
+
+    if (tmplimit != rng_limit)
+      rng_limit = tmplimit;
+  }
 
   Range (double b, double l, double i)
     : rng_base (b), rng_limit (l), rng_inc (i),
-      rng_nelem (nelem_internal ()), cache () { }
+      rng_numel (numel_internal ()), cache ()
+  {
+    double tmplimit = rng_limit;
+
+    if (rng_inc > 0)
+      tmplimit = max ();
+    else
+      tmplimit = min ();
+
+    if (tmplimit != rng_limit)
+      rng_limit = tmplimit;
+  }
 
   // For operators' usage (to preserve element count).
   Range (double b, double i, octave_idx_type n)
     : rng_base (b), rng_limit (b + (n-1) * i), rng_inc (i),
-      rng_nelem (n), cache ()
+      rng_numel (n), cache ()
   {
     if (! xfinite (b) || ! xfinite (i) || ! xfinite (rng_limit))
-      rng_nelem = -2;
+      rng_numel = -2;
+    else
+      {
+        // Code below is only needed if the resulting range must be 100%
+        // correctly constructed.  If the Range object created is only
+        // a temporary one used by operators this may be unnecessary.
+        double tmplimit = rng_limit;
+
+        if (rng_inc > 0)
+          tmplimit = max ();
+        else
+          tmplimit = min ();
+
+        if (tmplimit != rng_limit)
+          rng_limit = tmplimit;
+      }
   }
 
   double base (void) const { return rng_base; }
   double limit (void) const { return rng_limit; }
   double inc (void) const { return rng_inc; }
-  octave_idx_type nelem (void) const { return rng_nelem; }
+  GCC_ATTR_DEPRECATED octave_idx_type nelem (void) const { return numel (); }
+  octave_idx_type numel (void) const { return rng_numel; }
 
   bool all_elements_are_ints (void) const;
 
@@ -90,32 +128,11 @@
 
   Array<double> index (const idx_vector& i) const;
 
-  void set_base (double b)
-  {
-    if (rng_base != b)
-      {
-        rng_base = b;
-        clear_cache ();
-      }
-  }
+  void set_base (double b);
 
-  void set_limit (double l)
-  {
-    if (rng_limit != l)
-      {
-        rng_limit = l;
-        clear_cache ();
-      }
-  }
+  void set_limit (double l);
 
-  void set_inc (double i)
-  {
-    if (rng_inc != i)
-      {
-        rng_inc = i;
-        clear_cache ();
-      }
-  }
+  void set_inc (double i);
 
   friend OCTAVE_API std::ostream& operator << (std::ostream& os,
                                                const Range& r);
@@ -137,11 +154,11 @@
   double rng_limit;
   double rng_inc;
 
-  octave_idx_type rng_nelem;
+  octave_idx_type rng_numel;
 
   mutable Matrix cache;
 
-  octave_idx_type nelem_internal (void) const;
+  octave_idx_type numel_internal (void) const;
 
   void clear_cache (void) const { cache.resize (0, 0); }
 
@@ -150,10 +167,10 @@
   // For operators' usage (to allow all values to be set directly).
   Range (double b, double l, double i, octave_idx_type n)
     : rng_base (b), rng_limit (l), rng_inc (i),
-      rng_nelem (n), cache ()
+      rng_numel (n), cache ()
   {
     if (! xfinite (b) || ! xfinite (i) || ! xfinite (l))
-      rng_nelem = -2;
+      rng_numel = -2;
   }
 };
 
--- a/liboctave/array/Sparse.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/Sparse.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -239,8 +239,8 @@
   // Work in unsigned long long to avoid overflow issues with numel
   unsigned long long a_nel = static_cast<unsigned long long>(a.rows ()) *
                              static_cast<unsigned long long>(a.cols ());
-  unsigned long long dv_nel = static_cast<unsigned long long>(dv (0)) *
-                              static_cast<unsigned long long>(dv (1));
+  unsigned long long dv_nel = static_cast<unsigned long long>(dv(0)) *
+                              static_cast<unsigned long long>(dv(1));
 
   if (a_nel != dv_nel)
     (*current_liboctave_error_handler)
@@ -249,10 +249,10 @@
     {
       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);
-      octave_idx_type old_nr = old_dims (0);
-      octave_idx_type old_nc = old_dims (1);
+      octave_idx_type new_nr = dv(0);
+      octave_idx_type new_nc = dv(1);
+      octave_idx_type old_nr = old_dims(0);
+      octave_idx_type old_nc = old_dims(1);
 
       rep = new typename Sparse<T>::SparseRep (new_nr, new_nc, new_nzmx);
 
@@ -646,7 +646,7 @@
     {
       octave_idx_type nr = rows ();
       octave_idx_type nc = cols ();
-      octave_idx_type len = a.length ();
+      octave_idx_type len = a.numel ();
       octave_idx_type new_nzmx = 0;
 
       // First count the number of nonzero terms
@@ -704,7 +704,7 @@
 
   octave_idx_type n = dimensions.length ();
 
-  if (n > 0 && n == ra_idx.length ())
+  if (n > 0 && n == ra_idx.numel ())
     {
       retval = ra_idx(--n);
 
@@ -767,7 +767,7 @@
 
   buf << fcn << " (";
 
-  octave_idx_type n = ra_idx.length ();
+  octave_idx_type n = ra_idx.numel ();
 
   if (n > 0)
     buf << ra_idx(0);
@@ -792,7 +792,7 @@
 
   buf << fcn << " (";
 
-  octave_idx_type n = ra_idx.length ();
+  octave_idx_type n = ra_idx.numel ();
 
   if (n > 0)
     buf << ra_idx(0);
@@ -886,7 +886,7 @@
   bool fail = false;
   bool trans = false;
 
-  if (perm_vec.length () == 2)
+  if (perm_vec.numel () == 2)
     {
       if (perm_vec(0) == 0 && perm_vec(1) == 1)
         /* do nothing */;
@@ -1082,13 +1082,13 @@
 Sparse<T>::insert (const Sparse<T>& a, const Array<octave_idx_type>& ra_idx)
 {
 
-  if (ra_idx.length () != 2)
+  if (ra_idx.numel () != 2)
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
     }
 
-  return insert (a, ra_idx (0), ra_idx (1));
+  return insert (a, ra_idx(0), ra_idx(1));
 }
 
 template <class T>
@@ -1431,7 +1431,7 @@
           retval = tmp.index (idx);
         }
       else
-        gripe_index_out_of_range (1, 1, idx.extent (nel), nel);
+        gripe_index_out_of_range (1, 1, idx.extent (nel), nel, dims ());
     }
   else if (nr == 1 && nc == 1)
     {
@@ -1614,9 +1614,9 @@
           retval = tmp.index (idx_i, idx_j);
         }
       else if (idx_i.extent (nr) > nr)
-        gripe_index_out_of_range (2, 1, idx_i.extent (nr), nr);
+        gripe_index_out_of_range (2, 1, idx_i.extent (nr), nr, dims ());
       else
-        gripe_index_out_of_range (2, 2, idx_j.extent (nc), nc);
+        gripe_index_out_of_range (2, 2, idx_j.extent (nc), nc, dims ());
     }
   else if (nr == 1 && nc == 1)
     {
@@ -1879,7 +1879,7 @@
               octave_idx_type rnz = rhs.nnz ();
               octave_idx_type new_nz = nz - (ui - li) + rnz;
 
-              if (new_nz >= nz && new_nz <= capacity ())
+              if (new_nz >= nz && new_nz <= nzmax ())
                 {
                   // Adding/overwriting elements, enough capacity allocated.
 
@@ -1978,7 +1978,7 @@
         assign (idx, Sparse<T> (rhl, 1));
     }
   else
-    gripe_invalid_assignment_size ();
+    gripe_nonconformant ("=", dim_vector(idx.length (n),1), rhs.dims());
 }
 
 template <class T>
@@ -2062,7 +2062,7 @@
               octave_idx_type rnz = rhs.nnz ();
               octave_idx_type new_nz = nz - (ui - li) + rnz;
 
-              if (new_nz >= nz && new_nz <= capacity ())
+              if (new_nz >= nz && new_nz <= nzmax ())
                 {
                   // Adding/overwriting elements, enough capacity allocated.
 
@@ -2213,8 +2213,12 @@
       else
         assign (idx_i, idx_j, Sparse<T> (n, m));
     }
+  else if (idx_i.length (nr) == m && idx_j.length (nc) == n && (n==1 || m==1))
+    {
+      assign (idx_i, idx_j, rhs.transpose ());
+    }
   else
-    gripe_assignment_dimension_mismatch ();
+    gripe_nonconformant  ("=", idx_i.length (nr), idx_j.length (nc), n, m);
 }
 
 // Can't use versions of these in Array.cc due to duplication of the
@@ -2244,7 +2248,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.columns ();
 
-  if (m.length () < 1 || dim > 1)
+  if (m.numel () < 1 || dim > 1)
     return m;
 
   if (dim > 0)
@@ -2310,7 +2314,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.columns ();
 
-  if (m.length () < 1 || dim > 1)
+  if (m.numel () < 1 || dim > 1)
     {
       sidx = Array<octave_idx_type> (dim_vector (nr, nc), 1);
       return m;
@@ -2896,6 +2900,14 @@
 %! assert (size (all (a)), [1 1]);
 %!test a=sparse (2,2); assert (isequal (all (a), sparse ([0 0])));
 
+## Test assigning row to a column slice (bug #45589)
+%!test
+%! a = sparse (magic (3));
+%! b = a;
+%! a(1,:) = 1:3;
+%! b(1,:) = (1:3)';
+%! assert (a, b);
+
 */
 
 template <class T>
--- a/liboctave/array/Sparse.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/Sparse.h	Thu Dec 10 12:50:06 2015 -0800
@@ -23,7 +23,7 @@
 
 */
 
-#if !defined (octave_Sparse_h)
+#if ! defined (octave_Sparse_h)
 #define octave_Sparse_h 1
 
 #include <cassert>
@@ -240,11 +240,13 @@
 
   Sparse<T>& operator = (const Sparse<T>& a);
 
-  // Note that nzmax and capacity are the amount of storage for
-  // nonzero elements, while nnz is the actual number of nonzero
-  // terms.
+  //! Amount of storage for nonzero elements.
+  //! This may differ from the actual number of elements, see nnz().
   octave_idx_type nzmax (void) const { return rep->length (); }
-  octave_idx_type capacity (void) const { return nzmax (); }
+  //! Amount of storage for nonzero elements.
+  //! Synonymous with nzmax().
+  GCC_ATTR_DEPRECATED octave_idx_type capacity (void) const { return nzmax (); }
+  //!Actual number of nonzero terms.
   octave_idx_type nnz (void) const { return rep->nnz (); }
 
   // Querying the number of elements (incl. zeros) may overflow the index type,
@@ -254,8 +256,8 @@
     return dimensions.safe_numel ();
   }
 
-  octave_idx_type nelem (void) const { return capacity (); }
-  octave_idx_type length (void) const { return numel (); }
+  GCC_ATTR_DEPRECATED octave_idx_type nelem (void) const { return nzmax (); }
+  GCC_ATTR_DEPRECATED octave_idx_type length (void) const { return numel (); }
 
   octave_idx_type dim1 (void) const { return dimensions(0); }
   octave_idx_type dim2 (void) const { return dimensions(1); }
@@ -276,7 +278,7 @@
   size_t byte_size (void) const
   {
     return (static_cast<size_t>(cols () + 1) * sizeof (octave_idx_type)
-            + static_cast<size_t> (capacity ())
+            + static_cast<size_t> (nzmax ())
             * (sizeof (T) + sizeof (octave_idx_type)));
   }
 
--- a/liboctave/array/boolMatrix.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/boolMatrix.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -43,7 +43,7 @@
   if (rows () != a.rows () || cols () != a.cols ())
     return 0;
 
-  return mx_inline_equal (length (), data (), a.data ());
+  return mx_inline_equal (numel (), data (), a.data ());
 }
 
 bool
--- a/liboctave/array/boolMatrix.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/boolMatrix.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_boolMatrix_h)
+#if ! defined (octave_boolMatrix_h)
 #define octave_boolMatrix_h 1
 
 #include "Array.h"
--- a/liboctave/array/boolNDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/boolNDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_boolNDArray_h)
+#if ! defined (octave_boolNDArray_h)
 #define octave_boolNDArray_h 1
 
 #include "Array.h"
--- a/liboctave/array/boolSparse.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/boolSparse.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,11 +21,11 @@
 
 */
 
-#if !defined (octave_boolSparse_h)
+#if ! defined (octave_boolSparse_h)
 #define octave_boolSparse_h 1
 
 #include "Sparse.h"
-#include "MSparse-defs.h"
+#include "MSparse.h"
 
 #include "boolMatrix.h"
 #include "boolNDArray.h"
--- a/liboctave/array/chMatrix.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/chMatrix.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -45,7 +45,7 @@
   if (rows () != a.rows () || cols () != a.cols ())
     return 0;
 
-  return mx_inline_equal (length (), data (), a.data ());
+  return mx_inline_equal (numel (), data (), a.data ());
 }
 
 bool
--- a/liboctave/array/chMatrix.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/chMatrix.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_chMatrix_h)
+#if ! defined (octave_chMatrix_h)
 #define octave_chMatrix_h 1
 
 #include <string>
--- a/liboctave/array/chNDArray.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/chNDArray.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -70,7 +70,7 @@
 }
 
 charNDArray::charNDArray (const string_vector& s, char fill_value)
-  : Array<char> (dim_vector (s.length (), s.max_length ()), fill_value)
+  : Array<char> (dim_vector (s.numel (), s.max_length ()), fill_value)
 {
   octave_idx_type nr = rows ();
 
--- a/liboctave/array/chNDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/chNDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_chNDArray_h)
+#if ! defined (octave_chNDArray_h)
 #define octave_chNDArray_h 1
 
 #include <string>
--- a/liboctave/array/dColVector.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/dColVector.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -55,8 +55,8 @@
 bool
 ColumnVector::operator == (const ColumnVector& a) const
 {
-  octave_idx_type len = length ();
-  if (len != a.length ())
+  octave_idx_type len = numel ();
+  if (len != a.numel ())
     return 0;
   return mx_inline_equal (len, data (), a.data ());
 }
@@ -70,9 +70,9 @@
 ColumnVector&
 ColumnVector::insert (const ColumnVector& a, octave_idx_type r)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
-  if (r < 0 || r + a_len > length ())
+  if (r < 0 || r + a_len > numel ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -92,7 +92,7 @@
 ColumnVector&
 ColumnVector::fill (double val)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -108,7 +108,7 @@
 ColumnVector&
 ColumnVector::fill (double val, octave_idx_type r1, octave_idx_type r2)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len)
     {
@@ -132,9 +132,9 @@
 ColumnVector
 ColumnVector::stack (const ColumnVector& a) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   octave_idx_type nr_insert = len;
-  ColumnVector retval (len + a.length ());
+  ColumnVector retval (len + a.numel ());
   retval.insert (*this, 0);
   retval.insert (a, nr_insert);
   return retval;
@@ -202,7 +202,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.cols ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (nc != a_len)
     gripe_nonconformant ("operator *", nr, nc, a_len, 1);
@@ -239,7 +239,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.cols ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (nc != a_len)
     gripe_nonconformant ("operator *", nr, nc, a_len, 1);
@@ -267,7 +267,7 @@
 double
 ColumnVector::min (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return 0.0;
 
@@ -283,7 +283,7 @@
 double
 ColumnVector::max (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return 0.0;
 
@@ -300,7 +300,7 @@
 operator << (std::ostream& os, const ColumnVector& a)
 {
 //  int field_width = os.precision () + 7;
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     os << /* setw (field_width) << */ a.elem (i) << "\n";
   return os;
 }
@@ -308,7 +308,7 @@
 std::istream&
 operator >> (std::istream& is, ColumnVector& a)
 {
-  octave_idx_type len = a.length ();
+  octave_idx_type len = a.numel ();
 
   if (len > 0)
     {
--- a/liboctave/array/dColVector.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/dColVector.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_dColVector_h)
+#if ! defined (octave_dColVector_h)
 #define octave_dColVector_h 1
 
 #include "MArray.h"
--- a/liboctave/array/dDiagMatrix.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/dDiagMatrix.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -78,7 +78,7 @@
 DiagMatrix::fill (const ColumnVector& a)
 {
   octave_idx_type len = length ();
-  if (a.length () != len)
+  if (a.numel () != len)
     {
       (*current_liboctave_error_handler) ("range error for fill");
       return *this;
@@ -94,7 +94,7 @@
 DiagMatrix::fill (const RowVector& a)
 {
   octave_idx_type len = length ();
-  if (a.length () != len)
+  if (a.numel () != len)
     {
       (*current_liboctave_error_handler) ("range error for fill");
       return *this;
@@ -109,7 +109,7 @@
 DiagMatrix&
 DiagMatrix::fill (const ColumnVector& a, octave_idx_type beg)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (beg < 0 || beg + a_len >= length ())
     {
       (*current_liboctave_error_handler) ("range error for fill");
@@ -125,7 +125,7 @@
 DiagMatrix&
 DiagMatrix::fill (const RowVector& a, octave_idx_type beg)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (beg < 0 || beg + a_len >= length ())
     {
       (*current_liboctave_error_handler) ("range error for fill");
@@ -280,10 +280,7 @@
   for (octave_idx_type i = 0; i < len; i++)
     {
       if (elem (i, i) == 0.0)
-        {
-          info = -1;
-          return *this;
-        }
+        retval.elem (i, i) = octave_Inf;
       else
         retval.elem (i, i) = 1.0 / elem (i, i);
     }
--- a/liboctave/array/dDiagMatrix.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/dDiagMatrix.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_dDiagMatrix_h)
+#if ! defined (octave_dDiagMatrix_h)
 #define octave_dDiagMatrix_h 1
 
 #include "MDiagArray2.h"
--- a/liboctave/array/dMatrix.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/dMatrix.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -306,7 +306,7 @@
   if (rows () != a.rows () || cols () != a.cols ())
     return false;
 
-  return mx_inline_equal (length (), data (), a.data ());
+  return mx_inline_equal (numel (), data (), a.data ());
 }
 
 bool
@@ -341,7 +341,7 @@
 Matrix&
 Matrix::insert (const RowVector& a, octave_idx_type r, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ())
     {
@@ -363,7 +363,7 @@
 Matrix&
 Matrix::insert (const ColumnVector& a, octave_idx_type r, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ())
     {
@@ -486,7 +486,7 @@
     }
 
   octave_idx_type nc_insert = nc;
-  Matrix retval (nr, nc + a.length ());
+  Matrix retval (nr, nc + a.numel ());
   retval.insert (*this, 0, 0);
   retval.insert (a, 0, nc_insert);
   return retval;
@@ -497,7 +497,7 @@
 {
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
-  if (nr != a.length ())
+  if (nr != a.numel ())
     {
       (*current_liboctave_error_handler) ("row dimension mismatch for append");
       return Matrix ();
@@ -552,7 +552,7 @@
 {
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
-  if (nc != a.length ())
+  if (nc != a.numel ())
     {
       (*current_liboctave_error_handler)
         ("column dimension mismatch for stack");
@@ -579,7 +579,7 @@
     }
 
   octave_idx_type nr_insert = nr;
-  Matrix retval (nr + a.length (), nc);
+  Matrix retval (nr + a.numel (), nc);
   retval.insert (*this, 0, 0);
   retval.insert (a, nr_insert, 0);
   return retval;
@@ -843,7 +843,7 @@
     {
       if (mattype.is_hermitian ())
         {
-          CHOL chol (*this, info, calc_cond);
+          CHOL chol (*this, info, true, calc_cond);
           if (info == 0)
             {
               if (calc_cond)
@@ -877,7 +877,7 @@
 
   ColumnVector sigma = S.extract_diag ();
 
-  octave_idx_type r = sigma.length () - 1;
+  octave_idx_type r = sigma.numel () - 1;
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
 
@@ -967,7 +967,7 @@
 ComplexMatrix
 Matrix::fourier2d (void) const
 {
-  dim_vector dv(rows (), cols ());
+  dim_vector dv (rows (), cols ());
 
   const double *in = fortran_vec ();
   ComplexMatrix retval (rows (), cols ());
@@ -979,7 +979,7 @@
 ComplexMatrix
 Matrix::ifourier2d (void) const
 {
-  dim_vector dv(rows (), cols ());
+  dim_vector dv (rows (), cols ());
 
   ComplexMatrix retval (*this);
   Complex *out (retval.fortran_vec ());
@@ -2467,7 +2467,7 @@
   octave_idx_type m = rows ();
   octave_idx_type n = cols ();
 
-  if (m != b.length ())
+  if (m != b.numel ())
     (*current_liboctave_error_handler)
       ("matrix dimension mismatch solution of linear equations");
   else if (m == 0 || n == 0)
@@ -2636,11 +2636,11 @@
 {
   Matrix retval;
 
-  octave_idx_type len = v.length ();
+  octave_idx_type len = v.numel ();
 
   if (len != 0)
     {
-      octave_idx_type a_len = a.length ();
+      octave_idx_type a_len = a.numel ();
 
       retval = Matrix (len, a_len);
       double *c = retval.fortran_vec ();
@@ -3240,7 +3240,7 @@
   if (nr != b.rows () || nc != b.columns ())
     {
       (*current_liboctave_error_handler)
-        ("two-arg min expecting args of same size");
+        ("two-arg min requires same size arguments");
       return Matrix ();
     }
 
@@ -3307,7 +3307,7 @@
   if (nr != b.rows () || nc != b.columns ())
     {
       (*current_liboctave_error_handler)
-        ("two-arg max expecting args of same size");
+        ("two-arg max requires same size arguments");
       return Matrix ();
     }
 
@@ -3330,21 +3330,25 @@
                  octave_idx_type n)
 
 {
-  if (n < 1) n = 1;
-
-  octave_idx_type m = x1.length ();
-
-  if (x2.length () != m)
+  octave_idx_type m = x1.numel ();
+
+  if (x2.numel () != m)
     (*current_liboctave_error_handler)
       ("linspace: vectors must be of equal length");
 
   NoAlias<Matrix> retval;
 
+  if (n < 1)
+    {
+      retval.clear (m, 0);
+      return retval;
+    }
+
   retval.clear (m, n);
   for (octave_idx_type i = 0; i < m; i++)
     retval(i, 0) = x1(i);
 
-  // The last column is not needed while using delta.
+  // The last column is unused so temporarily store delta there
   double *delta = &retval(0, n-1);
   for (octave_idx_type i = 0; i < m; i++)
     delta[i] = (x2(i) - x1(i)) / (n - 1);
@@ -3359,6 +3363,7 @@
   return retval;
 }
 
+
 MS_CMP_OPS (Matrix, double)
 MS_BOOL_OPS (Matrix, double)
 
--- a/liboctave/array/dMatrix.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/dMatrix.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_dMatrix_h)
+#if ! defined (octave_dMatrix_h)
 #define octave_dMatrix_h 1
 
 #include "dNDArray.h"
--- a/liboctave/array/dNDArray.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/dNDArray.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -110,9 +110,9 @@
   for (int i = 0; i < dim; i++)
     stride *= dv(i);
 
-  octave_idx_type howmany = numel () / dv (dim);
+  octave_idx_type howmany = numel () / dv(dim);
   howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
-  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
+  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride);
   octave_idx_type dist = (stride == 1 ? n : 1);
 
   const double *in (fortran_vec ());
@@ -141,9 +141,9 @@
   for (int i = 0; i < dim; i++)
     stride *= dv(i);
 
-  octave_idx_type howmany = numel () / dv (dim);
+  octave_idx_type howmany = numel () / dv(dim);
   howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
-  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
+  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride);
   octave_idx_type dist = (stride == 1 ? n : 1);
 
   ComplexNDArray retval (*this);
@@ -164,7 +164,7 @@
   if (dv.length () < 2)
     return ComplexNDArray ();
 
-  dim_vector dv2(dv(0), dv(1));
+  dim_vector dv2 (dv(0), dv(1));
   const double *in = fortran_vec ();
   ComplexNDArray retval (dv);
   Complex *out = retval.fortran_vec ();
@@ -184,7 +184,7 @@
   if (dv.length () < 2)
     return ComplexNDArray ();
 
-  dim_vector dv2(dv(0), dv(1));
+  dim_vector dv2 (dv(0), dv(1));
   ComplexNDArray retval (*this);
   Complex *out = retval.fortran_vec ();
   octave_idx_type howmany = numel () / dv(0) / dv(1);
@@ -596,7 +596,7 @@
 bool
 NDArray::all_integers (double& max_val, double& min_val) const
 {
-  octave_idx_type nel = nelem ();
+  octave_idx_type nel = numel ();
 
   if (nel > 0)
     {
@@ -872,7 +872,7 @@
 std::ostream&
 operator << (std::ostream& os, const NDArray& a)
 {
-  octave_idx_type nel = a.nelem ();
+  octave_idx_type nel = a.numel ();
 
   for (octave_idx_type i = 0; i < nel; i++)
     {
@@ -886,7 +886,7 @@
 std::istream&
 operator >> (std::istream& is, NDArray& a)
 {
-  octave_idx_type nel = a.nelem ();
+  octave_idx_type nel = a.numel ();
 
   if (nel > 0)
     {
--- a/liboctave/array/dNDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/dNDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_dNDArray_h)
+#if ! defined (octave_dNDArray_h)
 #define octave_dNDArray_h 1
 
 #include "MArray.h"
--- a/liboctave/array/dRowVector.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/dRowVector.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -58,8 +58,8 @@
 bool
 RowVector::operator == (const RowVector& a) const
 {
-  octave_idx_type len = length ();
-  if (len != a.length ())
+  octave_idx_type len = numel ();
+  if (len != a.numel ())
     return 0;
   return mx_inline_equal (len, data (), a.data ());
 }
@@ -73,9 +73,9 @@
 RowVector&
 RowVector::insert (const RowVector& a, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
-  if (c < 0 || c + a_len > length ())
+  if (c < 0 || c + a_len > numel ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -95,7 +95,7 @@
 RowVector&
 RowVector::fill (double val)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -111,7 +111,7 @@
 RowVector&
 RowVector::fill (double val, octave_idx_type c1, octave_idx_type c2)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len)
     {
@@ -135,9 +135,9 @@
 RowVector
 RowVector::append (const RowVector& a) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   octave_idx_type nc_insert = len;
-  RowVector retval (len + a.length ());
+  RowVector retval (len + a.numel ());
   retval.insert (*this, 0);
   retval.insert (a, nc_insert);
   return retval;
@@ -194,7 +194,7 @@
 {
   RowVector retval;
 
-  octave_idx_type len = v.length ();
+  octave_idx_type len = v.numel ();
 
   octave_idx_type a_nr = a.rows ();
   octave_idx_type a_nc = a.cols ();
@@ -229,7 +229,7 @@
 double
 RowVector::min (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return 0;
 
@@ -245,7 +245,7 @@
 double
 RowVector::max (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return 0;
 
@@ -263,7 +263,7 @@
 {
 //  int field_width = os.precision () + 7;
 
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     os << " " /* setw (field_width) */ << a.elem (i);
   return os;
 }
@@ -271,7 +271,7 @@
 std::istream&
 operator >> (std::istream& is, RowVector& a)
 {
-  octave_idx_type len = a.length ();
+  octave_idx_type len = a.numel ();
 
   if (len > 0)
     {
@@ -293,14 +293,19 @@
 RowVector
 linspace (double x1, double x2, octave_idx_type n)
 {
-  if (n < 1) n = 1;
+  NoAlias<RowVector> retval;
 
-  NoAlias<RowVector> retval (n);
+  if (n < 1)
+    return retval;
+  else
+    retval.clear (n);
+
+  retval(0) = x1;
 
   double delta = (x2 - x1) / (n - 1);
-  retval(0) = x1;
   for (octave_idx_type i = 1; i < n-1; i++)
     retval(i) = x1 + i*delta;
+
   retval(n-1) = x2;
 
   return retval;
@@ -313,9 +318,9 @@
 {
   double retval = 0.0;
 
-  octave_idx_type len = v.length ();
+  octave_idx_type len = v.numel ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (len != a_len)
     gripe_nonconformant ("operator *", len, a_len);
--- a/liboctave/array/dRowVector.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/dRowVector.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_dRowVector_h)
+#if ! defined (octave_dRowVector_h)
 #define octave_dRowVector_h 1
 
 #include "MArray.h"
--- a/liboctave/array/dSparse.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/dSparse.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_dSparse_h)
+#if ! defined (octave_dSparse_h)
 #define octave_dSparse_h 1
 
 #include "dMatrix.h"
@@ -32,7 +32,6 @@
 
 #include "DET.h"
 #include "MSparse.h"
-#include "MSparse-defs.h"
 
 #include "Sparse-op-decls.h"
 
--- a/liboctave/array/dim-vector.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/dim-vector.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_dim_vector_h)
+#if ! defined (octave_dim_vector_h)
 #define octave_dim_vector_h 1
 
 #include <cassert>
@@ -34,21 +34,54 @@
 #include "lo-macros.h"
 #include "oct-refcount.h"
 
-// Rationale: This implementation is more tricky than Array, but the
-// big plus is that dim_vector requires only one allocation instead of
-// two.  It is (slightly) patterned after GCC's basic_string
-// implementation.  rep is a pointer to an array of memory, comprising
-// count, length, and the data:
-//
-//          <count>
-//          <ndims>
-//  rep --> <dims[0]>
-//          <dims[1]>
-//          ...
-//
-// The inlines count(), ndims() recover this data from the rep.  Note
-// that rep points to the beginning of dims to grant faster access
-// (reinterpret_cast is assumed to be an inexpensive operation).
+//! Vector representing the dimensions (size) of an Array.
+/*!
+  A dim_vector is used to represent dimensions of an Array.  It is used
+  on its constructor to specify its size, or when reshaping it.
+
+  @code{.cc}
+  // Matrix with 10 rows and 20 columns.
+  Matrix m Matrix (dim_vector (10, 20));
+
+  // Change its size to 5 rows and 40 columns.
+  Matrix m2 = m.reshape (dim_vector (5, 40));
+
+  // Five dimensional Array of length 10, 20, 3, 8, 7 on each dimension.
+  NDArray a (dim_vector (10, 20, 3, 8, 7));
+
+  // Uninitialized array of same size as other.
+  NDArray b (a.dims ());
+  @endcode
+
+  The main thing to understand about this class, is that methods such as
+  ndims() and numel(), return the value for an Array of these dimensions,
+  not the actual number of elements in the dim_vector.
+
+  @code{.cc}
+  dim_vector d (10, 5, 3);
+  octave_idx_type n = d.numel (); // returns 150
+  octave_idx_type nd = d.ndims (); // returns 2
+  @endcode
+
+  ## Implementation details ##
+
+  This implementation is more tricky than Array, but the big plus is that
+  dim_vector requires only one allocation instead of two.  It is (slightly)
+  patterned after GCC's basic_string implementation.  rep is a pointer to an
+  array of memory, comprising count, length, and the data:
+
+  @verbatim
+          <count>
+          <ndims>
+  rep --> <dims[0]>
+          <dims[1]>
+          ...
+  @endverbatim
+
+  The inlines count(), ndims() recover this data from the rep.  Note
+  that rep points to the beginning of dims to grant faster access
+  (reinterpret_cast is assumed to be an inexpensive operation).
+*/
 
 class
 OCTAVE_API
@@ -458,7 +491,7 @@
   {
     octave_idx_type k = 0;
     for (int i = length () - 1; i >= 0; i--)
-      k = k * rep[i] + idx[i];
+      k = rep[i] * k + idx[i];
 
     return k;
   }
@@ -469,7 +502,7 @@
   {
     octave_idx_type k = 0;
     for (int i = nidx - 1; i >= 0; i--)
-      k = k * rep[i] + idx[i];
+      k = rep[i] * k + idx[i];
 
     return k;
   }
--- a/liboctave/array/fCColVector.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fCColVector.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -60,8 +60,8 @@
 bool
 FloatComplexColumnVector::operator == (const FloatComplexColumnVector& a) const
 {
-  octave_idx_type len = length ();
-  if (len != a.length ())
+  octave_idx_type len = numel ();
+  if (len != a.numel ())
     return 0;
   return mx_inline_equal (len, data (), a.data ());
 }
@@ -77,9 +77,9 @@
 FloatComplexColumnVector&
 FloatComplexColumnVector::insert (const FloatColumnVector& a, octave_idx_type r)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
-  if (r < 0 || r + a_len > length ())
+  if (r < 0 || r + a_len > numel ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -100,9 +100,9 @@
 FloatComplexColumnVector::insert (const FloatComplexColumnVector& a,
                                   octave_idx_type r)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
-  if (r < 0 || r + a_len > length ())
+  if (r < 0 || r + a_len > numel ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -122,7 +122,7 @@
 FloatComplexColumnVector&
 FloatComplexColumnVector::fill (float val)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -138,7 +138,7 @@
 FloatComplexColumnVector&
 FloatComplexColumnVector::fill (const FloatComplex& val)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -156,7 +156,7 @@
 FloatComplexColumnVector::fill (float val,
                                 octave_idx_type r1, octave_idx_type r2)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len)
     {
@@ -181,7 +181,7 @@
 FloatComplexColumnVector::fill (const FloatComplex& val,
                                 octave_idx_type r1, octave_idx_type r2)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len)
     {
@@ -205,9 +205,9 @@
 FloatComplexColumnVector
 FloatComplexColumnVector::stack (const FloatColumnVector& a) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   octave_idx_type nr_insert = len;
-  FloatComplexColumnVector retval (len + a.length ());
+  FloatComplexColumnVector retval (len + a.numel ());
   retval.insert (*this, 0);
   retval.insert (a, nr_insert);
   return retval;
@@ -216,9 +216,9 @@
 FloatComplexColumnVector
 FloatComplexColumnVector::stack (const FloatComplexColumnVector& a) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   octave_idx_type nr_insert = len;
-  FloatComplexColumnVector retval (len + a.length ());
+  FloatComplexColumnVector retval (len + a.numel ());
   retval.insert (*this, 0);
   retval.insert (a, nr_insert);
   return retval;
@@ -282,9 +282,9 @@
 FloatComplexColumnVector&
 FloatComplexColumnVector::operator += (const FloatColumnVector& a)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (len != a_len)
     {
@@ -304,9 +304,9 @@
 FloatComplexColumnVector&
 FloatComplexColumnVector::operator -= (const FloatColumnVector& a)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (len != a_len)
     {
@@ -340,7 +340,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.cols ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (nc != a_len)
     gripe_nonconformant ("operator *", nr, nc, a_len, 1);
@@ -384,7 +384,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.cols ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (nc != a_len)
     {
@@ -412,7 +412,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.cols ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (nc != a_len)
     {
@@ -440,7 +440,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.cols ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (nc != a_len)
     {
@@ -467,7 +467,7 @@
 FloatComplex
 FloatComplexColumnVector::min (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return 0.0;
 
@@ -487,7 +487,7 @@
 FloatComplex
 FloatComplexColumnVector::max (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return 0.0;
 
@@ -510,7 +510,7 @@
 operator << (std::ostream& os, const FloatComplexColumnVector& a)
 {
 //  int field_width = os.precision () + 7;
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     os << /* setw (field_width) << */ a.elem (i) << "\n";
   return os;
 }
@@ -518,7 +518,7 @@
 std::istream&
 operator >> (std::istream& is, FloatComplexColumnVector& a)
 {
-  octave_idx_type len = a.length ();
+  octave_idx_type len = a.numel ();
 
   if (len > 0)
     {
--- a/liboctave/array/fCColVector.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fCColVector.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_fCColVector_h)
+#if ! defined (octave_fCColVector_h)
 #define octave_fCColVector_h 1
 
 #include "MArray.h"
--- a/liboctave/array/fCDiagMatrix.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fCDiagMatrix.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -111,7 +111,7 @@
 FloatComplexDiagMatrix::fill (const FloatColumnVector& a)
 {
   octave_idx_type len = length ();
-  if (a.length () != len)
+  if (a.numel () != len)
     {
       (*current_liboctave_error_handler) ("range error for fill");
       return *this;
@@ -127,7 +127,7 @@
 FloatComplexDiagMatrix::fill (const FloatComplexColumnVector& a)
 {
   octave_idx_type len = length ();
-  if (a.length () != len)
+  if (a.numel () != len)
     {
       (*current_liboctave_error_handler) ("range error for fill");
       return *this;
@@ -143,7 +143,7 @@
 FloatComplexDiagMatrix::fill (const FloatRowVector& a)
 {
   octave_idx_type len = length ();
-  if (a.length () != len)
+  if (a.numel () != len)
     {
       (*current_liboctave_error_handler) ("range error for fill");
       return *this;
@@ -159,7 +159,7 @@
 FloatComplexDiagMatrix::fill (const FloatComplexRowVector& a)
 {
   octave_idx_type len = length ();
-  if (a.length () != len)
+  if (a.numel () != len)
     {
       (*current_liboctave_error_handler) ("range error for fill");
       return *this;
@@ -174,7 +174,7 @@
 FloatComplexDiagMatrix&
 FloatComplexDiagMatrix::fill (const FloatColumnVector& a, octave_idx_type beg)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (beg < 0 || beg + a_len >= length ())
     {
       (*current_liboctave_error_handler) ("range error for fill");
@@ -191,7 +191,7 @@
 FloatComplexDiagMatrix::fill (const FloatComplexColumnVector& a,
                               octave_idx_type beg)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (beg < 0 || beg + a_len >= length ())
     {
       (*current_liboctave_error_handler) ("range error for fill");
@@ -207,7 +207,7 @@
 FloatComplexDiagMatrix&
 FloatComplexDiagMatrix::fill (const FloatRowVector& a, octave_idx_type beg)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (beg < 0 || beg + a_len >= length ())
     {
       (*current_liboctave_error_handler) ("range error for fill");
@@ -224,7 +224,7 @@
 FloatComplexDiagMatrix::fill (const FloatComplexRowVector& a,
                               octave_idx_type beg)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (beg < 0 || beg + a_len >= length ())
     {
       (*current_liboctave_error_handler) ("range error for fill");
--- a/liboctave/array/fCDiagMatrix.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fCDiagMatrix.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fCDiagMatrix_h)
+#if ! defined (octave_fCDiagMatrix_h)
 #define octave_fCDiagMatrix_h 1
 
 #include "MDiagArray2.h"
--- a/liboctave/array/fCMatrix.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fCMatrix.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -369,7 +369,7 @@
   if (rows () != a.rows () || cols () != a.cols ())
     return false;
 
-  return mx_inline_equal (length (), data (), a.data ());
+  return mx_inline_equal (numel (), data (), a.data ());
 }
 
 bool
@@ -428,7 +428,7 @@
 FloatComplexMatrix::insert (const FloatRowVector& a,
                             octave_idx_type r, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ())
     {
@@ -451,7 +451,7 @@
 FloatComplexMatrix::insert (const FloatColumnVector& a,
                             octave_idx_type r, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ())
     {
@@ -510,7 +510,7 @@
 FloatComplexMatrix::insert (const FloatComplexRowVector& a,
                             octave_idx_type r, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
@@ -527,7 +527,7 @@
 FloatComplexMatrix::insert (const FloatComplexColumnVector& a,
                             octave_idx_type r, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ())
     {
@@ -699,7 +699,7 @@
     }
 
   octave_idx_type nc_insert = nc;
-  FloatComplexMatrix retval (nr, nc + a.length ());
+  FloatComplexMatrix retval (nr, nc + a.numel ());
   retval.insert (*this, 0, 0);
   retval.insert (a, 0, nc_insert);
   return retval;
@@ -710,7 +710,7 @@
 {
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
-  if (nr != a.length ())
+  if (nr != a.numel ())
     {
       (*current_liboctave_error_handler) ("row dimension mismatch for append");
       return *this;
@@ -771,7 +771,7 @@
     }
 
   octave_idx_type nc_insert = nc;
-  FloatComplexMatrix retval (nr, nc + a.length ());
+  FloatComplexMatrix retval (nr, nc + a.numel ());
   retval.insert (*this, 0, 0);
   retval.insert (a, 0, nc_insert);
   return retval;
@@ -782,7 +782,7 @@
 {
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
-  if (nr != a.length ())
+  if (nr != a.numel ())
     {
       (*current_liboctave_error_handler) ("row dimension mismatch for append");
       return *this;
@@ -837,7 +837,7 @@
 {
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
-  if (nc != a.length ())
+  if (nc != a.numel ())
     {
       (*current_liboctave_error_handler)
         ("column dimension mismatch for stack");
@@ -864,7 +864,7 @@
     }
 
   octave_idx_type nr_insert = nr;
-  FloatComplexMatrix retval (nr + a.length (), nc);
+  FloatComplexMatrix retval (nr + a.numel (), nc);
   retval.insert (*this, 0, 0);
   retval.insert (a, nr_insert, 0);
   return retval;
@@ -913,7 +913,7 @@
 {
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
-  if (nc != a.length ())
+  if (nc != a.numel ())
     {
       (*current_liboctave_error_handler)
         ("column dimension mismatch for stack");
@@ -940,7 +940,7 @@
     }
 
   octave_idx_type nr_insert = nr;
-  FloatComplexMatrix retval (nr + a.length (), nc);
+  FloatComplexMatrix retval (nr + a.numel (), nc);
   retval.insert (*this, 0, 0);
   retval.insert (a, nr_insert, 0);
   return retval;
@@ -1199,7 +1199,7 @@
     {
       if (mattype.is_hermitian ())
         {
-          FloatComplexCHOL chol (*this, info, calc_cond);
+          FloatComplexCHOL chol (*this, info, true, calc_cond);
           if (info == 0)
             {
               if (calc_cond)
@@ -1236,7 +1236,7 @@
 
   FloatColumnVector sigma = S.extract_diag ();
 
-  octave_idx_type r = sigma.length () - 1;
+  octave_idx_type r = sigma.numel () - 1;
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
 
@@ -1327,7 +1327,7 @@
 FloatComplexMatrix
 FloatComplexMatrix::fourier2d (void) const
 {
-  dim_vector dv(rows (), cols ());
+  dim_vector dv (rows (), cols ());
 
   FloatComplexMatrix retval (rows (), cols ());
   const FloatComplex *in (data ());
@@ -1341,7 +1341,7 @@
 FloatComplexMatrix
 FloatComplexMatrix::ifourier2d (void) const
 {
-  dim_vector dv(rows (), cols ());
+  dim_vector dv (rows (), cols ());
 
   FloatComplexMatrix retval (rows (), cols ());
   const FloatComplex *in (data ());
@@ -2862,7 +2862,7 @@
   octave_idx_type m = rows ();
   octave_idx_type n = cols ();
 
-  if (m != b.length ())
+  if (m != b.numel ())
     (*current_liboctave_error_handler)
       ("matrix dimension mismatch solution of linear equations");
   else if (m == 0 || n == 0 || b.cols () == 0)
@@ -2975,11 +2975,11 @@
 {
   FloatComplexMatrix retval;
 
-  octave_idx_type len = v.length ();
+  octave_idx_type len = v.numel ();
 
   if (len != 0)
     {
-      octave_idx_type a_len = a.length ();
+      octave_idx_type a_len = a.numel ();
 
       retval = FloatComplexMatrix (len, a_len);
       FloatComplex *c = retval.fortran_vec ();
@@ -3103,7 +3103,7 @@
 
   FloatComplex *d = fortran_vec (); // Ensures only 1 reference to my privates!
 
-  mx_inline_add2 (length (), d, a.data ());
+  mx_inline_add2 (numel (), d, a.data ());
   return *this;
 }
 
@@ -3127,7 +3127,7 @@
 
   FloatComplex *d = fortran_vec (); // Ensures only 1 reference to my privates!
 
-  mx_inline_sub2 (length (), d, a.data ());
+  mx_inline_sub2 (numel (), d, a.data ());
   return *this;
 }
 
@@ -3884,7 +3884,7 @@
   if (nr != b.rows () || nc != b.columns ())
     {
       (*current_liboctave_error_handler)
-        ("two-arg min expecting args of same size");
+        ("two-arg min requires same size arguments");
       return FloatComplexMatrix ();
     }
 
@@ -3972,7 +3972,7 @@
   if (nr != b.rows () || nc != b.columns ())
     {
       (*current_liboctave_error_handler)
-        ("two-arg max expecting args of same size");
+        ("two-arg max requires same size arguments");
       return FloatComplexMatrix ();
     }
 
@@ -4019,21 +4019,25 @@
                              octave_idx_type n)
 
 {
-  if (n < 1) n = 1;
-
-  octave_idx_type m = x1.length ();
-
-  if (x2.length () != m)
+  octave_idx_type m = x1.numel ();
+
+  if (x2.numel () != m)
     (*current_liboctave_error_handler)
       ("linspace: vectors must be of equal length");
 
   NoAlias<FloatComplexMatrix> retval;
 
+  if (n < 1)
+    {
+      retval.clear (m, 0);
+      return retval;
+    }
+
   retval.clear (m, n);
   for (octave_idx_type i = 0; i < m; i++)
     retval(i, 0) = x1(i);
 
-  // The last column is not needed while using delta.
+  // The last column is unused so temporarily store delta there
   FloatComplex *delta = &retval(0, n-1);
   for (octave_idx_type i = 0; i < m; i++)
     delta[i] = (x2(i) - x1(i)) / (n - 1.0f);
--- a/liboctave/array/fCMatrix.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fCMatrix.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fCMatrix_h)
+#if ! defined (octave_fCMatrix_h)
 #define octave_fCMatrix_h 1
 
 #include "fCNDArray.h"
--- a/liboctave/array/fCNDArray.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fCNDArray.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -69,9 +69,9 @@
   for (int i = 0; i < dim; i++)
     stride *= dv(i);
 
-  octave_idx_type howmany = numel () / dv (dim);
+  octave_idx_type howmany = numel () / dv(dim);
   howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
-  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
+  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride);
   octave_idx_type dist = (stride == 1 ? n : 1);
 
   const FloatComplex *in (fortran_vec ());
@@ -100,9 +100,9 @@
   for (int i = 0; i < dim; i++)
     stride *= dv(i);
 
-  octave_idx_type howmany = numel () / dv (dim);
+  octave_idx_type howmany = numel () / dv(dim);
   howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
-  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
+  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride);
   octave_idx_type dist = (stride == 1 ? n : 1);
 
   const FloatComplex *in (fortran_vec ());
@@ -124,7 +124,7 @@
   if (dv.length () < 2)
     return FloatComplexNDArray ();
 
-  dim_vector dv2(dv(0), dv(1));
+  dim_vector dv2 (dv(0), dv(1));
   const FloatComplex *in = fortran_vec ();
   FloatComplexNDArray retval (dv);
   FloatComplex *out = retval.fortran_vec ();
@@ -144,7 +144,7 @@
   if (dv.length () < 2)
     return FloatComplexNDArray ();
 
-  dim_vector dv2(dv(0), dv(1));
+  dim_vector dv2 (dv(0), dv(1));
   const FloatComplex *in = fortran_vec ();
   FloatComplexNDArray retval (dv);
   FloatComplex *out = retval.fortran_vec ();
@@ -532,7 +532,7 @@
 bool
 FloatComplexNDArray::all_integers (float& max_val, float& min_val) const
 {
-  octave_idx_type nel = nelem ();
+  octave_idx_type nel = numel ();
 
   if (nel > 0)
     {
@@ -776,7 +776,7 @@
 
       for (int i = 0; i < n; i++)
         {
-          if (a_ra_idx (i) < 0 || (a_ra_idx (i) + a_dv (i)) > dimensions (i))
+          if (a_ra_idx(i) < 0 || (a_ra_idx(i) + a_dv(i)) > dimensions(i))
             {
               (*current_liboctave_error_handler)
                 ("Array<T>::insert: range error for insert");
@@ -789,14 +789,14 @@
 
       octave_idx_type n_elt = a.numel ();
 
-      // IS make_unique () NECCESSARY HERE??
+      // IS make_unique () NECESSARY HERE?
 
       for (octave_idx_type i = 0; i < n_elt; i++)
         {
           Array<octave_idx_type> ra_idx = a_ra_idx;
 
-          ra_idx.elem (0) = a_ra_idx (0) + r;
-          ra_idx.elem (1) = a_ra_idx (1) + c;
+          ra_idx.elem (0) = a_ra_idx(0) + r;
+          ra_idx.elem (1) = a_ra_idx(1) + c;
 
           elem (ra_idx) = a.elem (a_ra_idx);
 
@@ -857,7 +857,7 @@
 std::ostream&
 operator << (std::ostream& os, const FloatComplexNDArray& a)
 {
-  octave_idx_type nel = a.nelem ();
+  octave_idx_type nel = a.numel ();
 
   for (octave_idx_type i = 0; i < nel; i++)
     {
@@ -871,7 +871,7 @@
 std::istream&
 operator >> (std::istream& is, FloatComplexNDArray& a)
 {
-  octave_idx_type nel = a.nelem ();
+  octave_idx_type nel = a.numel ();
 
   if (nel > 0)
     {
--- a/liboctave/array/fCNDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fCNDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fCNDArray_h)
+#if ! defined (octave_fCNDArray_h)
 #define octave_fCNDArray_h 1
 
 #include "MArray.h"
--- a/liboctave/array/fCRowVector.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fCRowVector.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -59,8 +59,8 @@
 bool
 FloatComplexRowVector::operator == (const FloatComplexRowVector& a) const
 {
-  octave_idx_type len = length ();
-  if (len != a.length ())
+  octave_idx_type len = numel ();
+  if (len != a.numel ())
     return 0;
   return mx_inline_equal (len, data (), a.data ());
 }
@@ -76,9 +76,9 @@
 FloatComplexRowVector&
 FloatComplexRowVector::insert (const FloatRowVector& a, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
-  if (c < 0 || c + a_len > length ())
+  if (c < 0 || c + a_len > numel ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -99,9 +99,9 @@
 FloatComplexRowVector::insert (const FloatComplexRowVector& a,
                                octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
-  if (c < 0 || c + a_len > length ())
+  if (c < 0 || c + a_len > numel ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -121,7 +121,7 @@
 FloatComplexRowVector&
 FloatComplexRowVector::fill (float val)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -137,7 +137,7 @@
 FloatComplexRowVector&
 FloatComplexRowVector::fill (const FloatComplex& val)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -153,7 +153,7 @@
 FloatComplexRowVector&
 FloatComplexRowVector::fill (float val, octave_idx_type c1, octave_idx_type c2)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len)
     {
@@ -178,7 +178,7 @@
 FloatComplexRowVector::fill (const FloatComplex& val,
                              octave_idx_type c1, octave_idx_type c2)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len)
     {
@@ -202,9 +202,9 @@
 FloatComplexRowVector
 FloatComplexRowVector::append (const FloatRowVector& a) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   octave_idx_type nc_insert = len;
-  FloatComplexRowVector retval (len + a.length ());
+  FloatComplexRowVector retval (len + a.numel ());
   retval.insert (*this, 0);
   retval.insert (a, nc_insert);
   return retval;
@@ -213,9 +213,9 @@
 FloatComplexRowVector
 FloatComplexRowVector::append (const FloatComplexRowVector& a) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   octave_idx_type nc_insert = len;
-  FloatComplexRowVector retval (len + a.length ());
+  FloatComplexRowVector retval (len + a.numel ());
   retval.insert (*this, 0);
   retval.insert (a, nc_insert);
   return retval;
@@ -272,9 +272,9 @@
 FloatComplexRowVector&
 FloatComplexRowVector::operator += (const FloatRowVector& a)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (len != a_len)
     {
@@ -294,9 +294,9 @@
 FloatComplexRowVector&
 FloatComplexRowVector::operator -= (const FloatRowVector& a)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (len != a_len)
     {
@@ -320,7 +320,7 @@
 {
   FloatComplexRowVector retval;
 
-  octave_idx_type len = v.length ();
+  octave_idx_type len = v.numel ();
 
   octave_idx_type a_nr = a.rows ();
   octave_idx_type a_nc = a.cols ();
@@ -362,7 +362,7 @@
 FloatComplex
 FloatComplexRowVector::min (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return FloatComplex (0.0);
 
@@ -382,7 +382,7 @@
 FloatComplex
 FloatComplexRowVector::max (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return FloatComplex (0.0);
 
@@ -405,7 +405,7 @@
 operator << (std::ostream& os, const FloatComplexRowVector& a)
 {
 //  int field_width = os.precision () + 7;
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     os << " " /* setw (field_width) */ << a.elem (i);
   return os;
 }
@@ -413,7 +413,7 @@
 std::istream&
 operator >> (std::istream& is, FloatComplexRowVector& a)
 {
-  octave_idx_type len = a.length ();
+  octave_idx_type len = a.numel ();
 
   if (len > 0)
     {
@@ -446,9 +446,9 @@
 {
   FloatComplex retval (0.0, 0.0);
 
-  octave_idx_type len = v.length ();
+  octave_idx_type len = v.numel ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (len != a_len)
     gripe_nonconformant ("operator *", len, a_len);
@@ -463,14 +463,19 @@
 FloatComplexRowVector
 linspace (const FloatComplex& x1, const FloatComplex& x2, octave_idx_type n)
 {
-  if (n < 1) n = 1;
+  NoAlias<FloatComplexRowVector> retval;
 
-  NoAlias<FloatComplexRowVector> retval (n);
+  if (n < 1)
+    return retval;
+  else
+    retval.clear (n);
+
+  retval(0) = x1;
 
   FloatComplex delta = (x2 - x1) / (n - 1.0f);
-  retval(0) = x1;
   for (octave_idx_type i = 1; i < n-1; i++)
     retval(i) = x1 + static_cast<float> (i)*delta;
+
   retval(n-1) = x2;
 
   return retval;
--- a/liboctave/array/fCRowVector.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fCRowVector.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fCRowVector_h)
+#if ! defined (octave_fCRowVector_h)
 #define octave_fCRowVector_h 1
 
 #include "MArray.h"
--- a/liboctave/array/fColVector.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fColVector.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -54,8 +54,8 @@
 bool
 FloatColumnVector::operator == (const FloatColumnVector& a) const
 {
-  octave_idx_type len = length ();
-  if (len != a.length ())
+  octave_idx_type len = numel ();
+  if (len != a.numel ())
     return 0;
   return mx_inline_equal (len, data (), a.data ());
 }
@@ -69,9 +69,9 @@
 FloatColumnVector&
 FloatColumnVector::insert (const FloatColumnVector& a, octave_idx_type r)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
-  if (r < 0 || r + a_len > length ())
+  if (r < 0 || r + a_len > numel ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -91,7 +91,7 @@
 FloatColumnVector&
 FloatColumnVector::fill (float val)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -107,7 +107,7 @@
 FloatColumnVector&
 FloatColumnVector::fill (float val, octave_idx_type r1, octave_idx_type r2)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len)
     {
@@ -131,9 +131,9 @@
 FloatColumnVector
 FloatColumnVector::stack (const FloatColumnVector& a) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   octave_idx_type nr_insert = len;
-  FloatColumnVector retval (len + a.length ());
+  FloatColumnVector retval (len + a.numel ());
   retval.insert (*this, 0);
   retval.insert (a, nr_insert);
   return retval;
@@ -201,7 +201,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.cols ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (nc != a_len)
     gripe_nonconformant ("operator *", nr, nc, a_len, 1);
@@ -238,7 +238,7 @@
   octave_idx_type nr = m.rows ();
   octave_idx_type nc = m.cols ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (nc != a_len)
     gripe_nonconformant ("operator *", nr, nc, a_len, 1);
@@ -266,7 +266,7 @@
 float
 FloatColumnVector::min (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return 0.0;
 
@@ -282,7 +282,7 @@
 float
 FloatColumnVector::max (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return 0.0;
 
@@ -299,7 +299,7 @@
 operator << (std::ostream& os, const FloatColumnVector& a)
 {
 //  int field_width = os.precision () + 7;
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     os << /* setw (field_width) << */ a.elem (i) << "\n";
   return os;
 }
@@ -307,7 +307,7 @@
 std::istream&
 operator >> (std::istream& is, FloatColumnVector& a)
 {
-  octave_idx_type len = a.length ();
+  octave_idx_type len = a.numel ();
 
   if (len > 0)
     {
--- a/liboctave/array/fColVector.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fColVector.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_fColVector_h)
+#if ! defined (octave_fColVector_h)
 #define octave_fColVector_h 1
 
 #include "MArray.h"
--- a/liboctave/array/fDiagMatrix.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fDiagMatrix.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -78,7 +78,7 @@
 FloatDiagMatrix::fill (const FloatColumnVector& a)
 {
   octave_idx_type len = length ();
-  if (a.length () != len)
+  if (a.numel () != len)
     {
       (*current_liboctave_error_handler) ("range error for fill");
       return *this;
@@ -94,7 +94,7 @@
 FloatDiagMatrix::fill (const FloatRowVector& a)
 {
   octave_idx_type len = length ();
-  if (a.length () != len)
+  if (a.numel () != len)
     {
       (*current_liboctave_error_handler) ("range error for fill");
       return *this;
@@ -109,7 +109,7 @@
 FloatDiagMatrix&
 FloatDiagMatrix::fill (const FloatColumnVector& a, octave_idx_type beg)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (beg < 0 || beg + a_len >= length ())
     {
       (*current_liboctave_error_handler) ("range error for fill");
@@ -125,7 +125,7 @@
 FloatDiagMatrix&
 FloatDiagMatrix::fill (const FloatRowVector& a, octave_idx_type beg)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
   if (beg < 0 || beg + a_len >= length ())
     {
       (*current_liboctave_error_handler) ("range error for fill");
@@ -280,10 +280,7 @@
   for (octave_idx_type i = 0; i < len; i++)
     {
       if (elem (i, i) == 0.0)
-        {
-          info = -1;
-          return *this;
-        }
+        retval.elem (i, i) = octave_Inf;
       else
         retval.elem (i, i) = 1.0 / elem (i, i);
     }
--- a/liboctave/array/fDiagMatrix.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fDiagMatrix.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fDiagMatrix_h)
+#if ! defined (octave_fDiagMatrix_h)
 #define octave_fDiagMatrix_h 1
 
 #include "MDiagArray2.h"
--- a/liboctave/array/fMatrix.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fMatrix.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -309,7 +309,7 @@
   if (rows () != a.rows () || cols () != a.cols ())
     return false;
 
-  return mx_inline_equal (length (), data (), a.data ());
+  return mx_inline_equal (numel (), data (), a.data ());
 }
 
 bool
@@ -346,7 +346,7 @@
 FloatMatrix::insert (const FloatRowVector& a,
                      octave_idx_type r, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ())
     {
@@ -369,7 +369,7 @@
 FloatMatrix::insert (const FloatColumnVector& a,
                      octave_idx_type r, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ())
     {
@@ -493,7 +493,7 @@
     }
 
   octave_idx_type nc_insert = nc;
-  FloatMatrix retval (nr, nc + a.length ());
+  FloatMatrix retval (nr, nc + a.numel ());
   retval.insert (*this, 0, 0);
   retval.insert (a, 0, nc_insert);
   return retval;
@@ -504,7 +504,7 @@
 {
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
-  if (nr != a.length ())
+  if (nr != a.numel ())
     {
       (*current_liboctave_error_handler) ("row dimension mismatch for append");
       return FloatMatrix ();
@@ -559,7 +559,7 @@
 {
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
-  if (nc != a.length ())
+  if (nc != a.numel ())
     {
       (*current_liboctave_error_handler)
         ("column dimension mismatch for stack");
@@ -586,7 +586,7 @@
     }
 
   octave_idx_type nr_insert = nr;
-  FloatMatrix retval (nr + a.length (), nc);
+  FloatMatrix retval (nr + a.numel (), nc);
   retval.insert (*this, 0, 0);
   retval.insert (a, nr_insert, 0);
   return retval;
@@ -850,7 +850,7 @@
     {
       if (mattype.is_hermitian ())
         {
-          FloatCHOL chol (*this, info, calc_cond);
+          FloatCHOL chol (*this, info, true, calc_cond);
           if (info == 0)
             {
               if (calc_cond)
@@ -884,7 +884,7 @@
 
   FloatColumnVector sigma = S.extract_diag ();
 
-  octave_idx_type r = sigma.length () - 1;
+  octave_idx_type r = sigma.numel () - 1;
   octave_idx_type nr = rows ();
   octave_idx_type nc = cols ();
 
@@ -974,7 +974,7 @@
 FloatComplexMatrix
 FloatMatrix::fourier2d (void) const
 {
-  dim_vector dv(rows (), cols ());
+  dim_vector dv (rows (), cols ());
 
   const float *in = fortran_vec ();
   FloatComplexMatrix retval (rows (), cols ());
@@ -986,7 +986,7 @@
 FloatComplexMatrix
 FloatMatrix::ifourier2d (void) const
 {
-  dim_vector dv(rows (), cols ());
+  dim_vector dv (rows (), cols ());
 
   FloatComplexMatrix retval (*this);
   FloatComplex *out (retval.fortran_vec ());
@@ -2491,7 +2491,7 @@
   octave_idx_type m = rows ();
   octave_idx_type n = cols ();
 
-  if (m != b.length ())
+  if (m != b.numel ())
     (*current_liboctave_error_handler)
       ("matrix dimension mismatch solution of linear equations");
   else if (m == 0 || n == 0)
@@ -2659,11 +2659,11 @@
 {
   FloatMatrix retval;
 
-  octave_idx_type len = v.length ();
+  octave_idx_type len = v.numel ();
 
   if (len != 0)
     {
-      octave_idx_type a_len = a.length ();
+      octave_idx_type a_len = a.numel ();
 
       retval = FloatMatrix (len, a_len);
       float *c = retval.fortran_vec ();
@@ -3245,7 +3245,7 @@
   if (nr != b.rows () || nc != b.columns ())
     {
       (*current_liboctave_error_handler)
-        ("two-arg min expecting args of same size");
+        ("two-arg min requires same size arguments");
       return FloatMatrix ();
     }
 
@@ -3312,7 +3312,7 @@
   if (nr != b.rows () || nc != b.columns ())
     {
       (*current_liboctave_error_handler)
-        ("two-arg max expecting args of same size");
+        ("two-arg max requires same size arguments");
       return FloatMatrix ();
     }
 
@@ -3335,21 +3335,25 @@
                       octave_idx_type n)
 
 {
-  if (n < 1) n = 1;
-
-  octave_idx_type m = x1.length ();
-
-  if (x2.length () != m)
+  octave_idx_type m = x1.numel ();
+
+  if (x2.numel () != m)
     (*current_liboctave_error_handler)
       ("linspace: vectors must be of equal length");
 
   NoAlias<FloatMatrix> retval;
 
+  if (n < 1)
+    {
+      retval.clear (m, 0);
+      return retval;
+    }
+
   retval.clear (m, n);
   for (octave_idx_type i = 0; i < m; i++)
     retval(i, 0) = x1(i);
 
-  // The last column is not needed while using delta.
+  // The last column is unused so temporarily store delta there
   float *delta = &retval(0, n-1);
   for (octave_idx_type i = 0; i < m; i++)
     delta[i] = (x2(i) - x1(i)) / (n - 1);
--- a/liboctave/array/fMatrix.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fMatrix.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fMatrix_h)
+#if ! defined (octave_fMatrix_h)
 #define octave_fMatrix_h 1
 
 #include "fNDArray.h"
--- a/liboctave/array/fNDArray.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fNDArray.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -68,9 +68,9 @@
   for (int i = 0; i < dim; i++)
     stride *= dv(i);
 
-  octave_idx_type howmany = numel () / dv (dim);
+  octave_idx_type howmany = numel () / dv(dim);
   howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
-  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
+  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride);
   octave_idx_type dist = (stride == 1 ? n : 1);
 
   const float *in (fortran_vec ());
@@ -99,9 +99,9 @@
   for (int i = 0; i < dim; i++)
     stride *= dv(i);
 
-  octave_idx_type howmany = numel () / dv (dim);
+  octave_idx_type howmany = numel () / dv(dim);
   howmany = (stride == 1 ? howmany : (howmany > stride ? stride : howmany));
-  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv (dim) / stride);
+  octave_idx_type nloop = (stride == 1 ? 1 : numel () / dv(dim) / stride);
   octave_idx_type dist = (stride == 1 ? n : 1);
 
   FloatComplexNDArray retval (*this);
@@ -122,7 +122,7 @@
   if (dv.length () < 2)
     return FloatComplexNDArray ();
 
-  dim_vector dv2(dv(0), dv(1));
+  dim_vector dv2 (dv(0), dv(1));
   const float *in = fortran_vec ();
   FloatComplexNDArray retval (dv);
   FloatComplex *out = retval.fortran_vec ();
@@ -142,7 +142,7 @@
   if (dv.length () < 2)
     return FloatComplexNDArray ();
 
-  dim_vector dv2(dv(0), dv(1));
+  dim_vector dv2 (dv(0), dv(1));
   FloatComplexNDArray retval (*this);
   FloatComplex *out = retval.fortran_vec ();
   octave_idx_type howmany = numel () / dv(0) / dv(1);
@@ -556,7 +556,7 @@
 bool
 FloatNDArray::all_integers (float& max_val, float& min_val) const
 {
-  octave_idx_type nel = nelem ();
+  octave_idx_type nel = numel ();
 
   if (nel > 0)
     {
@@ -843,7 +843,7 @@
 std::ostream&
 operator << (std::ostream& os, const FloatNDArray& a)
 {
-  octave_idx_type nel = a.nelem ();
+  octave_idx_type nel = a.numel ();
 
   for (octave_idx_type i = 0; i < nel; i++)
     {
@@ -857,7 +857,7 @@
 std::istream&
 operator >> (std::istream& is, FloatNDArray& a)
 {
-  octave_idx_type nel = a.nelem ();
+  octave_idx_type nel = a.numel ();
 
   if (nel > 0)
     {
--- a/liboctave/array/fNDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fNDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fNDArray_h)
+#if ! defined (octave_fNDArray_h)
 #define octave_fNDArray_h 1
 
 #include "MArray.h"
--- a/liboctave/array/fRowVector.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fRowVector.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -58,8 +58,8 @@
 bool
 FloatRowVector::operator == (const FloatRowVector& a) const
 {
-  octave_idx_type len = length ();
-  if (len != a.length ())
+  octave_idx_type len = numel ();
+  if (len != a.numel ())
     return 0;
   return mx_inline_equal (len, data (), a.data ());
 }
@@ -73,9 +73,9 @@
 FloatRowVector&
 FloatRowVector::insert (const FloatRowVector& a, octave_idx_type c)
 {
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
-  if (c < 0 || c + a_len > length ())
+  if (c < 0 || c + a_len > numel ())
     {
       (*current_liboctave_error_handler) ("range error for insert");
       return *this;
@@ -95,7 +95,7 @@
 FloatRowVector&
 FloatRowVector::fill (float val)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -111,7 +111,7 @@
 FloatRowVector&
 FloatRowVector::fill (float val, octave_idx_type c1, octave_idx_type c2)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len)
     {
@@ -135,9 +135,9 @@
 FloatRowVector
 FloatRowVector::append (const FloatRowVector& a) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   octave_idx_type nc_insert = len;
-  FloatRowVector retval (len + a.length ());
+  FloatRowVector retval (len + a.numel ());
   retval.insert (*this, 0);
   retval.insert (a, nc_insert);
   return retval;
@@ -194,7 +194,7 @@
 {
   FloatRowVector retval;
 
-  octave_idx_type len = v.length ();
+  octave_idx_type len = v.numel ();
 
   octave_idx_type a_nr = a.rows ();
   octave_idx_type a_nc = a.cols ();
@@ -229,7 +229,7 @@
 float
 FloatRowVector::min (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return 0;
 
@@ -245,7 +245,7 @@
 float
 FloatRowVector::max (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
   if (len == 0)
     return 0;
 
@@ -263,7 +263,7 @@
 {
 //  int field_width = os.precision () + 7;
 
-  for (octave_idx_type i = 0; i < a.length (); i++)
+  for (octave_idx_type i = 0; i < a.numel (); i++)
     os << " " /* setw (field_width) */ << a.elem (i);
   return os;
 }
@@ -271,7 +271,7 @@
 std::istream&
 operator >> (std::istream& is, FloatRowVector& a)
 {
-  octave_idx_type len = a.length ();
+  octave_idx_type len = a.numel ();
 
   if (len > 0)
     {
@@ -293,14 +293,19 @@
 FloatRowVector
 linspace (float x1, float x2, octave_idx_type n)
 {
-  if (n < 1) n = 1;
+  NoAlias<FloatRowVector> retval;
 
-  NoAlias<FloatRowVector> retval (n);
+  if (n < 1)
+    return retval;
+  else
+    retval.clear (n);
+
+  retval(0) = x1;
 
   float delta = (x2 - x1) / (n - 1);
-  retval(0) = x1;
   for (octave_idx_type i = 1; i < n-1; i++)
     retval(i) = x1 + i*delta;
+
   retval(n-1) = x2;
 
   return retval;
@@ -313,9 +318,9 @@
 {
   float retval = 0.0;
 
-  octave_idx_type len = v.length ();
+  octave_idx_type len = v.numel ();
 
-  octave_idx_type a_len = a.length ();
+  octave_idx_type a_len = a.numel ();
 
   if (len != a_len)
     gripe_nonconformant ("operator *", len, a_len);
--- a/liboctave/array/fRowVector.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/fRowVector.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fRowVector_h)
+#if ! defined (octave_fRowVector_h)
 #define octave_fRowVector_h 1
 
 #include "MArray.h"
--- a/liboctave/array/idx-vector.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/idx-vector.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -113,15 +113,20 @@
       gripe_invalid_range ();
       err = true;
     }
-  else if (start < 0 || (step < 0 && start + (len-1)*step < 0))
+  else if (start < 0)
     {
-      gripe_invalid_index ();
+      gripe_invalid_index (start);
+      err = true;
+    }
+  else if (step < 0 && start + (len-1)*step < 0)
+    {
+      gripe_invalid_index (start + (len-1)*step);
       err = true;
     }
 }
 
 idx_vector::idx_range_rep::idx_range_rep (const Range& r)
-  : start (0), len (r.nelem ()), step (1)
+  : start (0), len (r.numel ()), step (1)
 {
   if (len < 0)
     {
@@ -134,15 +139,23 @@
         {
           start = static_cast<octave_idx_type> (r.base ()) - 1;
           step = static_cast<octave_idx_type> (r.inc ());
-          if (start < 0 || (step < 0 && start + (len-1)*step < 0))
+          if (start < 0)
             {
-              gripe_invalid_index ();
+              gripe_invalid_index (start);
+              err = true;
+            }
+          else if (step < 0 && start + (len - 1)*step < 0)
+            {
+              gripe_invalid_index (start + (len - 1)*step);
               err = true;
             }
         }
       else
         {
-          gripe_invalid_index ();
+          // find first non-integer, then gripe about it
+          double b = r.base ();
+          double inc = r.inc ();
+          gripe_invalid_index (b != gnulib::floor (b) ? b : b + inc);
           err = true;
         }
     }
@@ -221,7 +234,11 @@
                octave_idx_type& ext)
 {
   if (i <= 0)
-    conv_error = true;
+    {
+      if (!conv_error)          // only gripe once, for things like A(-10000:0)
+        gripe_invalid_index (i-1);
+      conv_error = true;
+    }
 
   if (ext < i)
     ext = i;
@@ -235,7 +252,10 @@
   octave_idx_type i = static_cast<octave_idx_type> (x);
 
   if (static_cast<double> (i) != x)
-    conv_error = true;
+    {
+      gripe_invalid_index (x-1);
+      conv_error = true;
+    }
 
   return convert_index (i, conv_error, ext);
 }
@@ -264,9 +284,6 @@
   octave_idx_type dummy = 0;
 
   data = convert_index (x, err, dummy);
-
-  if (err)
-    gripe_invalid_index ();
 }
 
 idx_vector::idx_scalar_rep::idx_scalar_rep (octave_idx_type i)
@@ -274,7 +291,7 @@
 {
   if (data < 0)
     {
-      gripe_invalid_index ();
+      gripe_invalid_index (data);
       err = true;
     }
 }
@@ -327,10 +344,7 @@
       data = d;
 
       if (err)
-        {
-          delete [] data;
-          gripe_invalid_index ();
-        }
+        delete [] data;
     }
 }
 
@@ -347,15 +361,16 @@
         {
           octave_idx_type k = inda.xelem (i);
           if (k < 0)
-            err = true;
+            {
+              if (!err)         // only report first error, in case 1000s.
+                gripe_invalid_index (k);
+              err = true;
+            }
           else if (k > max)
             max = k;
         }
 
       ext = max + 1;
-
-      if (err)
-        gripe_invalid_index ();
     }
 }
 
@@ -405,7 +420,7 @@
     {
       octave_idx_type *d = new octave_idx_type [len];
 
-      octave_idx_type ntot = bnda.length ();
+      octave_idx_type ntot = bnda.numel ();
 
       octave_idx_type k = 0;
       for (octave_idx_type i = 0; i < ntot; i++)
@@ -459,7 +474,7 @@
 {
   if (n < 0 || n >= len)
     {
-      gripe_invalid_index ();
+      gripe_invalid_index (n);
       return 0;
     }
 
@@ -709,7 +724,7 @@
 {
   if (n < 0 || n >= len)
     {
-      gripe_invalid_index ();
+      gripe_invalid_index (n);
       return 0;
     }
 
--- a/liboctave/array/idx-vector.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/idx-vector.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 */
 
-#if !defined (octave_idx_vector_h)
+#if ! defined (octave_idx_vector_h)
 #define octave_idx_vector_h 1
 
 #include <cassert>
--- a/liboctave/array/int16NDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/int16NDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_int16NDArray_h)
+#if ! defined (octave_int16NDArray_h)
 #define octave_int16NDArray_h 1
 
 #include "intNDArray.h"
--- a/liboctave/array/int32NDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/int32NDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_int32NDArray_h)
+#if ! defined (octave_int32NDArray_h)
 #define octave_int32NDArray_h 1
 
 #include "intNDArray.h"
--- a/liboctave/array/int64NDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/int64NDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_int64NDArray_h)
+#if ! defined (octave_int64NDArray_h)
 #define octave_int64NDArray_h 1
 
 #include "intNDArray.h"
--- a/liboctave/array/int8NDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/int8NDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_int8NDArray_h)
+#if ! defined (octave_int8NDArray_h)
 #define octave_int8NDArray_h 1
 
 #include "intNDArray.h"
--- a/liboctave/array/intNDArray.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/intNDArray.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -39,7 +39,7 @@
 {
   boolNDArray b (this->dims ());
 
-  for (octave_idx_type i = 0; i < this->length (); i++)
+  for (octave_idx_type i = 0; i < this->numel (); i++)
     b.elem (i) = ! this->elem (i);
 
   return b;
@@ -49,7 +49,7 @@
 bool
 intNDArray<T>::any_element_not_one_or_zero (void) const
 {
-  octave_idx_type nel = this->nelem ();
+  octave_idx_type nel = this->numel ();
 
   for (octave_idx_type i = 0; i < nel; i++)
     {
@@ -143,7 +143,7 @@
 std::ostream&
 operator << (std::ostream& os, const intNDArray<T>& a)
 {
-  octave_idx_type nel = a.nelem ();
+  octave_idx_type nel = a.numel ();
 
   for (octave_idx_type i = 0; i < nel; i++)
     os << " " << a.elem (i) << "\n";
@@ -155,7 +155,7 @@
 std::istream&
 operator >> (std::istream& is, intNDArray<T>& a)
 {
-  octave_idx_type nel = a.nelem ();
+  octave_idx_type nel = a.numel ();
 
   if (nel > 0)
     {
@@ -183,7 +183,7 @@
 intNDArray<T>
 intNDArray<T>::abs (void) const
 {
-  octave_idx_type nel = this->nelem ();
+  octave_idx_type nel = this->numel ();
   intNDArray<T> ret (this->dims ());
 
   for (octave_idx_type i = 0; i < nel; i++)
@@ -199,7 +199,7 @@
 intNDArray<T>
 intNDArray<T>::signum (void) const
 {
-  octave_idx_type nel = this->nelem ();
+  octave_idx_type nel = this->numel ();
   intNDArray<T> ret (this->dims ());
 
   for (octave_idx_type i = 0; i < nel; i++)
--- a/liboctave/array/intNDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/intNDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_intNDArray_h)
+#if ! defined (octave_intNDArray_h)
 #define octave_intNDArray_h 1
 
 #include "MArray.h"
--- a/liboctave/array/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,140 +1,141 @@
-EXTRA_DIST += \
-  array/module.mk
-
 ARRAY_INC = \
-  array/Array.h \
-  array/Array-util.h \
-  array/boolMatrix.h \
-  array/boolNDArray.h \
-  array/boolSparse.h \
-  array/CColVector.h \
-  array/CDiagMatrix.h \
-  array/chMatrix.h \
-  array/chNDArray.h \
-  array/CMatrix.h \
-  array/CNDArray.h \
-  array/CRowVector.h \
-  array/CSparse.h \
-  array/dColVector.h \
-  array/dDiagMatrix.h \
-  array/DiagArray2.h \
-  array/dim-vector.h \
-  array/dMatrix.h \
-  array/dNDArray.h \
-  array/dRowVector.h \
-  array/dSparse.h \
-  array/fCColVector.h \
-  array/fCDiagMatrix.h \
-  array/fCMatrix.h \
-  array/fCNDArray.h \
-  array/fColVector.h \
-  array/fCRowVector.h \
-  array/fDiagMatrix.h \
-  array/fMatrix.h \
-  array/fNDArray.h \
-  array/fRowVector.h \
-  array/idx-vector.h \
-  array/int16NDArray.h \
-  array/int32NDArray.h \
-  array/int64NDArray.h \
-  array/int8NDArray.h \
-  array/intNDArray.h \
-  array/MArray-decl.h \
-  array/MArray-defs.h \
-  array/MArray.h \
-  array/Matrix.h \
-  array/MatrixType.h \
-  array/MDiagArray2.h \
-  array/MSparse-defs.h \
-  array/MSparse.h \
-  array/PermMatrix.h \
-  array/Range.h \
-  array/Sparse.h \
-  array/uint16NDArray.h \
-  array/uint32NDArray.h \
-  array/uint64NDArray.h \
-  array/uint8NDArray.h
+  liboctave/array/Array.h \
+  liboctave/array/Array-util.h \
+  liboctave/array/boolMatrix.h \
+  liboctave/array/boolNDArray.h \
+  liboctave/array/boolSparse.h \
+  liboctave/array/CColVector.h \
+  liboctave/array/CDiagMatrix.h \
+  liboctave/array/chMatrix.h \
+  liboctave/array/chNDArray.h \
+  liboctave/array/CMatrix.h \
+  liboctave/array/CNDArray.h \
+  liboctave/array/CRowVector.h \
+  liboctave/array/CSparse.h \
+  liboctave/array/dColVector.h \
+  liboctave/array/dDiagMatrix.h \
+  liboctave/array/DiagArray2.h \
+  liboctave/array/dim-vector.h \
+  liboctave/array/dMatrix.h \
+  liboctave/array/dNDArray.h \
+  liboctave/array/dRowVector.h \
+  liboctave/array/dSparse.h \
+  liboctave/array/fCColVector.h \
+  liboctave/array/fCDiagMatrix.h \
+  liboctave/array/fCMatrix.h \
+  liboctave/array/fCNDArray.h \
+  liboctave/array/fColVector.h \
+  liboctave/array/fCRowVector.h \
+  liboctave/array/fDiagMatrix.h \
+  liboctave/array/fMatrix.h \
+  liboctave/array/fNDArray.h \
+  liboctave/array/fRowVector.h \
+  liboctave/array/idx-vector.h \
+  liboctave/array/int16NDArray.h \
+  liboctave/array/int32NDArray.h \
+  liboctave/array/int64NDArray.h \
+  liboctave/array/int8NDArray.h \
+  liboctave/array/intNDArray.h \
+  liboctave/array/MArray-decl.h \
+  liboctave/array/MArray-defs.h \
+  liboctave/array/MArray.h \
+  liboctave/array/Matrix.h \
+  liboctave/array/MatrixType.h \
+  liboctave/array/MDiagArray2.h \
+  liboctave/array/MSparse.h \
+  liboctave/array/PermMatrix.h \
+  liboctave/array/Range.h \
+  liboctave/array/Sparse.h \
+  liboctave/array/uint16NDArray.h \
+  liboctave/array/uint32NDArray.h \
+  liboctave/array/uint64NDArray.h \
+  liboctave/array/uint8NDArray.h
 
 ARRAY_SRC = \
-  array/Array-b.cc \
-  array/Array-C.cc \
-  array/Array-ch.cc \
-  array/Array-d.cc \
-  array/Array-f.cc \
-  array/Array-fC.cc \
-  array/Array-i.cc \
-  array/Array-idx-vec.cc \
-  array/Array-s.cc \
-  array/Array-str.cc \
-  array/Array-util.cc \
-  array/Array-voidp.cc \
-  array/boolMatrix.cc \
-  array/boolNDArray.cc \
-  array/boolSparse.cc \
-  array/CColVector.cc \
-  array/CDiagMatrix.cc \
-  array/chMatrix.cc \
-  array/chNDArray.cc \
-  array/CMatrix.cc \
-  array/CNDArray.cc \
-  array/CRowVector.cc \
-  array/CSparse.cc \
-  array/dColVector.cc \
-  array/dDiagMatrix.cc \
-  array/dim-vector.cc \
-  array/dMatrix.cc \
-  array/dNDArray.cc \
-  array/dRowVector.cc \
-  array/dSparse.cc \
-  array/fCColVector.cc \
-  array/fCDiagMatrix.cc \
-  array/fCMatrix.cc \
-  array/fCNDArray.cc \
-  array/fColVector.cc \
-  array/fCRowVector.cc \
-  array/fDiagMatrix.cc \
-  array/fMatrix.cc \
-  array/fNDArray.cc \
-  array/fRowVector.cc \
-  array/idx-vector.cc \
-  array/int16NDArray.cc \
-  array/int32NDArray.cc \
-  array/int64NDArray.cc \
-  array/int8NDArray.cc \
-  array/MArray-C.cc \
-  array/MArray-d.cc \
-  array/MArray-f.cc \
-  array/MArray-fC.cc \
-  array/MArray-i.cc \
-  array/MArray-s.cc \
-  array/MatrixType.cc \
-  array/MSparse-C.cc \
-  array/MSparse-d.cc \
-  array/PermMatrix.cc \
-  array/Range.cc \
-  array/Sparse-b.cc \
-  array/Sparse-C.cc \
-  array/Sparse-d.cc \
-  array/uint16NDArray.cc \
-  array/uint32NDArray.cc \
-  array/uint64NDArray.cc \
-  array/uint8NDArray.cc
+  liboctave/array/Array-b.cc \
+  liboctave/array/Array-C.cc \
+  liboctave/array/Array-ch.cc \
+  liboctave/array/Array-d.cc \
+  liboctave/array/Array-f.cc \
+  liboctave/array/Array-fC.cc \
+  liboctave/array/Array-i.cc \
+  liboctave/array/Array-idx-vec.cc \
+  liboctave/array/Array-s.cc \
+  liboctave/array/Array-str.cc \
+  liboctave/array/Array-util.cc \
+  liboctave/array/Array-voidp.cc \
+  liboctave/array/boolMatrix.cc \
+  liboctave/array/boolNDArray.cc \
+  liboctave/array/boolSparse.cc \
+  liboctave/array/CColVector.cc \
+  liboctave/array/CDiagMatrix.cc \
+  liboctave/array/chMatrix.cc \
+  liboctave/array/chNDArray.cc \
+  liboctave/array/CMatrix.cc \
+  liboctave/array/CNDArray.cc \
+  liboctave/array/CRowVector.cc \
+  liboctave/array/CSparse.cc \
+  liboctave/array/dColVector.cc \
+  liboctave/array/dDiagMatrix.cc \
+  liboctave/array/dim-vector.cc \
+  liboctave/array/dMatrix.cc \
+  liboctave/array/dNDArray.cc \
+  liboctave/array/dRowVector.cc \
+  liboctave/array/dSparse.cc \
+  liboctave/array/fCColVector.cc \
+  liboctave/array/fCDiagMatrix.cc \
+  liboctave/array/fCMatrix.cc \
+  liboctave/array/fCNDArray.cc \
+  liboctave/array/fColVector.cc \
+  liboctave/array/fCRowVector.cc \
+  liboctave/array/fDiagMatrix.cc \
+  liboctave/array/fMatrix.cc \
+  liboctave/array/fNDArray.cc \
+  liboctave/array/fRowVector.cc \
+  liboctave/array/idx-vector.cc \
+  liboctave/array/int16NDArray.cc \
+  liboctave/array/int32NDArray.cc \
+  liboctave/array/int64NDArray.cc \
+  liboctave/array/int8NDArray.cc \
+  liboctave/array/MArray-C.cc \
+  liboctave/array/MArray-d.cc \
+  liboctave/array/MArray-f.cc \
+  liboctave/array/MArray-fC.cc \
+  liboctave/array/MArray-i.cc \
+  liboctave/array/MArray-s.cc \
+  liboctave/array/MatrixType.cc \
+  liboctave/array/MSparse-C.cc \
+  liboctave/array/MSparse-d.cc \
+  liboctave/array/PermMatrix.cc \
+  liboctave/array/Range.cc \
+  liboctave/array/Sparse-b.cc \
+  liboctave/array/Sparse-C.cc \
+  liboctave/array/Sparse-d.cc \
+  liboctave/array/uint16NDArray.cc \
+  liboctave/array/uint32NDArray.cc \
+  liboctave/array/uint64NDArray.cc \
+  liboctave/array/uint8NDArray.cc
 
-TEMPLATE_SRC += \
-  array/Array.cc \
-  array/DiagArray2.cc \
-  array/intNDArray.cc \
-  array/MArray.cc \
-  array/MDiagArray2.cc \
-  array/MSparse.cc \
-  array/Sparse.cc
+LIBOCTAVE_TEMPLATE_SRC += \
+  liboctave/array/Array.cc \
+  liboctave/array/DiagArray2.cc \
+  liboctave/array/intNDArray.cc \
+  liboctave/array/MArray.cc \
+  liboctave/array/MDiagArray2.cc \
+  liboctave/array/MSparse.cc \
+  liboctave/array/Sparse.cc
 
-noinst_LTLIBRARIES += array/libarray.la
+noinst_LTLIBRARIES += liboctave/array/libarray.la
 
-array_libarray_la_SOURCES = $(ARRAY_SRC)
-array_libarray_la_CPPFLAGS = \
-  $(liboctave_la_CPPFLAGS) \
+liboctave_array_libarray_la_SOURCES = $(ARRAY_SRC)
+
+liboctave_array_libarray_la_CPPFLAGS = \
+  $(liboctave_liboctave_la_CPPFLAGS) \
   $(FFTW_XCPPFLAGS) \
   $(SPARSE_XCPPFLAGS)
 
-liboctave_la_LIBADD += array/libarray.la
+liboctave_array_libarray_la_CFLAGS = $(liboctave_liboctave_la_CFLAGS)
+
+liboctave_array_libarray_la_CXXFLAGS = $(liboctave_liboctave_la_CXXFLAGS)
+
+liboctave_liboctave_la_LIBADD += liboctave/array/libarray.la
--- a/liboctave/array/uint16NDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/uint16NDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_uint16NDArray_h)
+#if ! defined (octave_uint16NDArray_h)
 #define octave_uint16NDArray_h 1
 
 #include "intNDArray.h"
--- a/liboctave/array/uint32NDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/uint32NDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_uint32NDArray_h)
+#if ! defined (octave_uint32NDArray_h)
 #define octave_uint32NDArray_h 1
 
 #include "intNDArray.h"
--- a/liboctave/array/uint64NDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/uint64NDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_uint64NDArray_h)
+#if ! defined (octave_uint64NDArray_h)
 #define octave_uint64NDArray_h 1
 
 #include "intNDArray.h"
--- a/liboctave/array/uint8NDArray.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/array/uint8NDArray.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_uint8NDArray_h)
+#if ! defined (octave_uint8NDArray_h)
 #define octave_uint8NDArray_h 1
 
 #include "intNDArray.h"
--- a/liboctave/cruft/Faddeeva/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/Faddeeva/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,5 +1,3 @@
-EXTRA_DIST += cruft/Faddeeva/module.mk
-
 CRUFT_SOURCES += \
-  cruft/Faddeeva/Faddeeva.cc \
-  cruft/Faddeeva/Faddeeva.hh
+  liboctave/cruft/Faddeeva/Faddeeva.cc \
+  liboctave/cruft/Faddeeva/Faddeeva.hh
--- a/liboctave/cruft/amos/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/amos/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,69 +1,67 @@
-EXTRA_DIST += cruft/amos/module.mk
-
 CRUFT_SOURCES += \
-  cruft/amos/cacai.f \
-  cruft/amos/cacon.f \
-  cruft/amos/cbesh.f \
-  cruft/amos/cbesi.f \
-  cruft/amos/cbesj.f \
-  cruft/amos/cbesk.f \
-  cruft/amos/cbesy.f \
-  cruft/amos/cbinu.f \
-  cruft/amos/cbuni.f \
-  cruft/amos/cbunk.f \
-  cruft/amos/cunk1.f \
-  cruft/amos/cunk2.f \
-  cruft/amos/crati.f \
-  cruft/amos/cshch.f \
-  cruft/amos/cuni1.f \
-  cruft/amos/cuoik.f \
-  cruft/amos/cairy.f \
-  cruft/amos/cbiry.f \
-  cruft/amos/ckscl.f \
-  cruft/amos/cs1s2.f \
-  cruft/amos/cuchk.f \
-  cruft/amos/cuni2.f \
-  cruft/amos/cwrsk.f \
-  cruft/amos/casyi.f \
-  cruft/amos/cbknu.f \
-  cruft/amos/cmlri.f \
-  cruft/amos/cseri.f \
-  cruft/amos/cunhj.f \
-  cruft/amos/cunik.f \
-  cruft/amos/dgamln.f \
-  cruft/amos/gamln.f \
-  cruft/amos/xzabs.f \
-  cruft/amos/xzexp.f \
-  cruft/amos/xzlog.f \
-  cruft/amos/xzsqrt.f \
-  cruft/amos/zacai.f \
-  cruft/amos/zacon.f \
-  cruft/amos/zairy.f \
-  cruft/amos/zasyi.f \
-  cruft/amos/zbesh.f \
-  cruft/amos/zbesi.f \
-  cruft/amos/zbesj.f \
-  cruft/amos/zbesk.f \
-  cruft/amos/zbesy.f \
-  cruft/amos/zbinu.f \
-  cruft/amos/zbiry.f \
-  cruft/amos/zbknu.f \
-  cruft/amos/zbuni.f \
-  cruft/amos/zbunk.f \
-  cruft/amos/zdiv.f \
-  cruft/amos/zkscl.f \
-  cruft/amos/zmlri.f \
-  cruft/amos/zmlt.f \
-  cruft/amos/zrati.f \
-  cruft/amos/zs1s2.f \
-  cruft/amos/zseri.f \
-  cruft/amos/zshch.f \
-  cruft/amos/zuchk.f \
-  cruft/amos/zunhj.f \
-  cruft/amos/zuni1.f \
-  cruft/amos/zuni2.f \
-  cruft/amos/zunik.f \
-  cruft/amos/zunk1.f \
-  cruft/amos/zunk2.f \
-  cruft/amos/zuoik.f \
-  cruft/amos/zwrsk.f
+  liboctave/cruft/amos/cacai.f \
+  liboctave/cruft/amos/cacon.f \
+  liboctave/cruft/amos/cbesh.f \
+  liboctave/cruft/amos/cbesi.f \
+  liboctave/cruft/amos/cbesj.f \
+  liboctave/cruft/amos/cbesk.f \
+  liboctave/cruft/amos/cbesy.f \
+  liboctave/cruft/amos/cbinu.f \
+  liboctave/cruft/amos/cbuni.f \
+  liboctave/cruft/amos/cbunk.f \
+  liboctave/cruft/amos/cunk1.f \
+  liboctave/cruft/amos/cunk2.f \
+  liboctave/cruft/amos/crati.f \
+  liboctave/cruft/amos/cshch.f \
+  liboctave/cruft/amos/cuni1.f \
+  liboctave/cruft/amos/cuoik.f \
+  liboctave/cruft/amos/cairy.f \
+  liboctave/cruft/amos/cbiry.f \
+  liboctave/cruft/amos/ckscl.f \
+  liboctave/cruft/amos/cs1s2.f \
+  liboctave/cruft/amos/cuchk.f \
+  liboctave/cruft/amos/cuni2.f \
+  liboctave/cruft/amos/cwrsk.f \
+  liboctave/cruft/amos/casyi.f \
+  liboctave/cruft/amos/cbknu.f \
+  liboctave/cruft/amos/cmlri.f \
+  liboctave/cruft/amos/cseri.f \
+  liboctave/cruft/amos/cunhj.f \
+  liboctave/cruft/amos/cunik.f \
+  liboctave/cruft/amos/dgamln.f \
+  liboctave/cruft/amos/gamln.f \
+  liboctave/cruft/amos/xzabs.f \
+  liboctave/cruft/amos/xzexp.f \
+  liboctave/cruft/amos/xzlog.f \
+  liboctave/cruft/amos/xzsqrt.f \
+  liboctave/cruft/amos/zacai.f \
+  liboctave/cruft/amos/zacon.f \
+  liboctave/cruft/amos/zairy.f \
+  liboctave/cruft/amos/zasyi.f \
+  liboctave/cruft/amos/zbesh.f \
+  liboctave/cruft/amos/zbesi.f \
+  liboctave/cruft/amos/zbesj.f \
+  liboctave/cruft/amos/zbesk.f \
+  liboctave/cruft/amos/zbesy.f \
+  liboctave/cruft/amos/zbinu.f \
+  liboctave/cruft/amos/zbiry.f \
+  liboctave/cruft/amos/zbknu.f \
+  liboctave/cruft/amos/zbuni.f \
+  liboctave/cruft/amos/zbunk.f \
+  liboctave/cruft/amos/zdiv.f \
+  liboctave/cruft/amos/zkscl.f \
+  liboctave/cruft/amos/zmlri.f \
+  liboctave/cruft/amos/zmlt.f \
+  liboctave/cruft/amos/zrati.f \
+  liboctave/cruft/amos/zs1s2.f \
+  liboctave/cruft/amos/zseri.f \
+  liboctave/cruft/amos/zshch.f \
+  liboctave/cruft/amos/zuchk.f \
+  liboctave/cruft/amos/zunhj.f \
+  liboctave/cruft/amos/zuni1.f \
+  liboctave/cruft/amos/zuni2.f \
+  liboctave/cruft/amos/zunik.f \
+  liboctave/cruft/amos/zunk1.f \
+  liboctave/cruft/amos/zunk2.f \
+  liboctave/cruft/amos/zuoik.f \
+  liboctave/cruft/amos/zwrsk.f
--- a/liboctave/cruft/blas-xtra/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/blas-xtra/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,28 +1,26 @@
-EXTRA_DIST += cruft/blas-xtra/module.mk
-
 CRUFT_SOURCES += \
-  cruft/blas-xtra/ddot3.f \
-  cruft/blas-xtra/zdotc3.f \
-  cruft/blas-xtra/sdot3.f \
-  cruft/blas-xtra/cdotc3.f \
-  cruft/blas-xtra/dmatm3.f \
-  cruft/blas-xtra/zmatm3.f \
-  cruft/blas-xtra/smatm3.f \
-  cruft/blas-xtra/cmatm3.f \
-  cruft/blas-xtra/xddot.f \
-  cruft/blas-xtra/xdnrm2.f \
-  cruft/blas-xtra/xdznrm2.f \
-  cruft/blas-xtra/xzdotc.f \
-  cruft/blas-xtra/xzdotu.f \
-  cruft/blas-xtra/xsdot.f \
-  cruft/blas-xtra/xsnrm2.f \
-  cruft/blas-xtra/xscnrm2.f \
-  cruft/blas-xtra/xcdotc.f \
-  cruft/blas-xtra/xcdotu.f \
-  cruft/blas-xtra/xerbla.f \
-  cruft/blas-xtra/cconv2.f \
-  cruft/blas-xtra/csconv2.f \
-  cruft/blas-xtra/dconv2.f \
-  cruft/blas-xtra/sconv2.f \
-  cruft/blas-xtra/zconv2.f \
-  cruft/blas-xtra/zdconv2.f
+  liboctave/cruft/blas-xtra/ddot3.f \
+  liboctave/cruft/blas-xtra/zdotc3.f \
+  liboctave/cruft/blas-xtra/sdot3.f \
+  liboctave/cruft/blas-xtra/cdotc3.f \
+  liboctave/cruft/blas-xtra/dmatm3.f \
+  liboctave/cruft/blas-xtra/zmatm3.f \
+  liboctave/cruft/blas-xtra/smatm3.f \
+  liboctave/cruft/blas-xtra/cmatm3.f \
+  liboctave/cruft/blas-xtra/xddot.f \
+  liboctave/cruft/blas-xtra/xdnrm2.f \
+  liboctave/cruft/blas-xtra/xdznrm2.f \
+  liboctave/cruft/blas-xtra/xzdotc.f \
+  liboctave/cruft/blas-xtra/xzdotu.f \
+  liboctave/cruft/blas-xtra/xsdot.f \
+  liboctave/cruft/blas-xtra/xsnrm2.f \
+  liboctave/cruft/blas-xtra/xscnrm2.f \
+  liboctave/cruft/blas-xtra/xcdotc.f \
+  liboctave/cruft/blas-xtra/xcdotu.f \
+  liboctave/cruft/blas-xtra/xerbla.f \
+  liboctave/cruft/blas-xtra/cconv2.f \
+  liboctave/cruft/blas-xtra/csconv2.f \
+  liboctave/cruft/blas-xtra/dconv2.f \
+  liboctave/cruft/blas-xtra/sconv2.f \
+  liboctave/cruft/blas-xtra/zconv2.f \
+  liboctave/cruft/blas-xtra/zdconv2.f
--- a/liboctave/cruft/daspk/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/daspk/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,31 +1,29 @@
-EXTRA_DIST += cruft/daspk/module.mk
-
 CRUFT_SOURCES += \
-  cruft/daspk/datv.f \
-  cruft/daspk/dcnst0.f \
-  cruft/daspk/dcnstr.f \
-  cruft/daspk/ddasic.f \
-  cruft/daspk/ddasid.f \
-  cruft/daspk/ddasik.f \
-  cruft/daspk/ddaspk.f \
-  cruft/daspk/ddstp.f \
-  cruft/daspk/ddwnrm.f \
-  cruft/daspk/dfnrmd.f \
-  cruft/daspk/dfnrmk.f \
-  cruft/daspk/dhels.f \
-  cruft/daspk/dheqr.f \
-  cruft/daspk/dinvwt.f \
-  cruft/daspk/dlinsd.f \
-  cruft/daspk/dlinsk.f \
-  cruft/daspk/dmatd.f \
-  cruft/daspk/dnedd.f \
-  cruft/daspk/dnedk.f \
-  cruft/daspk/dnsd.f \
-  cruft/daspk/dnsid.f \
-  cruft/daspk/dnsik.f \
-  cruft/daspk/dnsk.f \
-  cruft/daspk/dorth.f \
-  cruft/daspk/dslvd.f \
-  cruft/daspk/dslvk.f \
-  cruft/daspk/dspigm.f \
-  cruft/daspk/dyypnw.f
+  liboctave/cruft/daspk/datv.f \
+  liboctave/cruft/daspk/dcnst0.f \
+  liboctave/cruft/daspk/dcnstr.f \
+  liboctave/cruft/daspk/ddasic.f \
+  liboctave/cruft/daspk/ddasid.f \
+  liboctave/cruft/daspk/ddasik.f \
+  liboctave/cruft/daspk/ddaspk.f \
+  liboctave/cruft/daspk/ddstp.f \
+  liboctave/cruft/daspk/ddwnrm.f \
+  liboctave/cruft/daspk/dfnrmd.f \
+  liboctave/cruft/daspk/dfnrmk.f \
+  liboctave/cruft/daspk/dhels.f \
+  liboctave/cruft/daspk/dheqr.f \
+  liboctave/cruft/daspk/dinvwt.f \
+  liboctave/cruft/daspk/dlinsd.f \
+  liboctave/cruft/daspk/dlinsk.f \
+  liboctave/cruft/daspk/dmatd.f \
+  liboctave/cruft/daspk/dnedd.f \
+  liboctave/cruft/daspk/dnedk.f \
+  liboctave/cruft/daspk/dnsd.f \
+  liboctave/cruft/daspk/dnsid.f \
+  liboctave/cruft/daspk/dnsik.f \
+  liboctave/cruft/daspk/dnsk.f \
+  liboctave/cruft/daspk/dorth.f \
+  liboctave/cruft/daspk/dslvd.f \
+  liboctave/cruft/daspk/dslvk.f \
+  liboctave/cruft/daspk/dspigm.f \
+  liboctave/cruft/daspk/dyypnw.f
--- a/liboctave/cruft/dasrt/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/dasrt/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,6 +1,4 @@
-EXTRA_DIST += cruft/dasrt/module.mk
-
 CRUFT_SOURCES += \
-  cruft/dasrt/ddasrt.f \
-  cruft/dasrt/drchek.f \
-  cruft/dasrt/droots.f
+  liboctave/cruft/dasrt/ddasrt.f \
+  liboctave/cruft/dasrt/drchek.f \
+  liboctave/cruft/dasrt/droots.f
--- a/liboctave/cruft/dassl/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/dassl/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,11 +1,9 @@
-EXTRA_DIST += cruft/dassl/module.mk
-
 CRUFT_SOURCES += \
-  cruft/dassl/ddaini.f \
-  cruft/dassl/ddajac.f \
-  cruft/dassl/ddanrm.f \
-  cruft/dassl/ddaslv.f \
-  cruft/dassl/ddassl.f \
-  cruft/dassl/ddastp.f \
-  cruft/dassl/ddatrp.f \
-  cruft/dassl/ddawts.f
+  liboctave/cruft/dassl/ddaini.f \
+  liboctave/cruft/dassl/ddajac.f \
+  liboctave/cruft/dassl/ddanrm.f \
+  liboctave/cruft/dassl/ddaslv.f \
+  liboctave/cruft/dassl/ddassl.f \
+  liboctave/cruft/dassl/ddastp.f \
+  liboctave/cruft/dassl/ddatrp.f \
+  liboctave/cruft/dassl/ddawts.f
--- a/liboctave/cruft/fftpack/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/fftpack/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,43 +1,42 @@
-EXTRA_DIST += \
-  cruft/fftpack/module.mk \
-  cruft/fftpack/fftpack.doc
-
 FFTPACK_SRC = \
-  cruft/fftpack/cfftb.f \
-  cruft/fftpack/cfftb1.f \
-  cruft/fftpack/cfftf.f \
-  cruft/fftpack/cfftf1.f \
-  cruft/fftpack/cffti.f \
-  cruft/fftpack/cffti1.f \
-  cruft/fftpack/passb.f \
-  cruft/fftpack/passb2.f \
-  cruft/fftpack/passb3.f \
-  cruft/fftpack/passb4.f \
-  cruft/fftpack/passb5.f \
-  cruft/fftpack/passf.f \
-  cruft/fftpack/passf2.f \
-  cruft/fftpack/passf3.f \
-  cruft/fftpack/passf4.f \
-  cruft/fftpack/passf5.f \
-  cruft/fftpack/zfftb.f \
-  cruft/fftpack/zfftb1.f \
-  cruft/fftpack/zfftf.f \
-  cruft/fftpack/zfftf1.f \
-  cruft/fftpack/zffti.f \
-  cruft/fftpack/zffti1.f \
-  cruft/fftpack/zpassb.f \
-  cruft/fftpack/zpassb2.f \
-  cruft/fftpack/zpassb3.f \
-  cruft/fftpack/zpassb4.f \
-  cruft/fftpack/zpassb5.f \
-  cruft/fftpack/zpassf.f \
-  cruft/fftpack/zpassf2.f \
-  cruft/fftpack/zpassf3.f \
-  cruft/fftpack/zpassf4.f \
-  cruft/fftpack/zpassf5.f
+  liboctave/cruft/fftpack/cfftb.f \
+  liboctave/cruft/fftpack/cfftb1.f \
+  liboctave/cruft/fftpack/cfftf.f \
+  liboctave/cruft/fftpack/cfftf1.f \
+  liboctave/cruft/fftpack/cffti.f \
+  liboctave/cruft/fftpack/cffti1.f \
+  liboctave/cruft/fftpack/passb.f \
+  liboctave/cruft/fftpack/passb2.f \
+  liboctave/cruft/fftpack/passb3.f \
+  liboctave/cruft/fftpack/passb4.f \
+  liboctave/cruft/fftpack/passb5.f \
+  liboctave/cruft/fftpack/passf.f \
+  liboctave/cruft/fftpack/passf2.f \
+  liboctave/cruft/fftpack/passf3.f \
+  liboctave/cruft/fftpack/passf4.f \
+  liboctave/cruft/fftpack/passf5.f \
+  liboctave/cruft/fftpack/zfftb.f \
+  liboctave/cruft/fftpack/zfftb1.f \
+  liboctave/cruft/fftpack/zfftf.f \
+  liboctave/cruft/fftpack/zfftf1.f \
+  liboctave/cruft/fftpack/zffti.f \
+  liboctave/cruft/fftpack/zffti1.f \
+  liboctave/cruft/fftpack/zpassb.f \
+  liboctave/cruft/fftpack/zpassb2.f \
+  liboctave/cruft/fftpack/zpassb3.f \
+  liboctave/cruft/fftpack/zpassb4.f \
+  liboctave/cruft/fftpack/zpassb5.f \
+  liboctave/cruft/fftpack/zpassf.f \
+  liboctave/cruft/fftpack/zpassf2.f \
+  liboctave/cruft/fftpack/zpassf3.f \
+  liboctave/cruft/fftpack/zpassf4.f \
+  liboctave/cruft/fftpack/zpassf5.f
 
 if AMCOND_HAVE_FFTW
-  EXTRA_DIST += $(FFTPACK_SRC)
+  liboctave_EXTRA_DIST += $(FFTPACK_SRC)
 else
   CRUFT_SOURCES += $(FFTPACK_SRC)
 endif
+
+liboctave_EXTRA_DIST += \
+  liboctave/cruft/fftpack/fftpack.doc
--- a/liboctave/cruft/lapack-xtra/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/lapack-xtra/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,12 +1,10 @@
-EXTRA_DIST += cruft/lapack-xtra/module.mk
-
 CRUFT_SOURCES += \
-  cruft/lapack-xtra/xclange.f \
-  cruft/lapack-xtra/xdlamch.f \
-  cruft/lapack-xtra/xdlange.f \
-  cruft/lapack-xtra/xilaenv.f \
-  cruft/lapack-xtra/xslamch.f \
-  cruft/lapack-xtra/xslange.f \
-  cruft/lapack-xtra/xzlange.f \
-  cruft/lapack-xtra/zrsf2csf.f \
-  cruft/lapack-xtra/crsf2csf.f
+  liboctave/cruft/lapack-xtra/xclange.f \
+  liboctave/cruft/lapack-xtra/xdlamch.f \
+  liboctave/cruft/lapack-xtra/xdlange.f \
+  liboctave/cruft/lapack-xtra/xilaenv.f \
+  liboctave/cruft/lapack-xtra/xslamch.f \
+  liboctave/cruft/lapack-xtra/xslange.f \
+  liboctave/cruft/lapack-xtra/xzlange.f \
+  liboctave/cruft/lapack-xtra/zrsf2csf.f \
+  liboctave/cruft/lapack-xtra/crsf2csf.f
--- a/liboctave/cruft/misc/f77-fcn.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/misc/f77-fcn.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_f77_fcn_h)
+#if ! defined (octave_f77_fcn_h)
 #define octave_f77_fcn_h 1
 
 #include "quit.h"
@@ -45,8 +45,7 @@
    here, we'll restore the previous context and return.  We may also
    end up here if an interrupt is processed when the Fortran
    subroutine is called.  In that case, we resotre the context and go
-   to the top level.  The error_state should be checked immediately
-   after this macro is used. */
+   to the top level. */
 
 #define F77_XFCN(f, F, args) \
   do \
@@ -77,7 +76,7 @@
 /* So we can check to see if an exception has occurred. */
 CRUFT_API extern int f77_exception_encountered;
 
-#if !defined (F77_FCN)
+#if ! defined (F77_FCN)
 #define F77_FCN(f, F) F77_FUNC (f, F)
 #endif
 
--- a/liboctave/cruft/misc/lo-error.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/misc/lo-error.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_lo_error_h)
+#if ! defined (octave_lo_error_h)
 #define octave_lo_error_h 1
 
 #ifdef __cplusplus
--- a/liboctave/cruft/misc/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/misc/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,19 +1,18 @@
-EXTRA_DIST += \
-  cruft/misc/module.mk \
-  cruft/misc/d1mach-tst.for
-
 CRUFT_SOURCES += \
-  cruft/misc/blaswrap.c \
-  cruft/misc/cquit.c \
-  cruft/misc/d1mach.f \
-  cruft/misc/f77-extern.cc \
-  cruft/misc/f77-fcn.c \
-  cruft/misc/i1mach.f \
-  cruft/misc/lo-error.c \
-  cruft/misc/quit.cc \
-  cruft/misc/r1mach.f
+  liboctave/cruft/misc/blaswrap.c \
+  liboctave/cruft/misc/cquit.c \
+  liboctave/cruft/misc/d1mach.f \
+  liboctave/cruft/misc/f77-extern.cc \
+  liboctave/cruft/misc/f77-fcn.c \
+  liboctave/cruft/misc/i1mach.f \
+  liboctave/cruft/misc/lo-error.c \
+  liboctave/cruft/misc/quit.cc \
+  liboctave/cruft/misc/r1mach.f
 
 CRUFT_INC += \
-  cruft/misc/f77-fcn.h \
-  cruft/misc/lo-error.h \
-  cruft/misc/quit.h
+  liboctave/cruft/misc/f77-fcn.h \
+  liboctave/cruft/misc/lo-error.h \
+  liboctave/cruft/misc/quit.h
+
+liboctave_EXTRA_DIST += \
+  liboctave/cruft/misc/d1mach-tst.for
--- a/liboctave/cruft/misc/quit.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/misc/quit.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_quit_h)
+#if ! defined (octave_quit_h)
 #define octave_quit_h 1
 
 #include <stdio.h>
@@ -30,6 +30,7 @@
 
 #ifdef __cplusplus
 #include <new>
+#include <string>
 extern "C" {
 #endif
 
@@ -75,6 +76,41 @@
 class
 octave_execution_exception
 {
+public:
+
+  octave_execution_exception (void) : m_stack_trace () { }
+
+  octave_execution_exception (const octave_execution_exception& x)
+    : m_stack_trace (x.m_stack_trace) { }
+
+  octave_execution_exception& operator = (const octave_execution_exception& x)
+  {
+    if (&x != this)
+      m_stack_trace = x.m_stack_trace;
+
+    return *this;
+  }
+
+  ~octave_execution_exception (void) { }
+
+  virtual void set_stack_trace (const std::string& st)
+  {
+    m_stack_trace = st;
+  }
+
+  virtual void set_stack_trace (void)
+  {
+    m_stack_trace = "";
+  }
+
+  virtual std::string info (void) const
+  {
+    return m_stack_trace;
+  }
+
+private:
+
+  std::string m_stack_trace;
 };
 
 class
@@ -195,18 +231,18 @@
 
 #define END_INTERRUPT_WITH_EXCEPTIONS \
     } \
-  catch (octave_interrupt_exception) \
+  catch (const octave_interrupt_exception&) \
     { \
       octave_interrupt_immediately = saved_octave_interrupt_immediately; \
       octave_jump_to_enclosing_context (); \
     } \
-  catch (octave_execution_exception) \
+  catch (const octave_execution_exception&) \
     { \
       octave_interrupt_immediately = saved_octave_interrupt_immediately; \
       octave_exception_state = octave_exec_exception; \
       octave_jump_to_enclosing_context (); \
     } \
-  catch (std::bad_alloc) \
+  catch (const std::bad_alloc&) \
     { \
       octave_interrupt_immediately = saved_octave_interrupt_immediately; \
       octave_exception_state = octave_alloc_exception; \
--- a/liboctave/cruft/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,51 +1,55 @@
-EXTRA_DIST += cruft/mkf77def.in
-
-nodist_cruft_libcruft_la_SOURCES =
+nodist_liboctave_cruft_libcruft_la_SOURCES =
 
-cruft_libcruft_la_FFLAGS = $(F77_INTEGER_8_FLAG)
+liboctave_cruft_libcruft_la_FFLAGS = $(F77_INTEGER_8_FLAG)
 
-cruft_libcruft_la_DEPENDENCIES = cruft/cruft.def
+liboctave_cruft_libcruft_la_DEPENDENCIES = liboctave/cruft/cruft.def
 
 CRUFT_INC =
 
 CRUFT_SOURCES =
 
-include cruft/amos/module.mk
-include cruft/blas-xtra/module.mk
-include cruft/daspk/module.mk
-include cruft/dasrt/module.mk
-include cruft/dassl/module.mk
-include cruft/Faddeeva/module.mk
-include cruft/fftpack/module.mk
-include cruft/lapack-xtra/module.mk
-include cruft/misc/module.mk
-include cruft/odepack/module.mk
-include cruft/ordered-qz/module.mk
-include cruft/quadpack/module.mk
-include cruft/ranlib/module.mk
-include cruft/slatec-err/module.mk
-include cruft/slatec-fn/module.mk
+include liboctave/cruft/amos/module.mk
+include liboctave/cruft/blas-xtra/module.mk
+include liboctave/cruft/daspk/module.mk
+include liboctave/cruft/dasrt/module.mk
+include liboctave/cruft/dassl/module.mk
+include liboctave/cruft/Faddeeva/module.mk
+include liboctave/cruft/fftpack/module.mk
+include liboctave/cruft/lapack-xtra/module.mk
+include liboctave/cruft/misc/module.mk
+include liboctave/cruft/odepack/module.mk
+include liboctave/cruft/ordered-qz/module.mk
+include liboctave/cruft/quadpack/module.mk
+include liboctave/cruft/ranlib/module.mk
+include liboctave/cruft/slatec-err/module.mk
+include liboctave/cruft/slatec-fn/module.mk
 
 define gen-cruft-def
   rm -f $@-t $@ && \
-  $(SHELL) cruft/mkf77def $(srcdir) $(cruft_libcruft_la_SOURCES) > $@-t && \
+  $(SHELL) liboctave/cruft/mkf77def $(top_srcdir) $(liboctave_cruft_libcruft_la_SOURCES) > $@-t && \
   mv $@-t $@
 endef
 
 ## Special rules for files which must be built before compilation
-cruft/cruft.def: $(cruft_libcruft_la_SOURCES) cruft/mkf77def
+liboctave/cruft/cruft.def: $(liboctave_cruft_libcruft_la_SOURCES) liboctave/cruft/mkf77def
 	$(AM_V_GEN)$(gen-cruft-def)
 
-DISTCLEANFILES += \
-  cruft/cruft.def \
-  cruft/mkf77def \
-  cruft/ranlib/ranlib.def \
-  $(nodist_cruft_libcruft_la_SOURCES)
+liboctave_DISTCLEANFILES += \
+  liboctave/cruft/cruft.def \
+  liboctave/cruft/mkf77def \
+  liboctave/cruft/ranlib/ranlib.def \
+  $(nodist_liboctave_cruft_libcruft_la_SOURCES)
+
+noinst_LTLIBRARIES += liboctave/cruft/libcruft.la
+
+liboctave_cruft_libcruft_la_SOURCES = $(CRUFT_SOURCES)
 
-noinst_LTLIBRARIES += cruft/libcruft.la
+liboctave_cruft_libcruft_la_CPPFLAGS = $(liboctave_liboctave_la_CPPFLAGS)
+
+liboctave_cruft_libcruft_la_CFLAGS = $(liboctave_liboctave_la_CFLAGS)
 
-cruft_libcruft_la_SOURCES = $(CRUFT_SOURCES)
-cruft_libcruft_la_CPPFLAGS = \
-  $(liboctave_la_CPPFLAGS)
+liboctave_cruft_libcruft_la_CXXFLAGS = $(liboctave_liboctave_la_CXXFLAGS)
 
-liboctave_la_LIBADD += cruft/libcruft.la
+liboctave_liboctave_la_LIBADD += liboctave/cruft/libcruft.la
+
+liboctave_EXTRA_DIST += liboctave/cruft/mkf77def.in
--- a/liboctave/cruft/odepack/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/odepack/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,19 +1,17 @@
-EXTRA_DIST += cruft/odepack/module.mk
-
 CRUFT_SOURCES += \
-  cruft/odepack/cfode.f \
-  cruft/odepack/dlsode.f \
-  cruft/odepack/ewset.f \
-  cruft/odepack/intdy.f \
-  cruft/odepack/prepj.f \
-  cruft/odepack/solsy.f \
-  cruft/odepack/stode.f \
-  cruft/odepack/vnorm.f \
-  cruft/odepack/scfode.f \
-  cruft/odepack/sewset.f \
-  cruft/odepack/sintdy.f \
-  cruft/odepack/slsode.f \
-  cruft/odepack/sprepj.f \
-  cruft/odepack/ssolsy.f \
-  cruft/odepack/sstode.f \
-  cruft/odepack/svnorm.f
+  liboctave/cruft/odepack/cfode.f \
+  liboctave/cruft/odepack/dlsode.f \
+  liboctave/cruft/odepack/ewset.f \
+  liboctave/cruft/odepack/intdy.f \
+  liboctave/cruft/odepack/prepj.f \
+  liboctave/cruft/odepack/solsy.f \
+  liboctave/cruft/odepack/stode.f \
+  liboctave/cruft/odepack/vnorm.f \
+  liboctave/cruft/odepack/scfode.f \
+  liboctave/cruft/odepack/sewset.f \
+  liboctave/cruft/odepack/sintdy.f \
+  liboctave/cruft/odepack/slsode.f \
+  liboctave/cruft/odepack/sprepj.f \
+  liboctave/cruft/odepack/ssolsy.f \
+  liboctave/cruft/odepack/sstode.f \
+  liboctave/cruft/odepack/svnorm.f
--- a/liboctave/cruft/ordered-qz/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/ordered-qz/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,7 +1,5 @@
-EXTRA_DIST += cruft/ordered-qz/module.mk
-
 CRUFT_SOURCES += \
-  cruft/ordered-qz/dsubsp.f \
-  cruft/ordered-qz/exchqz.f \
-  cruft/ordered-qz/ssubsp.f \
-  cruft/ordered-qz/sexchqz.f
+  liboctave/cruft/ordered-qz/dsubsp.f \
+  liboctave/cruft/ordered-qz/exchqz.f \
+  liboctave/cruft/ordered-qz/ssubsp.f \
+  liboctave/cruft/ordered-qz/sexchqz.f
--- a/liboctave/cruft/quadpack/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/quadpack/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,20 +1,18 @@
-EXTRA_DIST += cruft/quadpack/module.mk
-
 CRUFT_SOURCES += \
-  cruft/quadpack/dqagi.f \
-  cruft/quadpack/dqagie.f \
-  cruft/quadpack/dqagp.f \
-  cruft/quadpack/dqagpe.f \
-  cruft/quadpack/dqelg.f \
-  cruft/quadpack/dqk15i.f \
-  cruft/quadpack/dqk21.f \
-  cruft/quadpack/dqpsrt.f \
-  cruft/quadpack/qagie.f \
-  cruft/quadpack/qagi.f \
-  cruft/quadpack/qagpe.f \
-  cruft/quadpack/qagp.f \
-  cruft/quadpack/qelg.f \
-  cruft/quadpack/qk15i.f \
-  cruft/quadpack/qk21.f \
-  cruft/quadpack/qpsrt.f \
-  cruft/quadpack/xerror.f
+  liboctave/cruft/quadpack/dqagi.f \
+  liboctave/cruft/quadpack/dqagie.f \
+  liboctave/cruft/quadpack/dqagp.f \
+  liboctave/cruft/quadpack/dqagpe.f \
+  liboctave/cruft/quadpack/dqelg.f \
+  liboctave/cruft/quadpack/dqk15i.f \
+  liboctave/cruft/quadpack/dqk21.f \
+  liboctave/cruft/quadpack/dqpsrt.f \
+  liboctave/cruft/quadpack/qagie.f \
+  liboctave/cruft/quadpack/qagi.f \
+  liboctave/cruft/quadpack/qagpe.f \
+  liboctave/cruft/quadpack/qagp.f \
+  liboctave/cruft/quadpack/qelg.f \
+  liboctave/cruft/quadpack/qk15i.f \
+  liboctave/cruft/quadpack/qk21.f \
+  liboctave/cruft/quadpack/qpsrt.f \
+  liboctave/cruft/quadpack/xerror.f
--- a/liboctave/cruft/ranlib/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/ranlib/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,67 +1,66 @@
-EXTRA_DIST += \
-  cruft/ranlib/module.mk \
-  cruft/ranlib/Basegen.doc \
-  cruft/ranlib/HOWTOGET \
-  cruft/ranlib/README \
-  cruft/ranlib/randlib.chs \
-  cruft/ranlib/randlib.fdoc \
-  cruft/ranlib/tstbot.for \
-  cruft/ranlib/tstgmn.for \
-  cruft/ranlib/tstmid.for
+RANLIB_SRC = \
+  liboctave/cruft/ranlib/advnst.f \
+  liboctave/cruft/ranlib/genbet.f \
+  liboctave/cruft/ranlib/genchi.f \
+  liboctave/cruft/ranlib/genexp.f \
+  liboctave/cruft/ranlib/genf.f \
+  liboctave/cruft/ranlib/gengam.f \
+  liboctave/cruft/ranlib/genmn.f \
+  liboctave/cruft/ranlib/genmul.f \
+  liboctave/cruft/ranlib/gennch.f \
+  liboctave/cruft/ranlib/gennf.f \
+  liboctave/cruft/ranlib/gennor.f \
+  liboctave/cruft/ranlib/genprm.f \
+  liboctave/cruft/ranlib/genunf.f \
+  liboctave/cruft/ranlib/getcgn.f \
+  liboctave/cruft/ranlib/getsd.f \
+  liboctave/cruft/ranlib/ignbin.f \
+  liboctave/cruft/ranlib/ignlgi.f \
+  liboctave/cruft/ranlib/ignnbn.f \
+  liboctave/cruft/ranlib/ignpoi.f \
+  liboctave/cruft/ranlib/ignuin.f \
+  liboctave/cruft/ranlib/initgn.f \
+  liboctave/cruft/ranlib/inrgcm.f \
+  liboctave/cruft/ranlib/lennob.f \
+  liboctave/cruft/ranlib/mltmod.f \
+  liboctave/cruft/ranlib/phrtsd.f \
+  liboctave/cruft/ranlib/qrgnin.f \
+  liboctave/cruft/ranlib/ranf.f \
+  liboctave/cruft/ranlib/setall.f \
+  liboctave/cruft/ranlib/setant.f \
+  liboctave/cruft/ranlib/setgmn.f \
+  liboctave/cruft/ranlib/setsd.f \
+  liboctave/cruft/ranlib/sexpo.f \
+  liboctave/cruft/ranlib/sgamma.f \
+  liboctave/cruft/ranlib/snorm.f \
+  liboctave/cruft/ranlib/wrap.f
 
-RANLIB_SRC = \
-  cruft/ranlib/advnst.f \
-  cruft/ranlib/genbet.f \
-  cruft/ranlib/genchi.f \
-  cruft/ranlib/genexp.f \
-  cruft/ranlib/genf.f \
-  cruft/ranlib/gengam.f \
-  cruft/ranlib/genmn.f \
-  cruft/ranlib/genmul.f \
-  cruft/ranlib/gennch.f \
-  cruft/ranlib/gennf.f \
-  cruft/ranlib/gennor.f \
-  cruft/ranlib/genprm.f \
-  cruft/ranlib/genunf.f \
-  cruft/ranlib/getcgn.f \
-  cruft/ranlib/getsd.f \
-  cruft/ranlib/ignbin.f \
-  cruft/ranlib/ignlgi.f \
-  cruft/ranlib/ignnbn.f \
-  cruft/ranlib/ignpoi.f \
-  cruft/ranlib/ignuin.f \
-  cruft/ranlib/initgn.f \
-  cruft/ranlib/inrgcm.f \
-  cruft/ranlib/lennob.f \
-  cruft/ranlib/mltmod.f \
-  cruft/ranlib/phrtsd.f \
-  cruft/ranlib/qrgnin.f \
-  cruft/ranlib/ranf.f \
-  cruft/ranlib/setall.f \
-  cruft/ranlib/setant.f \
-  cruft/ranlib/setgmn.f \
-  cruft/ranlib/setsd.f \
-  cruft/ranlib/sexpo.f \
-  cruft/ranlib/sgamma.f \
-  cruft/ranlib/snorm.f \
-  cruft/ranlib/wrap.f
+noinst_LTLIBRARIES += liboctave/cruft/ranlib/libranlib.la
 
-noinst_LTLIBRARIES += cruft/ranlib/libranlib.la
+liboctave_cruft_ranlib_libranlib_la_SOURCES = $(RANLIB_SRC)
 
-cruft_ranlib_libranlib_la_SOURCES = $(RANLIB_SRC)
-
-cruft_ranlib_libranlib_la_DEPENDENCIES = cruft/ranlib/ranlib.def
+liboctave_cruft_ranlib_libranlib_la_DEPENDENCIES = liboctave/cruft/ranlib/ranlib.def
 
 define gen-ranlib-def
   rm -f $@-t $@ && \
-  $(MKDIR_P) cruft/ranlib && \
-  $(SHELL) cruft/mkf77def $(srcdir) $(RANLIB_SRC) > $@-t && \
+  $(MKDIR_P) liboctave/cruft/ranlib && \
+  $(SHELL) liboctave/cruft/mkf77def $(top_srcdir) $(RANLIB_SRC) > $@-t && \
   mv $@-t $@
 endef
 
 ## Special rules for files which must be built before compilation
 ## ranlib directory may not exist in VPATH build; create it if necessary.
-cruft/ranlib/ranlib.def: $(RANLIB_SRC) cruft/mkf77def
+liboctave/cruft/ranlib/ranlib.def: $(RANLIB_SRC) liboctave/cruft/mkf77def
 	$(AM_V_GEN)$(gen-ranlib-def)
 
-liboctave_la_LIBADD += cruft/ranlib/libranlib.la
+liboctave_liboctave_la_LIBADD += liboctave/cruft/ranlib/libranlib.la
+
+liboctave_EXTRA_DIST += \
+  liboctave/cruft/ranlib/Basegen.doc \
+  liboctave/cruft/ranlib/HOWTOGET \
+  liboctave/cruft/ranlib/README \
+  liboctave/cruft/ranlib/randlib.chs \
+  liboctave/cruft/ranlib/randlib.fdoc \
+  liboctave/cruft/ranlib/tstbot.for \
+  liboctave/cruft/ranlib/tstgmn.for \
+  liboctave/cruft/ranlib/tstmid.for
--- a/liboctave/cruft/slatec-err/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/slatec-err/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,17 +1,15 @@
-EXTRA_DIST += cruft/slatec-err/module.mk
-
 CRUFT_SOURCES += \
-  cruft/slatec-err/fdump.f \
-  cruft/slatec-err/ixsav.f \
-  cruft/slatec-err/j4save.f \
-  cruft/slatec-err/xerclr.f \
-  cruft/slatec-err/xercnt.f \
-  cruft/slatec-err/xerhlt.f \
-  cruft/slatec-err/xermsg.f \
-  cruft/slatec-err/xerprn.f \
-  cruft/slatec-err/xerrwd.f \
-  cruft/slatec-err/xersve.f \
-  cruft/slatec-err/xgetf.f \
-  cruft/slatec-err/xgetua.f \
-  cruft/slatec-err/xsetf.f \
-  cruft/slatec-err/xsetua.f
+  liboctave/cruft/slatec-err/fdump.f \
+  liboctave/cruft/slatec-err/ixsav.f \
+  liboctave/cruft/slatec-err/j4save.f \
+  liboctave/cruft/slatec-err/xerclr.f \
+  liboctave/cruft/slatec-err/xercnt.f \
+  liboctave/cruft/slatec-err/xerhlt.f \
+  liboctave/cruft/slatec-err/xermsg.f \
+  liboctave/cruft/slatec-err/xerprn.f \
+  liboctave/cruft/slatec-err/xerrwd.f \
+  liboctave/cruft/slatec-err/xersve.f \
+  liboctave/cruft/slatec-err/xgetf.f \
+  liboctave/cruft/slatec-err/xgetua.f \
+  liboctave/cruft/slatec-err/xsetf.f \
+  liboctave/cruft/slatec-err/xsetua.f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/cruft/slatec-fn/dpsifn.f	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,368 @@
+*DECK DPSIFN
+      SUBROUTINE DPSIFN (X, N, KODE, M, ANS, NZ, IERR)
+C***BEGIN PROLOGUE  DPSIFN
+C***PURPOSE  Compute derivatives of the Psi function.
+C***LIBRARY   SLATEC
+C***CATEGORY  C7C
+C***TYPE      DOUBLE PRECISION (PSIFN-S, DPSIFN-D)
+C***KEYWORDS  DERIVATIVES OF THE GAMMA FUNCTION, POLYGAMMA FUNCTION,
+C             PSI FUNCTION
+C***AUTHOR  Amos, D. E., (SNLA)
+C***DESCRIPTION
+C
+C         The following definitions are used in DPSIFN:
+C
+C      Definition 1
+C         PSI(X) = d/dx (ln(GAMMA(X)), the first derivative of
+C                  the log GAMMA function.
+C      Definition 2
+C                     K   K
+C         PSI(K,X) = d /dx (PSI(X)), the K-th derivative of PSI(X).
+C   ___________________________________________________________________
+C      DPSIFN computes a sequence of SCALED derivatives of
+C      the PSI function; i.e. for fixed X and M it computes
+C      the M-member sequence
+C
+C                    ((-1)**(K+1)/GAMMA(K+1))*PSI(K,X)
+C                       for K = N,...,N+M-1
+C
+C      where PSI(K,X) is as defined above.   For KODE=1, DPSIFN returns
+C      the scaled derivatives as described.  KODE=2 is operative only
+C      when K=0 and in that case DPSIFN returns -PSI(X) + LN(X).  That
+C      is, the logarithmic behavior for large X is removed when KODE=2
+C      and K=0.  When sums or differences of PSI functions are computed
+C      the logarithmic terms can be combined analytically and computed
+C      separately to help retain significant digits.
+C
+C         Note that CALL DPSIFN(X,0,1,1,ANS) results in
+C                   ANS = -PSI(X)
+C
+C     Input      X is DOUBLE PRECISION
+C           X      - Argument, X .gt. 0.0D0
+C           N      - First member of the sequence, 0 .le. N .le. 100
+C                    N=0 gives ANS(1) = -PSI(X)       for KODE=1
+C                                       -PSI(X)+LN(X) for KODE=2
+C           KODE   - Selection parameter
+C                    KODE=1 returns scaled derivatives of the PSI
+C                    function.
+C                    KODE=2 returns scaled derivatives of the PSI
+C                    function EXCEPT when N=0. In this case,
+C                    ANS(1) = -PSI(X) + LN(X) is returned.
+C           M      - Number of members of the sequence, M.ge.1
+C
+C    Output     ANS is DOUBLE PRECISION
+C           ANS    - A vector of length at least M whose first M
+C                    components contain the sequence of derivatives
+C                    scaled according to KODE.
+C           NZ     - Underflow flag
+C                    NZ.eq.0, A normal return
+C                    NZ.ne.0, Underflow, last NZ components of ANS are
+C                             set to zero, ANS(M-K+1)=0.0, K=1,...,NZ
+C           IERR   - Error flag
+C                    IERR=0, A normal return, computation completed
+C                    IERR=1, Input error,     no computation
+C                    IERR=2, Overflow,        X too small or N+M-1 too
+C                            large or both
+C                    IERR=3, Error,           N too large. Dimensioned
+C                            array TRMR(NMAX) is not large enough for N
+C
+C         The nominal computational accuracy is the maximum of unit
+C         roundoff (=D1MACH(4)) and 1.0D-18 since critical constants
+C         are given to only 18 digits.
+C
+C         PSIFN is the single precision version of DPSIFN.
+C
+C *Long Description:
+C
+C         The basic method of evaluation is the asymptotic expansion
+C         for large X.ge.XMIN followed by backward recursion on a two
+C         term recursion relation
+C
+C                  W(X+1) + X**(-N-1) = W(X).
+C
+C         This is supplemented by a series
+C
+C                  SUM( (X+K)**(-N-1) , K=0,1,2,... )
+C
+C         which converges rapidly for large N. Both XMIN and the
+C         number of terms of the series are calculated from the unit
+C         roundoff of the machine environment.
+C
+C***REFERENCES  Handbook of Mathematical Functions, National Bureau
+C                 of Standards Applied Mathematics Series 55, edited
+C                 by M. Abramowitz and I. A. Stegun, equations 6.3.5,
+C                 6.3.18, 6.4.6, 6.4.9 and 6.4.10, pp.258-260, 1964.
+C               D. E. Amos, A portable Fortran subroutine for
+C                 derivatives of the Psi function, Algorithm 610, ACM
+C                 Transactions on Mathematical Software 9, 4 (1983),
+C                 pp. 494-502.
+C***ROUTINES CALLED  D1MACH, I1MACH
+C***REVISION HISTORY  (YYMMDD)
+C   820601  DATE WRITTEN
+C   890531  Changed all specific intrinsics to generic.  (WRB)
+C   890911  Removed unnecessary intrinsics.  (WRB)
+C   891006  Cosmetic changes to prologue.  (WRB)
+C   891006  REVISION DATE from Version 3.2
+C   891214  Prologue converted to Version 4.0 format.  (BAB)
+C   920501  Reformatted the REFERENCES section.  (WRB)
+C***END PROLOGUE  DPSIFN
+      INTEGER I, IERR, J, K, KODE, M, MM, MX, N, NMAX, NN, NP, NX, NZ,
+     *  FN
+      INTEGER I1MACH
+      DOUBLE PRECISION ANS, ARG, B, DEN, ELIM, EPS, FLN,
+     * FX, RLN, RXSQ, R1M4, R1M5, S, SLOPE, T, TA, TK, TOL, TOLS, TRM,
+     * TRMR, TSS, TST, TT, T1, T2, WDTOL, X, XDMLN, XDMY, XINC, XLN,
+     * XM, XMIN, XQ, YINT
+      DOUBLE PRECISION D1MACH
+      DIMENSION B(22), TRM(22), TRMR(100), ANS(*)
+      SAVE NMAX, B
+      DATA NMAX /100/
+C-----------------------------------------------------------------------
+C             BERNOULLI NUMBERS
+C-----------------------------------------------------------------------
+      DATA B(1), B(2), B(3), B(4), B(5), B(6), B(7), B(8), B(9), B(10),
+     * B(11), B(12), B(13), B(14), B(15), B(16), B(17), B(18), B(19),
+     * B(20), B(21), B(22) /1.00000000000000000D+00,
+     * -5.00000000000000000D-01,1.66666666666666667D-01,
+     * -3.33333333333333333D-02,2.38095238095238095D-02,
+     * -3.33333333333333333D-02,7.57575757575757576D-02,
+     * -2.53113553113553114D-01,1.16666666666666667D+00,
+     * -7.09215686274509804D+00,5.49711779448621554D+01,
+     * -5.29124242424242424D+02,6.19212318840579710D+03,
+     * -8.65802531135531136D+04,1.42551716666666667D+06,
+     * -2.72982310678160920D+07,6.01580873900642368D+08,
+     * -1.51163157670921569D+10,4.29614643061166667D+11,
+     * -1.37116552050883328D+13,4.88332318973593167D+14,
+     * -1.92965793419400681D+16/
+C
+C***FIRST EXECUTABLE STATEMENT  DPSIFN
+      IERR = 0
+      NZ=0
+      IF (X.LE.0.0D0) IERR=1
+      IF (N.LT.0) IERR=1
+      IF (KODE.LT.1 .OR. KODE.GT.2) IERR=1
+      IF (M.LT.1) IERR=1
+      IF (IERR.NE.0) RETURN
+      MM=M
+      NX = MIN(-I1MACH(15),I1MACH(16))
+      R1M5 = D1MACH(5)
+      R1M4 = D1MACH(4)*0.5D0
+      WDTOL = MAX(R1M4,0.5D-18)
+C-----------------------------------------------------------------------
+C     ELIM = APPROXIMATE EXPONENTIAL OVER AND UNDERFLOW LIMIT
+C-----------------------------------------------------------------------
+      ELIM = 2.302D0*(NX*R1M5-3.0D0)
+      XLN = LOG(X)
+   41 CONTINUE
+      NN = N + MM - 1
+      FN = NN
+      T = (FN+1)*XLN
+C-----------------------------------------------------------------------
+C     OVERFLOW AND UNDERFLOW TEST FOR SMALL AND LARGE X
+C-----------------------------------------------------------------------
+      IF (ABS(T).GT.ELIM) GO TO 290
+      IF (X.LT.WDTOL) GO TO 260
+C-----------------------------------------------------------------------
+C     COMPUTE XMIN AND THE NUMBER OF TERMS OF THE SERIES, FLN+1
+C-----------------------------------------------------------------------
+      RLN = R1M5*I1MACH(14)
+      RLN = MIN(RLN,18.06D0)
+      FLN = MAX(RLN,3.0D0) - 3.0D0
+      YINT = 3.50D0 + 0.40D0*FLN
+      SLOPE = 0.21D0 + FLN*(0.0006038D0*FLN+0.008677D0)
+      XM = YINT + SLOPE*FN
+      MX = INT(XM) + 1
+      XMIN = MX
+      IF (N.EQ.0) GO TO 50
+      XM = -2.302D0*RLN - MIN(0.0D0,XLN)
+      ARG = XM/N
+      ARG = MIN(0.0D0,ARG)
+      EPS = EXP(ARG)
+      XM = 1.0D0 - EPS
+      IF (ABS(ARG).LT.1.0D-3) XM = -ARG
+      FLN = X*XM/EPS
+      XM = XMIN - X
+      IF (XM.GT.7.0D0 .AND. FLN.LT.15.0D0) GO TO 200
+   50 CONTINUE
+      XDMY = X
+      XDMLN = XLN
+      XINC = 0.0D0
+      IF (X.GE.XMIN) GO TO 60
+      NX = INT(X)
+      XINC = XMIN - NX
+      XDMY = X + XINC
+      XDMLN = LOG(XDMY)
+   60 CONTINUE
+C-----------------------------------------------------------------------
+C     GENERATE W(N+MM-1,X) BY THE ASYMPTOTIC EXPANSION
+C-----------------------------------------------------------------------
+      T = FN*XDMLN
+      T1 = XDMLN + XDMLN
+      T2 = T + XDMLN
+      TK = MAX(ABS(T),ABS(T1),ABS(T2))
+      IF (TK.GT.ELIM) GO TO 380
+      TSS = EXP(-T)
+      TT = 0.5D0/XDMY
+      T1 = TT
+      TST = WDTOL*TT
+      IF (NN.NE.0) T1 = TT + 1.0D0/FN
+      RXSQ = 1.0D0/(XDMY*XDMY)
+      TA = 0.5D0*RXSQ
+      T = (FN+1)*TA
+      S = T*B(3)
+      IF (ABS(S).LT.TST) GO TO 80
+      TK = 2.0D0
+      DO 70 K=4,22
+        T = T*((TK+FN+1)/(TK+1.0D0))*((TK+FN)/(TK+2.0D0))*RXSQ
+        TRM(K) = T*B(K)
+        IF (ABS(TRM(K)).LT.TST) GO TO 80
+        S = S + TRM(K)
+        TK = TK + 2.0D0
+   70 CONTINUE
+   80 CONTINUE
+      S = (S+T1)*TSS
+      IF (XINC.EQ.0.0D0) GO TO 100
+C-----------------------------------------------------------------------
+C     BACKWARD RECUR FROM XDMY TO X
+C-----------------------------------------------------------------------
+      NX = INT(XINC)
+      NP = NN + 1
+      IF (NX.GT.NMAX) GO TO 390
+      IF (NN.EQ.0) GO TO 160
+      XM = XINC - 1.0D0
+      FX = X + XM
+C-----------------------------------------------------------------------
+C     THIS LOOP SHOULD NOT BE CHANGED. FX IS ACCURATE WHEN X IS SMALL
+C-----------------------------------------------------------------------
+      DO 90 I=1,NX
+        TRMR(I) = FX**(-NP)
+        S = S + TRMR(I)
+        XM = XM - 1.0D0
+        FX = X + XM
+   90 CONTINUE
+  100 CONTINUE
+      ANS(MM) = S
+      IF (FN.EQ.0) GO TO 180
+C-----------------------------------------------------------------------
+C     GENERATE LOWER DERIVATIVES, J.LT.N+MM-1
+C-----------------------------------------------------------------------
+      IF (MM.EQ.1) RETURN
+      DO 150 J=2,MM
+        FN = FN - 1
+        TSS = TSS*XDMY
+        T1 = TT
+        IF (FN.NE.0) T1 = TT + 1.0D0/FN
+        T = (FN+1)*TA
+        S = T*B(3)
+        IF (ABS(S).LT.TST) GO TO 120
+        TK = 4 + FN
+        DO 110 K=4,22
+          TRM(K) = TRM(K)*(FN+1)/TK
+          IF (ABS(TRM(K)).LT.TST) GO TO 120
+          S = S + TRM(K)
+          TK = TK + 2.0D0
+  110   CONTINUE
+  120   CONTINUE
+        S = (S+T1)*TSS
+        IF (XINC.EQ.0.0D0) GO TO 140
+        IF (FN.EQ.0) GO TO 160
+        XM = XINC - 1.0D0
+        FX = X + XM
+        DO 130 I=1,NX
+          TRMR(I) = TRMR(I)*FX
+          S = S + TRMR(I)
+          XM = XM - 1.0D0
+          FX = X + XM
+  130   CONTINUE
+  140   CONTINUE
+        MX = MM - J + 1
+        ANS(MX) = S
+        IF (FN.EQ.0) GO TO 180
+  150 CONTINUE
+      RETURN
+C-----------------------------------------------------------------------
+C     RECURSION FOR N = 0
+C-----------------------------------------------------------------------
+  160 CONTINUE
+      DO 170 I=1,NX
+        S = S + 1.0D0/(X+NX-I)
+  170 CONTINUE
+  180 CONTINUE
+      IF (KODE.EQ.2) GO TO 190
+      ANS(1) = S - XDMLN
+      RETURN
+  190 CONTINUE
+      IF (XDMY.EQ.X) RETURN
+      XQ = XDMY/X
+      ANS(1) = S - LOG(XQ)
+      RETURN
+C-----------------------------------------------------------------------
+C     COMPUTE BY SERIES (X+K)**(-(N+1)) , K=0,1,2,...
+C-----------------------------------------------------------------------
+  200 CONTINUE
+      NN = INT(FLN) + 1
+      NP = N + 1
+      T1 = (N+1)*XLN
+      T = EXP(-T1)
+      S = T
+      DEN = X
+      DO 210 I=1,NN
+        DEN = DEN + 1.0D0
+        TRM(I) = DEN**(-NP)
+        S = S + TRM(I)
+  210 CONTINUE
+      ANS(1) = S
+      IF (N.NE.0) GO TO 220
+      IF (KODE.EQ.2) ANS(1) = S + XLN
+  220 CONTINUE
+      IF (MM.EQ.1) RETURN
+C-----------------------------------------------------------------------
+C     GENERATE HIGHER DERIVATIVES, J.GT.N
+C-----------------------------------------------------------------------
+      TOL = WDTOL/5.0D0
+      DO 250 J=2,MM
+        T = T/X
+        S = T
+        TOLS = T*TOL
+        DEN = X
+        DO 230 I=1,NN
+          DEN = DEN + 1.0D0
+          TRM(I) = TRM(I)/DEN
+          S = S + TRM(I)
+          IF (TRM(I).LT.TOLS) GO TO 240
+  230   CONTINUE
+  240   CONTINUE
+        ANS(J) = S
+  250 CONTINUE
+      RETURN
+C-----------------------------------------------------------------------
+C     SMALL X.LT.UNIT ROUND OFF
+C-----------------------------------------------------------------------
+  260 CONTINUE
+      ANS(1) = X**(-N-1)
+      IF (MM.EQ.1) GO TO 280
+      K = 1
+      DO 270 I=2,MM
+        ANS(K+1) = ANS(K)/X
+        K = K + 1
+  270 CONTINUE
+  280 CONTINUE
+      IF (N.NE.0) RETURN
+      IF (KODE.EQ.2) ANS(1) = ANS(1) + XLN
+      RETURN
+  290 CONTINUE
+      IF (T.GT.0.0D0) GO TO 380
+      NZ=0
+      IERR=2
+      RETURN
+  380 CONTINUE
+      NZ=NZ+1
+      ANS(MM)=0.0D0
+      MM=MM-1
+      IF (MM.EQ.0) RETURN
+      GO TO 41
+  390 CONTINUE
+      NZ=0
+      IERR=3
+      RETURN
+      END
--- a/liboctave/cruft/slatec-fn/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/cruft/slatec-fn/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,88 +1,89 @@
-EXTRA_DIST += \
-  cruft/slatec-fn/module.mk \
-  cruft/slatec-fn/derfc.in.f \
-  cruft/slatec-fn/erfc.in.f
+CRUFT_SOURCES += \
+  liboctave/cruft/slatec-fn/albeta.f \
+  liboctave/cruft/slatec-fn/alngam.f \
+  liboctave/cruft/slatec-fn/alnrel.f \
+  liboctave/cruft/slatec-fn/algams.f \
+  liboctave/cruft/slatec-fn/acosh.f \
+  liboctave/cruft/slatec-fn/asinh.f \
+  liboctave/cruft/slatec-fn/atanh.f \
+  liboctave/cruft/slatec-fn/betai.f \
+  liboctave/cruft/slatec-fn/csevl.f \
+  liboctave/cruft/slatec-fn/d9gmit.f \
+  liboctave/cruft/slatec-fn/d9lgic.f \
+  liboctave/cruft/slatec-fn/d9lgit.f \
+  liboctave/cruft/slatec-fn/d9lgmc.f \
+  liboctave/cruft/slatec-fn/dacosh.f \
+  liboctave/cruft/slatec-fn/dasinh.f \
+  liboctave/cruft/slatec-fn/datanh.f \
+  liboctave/cruft/slatec-fn/dbetai.f \
+  liboctave/cruft/slatec-fn/dcsevl.f \
+  liboctave/cruft/slatec-fn/derf.f \
+  liboctave/cruft/slatec-fn/dgami.f \
+  liboctave/cruft/slatec-fn/dgamit.f \
+  liboctave/cruft/slatec-fn/dgamlm.f \
+  liboctave/cruft/slatec-fn/dgamma.f \
+  liboctave/cruft/slatec-fn/dgamr.f \
+  liboctave/cruft/slatec-fn/dlbeta.f \
+  liboctave/cruft/slatec-fn/dlgams.f \
+  liboctave/cruft/slatec-fn/dlngam.f \
+  liboctave/cruft/slatec-fn/dlnrel.f \
+  liboctave/cruft/slatec-fn/dpchim.f \
+  liboctave/cruft/slatec-fn/dpchst.f \
+  liboctave/cruft/slatec-fn/dpsifn.f \
+  liboctave/cruft/slatec-fn/erf.f \
+  liboctave/cruft/slatec-fn/gami.f \
+  liboctave/cruft/slatec-fn/gamit.f \
+  liboctave/cruft/slatec-fn/gamlim.f \
+  liboctave/cruft/slatec-fn/gamma.f \
+  liboctave/cruft/slatec-fn/gamr.f \
+  liboctave/cruft/slatec-fn/initds.f \
+  liboctave/cruft/slatec-fn/inits.f \
+  liboctave/cruft/slatec-fn/pchim.f \
+  liboctave/cruft/slatec-fn/pchst.f \
+  liboctave/cruft/slatec-fn/psifn.f \
+  liboctave/cruft/slatec-fn/r9lgmc.f \
+  liboctave/cruft/slatec-fn/r9lgit.f \
+  liboctave/cruft/slatec-fn/r9gmit.f \
+  liboctave/cruft/slatec-fn/r9lgic.f \
+  liboctave/cruft/slatec-fn/xdacosh.f \
+  liboctave/cruft/slatec-fn/xdasinh.f \
+  liboctave/cruft/slatec-fn/xdatanh.f \
+  liboctave/cruft/slatec-fn/xdbetai.f \
+  liboctave/cruft/slatec-fn/xderf.f \
+  liboctave/cruft/slatec-fn/xderfc.f \
+  liboctave/cruft/slatec-fn/xdgami.f \
+  liboctave/cruft/slatec-fn/xdgamit.f \
+  liboctave/cruft/slatec-fn/xdgamma.f \
+  liboctave/cruft/slatec-fn/xgmainc.f \
+  liboctave/cruft/slatec-fn/xacosh.f \
+  liboctave/cruft/slatec-fn/xasinh.f \
+  liboctave/cruft/slatec-fn/xatanh.f \
+  liboctave/cruft/slatec-fn/xerf.f \
+  liboctave/cruft/slatec-fn/xerfc.f \
+  liboctave/cruft/slatec-fn/xsgmainc.f \
+  liboctave/cruft/slatec-fn/xgamma.f \
+  liboctave/cruft/slatec-fn/xbetai.f
 
-CRUFT_SOURCES += \
-  cruft/slatec-fn/albeta.f \
-  cruft/slatec-fn/alngam.f \
-  cruft/slatec-fn/alnrel.f \
-  cruft/slatec-fn/algams.f \
-  cruft/slatec-fn/acosh.f \
-  cruft/slatec-fn/asinh.f \
-  cruft/slatec-fn/atanh.f \
-  cruft/slatec-fn/betai.f \
-  cruft/slatec-fn/csevl.f \
-  cruft/slatec-fn/d9gmit.f \
-  cruft/slatec-fn/d9lgic.f \
-  cruft/slatec-fn/d9lgit.f \
-  cruft/slatec-fn/d9lgmc.f \
-  cruft/slatec-fn/dacosh.f \
-  cruft/slatec-fn/dasinh.f \
-  cruft/slatec-fn/datanh.f \
-  cruft/slatec-fn/dbetai.f \
-  cruft/slatec-fn/dcsevl.f \
-  cruft/slatec-fn/derf.f \
-  cruft/slatec-fn/dgami.f \
-  cruft/slatec-fn/dgamit.f \
-  cruft/slatec-fn/dgamlm.f \
-  cruft/slatec-fn/dgamma.f \
-  cruft/slatec-fn/dgamr.f \
-  cruft/slatec-fn/dlbeta.f \
-  cruft/slatec-fn/dlgams.f \
-  cruft/slatec-fn/dlngam.f \
-  cruft/slatec-fn/dlnrel.f \
-  cruft/slatec-fn/dpchim.f \
-  cruft/slatec-fn/dpchst.f \
-  cruft/slatec-fn/erf.f \
-  cruft/slatec-fn/gami.f \
-  cruft/slatec-fn/gamit.f \
-  cruft/slatec-fn/gamlim.f \
-  cruft/slatec-fn/gamma.f \
-  cruft/slatec-fn/gamr.f \
-  cruft/slatec-fn/initds.f \
-  cruft/slatec-fn/inits.f \
-  cruft/slatec-fn/pchim.f \
-  cruft/slatec-fn/pchst.f \
-  cruft/slatec-fn/r9lgmc.f \
-  cruft/slatec-fn/r9lgit.f \
-  cruft/slatec-fn/r9gmit.f \
-  cruft/slatec-fn/r9lgic.f \
-  cruft/slatec-fn/xdacosh.f \
-  cruft/slatec-fn/xdasinh.f \
-  cruft/slatec-fn/xdatanh.f \
-  cruft/slatec-fn/xdbetai.f \
-  cruft/slatec-fn/xderf.f \
-  cruft/slatec-fn/xderfc.f \
-  cruft/slatec-fn/xdgami.f \
-  cruft/slatec-fn/xdgamit.f \
-  cruft/slatec-fn/xdgamma.f \
-  cruft/slatec-fn/xgmainc.f \
-  cruft/slatec-fn/xacosh.f \
-  cruft/slatec-fn/xasinh.f \
-  cruft/slatec-fn/xatanh.f \
-  cruft/slatec-fn/xerf.f \
-  cruft/slatec-fn/xerfc.f \
-  cruft/slatec-fn/xsgmainc.f \
-  cruft/slatec-fn/xgamma.f \
-  cruft/slatec-fn/xbetai.f
-
-nodist_cruft_libcruft_la_SOURCES += \
-  cruft/slatec-fn/derfc.f \
-  cruft/slatec-fn/erfc.f
+nodist_liboctave_cruft_libcruft_la_SOURCES += \
+  liboctave/cruft/slatec-fn/derfc.f \
+  liboctave/cruft/slatec-fn/erfc.f
 
 ## slatec-fn directory may not exist in VPATH build; create it if necessary.
 
 define do-subst-isnan-macro
   rm -f $@-t $@ && \
-  $(MKDIR_P) cruft/slatec-fn && \
+  $(MKDIR_P) liboctave/cruft/slatec-fn && \
   $(SED) -e "${F77_ISNAN_MACRO}" < $< > $@-t && \
   mv $@-t $@
 endef
 
-cruft/slatec-fn/erfc.f: cruft/slatec-fn/erfc.in.f Makefile
+liboctave/cruft/slatec-fn/erfc.f: liboctave/cruft/slatec-fn/erfc.in.f Makefile
 	$(AM_V_GEN)$(do-subst-isnan-macro)
 
-cruft/slatec-fn/derfc.f: cruft/slatec-fn/derfc.in.f Makefile
+liboctave/cruft/slatec-fn/derfc.f: liboctave/cruft/slatec-fn/derfc.in.f Makefile
 	$(AM_V_GEN)$(do-subst-isnan-macro)
 
+liboctave_EXTRA_DIST += \
+  liboctave/cruft/slatec-fn/derfc.in.f \
+  liboctave/cruft/slatec-fn/erfc.in.f
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/cruft/slatec-fn/psifn.f	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,368 @@
+*DECK PSIFN
+      SUBROUTINE PSIFN (X, N, KODE, M, ANS, NZ, IERR)
+C***BEGIN PROLOGUE  PSIFN
+C***PURPOSE  Compute derivatives of the Psi function.
+C***LIBRARY   SLATEC
+C***CATEGORY  C7C
+C***TYPE      SINGLE PRECISION (PSIFN-S, DPSIFN-D)
+C***KEYWORDS  DERIVATIVES OF THE GAMMA FUNCTION, POLYGAMMA FUNCTION,
+C             PSI FUNCTION
+C***AUTHOR  Amos, D. E., (SNLA)
+C***DESCRIPTION
+C
+C         The following definitions are used in PSIFN:
+C
+C      Definition 1
+C         PSI(X) = d/dx (ln(GAMMA(X)), the first derivative of
+C                  the LOG GAMMA function.
+C      Definition 2
+C                     K   K
+C         PSI(K,X) = d /dx (PSI(X)), the K-th derivative of PSI(X).
+C   ___________________________________________________________________
+C       PSIFN computes a sequence of SCALED derivatives of
+C       the PSI function; i.e. for fixed X and M it computes
+C       the M-member sequence
+C
+C                  ((-1)**(K+1)/GAMMA(K+1))*PSI(K,X)
+C                    for K = N,...,N+M-1
+C
+C       where PSI(K,X) is as defined above.   For KODE=1, PSIFN returns
+C       the scaled derivatives as described.  KODE=2 is operative only
+C       when K=0 and in that case PSIFN returns -PSI(X) + LN(X).  That
+C       is, the logarithmic behavior for large X is removed when KODE=1
+C       and K=0.  When sums or differences of PSI functions are computed
+C       the logarithmic terms can be combined analytically and computed
+C       separately to help retain significant digits.
+C
+C         Note that CALL PSIFN(X,0,1,1,ANS) results in
+C                   ANS = -PSI(X)
+C
+C     Input
+C           X      - Argument, X .gt. 0.0E0
+C           N      - First member of the sequence, 0 .le. N .le. 100
+C                    N=0 gives ANS(1) = -PSI(X)       for KODE=1
+C                                       -PSI(X)+LN(X) for KODE=2
+C           KODE   - Selection parameter
+C                    KODE=1 returns scaled derivatives of the PSI
+C                    function.
+C                    KODE=2 returns scaled derivatives of the PSI
+C                    function EXCEPT when N=0. In this case,
+C                    ANS(1) = -PSI(X) + LN(X) is returned.
+C           M      - Number of members of the sequence, M .ge. 1
+C
+C    Output
+C           ANS    - A vector of length at least M whose first M
+C                    components contain the sequence of derivatives
+C                    scaled according to KODE.
+C           NZ     - Underflow flag
+C                    NZ.eq.0, A normal return
+C                    NZ.ne.0, Underflow, last NZ components of ANS are
+C                             set to zero, ANS(M-K+1)=0.0, K=1,...,NZ
+C           IERR   - Error flag
+C                    IERR=0, A normal return, computation completed
+C                    IERR=1, Input error,     no computation
+C                    IERR=2, Overflow,        X too small or N+M-1 too
+C                            large or both
+C                    IERR=3, Error,           N too large. Dimensioned
+C                            array TRMR(NMAX) is not large enough for N
+C
+C         The nominal computational accuracy is the maximum of unit
+C         roundoff (=R1MACH(4)) and 1.0E-18 since critical constants
+C         are given to only 18 digits.
+C
+C         DPSIFN is the Double Precision version of PSIFN.
+C
+C *Long Description:
+C
+C         The basic method of evaluation is the asymptotic expansion
+C         for large X.ge.XMIN followed by backward recursion on a two
+C         term recursion relation
+C
+C                  W(X+1) + X**(-N-1) = W(X).
+C
+C         This is supplemented by a series
+C
+C                  SUM( (X+K)**(-N-1) , K=0,1,2,... )
+C
+C         which converges rapidly for large N. Both XMIN and the
+C         number of terms of the series are calculated from the unit
+C         roundoff of the machine environment.
+C
+C***REFERENCES  Handbook of Mathematical Functions, National Bureau
+C                 of Standards Applied Mathematics Series 55, edited
+C                 by M. Abramowitz and I. A. Stegun, equations 6.3.5,
+C                 6.3.18, 6.4.6, 6.4.9 and 6.4.10, pp.258-260, 1964.
+C               D. E. Amos, A portable Fortran subroutine for
+C                 derivatives of the Psi function, Algorithm 610, ACM
+C                 Transactions on Mathematical Software 9, 4 (1983),
+C                 pp. 494-502.
+C***ROUTINES CALLED  I1MACH, R1MACH
+C***REVISION HISTORY  (YYMMDD)
+C   820601  DATE WRITTEN
+C   890531  Changed all specific intrinsics to generic.  (WRB)
+C   890531  REVISION DATE from Version 3.2
+C   891214  Prologue converted to Version 4.0 format.  (BAB)
+C   920501  Reformatted the REFERENCES section.  (WRB)
+C***END PROLOGUE  PSIFN
+      INTEGER I, IERR, J, K, KODE, M, MM, MX, N, NMAX, NN, NP, NX, NZ
+      INTEGER I1MACH
+      REAL ANS, ARG, B, DEN, ELIM, EPS, FLN, FN, FNP, FNS, FX, RLN,
+     * RXSQ, R1M4, R1M5, S, SLOPE, T, TA, TK, TOL, TOLS, TRM, TRMR,
+     * TSS, TST, TT, T1, T2, WDTOL, X, XDMLN, XDMY, XINC, XLN, XM,
+     * XMIN, XQ, YINT
+      REAL R1MACH
+      DIMENSION B(22), TRM(22), TRMR(100), ANS(*)
+      SAVE NMAX, B
+      DATA NMAX /100/
+C-----------------------------------------------------------------------
+C             BERNOULLI NUMBERS
+C-----------------------------------------------------------------------
+      DATA B(1), B(2), B(3), B(4), B(5), B(6), B(7), B(8), B(9), B(10),
+     * B(11), B(12), B(13), B(14), B(15), B(16), B(17), B(18), B(19),
+     * B(20), B(21), B(22) /1.00000000000000000E+00,
+     * -5.00000000000000000E-01,1.66666666666666667E-01,
+     * -3.33333333333333333E-02,2.38095238095238095E-02,
+     * -3.33333333333333333E-02,7.57575757575757576E-02,
+     * -2.53113553113553114E-01,1.16666666666666667E+00,
+     * -7.09215686274509804E+00,5.49711779448621554E+01,
+     * -5.29124242424242424E+02,6.19212318840579710E+03,
+     * -8.65802531135531136E+04,1.42551716666666667E+06,
+     * -2.72982310678160920E+07,6.01580873900642368E+08,
+     * -1.51163157670921569E+10,4.29614643061166667E+11,
+     * -1.37116552050883328E+13,4.88332318973593167E+14,
+     * -1.92965793419400681E+16/
+C
+C***FIRST EXECUTABLE STATEMENT  PSIFN
+      IERR = 0
+      NZ=0
+      IF (X.LE.0.0E0) IERR=1
+      IF (N.LT.0) IERR=1
+      IF (KODE.LT.1 .OR. KODE.GT.2) IERR=1
+      IF (M.LT.1) IERR=1
+      IF (IERR.NE.0) RETURN
+      MM=M
+      NX = MIN(-I1MACH(12),I1MACH(13))
+      R1M5 = R1MACH(5)
+      R1M4 = R1MACH(4)*0.5E0
+      WDTOL = MAX(R1M4,0.5E-18)
+C-----------------------------------------------------------------------
+C     ELIM = APPROXIMATE EXPONENTIAL OVER AND UNDERFLOW LIMIT
+C-----------------------------------------------------------------------
+      ELIM = 2.302E0*(NX*R1M5-3.0E0)
+      XLN = LOG(X)
+   41 CONTINUE
+      NN = N + MM - 1
+      FN = NN
+      FNP = FN + 1.0E0
+      T = FNP*XLN
+C-----------------------------------------------------------------------
+C     OVERFLOW AND UNDERFLOW TEST FOR SMALL AND LARGE X
+C-----------------------------------------------------------------------
+      IF (ABS(T).GT.ELIM) GO TO 290
+      IF (X.LT.WDTOL) GO TO 260
+C-----------------------------------------------------------------------
+C     COMPUTE XMIN AND THE NUMBER OF TERMS OF THE SERIES, FLN+1
+C-----------------------------------------------------------------------
+      RLN = R1M5*I1MACH(11)
+      RLN = MIN(RLN,18.06E0)
+      FLN = MAX(RLN,3.0E0) - 3.0E0
+      YINT = 3.50E0 + 0.40E0*FLN
+      SLOPE = 0.21E0 + FLN*(0.0006038E0*FLN+0.008677E0)
+      XM = YINT + SLOPE*FN
+      MX = INT(XM) + 1
+      XMIN = MX
+      IF (N.EQ.0) GO TO 50
+      XM = -2.302E0*RLN - MIN(0.0E0,XLN)
+      FNS = N
+      ARG = XM/FNS
+      ARG = MIN(0.0E0,ARG)
+      EPS = EXP(ARG)
+      XM = 1.0E0 - EPS
+      IF (ABS(ARG).LT.1.0E-3) XM = -ARG
+      FLN = X*XM/EPS
+      XM = XMIN - X
+      IF (XM.GT.7.0E0 .AND. FLN.LT.15.0E0) GO TO 200
+   50 CONTINUE
+      XDMY = X
+      XDMLN = XLN
+      XINC = 0.0E0
+      IF (X.GE.XMIN) GO TO 60
+      NX = INT(X)
+      XINC = XMIN - NX
+      XDMY = X + XINC
+      XDMLN = LOG(XDMY)
+   60 CONTINUE
+C-----------------------------------------------------------------------
+C     GENERATE W(N+MM-1,X) BY THE ASYMPTOTIC EXPANSION
+C-----------------------------------------------------------------------
+      T = FN*XDMLN
+      T1 = XDMLN + XDMLN
+      T2 = T + XDMLN
+      TK = MAX(ABS(T),ABS(T1),ABS(T2))
+      IF (TK.GT.ELIM) GO TO 380
+      TSS = EXP(-T)
+      TT = 0.5E0/XDMY
+      T1 = TT
+      TST = WDTOL*TT
+      IF (NN.NE.0) T1 = TT + 1.0E0/FN
+      RXSQ = 1.0E0/(XDMY*XDMY)
+      TA = 0.5E0*RXSQ
+      T = FNP*TA
+      S = T*B(3)
+      IF (ABS(S).LT.TST) GO TO 80
+      TK = 2.0E0
+      DO 70 K=4,22
+        T = T*((TK+FN+1.0E0)/(TK+1.0E0))*((TK+FN)/(TK+2.0E0))*RXSQ
+        TRM(K) = T*B(K)
+        IF (ABS(TRM(K)).LT.TST) GO TO 80
+        S = S + TRM(K)
+        TK = TK + 2.0E0
+   70 CONTINUE
+   80 CONTINUE
+      S = (S+T1)*TSS
+      IF (XINC.EQ.0.0E0) GO TO 100
+C-----------------------------------------------------------------------
+C     BACKWARD RECUR FROM XDMY TO X
+C-----------------------------------------------------------------------
+      NX = INT(XINC)
+      NP = NN + 1
+      IF (NX.GT.NMAX) GO TO 390
+      IF (NN.EQ.0) GO TO 160
+      XM = XINC - 1.0E0
+      FX = X + XM
+C-----------------------------------------------------------------------
+C     THIS LOOP SHOULD NOT BE CHANGED. FX IS ACCURATE WHEN X IS SMALL
+C-----------------------------------------------------------------------
+      DO 90 I=1,NX
+        TRMR(I) = FX**(-NP)
+        S = S + TRMR(I)
+        XM = XM - 1.0E0
+        FX = X + XM
+   90 CONTINUE
+  100 CONTINUE
+      ANS(MM) = S
+      IF (FN.EQ.0.0E0) GO TO 180
+C-----------------------------------------------------------------------
+C     GENERATE LOWER DERIVATIVES, J.LT.N+MM-1
+C-----------------------------------------------------------------------
+      IF (MM.EQ.1) RETURN
+      DO 150 J=2,MM
+        FNP = FN
+        FN = FN - 1.0E0
+        TSS = TSS*XDMY
+        T1 = TT
+        IF (FN.NE.0.0E0) T1 = TT + 1.0E0/FN
+        T = FNP*TA
+        S = T*B(3)
+        IF (ABS(S).LT.TST) GO TO 120
+        TK = 3.0E0 + FNP
+        DO 110 K=4,22
+          TRM(K) = TRM(K)*FNP/TK
+          IF (ABS(TRM(K)).LT.TST) GO TO 120
+          S = S + TRM(K)
+          TK = TK + 2.0E0
+  110   CONTINUE
+  120   CONTINUE
+        S = (S+T1)*TSS
+        IF (XINC.EQ.0.0E0) GO TO 140
+        IF (FN.EQ.0.0E0) GO TO 160
+        XM = XINC - 1.0E0
+        FX = X + XM
+        DO 130 I=1,NX
+          TRMR(I) = TRMR(I)*FX
+          S = S + TRMR(I)
+          XM = XM - 1.0E0
+          FX = X + XM
+  130   CONTINUE
+  140   CONTINUE
+        MX = MM - J + 1
+        ANS(MX) = S
+        IF (FN.EQ.0.0E0) GO TO 180
+  150 CONTINUE
+      RETURN
+C-----------------------------------------------------------------------
+C     RECURSION FOR N = 0
+C-----------------------------------------------------------------------
+  160 CONTINUE
+      DO 170 I=1,NX
+        S = S + 1.0E0/(X+NX-I)
+  170 CONTINUE
+  180 CONTINUE
+      IF (KODE.EQ.2) GO TO 190
+      ANS(1) = S - XDMLN
+      RETURN
+  190 CONTINUE
+      IF (XDMY.EQ.X) RETURN
+      XQ = XDMY/X
+      ANS(1) = S - LOG(XQ)
+      RETURN
+C-----------------------------------------------------------------------
+C     COMPUTE BY SERIES (X+K)**(-(N+1)) , K=0,1,2,...
+C-----------------------------------------------------------------------
+  200 CONTINUE
+      NN = INT(FLN) + 1
+      NP = N + 1
+      T1 = (FNS+1.0E0)*XLN
+      T = EXP(-T1)
+      S = T
+      DEN = X
+      DO 210 I=1,NN
+        DEN = DEN + 1.0E0
+        TRM(I) = DEN**(-NP)
+        S = S + TRM(I)
+  210 CONTINUE
+      ANS(1) = S
+      IF (N.NE.0) GO TO 220
+      IF (KODE.EQ.2) ANS(1) = S + XLN
+  220 CONTINUE
+      IF (MM.EQ.1) RETURN
+C-----------------------------------------------------------------------
+C     GENERATE HIGHER DERIVATIVES, J.GT.N
+C-----------------------------------------------------------------------
+      TOL = WDTOL/5.0E0
+      DO 250 J=2,MM
+        T = T/X
+        S = T
+        TOLS = T*TOL
+        DEN = X
+        DO 230 I=1,NN
+          DEN = DEN + 1.0E0
+          TRM(I) = TRM(I)/DEN
+          S = S + TRM(I)
+          IF (TRM(I).LT.TOLS) GO TO 240
+  230   CONTINUE
+  240   CONTINUE
+        ANS(J) = S
+  250 CONTINUE
+      RETURN
+C-----------------------------------------------------------------------
+C     SMALL X.LT.UNIT ROUND OFF
+C-----------------------------------------------------------------------
+  260 CONTINUE
+      ANS(1) = X**(-N-1)
+      IF (MM.EQ.1) GO TO 280
+      K = 1
+      DO 270 I=2,MM
+        ANS(K+1) = ANS(K)/X
+        K = K + 1
+  270 CONTINUE
+  280 CONTINUE
+      IF (N.NE.0) RETURN
+      IF (KODE.EQ.2) ANS(1) = ANS(1) + XLN
+      RETURN
+  290 CONTINUE
+      IF (T.GT.0.0E0) GO TO 380
+      NZ=0
+      IERR=2
+      RETURN
+  380 CONTINUE
+      NZ=NZ+1
+      ANS(MM)=0.0E0
+      MM=MM-1
+      IF(MM.EQ.0) RETURN
+      GO TO 41
+  390 CONTINUE
+      IERR=3
+      NZ=0
+      RETURN
+      END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/liboctave/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,124 @@
+liboctave_EXTRA_DIST =
+
+liboctave_CLEANFILES =
+liboctave_DISTCLEANFILES =
+liboctave_MAINTAINERCLEANFILES =
+
+## Search local directories before those specified by the user.
+liboctave_liboctave_la_CPPFLAGS = \
+  @OCTAVE_DLL_DEFS@ \
+  @CRUFT_DLL_DEFS@ \
+  -I$(srcdir)/liboctave/array \
+  -I$(srcdir)/liboctave/cruft/misc \
+  -Iliboctave/numeric -I$(srcdir)/liboctave/numeric \
+  -Iliboctave/operators -I$(srcdir)/liboctave/operators \
+  -I$(srcdir)/liboctave/system \
+  -I$(srcdir)/liboctave/util \
+  -I$(top_builddir)/libgnu -I$(top_srcdir)/libgnu
+
+liboctave_liboctave_la_CFLAGS = $(AM_CFLAGS) $(WARN_CFLAGS)
+
+liboctave_liboctave_la_CXXFLAGS = $(AM_CXXFLAGS) $(WARN_CXXFLAGS)
+
+octlib_LTLIBRARIES += liboctave/liboctave.la
+
+BUILT_INCS = \
+  liboctave/operators/mx-ops.h \
+  $(LIBOCTAVE_OPT_INC) \
+  $(MX_OP_INC) \
+  $(VX_OP_INC) \
+  $(SMX_OP_INC)
+
+BUILT_SOURCES += $(BUILT_INCS)
+
+octinclude_HEADERS += \
+  $(ARRAY_INC) \
+  $(CRUFT_INC) \
+  $(NUMERIC_INC) \
+  $(LIBOCTAVE_OPERATORS_INC) \
+  $(SYSTEM_INC) \
+  $(UTIL_INC) \
+  $(OTHER_INC) \
+  $(LIBOCTAVE_TEMPLATE_SRC)
+
+nodist_octinclude_HEADERS += \
+  $(BUILT_INCS)
+
+## C++ files that are #included, not compiled
+OTHER_INC =
+
+## C++ files with templates that are #included, not compiled
+LIBOCTAVE_TEMPLATE_SRC =
+
+## A list of all files that could include tests
+
+liboctave_liboctave_la_LIBADD =
+
+include liboctave/array/module.mk
+include liboctave/cruft/module.mk
+include liboctave/numeric/module.mk
+include liboctave/operators/module.mk
+include liboctave/system/module.mk
+include liboctave/util/module.mk
+
+## liboctave merely collects a bunch of compiled convenience libraries.
+## It has no source code itself.
+liboctave_liboctave_la_SOURCES =
+
+# Dummy C++ source to force C++ linking.
+nodist_EXTRA_liboctave_liboctave_la_SOURCES = liboctave/dummy.cc
+
+liboctave_liboctave_la_LIBADD += \
+  $(top_builddir)/libgnu/libgnu.la \
+  $(LIBOCTAVE_LINK_DEPS)
+
+# Increment these as needed and according to the rules in the libtool manual:
+liboctave_liboctave_current = 3
+liboctave_liboctave_revision = 0
+liboctave_liboctave_age = 0
+
+liboctave_liboctave_version_info = $(liboctave_liboctave_current):$(liboctave_liboctave_revision):$(liboctave_age)
+
+liboctave_liboctave_la_LDFLAGS = \
+  -version-info $(liboctave_liboctave_version_info) \
+  $(NO_UNDEFINED_LDFLAG) \
+  @XTRA_CRUFT_SH_LDFLAGS@ \
+  -bindir $(bindir) \
+  $(LIBOCTAVE_LINK_OPTS) \
+  $(WARN_LDFLAGS)
+
+## Rules to build test files
+
+LIBOCTAVE_TST_SRC = \
+  $(liboctave_array_libarray_la_SOURCES) \
+  $(liboctave_numeric_libnumeric_la_SOURCES) \
+  $(liboctave_system_libsystem_la_SOURCES) \
+  $(liboctave_util_libutil_la_SOURCES) \
+  $(LIBOCTAVE_TEMPLATE_SRC)
+
+LIBOCTAVE_TST_FILES_SRC := $(shell $(top_srcdir)/build-aux/find-files-with-tests.sh "$(srcdir)" $(LIBOCTAVE_TST_SRC))
+
+LIBOCTAVE_TST_FILES := $(addsuffix -tst,$(LIBOCTAVE_TST_FILES_SRC))
+
+liboctavetestsdir := $(octtestsdir)
+
+nobase_liboctavetests_DATA = $(LIBOCTAVE_TST_FILES)
+
+EXTRA_DIST += $(liboctave_EXTRA_DIST)
+
+liboctave_DISTCLEANFILES += \
+  $(BUILT_INCS) \
+  $(LIBOCTAVE_TST_FILES)
+
+CLEANFILES += $(liboctave_CLEANFILES)
+DISTCLEANFILES += $(liboctave_DISTCLEANFILES)
+MAINTAINERCLEANFILES += $(liboctave_MAINTAINERCLEANFILES)
+
+liboctave-clean:
+	rm -f $(liboctave_CLEANFILES)
+
+liboctave-distclean: liboctave-clean
+	rm -f $(liboctave_DISTCLEANFILES)
+
+liboctave-maintainer-clean: liboctave-distclean
+	rm -f $(liboctave_MAINTAINERCLEANFILES)
--- a/liboctave/numeric/CmplxAEPBAL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CmplxAEPBAL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_CmplxAEPBAL_h)
+#if ! defined (octave_CmplxAEPBAL_h)
 #define octave_CmplxAEPBAL_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/CmplxCHOL.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CmplxCHOL.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -86,7 +86,7 @@
 }
 
 octave_idx_type
-ComplexCHOL::init (const ComplexMatrix& a, bool calc_cond)
+ComplexCHOL::init (const ComplexMatrix& a, bool upper, bool calc_cond)
 {
   octave_idx_type a_nr = a.rows ();
   octave_idx_type a_nc = a.cols ();
@@ -101,14 +101,25 @@
   octave_idx_type n = a_nc;
   octave_idx_type info;
 
+  is_upper = upper;
+
   chol_mat.clear (n, n);
-  for (octave_idx_type j = 0; j < n; j++)
-    {
-      for (octave_idx_type i = 0; i <= j; i++)
-        chol_mat.xelem (i, j) = a(i, j);
-      for (octave_idx_type i = j+1; i < n; i++)
-        chol_mat.xelem (i, j) = 0.0;
-    }
+  if (is_upper)
+    for (octave_idx_type j = 0; j < n; j++)
+      {
+        for (octave_idx_type i = 0; i <= j; i++)
+          chol_mat.xelem (i, j) = a(i, j);
+        for (octave_idx_type i = j+1; i < n; i++)
+          chol_mat.xelem (i, j) = 0.0;
+      }
+  else
+    for (octave_idx_type j = 0; j < n; j++)
+      {
+        for (octave_idx_type i = 0; i < j; i++)
+          chol_mat.xelem (i, j) = 0.0;
+        for (octave_idx_type i = j; i < n; i++)
+          chol_mat.xelem (i, j) = a(i, j);
+      }
   Complex *h = chol_mat.fortran_vec ();
 
   // Calculate the norm of the matrix, for later use.
@@ -116,8 +127,12 @@
   if (calc_cond)
     anorm = xnorm (a, 1);
 
-  F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n, h, n, info
-                             F77_CHAR_ARG_LEN (1)));
+  if (is_upper)
+    F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n, h, n, info
+                               F77_CHAR_ARG_LEN (1)));
+  else
+    F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 ("L", 1), n, h, n, info
+                               F77_CHAR_ARG_LEN (1)));
 
   xrcond = 0.0;
   if (info > 0)
@@ -143,7 +158,7 @@
 }
 
 static ComplexMatrix
-chol2inv_internal (const ComplexMatrix& r)
+chol2inv_internal (const ComplexMatrix& r, bool is_upper = true)
 {
   ComplexMatrix retval;
 
@@ -157,17 +172,29 @@
 
       ComplexMatrix tmp = r;
 
-      F77_XFCN (zpotri, ZPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
-                                 tmp.fortran_vec (), n, info
-                                 F77_CHAR_ARG_LEN (1)));
+      if (is_upper)
+        F77_XFCN (zpotri, ZPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
+                                   tmp.fortran_vec (), n, info
+                                   F77_CHAR_ARG_LEN (1)));
+      else
+        F77_XFCN (zpotri, ZPOTRI, (F77_CONST_CHAR_ARG2 ("L", 1), n,
+                                   tmp.fortran_vec (), n, info
+                                   F77_CHAR_ARG_LEN (1)));
 
       // If someone thinks of a more graceful way of doing this (or
       // faster for that matter :-)), please let me know!
 
       if (n > 1)
-        for (octave_idx_type j = 0; j < r_nc; j++)
-          for (octave_idx_type i = j+1; i < r_nr; i++)
-            tmp.xelem (i, j) = std::conj (tmp.xelem (j, i));
+        {
+          if (is_upper)
+            for (octave_idx_type j = 0; j < r_nc; j++)
+              for (octave_idx_type i = j+1; i < r_nr; i++)
+                tmp.xelem (i, j) = tmp.xelem (j, i);
+          else
+            for (octave_idx_type j = 0; j < r_nc; j++)
+              for (octave_idx_type i = j+1; i < r_nr; i++)
+                tmp.xelem (j, i) = tmp.xelem (i, j);
+        }
 
       retval = tmp;
     }
@@ -181,7 +208,7 @@
 ComplexMatrix
 ComplexCHOL::inverse (void) const
 {
-  return chol2inv_internal (chol_mat);
+  return chol2inv_internal (chol_mat, is_upper);
 }
 
 void
@@ -200,7 +227,7 @@
 {
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       ComplexColumnVector utmp = u;
 
@@ -220,7 +247,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       ComplexColumnVector utmp = u;
 
@@ -242,7 +269,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () != n + 1)
+  if (u.numel () != n + 1)
     (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("cholinsert: index out of range");
@@ -305,10 +332,10 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       init (chol_mat.hermitian () * chol_mat
-            + ComplexMatrix (u) * ComplexMatrix (u).hermitian (), false);
+            + ComplexMatrix (u) * ComplexMatrix (u).hermitian (), true, false);
     }
   else
     (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
@@ -331,7 +358,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       if (singular (chol_mat))
         info = 2;
@@ -339,7 +366,7 @@
         {
           info = init (chol_mat.hermitian () * chol_mat
                        - ComplexMatrix (u) * ComplexMatrix (u).hermitian (),
-                       false);
+                       true, false);
           if (info) info = 1;
         }
     }
@@ -358,7 +385,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () != n + 1)
+  if (u.numel () != n + 1)
     (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("cholinsert: index out of range");
@@ -382,7 +409,7 @@
                 else
                   a1(k, l) = a(k < j ? k : k-1, l < j ? l : l-1);
               }
-          info = init (a1, false);
+          info = init (a1, true, false);
           if (info) info = 1;
         }
     }
@@ -404,7 +431,7 @@
       ComplexMatrix a = chol_mat.hermitian () * chol_mat;
       a.delete_elements (1, idx_vector (j));
       a.delete_elements (0, idx_vector (j));
-      init (a, false);
+      init (a, true, false);
     }
 }
 
@@ -433,7 +460,7 @@
           for (octave_idx_type k = j+1; k < i+1; k++) p(k) = k-1;
         }
 
-      init (a.index (idx_vector (p), idx_vector (p)), false);
+      init (a.index (idx_vector (p), idx_vector (p)), true, false);
     }
 }
 
--- a/liboctave/numeric/CmplxCHOL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CmplxCHOL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_CmplxCHOL_h)
+#if ! defined (octave_CmplxCHOL_h)
 #define octave_CmplxCHOL_h 1
 
 #include <iosfwd>
@@ -37,17 +37,17 @@
 
   ComplexCHOL (void) : chol_mat (), xrcond (0) { }
 
-  ComplexCHOL (const ComplexMatrix& a, bool calc_cond = false)
+  ComplexCHOL (const ComplexMatrix& a, bool upper = true, bool calc_cond = false)
     : chol_mat (), xrcond (0)
   {
-    init (a, calc_cond);
+    init (a, upper, calc_cond);
   }
 
-  ComplexCHOL (const ComplexMatrix& a, octave_idx_type& info,
+  ComplexCHOL (const ComplexMatrix& a, octave_idx_type& info, bool upper = true,
                bool calc_cond = false)
     : chol_mat (), xrcond (0)
   {
-    info = init (a, calc_cond);
+    info = init (a, upper, calc_cond);
   }
 
   ComplexCHOL (const ComplexCHOL& a)
@@ -91,7 +91,9 @@
 
   double xrcond;
 
-  octave_idx_type init (const ComplexMatrix& a, bool calc_cond);
+  bool is_upper;
+
+  octave_idx_type init (const ComplexMatrix& a, bool upper, bool calc_cond);
 };
 
 ComplexMatrix OCTAVE_API chol2inv (const ComplexMatrix& r);
--- a/liboctave/numeric/CmplxGEPBAL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CmplxGEPBAL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_CmplxGEPBAL_h)
+#if ! defined (octave_CmplxGEPBAL_h)
 #define octave_CmplxGEPBAL_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/CmplxHESS.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CmplxHESS.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_CmplxHESS_h)
+#if ! defined (octave_CmplxHESS_h)
 #define octave_CmplxHESS_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/CmplxLU.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CmplxLU.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -98,7 +98,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = l.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       ComplexColumnVector utmp = u;
       ComplexColumnVector vtmp = v;
@@ -149,7 +149,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = l.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       ComplexColumnVector utmp = u;
       ComplexColumnVector vtmp = v;
--- a/liboctave/numeric/CmplxLU.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CmplxLU.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_CmplxLU_h)
+#if ! defined (octave_CmplxLU_h)
 #define octave_CmplxLU_h 1
 
 #include "base-lu.h"
--- a/liboctave/numeric/CmplxQR.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CmplxQR.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -212,7 +212,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = q.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       ComplexColumnVector utmp = u;
       ComplexColumnVector vtmp = v;
@@ -259,7 +259,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = q.columns ();
 
-  if (u.length () != m)
+  if (u.numel () != m)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -292,14 +292,14 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, ASCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
 
   if (dups)
     (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
-  else if (u.length () != m || u.columns () != nj)
+  else if (u.numel () != m || u.columns () != nj)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (nj > 0 && (js(0) < 0 || js(nj-1) > n))
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -317,7 +317,7 @@
         }
 
       OCTAVE_LOCAL_BUFFER (double, rw, kmax);
-      for (volatile octave_idx_type i = 0; i < js.length (); i++)
+      for (volatile octave_idx_type i = 0; i < js.numel (); i++)
         {
           octave_idx_type ii = i;
           ComplexColumnVector utmp = u.column (jsi(i));
@@ -365,7 +365,7 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, DESCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
@@ -377,7 +377,7 @@
   else if (nj > 0)
     {
       OCTAVE_LOCAL_BUFFER (double, rw, k);
-      for (volatile octave_idx_type i = 0; i < js.length (); i++)
+      for (volatile octave_idx_type i = 0; i < js.numel (); i++)
         {
           octave_idx_type ii = i;
           F77_XFCN (zqrdec, ZQRDEC, (m, n - ii, k == m ? k : k - ii,
@@ -405,7 +405,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = std::min (m, n);
 
-  if (! q.is_square () || u.length () != n)
+  if (! q.is_square () || u.numel () != n)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > m)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -477,7 +477,7 @@
   octave_idx_type m = q.rows ();
   octave_idx_type n = r.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       init (q*r + ComplexMatrix (u) * ComplexMatrix (v).hermitian (),
             get_type ());
@@ -573,7 +573,7 @@
   octave_idx_type m = q.rows ();
   octave_idx_type n = r.columns ();
 
-  if (u.length () != m)
+  if (u.numel () != m)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -593,21 +593,21 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, ASCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
 
   if (dups)
     (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
-  else if (u.length () != m || u.columns () != nj)
+  else if (u.numel () != m || u.columns () != nj)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (nj > 0 && (js(0) < 0 || js(nj-1) > n))
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
   else if (nj > 0)
     {
       ComplexMatrix a = q*r;
-      for (octave_idx_type i = 0; i < js.length (); i++)
+      for (octave_idx_type i = 0; i < js.numel (); i++)
         a = ::insert_col (a, js(i), u.column (i));
       init (a, get_type ());
     }
@@ -637,7 +637,7 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, DESCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
@@ -649,7 +649,7 @@
   else if (nj > 0)
     {
       ComplexMatrix a = q*r;
-      for (octave_idx_type i = 0; i < js.length (); i++)
+      for (octave_idx_type i = 0; i < js.numel (); i++)
         a = ::delete_col (a, js(i));
       init (a, get_type ());
     }
@@ -663,7 +663,7 @@
   octave_idx_type m = r.rows ();
   octave_idx_type n = r.columns ();
 
-  if (! q.is_square () || u.length () != n)
+  if (! q.is_square () || u.numel () != n)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > m)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
--- a/liboctave/numeric/CmplxQR.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CmplxQR.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_CmplxQR_h)
+#if ! defined (octave_CmplxQR_h)
 #define octave_CmplxQR_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/CmplxQRP.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CmplxQRP.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_CmplxQRP_h)
+#if ! defined (octave_CmplxQRP_h)
 #define octave_CmplxQRP_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/CmplxSCHUR.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CmplxSCHUR.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_CmplxSCHUR_h)
+#if ! defined (octave_CmplxSCHUR_h)
 #define octave_CmplxSCHUR_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/CmplxSVD.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CmplxSVD.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_CmplxSVD_h)
+#if ! defined (octave_CmplxSVD_h)
 #define octave_CmplxSVD_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/CollocWt.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CollocWt.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -175,9 +175,9 @@
             dif2[i] = (ab + ap + z1) / z / z / (z + 1.0);
           else
             {
-              z = z * z;
+              z *= z;
               double y = z1 * (ab + z1);
-              y = y * (ap + y);
+              y *= (ap + y);
               dif2[i] = y / z / (z - 1.0);
             }
         }
@@ -218,11 +218,11 @@
           if (i != 0)
             {
               for (octave_idx_type j = 1; j <= i; j++)
-                zc = zc - z / (x - root[j-1]);
+                zc -= z / (x - root[j-1]);
             }
 
-          z = z / zc;
-          x = x - z;
+          z /= zc;
+          x -= z;
 
           // Famous last words:  100 iterations should be more than
           // enough in all cases.
@@ -235,7 +235,7 @@
         }
 
       root[i] = x;
-      x = x + sqrt (std::numeric_limits<double>::epsilon ());
+      x += sqrt (std::numeric_limits<double>::epsilon ());
     }
 
   // Add interpolation points at x = 0 and/or x = 1.
@@ -362,7 +362,7 @@
 
           vect[j] = ax / (dif1[j] * dif1[j]);
 
-          y = y + vect[j];
+          y += vect[j];
         }
 
       for (octave_idx_type j = 0; j < nt; j++)
@@ -375,7 +375,7 @@
 void
 CollocWt::error (const char* msg)
 {
-  (*current_liboctave_error_handler) ("fatal CollocWt error: %s", msg);
+  (*current_liboctave_error_handler) ("CollocWt: fatal error '%s'", msg);
 }
 
 CollocWt&
@@ -383,7 +383,7 @@
 {
   if (val >= rb)
     {
-      error ("left bound greater than right bound");
+      error ("CollocWt: left bound greater than right bound");
       return *this;
     }
 
@@ -397,7 +397,7 @@
 {
   if (val <= lb)
     {
-      error ("right bound less than left bound");
+      error ("CollocWt: right bound less than left bound");
       return *this;
     }
 
@@ -414,7 +414,7 @@
   double wid = rb - lb;
   if (wid <= 0.0)
     {
-      error ("width less than or equal to zero");
+      error ("CollocWt: width less than or equal to zero");
       return;
     }
 
@@ -422,7 +422,7 @@
 
   if (nt < 0)
     {
-      error ("total number of collocation points less than zero");
+      error ("CollocWt: total number of collocation points less than zero");
       return;
     }
   else if (nt == 0)
--- a/liboctave/numeric/CollocWt.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/CollocWt.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_CollocWt_h)
+#if ! defined (octave_CollocWt_h)
 #define octave_CollocWt_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/DAE.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/DAE.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_DAE_h)
+#if ! defined (octave_DAE_h)
 #define octave_DAE_h 1
 
 #include "DAEFunc.h"
--- a/liboctave/numeric/DAEFunc.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/DAEFunc.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_DAEFunc_h)
+#if ! defined (octave_DAEFunc_h)
 #define octave_DAEFunc_h 1
 
 class Matrix;
--- a/liboctave/numeric/DAERT.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/DAERT.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_DAERT_h)
+#if ! defined (octave_DAERT_h)
 #define octave_DAERT_h 1
 
 #include "DAE.h"
--- a/liboctave/numeric/DAERTFunc.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/DAERTFunc.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_DAERTFunc_h)
+#if ! defined (octave_DAERTFunc_h)
 #define octave_DAERTFunc_h 1
 
 #include "dMatrix.h"
--- a/liboctave/numeric/DASPK.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/DASPK.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -91,7 +91,7 @@
 
   if (ires >= 0)
     {
-      if (tmp_delta.length () == 0)
+      if (tmp_delta.numel () == 0)
         ires = -2;
       else
         {
@@ -196,7 +196,7 @@
 
           ColumnVector res = (*user_fun) (x, xdot, t, ires);
 
-          if (res.length () != x.length ())
+          if (res.numel () != x.numel ())
             {
               (*current_liboctave_error_handler)
                 ("daspk: inconsistent sizes for state and residual vectors");
@@ -240,8 +240,8 @@
       abs_tol = absolute_tolerance ();
       rel_tol = relative_tolerance ();
 
-      octave_idx_type abs_tol_len = abs_tol.length ();
-      octave_idx_type rel_tol_len = rel_tol.length ();
+      octave_idx_type abs_tol_len = abs_tol.numel ();
+      octave_idx_type rel_tol_len = rel_tol.numel ();
 
       if (abs_tol_len == 1 && rel_tol_len == 1)
         {
@@ -302,7 +302,7 @@
           {
             Array<octave_idx_type> ict = inequality_constraint_types ();
 
-            if (ict.length () == n)
+            if (ict.numel () == n)
               {
                 for (octave_idx_type i = 0; i < n; i++)
                   {
@@ -347,7 +347,7 @@
 
               Array<octave_idx_type> av = algebraic_variables ();
 
-              if (av.length () == n)
+              if (av.numel () == n)
                 {
                   octave_idx_type lid;
                   if (eiq == 0 || eiq == 2)
@@ -387,7 +387,7 @@
 
           Array<octave_idx_type> av = algebraic_variables ();
 
-          if (av.length () == n)
+          if (av.numel () == n)
             {
               octave_idx_type lid;
               if (eiq == 0 || eiq == 2)
@@ -406,7 +406,7 @@
         {
           Array<double> ich = initial_condition_heuristics ();
 
-          if (ich.length () == 6)
+          if (ich.numel () == 6)
             {
               iwork(31) = NINTbig (ich(0));
               iwork(32) = NINTbig (ich(1));
@@ -538,7 +538,7 @@
 {
   Matrix retval;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -583,7 +583,7 @@
 {
   Matrix retval;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -597,7 +597,7 @@
           xdot_out.elem (0, i) = xdot.elem (i);
         }
 
-      octave_idx_type n_crit = tcrit.capacity ();
+      octave_idx_type n_crit = tcrit.numel ();
 
       if (n_crit > 0)
         {
--- a/liboctave/numeric/DASPK.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/DASPK.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_DASPK_h)
+#if ! defined (octave_DASPK_h)
 #define octave_DASPK_h 1
 
 #include <cfloat>
--- a/liboctave/numeric/DASRT.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/DASRT.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -87,7 +87,7 @@
 
   ColumnVector tmp_fval = (*user_fsub) (tmp_state, tmp_deriv, t, ires);
 
-  if (tmp_fval.length () == 0)
+  if (tmp_fval.numel () == 0)
     ires = -2;
   else
     {
@@ -182,7 +182,7 @@
       if (user_csub)
         {
           ColumnVector tmp = (*user_csub) (x, t);
-          ng = tmp.length ();
+          ng = tmp.numel ();
         }
       else
         ng = 0;
@@ -233,7 +233,7 @@
 
           ColumnVector fval = (*user_fsub) (x, xdot, t, ires);
 
-          if (fval.length () != x.length ())
+          if (fval.numel () != x.numel ())
             {
               (*current_liboctave_error_handler)
                 ("dasrt: inconsistent sizes for state and residual vectors");
@@ -290,8 +290,8 @@
       abs_tol = absolute_tolerance ();
       rel_tol = relative_tolerance ();
 
-      octave_idx_type abs_tol_len = abs_tol.length ();
-      octave_idx_type rel_tol_len = rel_tol.length ();
+      octave_idx_type abs_tol_len = abs_tol.numel ();
+      octave_idx_type rel_tol_len = rel_tol.numel ();
 
       if (abs_tol_len == 1 && rel_tol_len == 1)
         {
@@ -393,7 +393,7 @@
   Matrix xdot_out;
   ColumnVector t_out = tout;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -452,7 +452,7 @@
   Matrix xdot_out;
   ColumnVector t_outs = tout;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -460,7 +460,7 @@
       x_out.resize (n_out, n);
       xdot_out.resize (n_out, n);
 
-      octave_idx_type n_crit = tcrit.capacity ();
+      octave_idx_type n_crit = tcrit.numel ();
 
       if (n_crit > 0)
         {
--- a/liboctave/numeric/DASRT.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/DASRT.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_DASRT_h)
+#if ! defined (octave_DASRT_h)
 #define octave_DASRT_h 1
 
 #include <cfloat>
--- a/liboctave/numeric/DASSL.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/DASSL.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -84,7 +84,7 @@
 
   if (ires >= 0)
     {
-      if (tmp_delta.length () == 0)
+      if (tmp_delta.numel () == 0)
         ires = -2;
       else
         {
@@ -175,7 +175,7 @@
 
           ColumnVector res = (*user_fun) (x, xdot, t, ires);
 
-          if (res.length () != x.length ())
+          if (res.numel () != x.numel ())
             {
               (*current_liboctave_error_handler)
                 ("dassl: inconsistent sizes for state and residual vectors");
@@ -251,8 +251,8 @@
       abs_tol = absolute_tolerance ();
       rel_tol = relative_tolerance ();
 
-      octave_idx_type abs_tol_len = abs_tol.length ();
-      octave_idx_type rel_tol_len = rel_tol.length ();
+      octave_idx_type abs_tol_len = abs_tol.numel ();
+      octave_idx_type rel_tol_len = rel_tol.numel ();
 
       if (abs_tol_len == 1 && rel_tol_len == 1)
         {
@@ -353,7 +353,7 @@
 {
   Matrix retval;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -398,7 +398,7 @@
 {
   Matrix retval;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -412,7 +412,7 @@
           xdot_out.elem (0, i) = xdot.elem (i);
         }
 
-      octave_idx_type n_crit = tcrit.capacity ();
+      octave_idx_type n_crit = tcrit.numel ();
 
       if (n_crit > 0)
         {
--- a/liboctave/numeric/DASSL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/DASSL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_DASSL_h)
+#if ! defined (octave_DASSL_h)
 #define octave_DASSL_h 1
 
 #include <cfloat>
--- a/liboctave/numeric/DET.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/DET.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_DET_h)
+#if ! defined (octave_DET_h)
 #define octave_DET_h 1
 
 #include <cmath>
--- a/liboctave/numeric/EIG.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/EIG.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -715,7 +715,7 @@
                              F77_CHAR_ARG_LEN (1)));
 
   if (a.is_hermitian () && b.is_hermitian () && info == 0)
-    return hermitian_init (a, calc_ev);
+    return hermitian_init (a, b, calc_ev);
 
   ComplexMatrix atmp = a;
   Complex *atmp_data = atmp.fortran_vec ();
--- a/liboctave/numeric/EIG.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/EIG.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_EIG_h)
+#if ! defined (octave_EIG_h)
 #define octave_EIG_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/LSODE.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/LSODE.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -74,7 +74,7 @@
 
   tmp_deriv = (*user_fun) (*tmp_x, time);
 
-  if (tmp_deriv.length () == 0)
+  if (tmp_deriv.numel () == 0)
     ierr = -1;
   else
     {
@@ -208,7 +208,7 @@
 
       ColumnVector xdot = (*user_fun) (x, t);
 
-      if (x.length () != xdot.length ())
+      if (x.numel () != xdot.numel ())
         {
           (*current_liboctave_error_handler)
             ("lsode: inconsistent sizes for state and derivative vectors");
@@ -224,7 +224,7 @@
       rel_tol = relative_tolerance ();
       abs_tol = absolute_tolerance ();
 
-      octave_idx_type abs_tol_len = abs_tol.length ();
+      octave_idx_type abs_tol_len = abs_tol.numel ();
 
       if (abs_tol_len == 1)
         itol = 1;
@@ -383,7 +383,7 @@
 {
   Matrix retval;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -413,7 +413,7 @@
 {
   Matrix retval;
 
-  octave_idx_type n_out = tout.capacity ();
+  octave_idx_type n_out = tout.numel ();
   octave_idx_type n = size ();
 
   if (n_out > 0 && n > 0)
@@ -423,7 +423,7 @@
       for (octave_idx_type i = 0; i < n; i++)
         retval.elem (0, i) = x.elem (i);
 
-      octave_idx_type n_crit = tcrit.capacity ();
+      octave_idx_type n_crit = tcrit.numel ();
 
       if (n_crit > 0)
         {
--- a/liboctave/numeric/LSODE.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/LSODE.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_LSODE_h)
+#if ! defined (octave_LSODE_h)
 #define octave_LSODE_h 1
 
 #include <cfloat>
--- a/liboctave/numeric/ODE.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/ODE.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ODE_h)
+#if ! defined (octave_ODE_h)
 #define octave_ODE_h 1
 
 #include "ODEFunc.h"
--- a/liboctave/numeric/ODEFunc.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/ODEFunc.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ODEFunc_h)
+#if ! defined (octave_ODEFunc_h)
 #define octave_ODEFunc_h 1
 
 class Matrix;
--- a/liboctave/numeric/ODES.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/ODES.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -31,7 +31,7 @@
 ODES::initialize (const ColumnVector& xx, double tt)
 {
   base_diff_eqn::initialize (xx, tt);
-  xdot = ColumnVector (xx.length (), 0.0);
+  xdot = ColumnVector (xx.numel (), 0.0);
 }
 
 void
@@ -39,6 +39,6 @@
                   const ColumnVector& xtheta)
 {
   base_diff_eqn::initialize (xx, tt);
-  xdot = ColumnVector (xx.length (), 0.0);
+  xdot = ColumnVector (xx.numel (), 0.0);
   theta = xtheta;
 }
--- a/liboctave/numeric/ODES.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/ODES.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ODES_h)
+#if ! defined (octave_ODES_h)
 #define octave_ODES_h 1
 
 #include "ODESFunc.h"
@@ -35,11 +35,11 @@
     : base_diff_eqn (), ODESFunc (), xdot (), theta () { }
 
   ODES (const ColumnVector& s, double tm, ODESFunc& f)
-    : base_diff_eqn (s, tm), ODESFunc (f), xdot (s.length (), 0.0), theta () { }
+    : base_diff_eqn (s, tm), ODESFunc (f), xdot (s.numel (), 0.0), theta () { }
 
   ODES (const ColumnVector& s, const ColumnVector& xtheta, double tm,
         ODESFunc& f)
-    : base_diff_eqn (s, tm), ODESFunc (f), xdot (s.length (), 0.0),
+    : base_diff_eqn (s, tm), ODESFunc (f), xdot (s.numel (), 0.0),
       theta (xtheta) { }
 
   ODES (const ODES& a)
--- a/liboctave/numeric/ODESFunc.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/ODESFunc.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_ODESFunc_h)
+#if ! defined (octave_ODESFunc_h)
 #define octave_ODESFunc_h 1
 
 #include "dMatrix.h"
--- a/liboctave/numeric/Quad.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/Quad.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -126,7 +126,7 @@
 DefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval,
                        double& abserr)
 {
-  octave_idx_type npts = singularities.capacity () + 2;
+  octave_idx_type npts = singularities.numel () + 2;
   double *points = singularities.fortran_vec ();
   double result = 0.0;
 
@@ -224,7 +224,7 @@
 FloatDefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval,
                             float& abserr)
 {
-  octave_idx_type npts = singularities.capacity () + 2;
+  octave_idx_type npts = singularities.numel () + 2;
   float *points = singularities.fortran_vec ();
   float result = 0.0;
 
--- a/liboctave/numeric/Quad.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/Quad.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_Quad_h)
+#if ! defined (octave_Quad_h)
 #define octave_Quad_h 1
 
 #include <cfloat>
--- a/liboctave/numeric/SparseCmplxCHOL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/SparseCmplxCHOL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_SparseCmplxCHOL_h)
+#if ! defined (octave_SparseCmplxCHOL_h)
 #define octave_SparseCmplxCHOL_h 1
 
 #include "sparse-base-chol.h"
--- a/liboctave/numeric/SparseCmplxLU.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/SparseCmplxLU.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -58,7 +58,7 @@
   double tmp = octave_sparse_params::get_key ("spumoni");
   if (!xisnan (tmp))
     Control (UMFPACK_PRL) = tmp;
-  if (piv_thres.nelem () == 2)
+  if (piv_thres.numel () == 2)
     {
       tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0));
       if (!xisnan (tmp))
@@ -267,7 +267,7 @@
       double tmp = octave_sparse_params::get_key ("spumoni");
       if (!xisnan (tmp))
         Control (UMFPACK_PRL) = tmp;
-      if (piv_thres.nelem () == 2)
+      if (piv_thres.numel () == 2)
         {
           tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0));
           if (!xisnan (tmp))
--- a/liboctave/numeric/SparseCmplxLU.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/SparseCmplxLU.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_SparseCmplxLU_h)
+#if ! defined (octave_SparseCmplxLU_h)
 #define octave_SparseCmplxLU_h 1
 
 #include "sparse-base-lu.h"
--- a/liboctave/numeric/SparseCmplxQR.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/SparseCmplxQR.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -29,7 +29,7 @@
 #include "SparseCmplxQR.h"
 #include "oct-locbuf.h"
 
-#if defined(CS_VER) && (((CS_VER == 2) && (CS_SUBVER < 2)) || (CS_VER < 2))
+#if defined (CS_VER) && (((CS_VER == 2) && (CS_SUBVER < 2)) || (CS_VER < 2))
 typedef double _Complex cs_complex_t;
 
 // Why did g++ 4.x stl_vector.h make
--- a/liboctave/numeric/SparseCmplxQR.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/SparseCmplxQR.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_SparseCmplxQR_h)
+#if ! defined (octave_SparseCmplxQR_h)
 #define octave_SparseCmplxQR_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/SparseQR.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/SparseQR.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_SparseQR_h)
+#if ! defined (octave_SparseQR_h)
 #define octave_SparseQR_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/SparsedbleCHOL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/SparsedbleCHOL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_SparsedbleCHOL_h)
+#if ! defined (octave_SparsedbleCHOL_h)
 #define octave_SparsedbleCHOL_h 1
 
 #include "sparse-base-chol.h"
--- a/liboctave/numeric/SparsedbleLU.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/SparsedbleLU.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -57,7 +57,7 @@
   if (!xisnan (tmp))
     Control (UMFPACK_PRL) = tmp;
 
-  if (piv_thres.nelem () == 2)
+  if (piv_thres.numel () == 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.numel () == 2)
         {
           tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0));
           if (!xisnan (tmp))
--- a/liboctave/numeric/SparsedbleLU.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/SparsedbleLU.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_SparsedbleLU_h)
+#if ! defined (octave_SparsedbleLU_h)
 #define octave_SparsedbleLU_h 1
 
 #include "sparse-base-lu.h"
--- a/liboctave/numeric/base-aepbal.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/base-aepbal.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_base_aepbal_h)
+#if ! defined (octave_base_aepbal_h)
 #define octave_base_aepbal_h 1
 
 template <class MatrixT, class VectorT>
--- a/liboctave/numeric/base-dae.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/base-dae.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_base_dae_h)
+#if ! defined (octave_base_dae_h)
 #define octave_base_dae_h 1
 
 #include "base-de.h"
@@ -34,7 +34,7 @@
     : base_diff_eqn (), xdot () { }
 
   base_diff_alg_eqn (const ColumnVector& xx, double tt)
-    : base_diff_eqn (xx, tt), xdot (xx.length (), 0.0) { }
+    : base_diff_eqn (xx, tt), xdot (xx.numel (), 0.0) { }
 
   base_diff_alg_eqn (const ColumnVector& xx, const ColumnVector& xxdot,
                      double tt)
@@ -58,7 +58,7 @@
   void initialize (const ColumnVector& x0, double t0)
   {
     base_diff_eqn::initialize (x0, t0);
-    xdot = ColumnVector (x0.length (), 0.0);
+    xdot = ColumnVector (x0.numel (), 0.0);
   }
 
   void initialize (const ColumnVector& x0, const ColumnVector& xdot0,
--- a/liboctave/numeric/base-de.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/base-de.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_base_de_h)
+#if ! defined (octave_base_de_h)
 #define octave_base_de_h 1
 
 #include <string>
@@ -72,7 +72,7 @@
     force_restart ();
   }
 
-  octave_idx_type size (void) const { return x.capacity (); }
+  octave_idx_type size (void) const { return x.numel (); }
 
   ColumnVector state (void) const { return x; }
 
--- a/liboctave/numeric/base-lu.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/base-lu.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -129,7 +129,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.numel (); i++)
         {
           octave_idx_type k = ipvt.xelem (i);
 
--- a/liboctave/numeric/base-lu.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/base-lu.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_base_lu_h)
+#if ! defined (octave_base_lu_h)
 #define octave_base_lu_h 1
 
 #include "MArray.h"
--- a/liboctave/numeric/base-min.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/base-min.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_base_min_h)
+#if ! defined (octave_base_min_h)
 #define octave_base_min_h 1
 
 #include "dColVector.h"
@@ -114,7 +114,7 @@
     return do_minimize (objf, inform, lambda);
   }
 
-  octave_idx_type size (void) const { return x.capacity (); }
+  octave_idx_type size (void) const { return x.numel (); }
 
 protected:
 
--- a/liboctave/numeric/base-qr.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/base-qr.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_base_qr_h)
+#if ! defined (octave_base_qr_h)
 #define octave_base_qr_h 1
 
 #include "MArray.h"
--- a/liboctave/numeric/bsxfun-decl.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/bsxfun-decl.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_bsxfun_decl_h)
+#if ! defined (octave_bsxfun_decl_h)
 #define octave_bsxfun_decl_h 1
 
 #define BSXFUN_OP_DECL(OP, ARRAY, API) \
--- a/liboctave/numeric/bsxfun-defs.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/bsxfun-defs.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_bsxfun_defs_h)
+#if ! defined (octave_bsxfun_defs_h)
 #define octave_bsxfun_defs_h 1
 
 #include <algorithm>
--- a/liboctave/numeric/bsxfun.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/bsxfun.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 // Author: Jordi Gutiérrez Hermoso <jordigh@octave.org>
 
-#if !defined (octave_bsxfun_h)
+#if ! defined (octave_bsxfun_h)
 #define octave_bsxfun_h 1
 
 #include <algorithm>
--- a/liboctave/numeric/dbleAEPBAL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/dbleAEPBAL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_dbleAEPBAL_h)
+#if ! defined (octave_dbleAEPBAL_h)
 #define octave_dbleAEPBAL_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/dbleCHOL.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/dbleCHOL.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -87,7 +87,7 @@
 }
 
 octave_idx_type
-CHOL::init (const Matrix& a, bool calc_cond)
+CHOL::init (const Matrix& a, bool upper, bool calc_cond)
 {
   octave_idx_type a_nr = a.rows ();
   octave_idx_type a_nc = a.cols ();
@@ -101,14 +101,25 @@
   octave_idx_type n = a_nc;
   octave_idx_type info;
 
+  is_upper = upper;
+
   chol_mat.clear (n, n);
-  for (octave_idx_type j = 0; j < n; j++)
-    {
-      for (octave_idx_type i = 0; i <= j; i++)
-        chol_mat.xelem (i, j) = a(i, j);
-      for (octave_idx_type i = j+1; i < n; i++)
-        chol_mat.xelem (i, j) = 0.0;
-    }
+  if (is_upper)
+    for (octave_idx_type j = 0; j < n; j++)
+      {
+        for (octave_idx_type i = 0; i <= j; i++)
+          chol_mat.xelem (i, j) = a(i, j);
+        for (octave_idx_type i = j+1; i < n; i++)
+          chol_mat.xelem (i, j) = 0.0;
+      }
+  else
+    for (octave_idx_type j = 0; j < n; j++)
+      {
+        for (octave_idx_type i = 0; i < j; i++)
+          chol_mat.xelem (i, j) = 0.0;
+        for (octave_idx_type i = j; i < n; i++)
+          chol_mat.xelem (i, j) = a(i, j);
+      }
   double *h = chol_mat.fortran_vec ();
 
   // Calculate the norm of the matrix, for later use.
@@ -116,9 +127,12 @@
   if (calc_cond)
     anorm = xnorm (a, 1);
 
-  F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1),
-                             n, h, n, info
-                             F77_CHAR_ARG_LEN (1)));
+  if (is_upper)
+    F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n, h, n, info
+                               F77_CHAR_ARG_LEN (1)));
+  else
+    F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 ("L", 1), n, h, n, info
+                               F77_CHAR_ARG_LEN (1)));
 
   xrcond = 0.0;
   if (info > 0)
@@ -132,9 +146,14 @@
       double *pz = z.fortran_vec ();
       Array<octave_idx_type> iz (dim_vector (n, 1));
       octave_idx_type *piz = iz.fortran_vec ();
-      F77_XFCN (dpocon, DPOCON, (F77_CONST_CHAR_ARG2 ("U", 1), n, h,
-                                 n, anorm, xrcond, pz, piz, dpocon_info
-                                 F77_CHAR_ARG_LEN (1)));
+      if (is_upper)
+        F77_XFCN (dpocon, DPOCON, (F77_CONST_CHAR_ARG2 ("U", 1), n, h,
+                                   n, anorm, xrcond, pz, piz, dpocon_info
+                                   F77_CHAR_ARG_LEN (1)));
+      else
+        F77_XFCN (dpocon, DPOCON, (F77_CONST_CHAR_ARG2 ("L", 1), n, h,
+                                   n, anorm, xrcond, pz, piz, dpocon_info
+                                   F77_CHAR_ARG_LEN (1)));
 
       if (dpocon_info != 0)
         info = -1;
@@ -144,7 +163,7 @@
 }
 
 static Matrix
-chol2inv_internal (const Matrix& r)
+chol2inv_internal (const Matrix& r, bool is_upper = true)
 {
   Matrix retval;
 
@@ -161,17 +180,29 @@
 
       if (info == 0)
         {
-          F77_XFCN (dpotri, DPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
-                                     v, n, info
-                                     F77_CHAR_ARG_LEN (1)));
+          if (is_upper)
+            F77_XFCN (dpotri, DPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
+                                       v, n, info
+                                       F77_CHAR_ARG_LEN (1)));
+          else
+            F77_XFCN (dpotri, DPOTRI, (F77_CONST_CHAR_ARG2 ("L", 1), n,
+                                       v, n, info
+                                       F77_CHAR_ARG_LEN (1)));
 
           // If someone thinks of a more graceful way of doing this (or
           // faster for that matter :-)), please let me know!
 
           if (n > 1)
-            for (octave_idx_type j = 0; j < r_nc; j++)
-              for (octave_idx_type i = j+1; i < r_nr; i++)
-                tmp.xelem (i, j) = tmp.xelem (j, i);
+            {
+              if (is_upper)
+                for (octave_idx_type j = 0; j < r_nc; j++)
+                  for (octave_idx_type i = j+1; i < r_nr; i++)
+                    tmp.xelem (i, j) = tmp.xelem (j, i);
+              else
+                for (octave_idx_type j = 0; j < r_nc; j++)
+                  for (octave_idx_type i = j+1; i < r_nr; i++)
+                    tmp.xelem (j, i) = tmp.xelem (i, j);
+            }
 
           retval = tmp;
         }
@@ -186,7 +217,7 @@
 Matrix
 CHOL::inverse (void) const
 {
-  return chol2inv_internal (chol_mat);
+  return chol2inv_internal (chol_mat, is_upper);
 }
 
 void
@@ -205,7 +236,7 @@
 {
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       ColumnVector utmp = u;
 
@@ -225,7 +256,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       ColumnVector utmp = u;
 
@@ -247,7 +278,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () != n + 1)
+  if (u.numel () != n + 1)
     (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("cholinsert: index out of range");
@@ -309,10 +340,10 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       init (chol_mat.transpose () * chol_mat
-            + Matrix (u) * Matrix (u).transpose (), false);
+            + Matrix (u) * Matrix (u).transpose (), true, false);
     }
   else
     (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
@@ -335,14 +366,14 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       if (singular (chol_mat))
         info = 2;
       else
         {
           info = init (chol_mat.transpose () * chol_mat
-                       - Matrix (u) * Matrix (u).transpose (), false);
+                       - Matrix (u) * Matrix (u).transpose (), true, false);
           if (info) info = 1;
         }
     }
@@ -361,7 +392,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () != n + 1)
+  if (u.numel () != n + 1)
     (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("cholinsert: index out of range");
@@ -383,7 +414,7 @@
                 else
                   a1(k, l) = a(k < j ? k : k-1, l < j ? l : l-1);
               }
-          info = init (a1, false);
+          info = init (a1, true, false);
           if (info) info = 1;
         }
     }
@@ -405,7 +436,7 @@
       Matrix a = chol_mat.transpose () * chol_mat;
       a.delete_elements (1, idx_vector (j));
       a.delete_elements (0, idx_vector (j));
-      init (a, false);
+      init (a, true, false);
     }
 }
 
@@ -434,7 +465,7 @@
           for (octave_idx_type k = j+1; k < i+1; k++) p(k) = k-1;
         }
 
-      init (a.index (idx_vector (p), idx_vector (p)), false);
+      init (a.index (idx_vector (p), idx_vector (p)), true, false);
     }
 }
 
--- a/liboctave/numeric/dbleCHOL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/dbleCHOL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_dbleCHOL_h)
+#if ! defined (octave_dbleCHOL_h)
 #define octave_dbleCHOL_h 1
 
 #include <iosfwd>
@@ -37,16 +37,16 @@
 
   CHOL (void) : chol_mat (), xrcond (0) { }
 
-  CHOL (const Matrix& a, bool calc_cond = false)
+  CHOL (const Matrix& a, bool upper = true, bool calc_cond = false)
     : chol_mat (), xrcond (0)
   {
-    init (a, calc_cond);
+    init (a, upper, calc_cond);
   }
 
-  CHOL (const Matrix& a, octave_idx_type& info, bool calc_cond = false)
-    : chol_mat (), xrcond (0)
+  CHOL (const Matrix& a, octave_idx_type& info, bool upper = true,
+        bool calc_cond = false) : chol_mat (), xrcond (0)
   {
-    info = init (a, calc_cond);
+    info = init (a, upper, calc_cond);
   }
 
   CHOL (const CHOL& a) : chol_mat (a.chol_mat), xrcond (a.xrcond) { }
@@ -88,7 +88,9 @@
 
   double xrcond;
 
-  octave_idx_type init (const Matrix& a, bool calc_cond);
+  bool is_upper;
+
+  octave_idx_type init (const Matrix& a, bool upper, bool calc_cond);
 };
 
 Matrix OCTAVE_API chol2inv (const Matrix& r);
--- a/liboctave/numeric/dbleGEPBAL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/dbleGEPBAL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_dbleGEPBAL_h)
+#if ! defined (octave_dbleGEPBAL_h)
 #define octave_dbleGEPBAL_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/dbleHESS.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/dbleHESS.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_dbleHESS_h)
+#if ! defined (octave_dbleHESS_h)
 #define octave_dbleHESS_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/dbleLU.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/dbleLU.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -97,7 +97,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = l.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       ColumnVector utmp = u;
       ColumnVector vtmp = v;
@@ -147,7 +147,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = l.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       ColumnVector utmp = u;
       ColumnVector vtmp = v;
--- a/liboctave/numeric/dbleLU.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/dbleLU.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_dbleLU_h)
+#if ! defined (octave_dbleLU_h)
 #define octave_dbleLU_h 1
 
 #include "base-lu.h"
--- a/liboctave/numeric/dbleQR.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/dbleQR.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -213,7 +213,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = q.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       ColumnVector utmp = u;
       ColumnVector vtmp = v;
@@ -257,7 +257,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = q.columns ();
 
-  if (u.length () != m)
+  if (u.numel () != m)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -290,14 +290,14 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, ASCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
 
   if (dups)
     (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
-  else if (u.length () != m || u.columns () != nj)
+  else if (u.numel () != m || u.columns () != nj)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (nj > 0 && (js(0) < 0 || js(nj-1) > n))
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -315,7 +315,7 @@
         }
 
       OCTAVE_LOCAL_BUFFER (double, w, kmax);
-      for (volatile octave_idx_type i = 0; i < js.length (); i++)
+      for (volatile octave_idx_type i = 0; i < js.numel (); i++)
         {
           octave_idx_type ii = i;
           ColumnVector utmp = u.column (jsi(i));
@@ -363,7 +363,7 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, DESCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
@@ -375,7 +375,7 @@
   else if (nj > 0)
     {
       OCTAVE_LOCAL_BUFFER (double, w, k);
-      for (volatile octave_idx_type i = 0; i < js.length (); i++)
+      for (volatile octave_idx_type i = 0; i < js.numel (); i++)
         {
           octave_idx_type ii = i;
           F77_XFCN (dqrdec, DQRDEC, (m, n - ii, k == m ? k : k - ii,
@@ -403,7 +403,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = std::min (m, n);
 
-  if (! q.is_square () || u.length () != n)
+  if (! q.is_square () || u.numel () != n)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > m)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -473,7 +473,7 @@
   octave_idx_type m = q.rows ();
   octave_idx_type n = r.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       init (q*r + Matrix (u) * Matrix (v).transpose (), get_type ());
     }
@@ -568,7 +568,7 @@
   octave_idx_type m = q.rows ();
   octave_idx_type n = r.columns ();
 
-  if (u.length () != m)
+  if (u.numel () != m)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -588,21 +588,21 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, ASCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
 
   if (dups)
     (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
-  else if (u.length () != m || u.columns () != nj)
+  else if (u.numel () != m || u.columns () != nj)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (nj > 0 && (js(0) < 0 || js(nj-1) > n))
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
   else if (nj > 0)
     {
       Matrix a = q*r;
-      for (octave_idx_type i = 0; i < js.length (); i++)
+      for (octave_idx_type i = 0; i < js.numel (); i++)
         a = ::insert_col (a, js(i), u.column (i));
       init (a, get_type ());
     }
@@ -632,7 +632,7 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, DESCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
@@ -644,7 +644,7 @@
   else if (nj > 0)
     {
       Matrix a = q*r;
-      for (octave_idx_type i = 0; i < js.length (); i++)
+      for (octave_idx_type i = 0; i < js.numel (); i++)
         a = ::delete_col (a, js(i));
       init (a, get_type ());
     }
@@ -658,7 +658,7 @@
   octave_idx_type m = r.rows ();
   octave_idx_type n = r.columns ();
 
-  if (! q.is_square () || u.length () != n)
+  if (! q.is_square () || u.numel () != n)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > m)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
--- a/liboctave/numeric/dbleQR.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/dbleQR.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_dbleQR_h)
+#if ! defined (octave_dbleQR_h)
 #define octave_dbleQR_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/dbleQRP.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/dbleQRP.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_dbleQRP_h)
+#if ! defined (octave_dbleQRP_h)
 #define octave_dbleQRP_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/dbleSCHUR.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/dbleSCHUR.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_dbleSCHUR_h)
+#if ! defined (octave_dbleSCHUR_h)
 #define octave_dbleSCHUR_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/dbleSVD.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/dbleSVD.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_dbleSVD_h)
+#if ! defined (octave_dbleSVD_h)
 #define octave_dbleSVD_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/eigs-base.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/eigs-base.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -166,7 +166,7 @@
 }
 
 
-#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
+#if ! defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
 static octave_idx_type
 lusolve (const SparseMatrix&, const SparseMatrix&, Matrix&);
 
@@ -445,7 +445,7 @@
     {
       if (cholB)
         {
-          if (permB.length ())
+          if (permB.numel ())
             {
               SparseMatrix tmp(n,n,n);
               for (octave_idx_type i = 0; i < n; i++)
@@ -457,15 +457,14 @@
                 }
               tmp.xcidx (n) = n;
 
-              AminusSigmaB = AminusSigmaB - sigma * tmp *
-                             b.transpose () * b * tmp.transpose ();
+              AminusSigmaB -= sigma * tmp *
+                              b.transpose () * b * tmp.transpose ();
             }
           else
-            AminusSigmaB = AminusSigmaB - sigma *
-                           b.transpose () * b;
+            AminusSigmaB -= sigma * b.transpose () * b;
         }
       else
-        AminusSigmaB = AminusSigmaB - sigma * b;
+        AminusSigmaB -= sigma * b;
     }
   else
     {
@@ -480,7 +479,7 @@
           sigmat.xcidx (i+1) = i + 1;
         }
 
-      AminusSigmaB = AminusSigmaB - sigmat;
+      AminusSigmaB -= sigmat;
     }
 
   SparseLU fact (AminusSigmaB);
@@ -542,7 +541,7 @@
           const double *pB = permB.fortran_vec ();
           double *p = AminusSigmaB.fortran_vec ();
 
-          if (permB.length ())
+          if (permB.numel ())
             {
               for (octave_idx_type j = 0;
                    j < b.cols (); j++)
@@ -552,10 +551,10 @@
                                      static_cast<octave_idx_type>(pB[j]));
             }
           else
-            AminusSigmaB = AminusSigmaB - tmp;
+            AminusSigmaB -= tmp;
         }
       else
-        AminusSigmaB = AminusSigmaB - sigma * b;
+        AminusSigmaB -= sigma * b;
     }
   else
     {
@@ -610,7 +609,7 @@
     {
       if (cholB)
         {
-          if (permB.length ())
+          if (permB.numel ())
             {
               SparseMatrix tmp(n,n,n);
               for (octave_idx_type i = 0; i < n; i++)
@@ -622,14 +621,14 @@
                 }
               tmp.xcidx (n) = n;
 
-              AminusSigmaB = AminusSigmaB - tmp * b.hermitian () * b *
-                             tmp.transpose () * sigma;
+              AminusSigmaB -= tmp * b.hermitian () * b *
+                              tmp.transpose () * sigma;
             }
           else
-            AminusSigmaB = AminusSigmaB - sigma * b.hermitian () * b;
+            AminusSigmaB -= sigma * b.hermitian () * b;
         }
       else
-        AminusSigmaB = AminusSigmaB - sigma * b;
+        AminusSigmaB -= sigma * b;
     }
   else
     {
@@ -644,7 +643,7 @@
           sigmat.xcidx (i+1) = i + 1;
         }
 
-      AminusSigmaB = AminusSigmaB - sigmat;
+      AminusSigmaB -= sigmat;
     }
 
   SparseComplexLU fact (AminusSigmaB);
@@ -706,7 +705,7 @@
           const double *pB = permB.fortran_vec ();
           Complex *p = AminusSigmaB.fortran_vec ();
 
-          if (permB.length ())
+          if (permB.numel ())
             {
               for (octave_idx_type j = 0;
                    j < b.cols (); j++)
@@ -716,10 +715,10 @@
                                      static_cast<octave_idx_type>(pB[j]));
             }
           else
-            AminusSigmaB = AminusSigmaB - tmp;
+            AminusSigmaB -= tmp;
         }
       else
-        AminusSigmaB = AminusSigmaB - sigma * b;
+        AminusSigmaB -= sigma * b;
     }
   else
     {
@@ -830,10 +829,10 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.length () != 0)
+  if (have_b && cholB && permB.numel () != 0)
     {
       // Check the we really have a permutation vector
-      if (permB.length () != n)
+      if (permB.numel () != n)
         {
           (*current_liboctave_error_handler)
             ("eigs: permB vector invalid");
@@ -881,7 +880,7 @@
         {
           bt = b;
           b = b.transpose ();
-          if (permB.length () == 0)
+          if (permB.numel () == 0)
             {
               permB = ColumnVector (n);
               for (octave_idx_type i = 0; i < n; i++)
@@ -1154,10 +1153,10 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.length () != 0)
+  if (have_b && cholB && permB.numel () != 0)
     {
       // Check the we really have a permutation vector
-      if (permB.length () != n)
+      if (permB.numel () != n)
         {
           (*current_liboctave_error_handler) ("eigs: permB vector invalid");
           return -1;
@@ -1744,10 +1743,10 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.length () != 0)
+  if (have_b && cholB && permB.numel () != 0)
     {
       // Check the we really have a permutation vector
-      if (permB.length () != n)
+      if (permB.numel () != n)
         {
           (*current_liboctave_error_handler)
             ("eigs: permB vector invalid");
@@ -1795,7 +1794,7 @@
         {
           bt = b;
           b = b.transpose ();
-          if (permB.length () == 0)
+          if (permB.numel () == 0)
             {
               permB = ColumnVector (n);
               for (octave_idx_type i = 0; i < n; i++)
@@ -2117,10 +2116,10 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.length () != 0)
+  if (have_b && cholB && permB.numel () != 0)
     {
       // Check that we really have a permutation vector
-      if (permB.length () != n)
+      if (permB.numel () != n)
         {
           (*current_liboctave_error_handler) ("eigs: permB vector invalid");
           return -1;
@@ -2812,10 +2811,10 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.length () != 0)
+  if (have_b && cholB && permB.numel () != 0)
     {
       // Check the we really have a permutation vector
-      if (permB.length () != n)
+      if (permB.numel () != n)
         {
           (*current_liboctave_error_handler)
             ("eigs: permB vector invalid");
@@ -2863,7 +2862,7 @@
         {
           bt = b;
           b = b.hermitian ();
-          if (permB.length () == 0)
+          if (permB.numel () == 0)
             {
               permB = ColumnVector (n);
               for (octave_idx_type i = 0; i < n; i++)
@@ -3137,10 +3136,10 @@
       return -1;
     }
 
-  if (have_b && cholB && permB.length () != 0)
+  if (have_b && cholB && permB.numel () != 0)
     {
       // Check that we really have a permutation vector
-      if (permB.length () != n)
+      if (permB.numel () != n)
         {
           (*current_liboctave_error_handler) ("eigs: permB vector invalid");
           return -1;
@@ -3657,7 +3656,7 @@
   return ip(4);
 }
 
-#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
+#if ! defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
 extern octave_idx_type
 EigsRealSymmetricMatrix (const Matrix& m, const std::string typ,
                          octave_idx_type k, octave_idx_type p,
--- a/liboctave/numeric/fCmplxAEPBAL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fCmplxAEPBAL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_fCmplxAEPBAL_h)
+#if ! defined (octave_fCmplxAEPBAL_h)
 #define octave_fCmplxAEPBAL_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/fCmplxCHOL.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fCmplxCHOL.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -86,7 +86,7 @@
 }
 
 octave_idx_type
-FloatComplexCHOL::init (const FloatComplexMatrix& a, bool calc_cond)
+FloatComplexCHOL::init (const FloatComplexMatrix& a, bool upper, bool calc_cond)
 {
   octave_idx_type a_nr = a.rows ();
   octave_idx_type a_nc = a.cols ();
@@ -101,14 +101,25 @@
   octave_idx_type n = a_nc;
   octave_idx_type info;
 
+  is_upper = upper;
+
   chol_mat.clear (n, n);
-  for (octave_idx_type j = 0; j < n; j++)
-    {
-      for (octave_idx_type i = 0; i <= j; i++)
-        chol_mat.xelem (i, j) = a(i, j);
-      for (octave_idx_type i = j+1; i < n; i++)
-        chol_mat.xelem (i, j) = 0.0f;
-    }
+  if (is_upper)
+    for (octave_idx_type j = 0; j < n; j++)
+      {
+        for (octave_idx_type i = 0; i <= j; i++)
+          chol_mat.xelem (i, j) = a(i, j);
+        for (octave_idx_type i = j+1; i < n; i++)
+          chol_mat.xelem (i, j) = 0.0f;
+      }
+  else
+    for (octave_idx_type j = 0; j < n; j++)
+      {
+        for (octave_idx_type i = 0; i < j; i++)
+          chol_mat.xelem (i, j) = 0.0f;
+        for (octave_idx_type i = j; i < n; i++)
+          chol_mat.xelem (i, j) = a(i, j);
+      }
   FloatComplex *h = chol_mat.fortran_vec ();
 
   // Calculate the norm of the matrix, for later use.
@@ -116,8 +127,12 @@
   if (calc_cond)
     anorm = xnorm (a, 1);
 
-  F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n, h, n, info
-                             F77_CHAR_ARG_LEN (1)));
+  if (is_upper)
+    F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n, h, n, info
+                               F77_CHAR_ARG_LEN (1)));
+  else
+    F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 ("L", 1), n, h, n, info
+                               F77_CHAR_ARG_LEN (1)));
 
   xrcond = 0.0;
   if (info > 0)
@@ -143,7 +158,7 @@
 }
 
 static FloatComplexMatrix
-chol2inv_internal (const FloatComplexMatrix& r)
+chol2inv_internal (const FloatComplexMatrix& r, bool is_upper = true)
 {
   FloatComplexMatrix retval;
 
@@ -157,17 +172,29 @@
 
       FloatComplexMatrix tmp = r;
 
-      F77_XFCN (cpotri, CPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
-                                 tmp.fortran_vec (), n, info
-                                 F77_CHAR_ARG_LEN (1)));
+      if (is_upper)
+        F77_XFCN (cpotri, CPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
+                                   tmp.fortran_vec (), n, info
+                                   F77_CHAR_ARG_LEN (1)));
+      else
+        F77_XFCN (cpotri, CPOTRI, (F77_CONST_CHAR_ARG2 ("L", 1), n,
+                                   tmp.fortran_vec (), n, info
+                                   F77_CHAR_ARG_LEN (1)));
 
       // If someone thinks of a more graceful way of doing this (or
       // faster for that matter :-)), please let me know!
 
       if (n > 1)
-        for (octave_idx_type j = 0; j < r_nc; j++)
-          for (octave_idx_type i = j+1; i < r_nr; i++)
-            tmp.xelem (i, j) = std::conj (tmp.xelem (j, i));
+        {
+          if (is_upper)
+            for (octave_idx_type j = 0; j < r_nc; j++)
+              for (octave_idx_type i = j+1; i < r_nr; i++)
+                tmp.xelem (i, j) = tmp.xelem (j, i);
+          else
+            for (octave_idx_type j = 0; j < r_nc; j++)
+              for (octave_idx_type i = j+1; i < r_nr; i++)
+                tmp.xelem (j, i) = tmp.xelem (i, j);
+        }
 
       retval = tmp;
     }
@@ -181,7 +208,7 @@
 FloatComplexMatrix
 FloatComplexCHOL::inverse (void) const
 {
-  return chol2inv_internal (chol_mat);
+  return chol2inv_internal (chol_mat, is_upper);
 }
 
 void
@@ -200,7 +227,7 @@
 {
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       FloatComplexColumnVector utmp = u;
 
@@ -220,7 +247,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       FloatComplexColumnVector utmp = u;
 
@@ -243,7 +270,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () != n + 1)
+  if (u.numel () != n + 1)
     (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("cholinsert: index out of range");
@@ -310,7 +337,7 @@
     {
       init (chol_mat.hermitian () * chol_mat
             + FloatComplexMatrix (u) * FloatComplexMatrix (u).hermitian (),
-            false);
+            true, false);
     }
   else
     (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
@@ -342,7 +369,7 @@
           info = init (chol_mat.hermitian () * chol_mat
                        - FloatComplexMatrix (u)
                        * FloatComplexMatrix (u).hermitian (),
-                       false);
+                       true, false);
           if (info) info = 1;
         }
     }
@@ -386,7 +413,7 @@
                 else
                   a1(k, l) = a(k < j ? k : k-1, l < j ? l : l-1);
               }
-          info = init (a1, false);
+          info = init (a1, true, false);
           if (info) info = 1;
         }
     }
@@ -408,7 +435,7 @@
       FloatComplexMatrix a = chol_mat.hermitian () * chol_mat;
       a.delete_elements (1, idx_vector (j));
       a.delete_elements (0, idx_vector (j));
-      init (a, false);
+      init (a, true, false);
     }
 }
 
@@ -437,7 +464,7 @@
           for (octave_idx_type k = j+1; k < i+1; k++) p(k) = k-1;
         }
 
-      init (a.index (idx_vector (p), idx_vector (p)), false);
+      init (a.index (idx_vector (p), idx_vector (p)), true, false);
     }
 }
 
--- a/liboctave/numeric/fCmplxCHOL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fCmplxCHOL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_fCmplxCHOL_h)
+#if ! defined (octave_fCmplxCHOL_h)
 #define octave_fCmplxCHOL_h 1
 
 #include <iosfwd>
@@ -37,17 +37,18 @@
 
   FloatComplexCHOL (void) : chol_mat (), xrcond (0) { }
 
-  FloatComplexCHOL (const FloatComplexMatrix& a, bool calc_cond = false)
+  FloatComplexCHOL (const FloatComplexMatrix& a, bool upper = true,
+                    bool calc_cond = false)
     : chol_mat (), xrcond (0)
   {
-    init (a, calc_cond);
+    init (a, upper, calc_cond);
   }
 
   FloatComplexCHOL (const FloatComplexMatrix& a, octave_idx_type& info,
-                    bool calc_cond = false)
+                    bool upper = true, bool calc_cond = false)
     : chol_mat (), xrcond (0)
   {
-    info = init (a, calc_cond);
+    info = init (a, upper, calc_cond);
   }
 
   FloatComplexCHOL (const FloatComplexCHOL& a)
@@ -92,7 +93,9 @@
 
   float xrcond;
 
-  octave_idx_type init (const FloatComplexMatrix& a, bool calc_cond);
+  bool is_upper;
+
+  octave_idx_type init (const FloatComplexMatrix& a, bool upper, bool calc_cond);
 };
 
 FloatComplexMatrix OCTAVE_API chol2inv (const FloatComplexMatrix& r);
--- a/liboctave/numeric/fCmplxGEPBAL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fCmplxGEPBAL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fCmplxGEPBAL_h)
+#if ! defined (octave_fCmplxGEPBAL_h)
 #define octave_fCmplxGEPBAL_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/fCmplxHESS.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fCmplxHESS.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fCmplxHESS_h)
+#if ! defined (octave_fCmplxHESS_h)
 #define octave_fCmplxHESS_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/fCmplxLU.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fCmplxLU.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -98,7 +98,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = l.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       FloatComplexColumnVector utmp = u;
       FloatComplexColumnVector vtmp = v;
@@ -150,7 +150,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = l.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       FloatComplexColumnVector utmp = u;
       FloatComplexColumnVector vtmp = v;
--- a/liboctave/numeric/fCmplxLU.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fCmplxLU.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fCmplxLU_h)
+#if ! defined (octave_fCmplxLU_h)
 #define octave_fCmplxLU_h 1
 
 #include "base-lu.h"
--- a/liboctave/numeric/fCmplxQR.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fCmplxQR.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -216,7 +216,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = q.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       FloatComplexColumnVector utmp = u;
       FloatComplexColumnVector vtmp = v;
@@ -265,7 +265,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = q.columns ();
 
-  if (u.length () != m)
+  if (u.numel () != m)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -299,14 +299,14 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, ASCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
 
   if (dups)
     (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
-  else if (u.length () != m || u.columns () != nj)
+  else if (u.numel () != m || u.columns () != nj)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (nj > 0 && (js(0) < 0 || js(nj-1) > n))
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -324,7 +324,7 @@
         }
 
       OCTAVE_LOCAL_BUFFER (float, rw, kmax);
-      for (volatile octave_idx_type i = 0; i < js.length (); i++)
+      for (volatile octave_idx_type i = 0; i < js.numel (); i++)
         {
           octave_idx_type ii = i;
           F77_XFCN (cqrinc, CQRINC, (m, n + ii, std::min (kmax, k + ii),
@@ -371,7 +371,7 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, DESCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
@@ -383,7 +383,7 @@
   else if (nj > 0)
     {
       OCTAVE_LOCAL_BUFFER (float, rw, k);
-      for (volatile octave_idx_type i = 0; i < js.length (); i++)
+      for (volatile octave_idx_type i = 0; i < js.numel (); i++)
         {
           octave_idx_type ii = i;
           F77_XFCN (cqrdec, CQRDEC, (m, n - ii, k == m ? k : k - ii,
@@ -411,7 +411,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = std::min (m, n);
 
-  if (! q.is_square () || u.length () != n)
+  if (! q.is_square () || u.numel () != n)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > m)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -484,7 +484,7 @@
   octave_idx_type m = q.rows ();
   octave_idx_type n = r.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       init (q*r + FloatComplexMatrix (u) * FloatComplexMatrix (v).hermitian (),
             get_type ());
@@ -582,7 +582,7 @@
   octave_idx_type m = q.rows ();
   octave_idx_type n = r.columns ();
 
-  if (u.length () != m)
+  if (u.numel () != m)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -603,21 +603,21 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, ASCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
 
   if (dups)
     (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
-  else if (u.length () != m || u.columns () != nj)
+  else if (u.numel () != m || u.columns () != nj)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (nj > 0 && (js(0) < 0 || js(nj-1) > n))
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
   else if (nj > 0)
     {
       FloatComplexMatrix a = q*r;
-      for (octave_idx_type i = 0; i < js.length (); i++)
+      for (octave_idx_type i = 0; i < js.numel (); i++)
         a = ::insert_col (a, js(i), u.column (i));
       init (a, get_type ());
     }
@@ -647,7 +647,7 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, DESCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
@@ -659,7 +659,7 @@
   else if (nj > 0)
     {
       FloatComplexMatrix a = q*r;
-      for (octave_idx_type i = 0; i < js.length (); i++)
+      for (octave_idx_type i = 0; i < js.numel (); i++)
         a = ::delete_col (a, js(i));
       init (a, get_type ());
     }
@@ -673,7 +673,7 @@
   octave_idx_type m = r.rows ();
   octave_idx_type n = r.columns ();
 
-  if (! q.is_square () || u.length () != n)
+  if (! q.is_square () || u.numel () != n)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > m)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
--- a/liboctave/numeric/fCmplxQR.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fCmplxQR.h	Thu Dec 10 12:50:06 2015 -0800
@@ -23,7 +23,7 @@
 
 // updating/downdating by Jaroslav Hajek 2008
 
-#if !defined (octave_fCmplxQR_h)
+#if ! defined (octave_fCmplxQR_h)
 #define octave_fCmplxQR_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/fCmplxQRP.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fCmplxQRP.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fCmplxQRP_h)
+#if ! defined (octave_fCmplxQRP_h)
 #define octave_fCmplxQRP_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/fCmplxSCHUR.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fCmplxSCHUR.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fCmplxSCHUR_h)
+#if ! defined (octave_fCmplxSCHUR_h)
 #define octave_fCmplxSCHUR_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/fCmplxSVD.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fCmplxSVD.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fCmplxSVD_h)
+#if ! defined (octave_fCmplxSVD_h)
 #define octave_fCmplxSVD_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/fEIG.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fEIG.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -712,7 +712,7 @@
                              F77_CHAR_ARG_LEN (1)));
 
   if (a.is_hermitian () && b.is_hermitian () && info == 0)
-    return hermitian_init (a, calc_ev);
+    return hermitian_init (a, b, calc_ev);
 
   FloatComplexMatrix atmp = a;
   FloatComplex *atmp_data = atmp.fortran_vec ();
--- a/liboctave/numeric/fEIG.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/fEIG.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_fEIG_h)
+#if ! defined (octave_fEIG_h)
 #define octave_fEIG_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/floatAEPBAL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/floatAEPBAL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_floatAEPBAL_h)
+#if ! defined (octave_floatAEPBAL_h)
 #define octave_floatAEPBAL_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/floatCHOL.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/floatCHOL.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -87,7 +87,7 @@
 }
 
 octave_idx_type
-FloatCHOL::init (const FloatMatrix& a, bool calc_cond)
+FloatCHOL::init (const FloatMatrix& a, bool upper, bool calc_cond)
 {
   octave_idx_type a_nr = a.rows ();
   octave_idx_type a_nc = a.cols ();
@@ -101,14 +101,25 @@
   octave_idx_type n = a_nc;
   octave_idx_type info;
 
+  is_upper = upper;
+
   chol_mat.clear (n, n);
-  for (octave_idx_type j = 0; j < n; j++)
-    {
-      for (octave_idx_type i = 0; i <= j; i++)
-        chol_mat.xelem (i, j) = a(i, j);
-      for (octave_idx_type i = j+1; i < n; i++)
-        chol_mat.xelem (i, j) = 0.0f;
-    }
+  if (is_upper)
+    for (octave_idx_type j = 0; j < n; j++)
+      {
+        for (octave_idx_type i = 0; i <= j; i++)
+          chol_mat.xelem (i, j) = a(i, j);
+        for (octave_idx_type i = j+1; i < n; i++)
+          chol_mat.xelem (i, j) = 0.0f;
+      }
+  else
+    for (octave_idx_type j = 0; j < n; j++)
+      {
+        for (octave_idx_type i = 0; i < j; i++)
+          chol_mat.xelem (i, j) = 0.0f;
+        for (octave_idx_type i = j; i < n; i++)
+          chol_mat.xelem (i, j) = a(i, j);
+      }
   float *h = chol_mat.fortran_vec ();
 
   // Calculate the norm of the matrix, for later use.
@@ -116,9 +127,12 @@
   if (calc_cond)
     anorm = xnorm (a, 1);
 
-  F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1),
-                             n, h, n, info
-                             F77_CHAR_ARG_LEN (1)));
+  if (is_upper)
+    F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n, h, n, info
+                               F77_CHAR_ARG_LEN (1)));
+  else
+    F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 ("L", 1), n, h, n, info
+                               F77_CHAR_ARG_LEN (1)));
 
   xrcond = 0.0;
   if (info > 0)
@@ -132,9 +146,14 @@
       float *pz = z.fortran_vec ();
       Array<octave_idx_type> iz (dim_vector (n, 1));
       octave_idx_type *piz = iz.fortran_vec ();
-      F77_XFCN (spocon, SPOCON, (F77_CONST_CHAR_ARG2 ("U", 1), n, h,
-                                 n, anorm, xrcond, pz, piz, spocon_info
-                                 F77_CHAR_ARG_LEN (1)));
+      if (is_upper)
+        F77_XFCN (spocon, SPOCON, (F77_CONST_CHAR_ARG2 ("U", 1), n, h,
+                                   n, anorm, xrcond, pz, piz, spocon_info
+                                   F77_CHAR_ARG_LEN (1)));
+      else
+        F77_XFCN (spocon, SPOCON, (F77_CONST_CHAR_ARG2 ("L", 1), n, h,
+                                   n, anorm, xrcond, pz, piz, spocon_info
+                                   F77_CHAR_ARG_LEN (1)));
 
       if (spocon_info != 0)
         info = -1;
@@ -144,7 +163,7 @@
 }
 
 static FloatMatrix
-chol2inv_internal (const FloatMatrix& r)
+chol2inv_internal (const FloatMatrix& r, bool is_upper = true)
 {
   FloatMatrix retval;
 
@@ -161,17 +180,29 @@
 
       if (info == 0)
         {
-          F77_XFCN (spotri, SPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
-                                     v, n, info
-                                     F77_CHAR_ARG_LEN (1)));
+          if (is_upper)
+            F77_XFCN (spotri, SPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
+                                       v, n, info
+                                       F77_CHAR_ARG_LEN (1)));
+          else
+            F77_XFCN (spotri, SPOTRI, (F77_CONST_CHAR_ARG2 ("L", 1), n,
+                                       v, n, info
+                                       F77_CHAR_ARG_LEN (1)));
 
           // If someone thinks of a more graceful way of doing this (or
           // faster for that matter :-)), please let me know!
 
           if (n > 1)
-            for (octave_idx_type j = 0; j < r_nc; j++)
-              for (octave_idx_type i = j+1; i < r_nr; i++)
-                tmp.xelem (i, j) = tmp.xelem (j, i);
+            {
+              if (is_upper)
+                for (octave_idx_type j = 0; j < r_nc; j++)
+                  for (octave_idx_type i = j+1; i < r_nr; i++)
+                    tmp.xelem (i, j) = tmp.xelem (j, i);
+              else
+                for (octave_idx_type j = 0; j < r_nc; j++)
+                  for (octave_idx_type i = j+1; i < r_nr; i++)
+                    tmp.xelem (j, i) = tmp.xelem (i, j);
+            }
 
           retval = tmp;
         }
@@ -186,7 +217,7 @@
 FloatMatrix
 FloatCHOL::inverse (void) const
 {
-  return chol2inv_internal (chol_mat);
+  return chol2inv_internal (chol_mat, is_upper);
 }
 
 void
@@ -205,7 +236,7 @@
 {
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       FloatColumnVector utmp = u;
 
@@ -225,7 +256,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       FloatColumnVector utmp = u;
 
@@ -247,7 +278,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () != n + 1)
+  if (u.numel () != n + 1)
     (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("cholinsert: index out of range");
@@ -309,10 +340,10 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       init (chol_mat.transpose () * chol_mat
-            + FloatMatrix (u) * FloatMatrix (u).transpose (), false);
+            + FloatMatrix (u) * FloatMatrix (u).transpose (), true, false);
     }
   else
     (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
@@ -335,14 +366,15 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       if (singular (chol_mat))
         info = 2;
       else
         {
           info = init (chol_mat.transpose () * chol_mat
-                       - FloatMatrix (u) * FloatMatrix (u).transpose (), false);
+                       - FloatMatrix (u) * FloatMatrix (u).transpose (), true,
+                       false);
           if (info) info = 1;
         }
     }
@@ -361,7 +393,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () != n + 1)
+  if (u.numel () != n + 1)
     (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("cholinsert: index out of range");
@@ -383,7 +415,7 @@
                 else
                   a1(k, l) = a(k < j ? k : k-1, l < j ? l : l-1);
               }
-          info = init (a1, false);
+          info = init (a1, true, false);
           if (info) info = 1;
         }
     }
@@ -405,7 +437,7 @@
       FloatMatrix a = chol_mat.transpose () * chol_mat;
       a.delete_elements (1, idx_vector (j));
       a.delete_elements (0, idx_vector (j));
-      init (a, false);
+      init (a, true, false);
     }
 }
 
@@ -434,7 +466,7 @@
           for (octave_idx_type k = j+1; k < i+1; k++) p(k) = k-1;
         }
 
-      init (a.index (idx_vector (p), idx_vector (p)), false);
+      init (a.index (idx_vector (p), idx_vector (p)), true, false);
     }
 }
 
--- a/liboctave/numeric/floatCHOL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/floatCHOL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_floatCHOL_h)
+#if ! defined (octave_floatCHOL_h)
 #define octave_floatCHOL_h 1
 
 #include <iosfwd>
@@ -37,17 +37,17 @@
 
   FloatCHOL (void) : chol_mat (), xrcond (0) { }
 
-  FloatCHOL (const FloatMatrix& a, bool calc_cond = false)
+  FloatCHOL (const FloatMatrix& a, bool upper = true, bool calc_cond = false)
     : chol_mat (), xrcond (0)
   {
-    init (a, calc_cond);
+    init (a, upper, calc_cond);
   }
 
-  FloatCHOL (const FloatMatrix& a, octave_idx_type& info,
+  FloatCHOL (const FloatMatrix& a, octave_idx_type& info, bool upper = true,
              bool calc_cond = false)
     : chol_mat (), xrcond (0)
   {
-    info = init (a, calc_cond);
+    info = init (a, upper, calc_cond);
   }
 
   FloatCHOL (const FloatCHOL& a) : chol_mat (a.chol_mat), xrcond (a.xrcond) { }
@@ -90,7 +90,9 @@
 
   float xrcond;
 
-  octave_idx_type init (const FloatMatrix& a, bool calc_cond);
+  bool is_upper;
+
+  octave_idx_type init (const FloatMatrix& a, bool upper, bool calc_cond);
 };
 
 FloatMatrix OCTAVE_API chol2inv (const FloatMatrix& r);
--- a/liboctave/numeric/floatGEPBAL.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/floatGEPBAL.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_floatGEPBAL_h)
+#if ! defined (octave_floatGEPBAL_h)
 #define octave_floatGEPBAL_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/floatHESS.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/floatHESS.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_floatHESS_h)
+#if ! defined (octave_floatHESS_h)
 #define octave_floatHESS_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/floatLU.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/floatLU.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -97,7 +97,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = l.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       FloatColumnVector utmp = u;
       FloatColumnVector vtmp = v;
@@ -149,7 +149,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = l.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       FloatColumnVector utmp = u;
       FloatColumnVector vtmp = v;
--- a/liboctave/numeric/floatLU.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/floatLU.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_floatLU_h)
+#if ! defined (octave_floatLU_h)
 #define octave_floatLU_h 1
 
 #include "base-lu.h"
--- a/liboctave/numeric/floatQR.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/floatQR.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -211,7 +211,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = q.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       FloatColumnVector utmp = u;
       FloatColumnVector vtmp = v;
@@ -255,7 +255,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = q.columns ();
 
-  if (u.length () != m)
+  if (u.numel () != m)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -288,14 +288,14 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, ASCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
 
   if (dups)
     (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
-  else if (u.length () != m || u.columns () != nj)
+  else if (u.numel () != m || u.columns () != nj)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (nj > 0 && (js(0) < 0 || js(nj-1) > n))
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -313,7 +313,7 @@
         }
 
       OCTAVE_LOCAL_BUFFER (float, w, kmax);
-      for (volatile octave_idx_type i = 0; i < js.length (); i++)
+      for (volatile octave_idx_type i = 0; i < js.numel (); i++)
         {
           octave_idx_type ii = i;
           FloatColumnVector utmp = u.column (jsi(i));
@@ -361,7 +361,7 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, DESCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
@@ -373,7 +373,7 @@
   else if (nj > 0)
     {
       OCTAVE_LOCAL_BUFFER (float, w, k);
-      for (volatile octave_idx_type i = 0; i < js.length (); i++)
+      for (volatile octave_idx_type i = 0; i < js.numel (); i++)
         {
           octave_idx_type ii = i;
           F77_XFCN (sqrdec, SQRDEC, (m, n - ii, k == m ? k : k - ii,
@@ -401,7 +401,7 @@
   octave_idx_type n = r.columns ();
   octave_idx_type k = std::min (m, n);
 
-  if (! q.is_square () || u.length () != n)
+  if (! q.is_square () || u.numel () != n)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > m)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -471,7 +471,7 @@
   octave_idx_type m = q.rows ();
   octave_idx_type n = r.columns ();
 
-  if (u.length () == m && v.length () == n)
+  if (u.numel () == m && v.numel () == n)
     {
       init (q*r + FloatMatrix (u) * FloatMatrix (v).transpose (), get_type ());
     }
@@ -566,7 +566,7 @@
   octave_idx_type m = q.rows ();
   octave_idx_type n = r.columns ();
 
-  if (u.length () != m)
+  if (u.numel () != m)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > n)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
@@ -586,21 +586,21 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, ASCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
 
   if (dups)
     (*current_liboctave_error_handler) ("qrinsert: duplicate index detected");
-  else if (u.length () != m || u.columns () != nj)
+  else if (u.numel () != m || u.columns () != nj)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (nj > 0 && (js(0) < 0 || js(nj-1) > n))
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
   else if (nj > 0)
     {
       FloatMatrix a = q*r;
-      for (octave_idx_type i = 0; i < js.length (); i++)
+      for (octave_idx_type i = 0; i < js.numel (); i++)
         a = ::insert_col (a, js(i), u.column (i));
       init (a, get_type ());
     }
@@ -630,7 +630,7 @@
 
   Array<octave_idx_type> jsi;
   Array<octave_idx_type> js = j.sort (jsi, 0, DESCENDING);
-  octave_idx_type nj = js.length ();
+  octave_idx_type nj = js.numel ();
   bool dups = false;
   for (octave_idx_type i = 0; i < nj - 1; i++)
     dups = dups && js(i) == js(i+1);
@@ -642,7 +642,7 @@
   else if (nj > 0)
     {
       FloatMatrix a = q*r;
-      for (octave_idx_type i = 0; i < js.length (); i++)
+      for (octave_idx_type i = 0; i < js.numel (); i++)
         a = ::delete_col (a, js(i));
       init (a, get_type ());
     }
@@ -656,7 +656,7 @@
   octave_idx_type m = r.rows ();
   octave_idx_type n = r.columns ();
 
-  if (! q.is_square () || u.length () != n)
+  if (! q.is_square () || u.numel () != n)
     (*current_liboctave_error_handler) ("qrinsert: dimensions mismatch");
   else if (j < 0 || j > m)
     (*current_liboctave_error_handler) ("qrinsert: index out of range");
--- a/liboctave/numeric/floatQR.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/floatQR.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_floatQR_h)
+#if ! defined (octave_floatQR_h)
 #define octave_floatQR_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/floatQRP.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/floatQRP.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_floatQRP_h)
+#if ! defined (octave_floatQRP_h)
 #define octave_floatQRP_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/floatSCHUR.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/floatSCHUR.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_floatSCHUR_h)
+#if ! defined (octave_floatSCHUR_h)
 #define octave_floatSCHUR_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/floatSVD.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/floatSVD.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_floatSVD_h)
+#if ! defined (octave_floatSVD_h)
 #define octave_floatSVD_h 1
 
 #include <iosfwd>
--- a/liboctave/numeric/lo-mappers.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/lo-mappers.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -139,7 +139,7 @@
 
 // double -> bool mappers.
 
-#if ! defined(HAVE_CMATH_ISNAN)
+#if ! defined (HAVE_CMATH_ISNAN)
 bool
 xisnan (double x)
 {
@@ -147,7 +147,7 @@
 }
 #endif
 
-#if ! defined(HAVE_CMATH_ISFINITE)
+#if ! defined (HAVE_CMATH_ISFINITE)
 bool
 xfinite (double x)
 {
@@ -155,7 +155,7 @@
 }
 #endif
 
-#if ! defined(HAVE_CMATH_ISINF)
+#if ! defined (HAVE_CMATH_ISINF)
 bool
 xisinf (double x)
 {
@@ -376,7 +376,7 @@
 
 // float -> bool mappers.
 
-#if ! defined(HAVE_CMATH_ISNANF)
+#if ! defined (HAVE_CMATH_ISNANF)
 bool
 xisnan (float x)
 {
@@ -384,7 +384,7 @@
 }
 #endif
 
-#if ! defined(HAVE_CMATH_ISFINITEF)
+#if ! defined (HAVE_CMATH_ISFINITEF)
 bool
 xfinite (float x)
 {
@@ -392,7 +392,7 @@
 }
 #endif
 
-#if ! defined(HAVE_CMATH_ISINFF)
+#if ! defined (HAVE_CMATH_ISINFF)
 bool
 xisinf (float x)
 {
--- a/liboctave/numeric/lo-mappers.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/lo-mappers.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,13 +21,14 @@
 
 */
 
-#if !defined (octave_lo_mappers_h)
+#if ! defined (octave_lo_mappers_h)
 #define octave_lo_mappers_h 1
 
 #include <limits>
 
 #include "oct-cmplx.h"
 #include "lo-math.h"
+#include "lo-ieee.h"
 
 // Double Precision
 extern OCTAVE_API double xtrunc (double x);
@@ -334,7 +335,7 @@
         }
     }
 
-  if (x != y && y != 0 && retval != 0)
+  if (x != y && y != 0)
     retval = xcopysign (retval, y);
 
   return retval;
@@ -347,7 +348,7 @@
   T retval;
 
   if (y == 0)
-    retval = x;
+    retval = octave_NaN;
   else
     {
       T q = x / y;
@@ -367,7 +368,7 @@
         }
     }
 
-  if (x != y && y != 0 && retval != 0)
+  if (x != y && y != 0)
     retval = xcopysign (retval, x);
 
   return retval;
--- a/liboctave/numeric/lo-specfun.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/lo-specfun.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -1,8 +1,10 @@
 /*
 
 Copyright (C) 1996-2015 John W. Eaton
+Copyright (C) 2007-2010 D. Martin
 Copyright (C) 2010 Jaroslav Hajek
 Copyright (C) 2010 VZLU Prague
+Copyright (C) 2015 Carnë Draug
 
 This file is part of Octave.
 
@@ -45,6 +47,7 @@
 #include "lo-specfun.h"
 #include "mx-inlines.cc"
 #include "lo-mappers.h"
+#include "lo-math.h"
 
 #include "Faddeeva.hh"
 
@@ -183,9 +186,19 @@
 
   F77_RET_T
   F77_FUNC (algams, ALGAMS) (const float&, float&, float&);
+
+  F77_RET_T
+  F77_FUNC (psifn, PSIFN) (const float*, const octave_idx_type&,
+                           const octave_idx_type&, const octave_idx_type&,
+                           float*, octave_idx_type*, octave_idx_type*);
+
+  F77_RET_T
+  F77_FUNC (dpsifn, DPSIFN) (const double*, const octave_idx_type&,
+                             const octave_idx_type&, const octave_idx_type&,
+                             double*, octave_idx_type*, octave_idx_type*);
 }
 
-#if !defined (HAVE_ACOSH)
+#if ! defined (HAVE_ACOSH)
 double
 acosh (double x)
 {
@@ -195,7 +208,7 @@
 }
 #endif
 
-#if !defined (HAVE_ACOSHF)
+#if ! defined (HAVE_ACOSHF)
 float
 acoshf (float x)
 {
@@ -205,7 +218,7 @@
 }
 #endif
 
-#if !defined (HAVE_ASINH)
+#if ! defined (HAVE_ASINH)
 double
 asinh (double x)
 {
@@ -215,7 +228,7 @@
 }
 #endif
 
-#if !defined (HAVE_ASINHF)
+#if ! defined (HAVE_ASINHF)
 float
 asinhf (float x)
 {
@@ -225,7 +238,7 @@
 }
 #endif
 
-#if !defined (HAVE_ATANH)
+#if ! defined (HAVE_ATANH)
 double
 atanh (double x)
 {
@@ -235,7 +248,7 @@
 }
 #endif
 
-#if !defined (HAVE_ATANHF)
+#if ! defined (HAVE_ATANHF)
 float
 atanhf (float x)
 {
@@ -245,7 +258,7 @@
 }
 #endif
 
-#if !defined (HAVE_ERF)
+#if ! defined (HAVE_ERF)
 double
 erf (double x)
 {
@@ -255,7 +268,7 @@
 }
 #endif
 
-#if !defined (HAVE_ERFF)
+#if ! defined (HAVE_ERFF)
 float
 erff (float x)
 {
@@ -265,7 +278,7 @@
 }
 #endif
 
-#if !defined (HAVE_ERFC)
+#if ! defined (HAVE_ERFC)
 double
 erfc (double x)
 {
@@ -275,7 +288,7 @@
 }
 #endif
 
-#if !defined (HAVE_ERFCF)
+#if ! defined (HAVE_ERFCF)
 float
 erfcf (float x)
 {
@@ -505,7 +518,7 @@
     return result;
 }
 
-#if !defined (HAVE_EXPM1)
+#if ! defined (HAVE_EXPM1)
 double
 expm1 (double x)
 {
@@ -560,7 +573,7 @@
   return retval;
 }
 
-#if !defined (HAVE_EXPM1F)
+#if ! defined (HAVE_EXPM1F)
 float
 expm1f (float x)
 {
@@ -615,7 +628,7 @@
   return retval;
 }
 
-#if !defined (HAVE_LOG1P)
+#if ! defined (HAVE_LOG1P)
 double
 log1p (double x)
 {
@@ -658,7 +671,7 @@
   return retval;
 }
 
-#if !defined (HAVE_CBRT)
+#if ! defined (HAVE_CBRT)
 double cbrt (double x)
 {
   static const double one_third = 0.3333333333333333333;
@@ -674,7 +687,7 @@
 }
 #endif
 
-#if !defined (HAVE_LOG1PF)
+#if ! defined (HAVE_LOG1PF)
 float
 log1pf (float x)
 {
@@ -717,7 +730,7 @@
   return retval;
 }
 
-#if !defined (HAVE_CBRTF)
+#if ! defined (HAVE_CBRTF)
 float cbrtf (float x)
 {
   static const float one_third = 0.3333333333333333333f;
@@ -1264,8 +1277,8 @@
            const ComplexColumnVector& x, bool scaled,
            Array<octave_idx_type>& ierr)
 {
-  octave_idx_type nr = x.length ();
-  octave_idx_type nc = alpha.length ();
+  octave_idx_type nr = x.numel ();
+  octave_idx_type nc = alpha.numel ();
 
   ComplexMatrix retval (nr, nc);
 
@@ -1875,8 +1888,8 @@
            const FloatComplexColumnVector& x, bool scaled,
            Array<octave_idx_type>& ierr)
 {
-  octave_idx_type nr = x.length ();
-  octave_idx_type nc = alpha.length ();
+  octave_idx_type nr = x.numel ();
+  octave_idx_type nc = alpha.numel ();
 
   FloatComplexMatrix retval (nr, nc);
 
@@ -2991,11 +3004,13 @@
 }
 
 // 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 Halley's 3rd order method.
-// For single precision, the accuracy is already OK, so we skip it to get
-// faster evaluation.
+//
+// The rational approximation has relative accuracy 1.15e-9 in the whole
+// region.  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.
 
 static double do_erfinv (double x, bool refine)
 {
@@ -3070,9 +3085,10 @@
   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.
+// 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)
 {
@@ -3237,14 +3253,14 @@
 
   for ( ; ; )
     {
-      term = term * temp * rx / (pp + ai);
-      value = value + term;
+      term *= temp * rx / (pp + ai);
+      value += term;
       temp = fabs (term);
 
       if (temp <= acu && temp <= acu * value)
         {
-          value = value * exp (pp * gnulib::log (xx)
-                               + (qq - 1.0) * gnulib::log (cx) - beta) / pp;
+          value *= exp (pp * gnulib::log (xx)
+                        + (qq - 1.0) * gnulib::log (cx) - beta) / pp;
 
           if (indx)
             {
@@ -3253,8 +3269,8 @@
           break;
         }
 
-      ai = ai + 1.0;
-      ns = ns - 1;
+      ai += 1.0;
+      ns -= 1;
 
       if (0 <= ns)
         {
@@ -3267,7 +3283,7 @@
       else
         {
           temp = psq;
-          psq = psq + 1.0;
+          psq += 1.0;
         }
     }
 
@@ -3439,7 +3455,7 @@
                       break;
                     }
                 }
-              g = g / 3.0;
+              g /= 3.0;
             }
 
           if (prev <= acu)
@@ -3465,7 +3481,7 @@
               break;
             }
 
-          g = g / 3.0;
+          g /= 3.0;
         }
 
       if (tx == value)
@@ -3636,7 +3652,7 @@
   if (m < 0 || m > 1)
     {
       (*current_liboctave_warning_with_id_handler)
-        ("Octave:ellipj-invalid-m", "ellipj: expecting 0 <= M <= 1");
+        ("Octave:ellipj-invalid-m", "ellipj: invalid M value, required value 0 <= M <= 1");
 
       sn = cn = dn = lo_ieee_nan_value ();
 
@@ -3724,3 +3740,212 @@
       dn = Complex (dd*cc1*dd1/ddd, -m*ss*cc*ss1/ddd);
     }
 }
+
+static const double pi = 3.14159265358979323846;
+
+template <class T>
+static inline T
+xlog (const T& x)
+{
+  return log (x);
+}
+
+template <>
+inline double
+xlog (const double& x)
+{
+  return gnulib::log (x);
+}
+
+template <>
+inline float
+xlog (const float& x)
+{
+  return gnulib::logf (x);
+}
+
+template<class T>
+static T
+Lanczos_approximation_psi (const T zc)
+{
+  // Coefficients for C.Lanczos expansion of psi function from XLiFE++
+  // gammaFunctions psi_coef[k] = - (2k+1) * lg_coef[k] (see melina++
+  // gamma functions -1/12, 3/360,-5/1260, 7/1680,-9/1188,
+  // 11*691/360360,-13/156, 15*3617/122400, ? , ?
+  static const T dg_coeff[10] = {
+    -0.83333333333333333e-1, 0.83333333333333333e-2,
+    -0.39682539682539683e-2, 0.41666666666666667e-2,
+    -0.75757575757575758e-2, 0.21092796092796093e-1,
+    -0.83333333333333333e-1, 0.4432598039215686,
+    -0.3053954330270122e+1,  0.125318899521531e+2
+  };
+
+  T overz2  = T (1.0) / (zc * zc);
+  T overz2k = overz2;
+
+  T p = 0;
+  for (octave_idx_type k = 0; k < 10; k++, overz2k *= overz2)
+    p += dg_coeff[k] * overz2k;
+  p += xlog (zc) - T (0.5) / zc;
+  return p;
+}
+
+template<class T>
+T
+psi (const T& z)
+{
+  static const double euler_mascheroni = 0.577215664901532860606512090082402431042;
+
+  const bool is_int = (xfloor (z) == z);
+
+  T p = 0;
+  if (z <= 0)
+    {
+      // limits - zeros of the gamma function
+      if (is_int)
+        p = -octave_Inf; // Matlab returns -Inf for psi (0)
+      else
+        // Abramowitz and Stegun, page 259, eq 6.3.7
+        p = psi (1 - z) - (pi / tan (pi * z));
+    }
+  else if (is_int)
+    {
+      // Abramowitz and Stegun, page 258, eq 6.3.2
+      p = - euler_mascheroni;
+      for (octave_idx_type k = z - 1; k > 0; k--)
+        p += 1.0 / k;
+    }
+  else if (xfloor (z + 0.5) == z + 0.5)
+    {
+      // Abramowitz and Stegun, page 258, eq 6.3.3 and 6.3.4
+      for (octave_idx_type k = z; k > 0; k--)
+        p += 1.0 / (2 * k - 1);
+
+      p = - euler_mascheroni - 2 * log (2) + 2 * (p);
+    }
+  else
+    {
+      // adapted from XLiFE++ gammaFunctions
+
+      T zc = z;
+      // Use formula for derivative of LogGamma(z)
+      if (z < 10)
+        {
+          const signed char n = 10 - z;
+          for (signed char k = n - 1; k >= 0; k--)
+            p -= 1.0 / (k + z);
+          zc += n;
+        }
+      p += Lanczos_approximation_psi (zc);
+    }
+
+  return p;
+}
+
+// explicit instantiations
+template double psi<double> (const double& z);
+template float  psi<float> (const float& z);
+
+template<class T>
+std::complex<T>
+psi (const std::complex<T>& z)
+{
+  // adapted from XLiFE++ gammaFunctions
+
+  typedef typename std::complex<T>::value_type P;
+
+  P z_r  = z.real ();
+  P z_ra = z_r;
+
+  std::complex<T> dgam (0.0, 0.0);
+  if (z.imag () == 0)
+    dgam = std::complex<T> (psi (z_r), 0.0);
+  else if (z_r < 0)
+    dgam = psi (P (1.0) - z)- (P (pi) / tan (P (pi) * z));
+  else
+    {
+      // Use formula for derivative of LogGamma(z)
+      std::complex<T> z_m = z;
+      if (z_ra < 8)
+        {
+          unsigned char n = 8 - z_ra;
+          z_m = z + std::complex<T> (n, 0.0);
+
+          // Recurrence formula.  For | Re(z) | < 8, use recursively
+          //
+          //   DiGamma(z) = DiGamma(z+1) - 1/z
+          std::complex<T> z_p = z + P (n - 1);
+          for (unsigned char k = n; k > 0; k--, z_p -= 1.0)
+            dgam -= P (1.0) / z_p;
+        }
+
+      // for | Re(z) | > 8, use derivative of C.Lanczos expansion for
+      // LogGamma
+      //
+      //   psi(z) = log(z) - 1/(2z) - 1/12z^2 + 3/360z^4 - 5/1260z^6
+      //     + 7/1680z^8 - 9/1188z^10 + ...
+      //
+      // (Abramowitz&Stegun, page 259, formula 6.3.18
+      dgam += Lanczos_approximation_psi (z_m);
+    }
+  return dgam;
+}
+
+// explicit instantiations
+template Complex psi<double> (const Complex& z);
+template FloatComplex psi<float> (const FloatComplex& z);
+
+
+template<typename T>
+static inline void
+fortran_psifn (const T z, const octave_idx_type n, T* ans,
+               octave_idx_type* ierr);
+
+template<>
+inline void
+fortran_psifn<double> (const double z, const octave_idx_type n,
+                       double* ans, octave_idx_type* ierr)
+{
+  octave_idx_type flag = 0;
+  F77_XFCN (dpsifn, DPSIFN, (&z, n, 1, 1, ans, &flag, ierr));
+}
+
+template<>
+inline void
+fortran_psifn<float> (const float z, const octave_idx_type n,
+                      float* ans, octave_idx_type* ierr)
+{
+  octave_idx_type flag = 0;
+  F77_XFCN (psifn, PSIFN, (&z, n, 1, 1, ans, &flag, ierr));
+}
+
+template<class T>
+T
+psi (const octave_idx_type n, const T z)
+{
+  T ans;
+  octave_idx_type ierr = 0;
+  fortran_psifn<T> (z, n, &ans, &ierr);
+  if (ierr == 0)
+    {
+      // Remember that psifn and dpsifn return scales values
+      // When n is 1: do nothing since ((-1)**(n+1)/gamma(n+1)) == 1
+      // When n is 0: change sign since ((-1)**(n+1)/gamma(n+1)) == -1
+      if (n > 1)
+        // FIXME xgamma here is a killer for our precision since it grows
+        //       way too fast
+        ans = ans / (pow (-1.0, n + 1) / xgamma (double (n+1)));
+      else if (n == 0)
+        ans = -ans;
+    }
+  else if (ierr == 2)
+    ans = - octave_Inf;
+  else // we probably never get here
+    ans = octave_NaN;
+
+  return ans;
+}
+
+// explicit instantiations
+template double psi<double> (const octave_idx_type n, const double z);
+template float  psi<float>  (const octave_idx_type n, const float z);
--- a/liboctave/numeric/lo-specfun.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/lo-specfun.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_lo_specfun_h)
+#if ! defined (octave_lo_specfun_h)
 #define octave_lo_specfun_h 1
 
 #include "oct-cmplx.h"
@@ -41,75 +41,75 @@
 class FloatComplexColumnVector;
 class Range;
 
-#if !defined (HAVE_ACOSH)
+#if ! defined (HAVE_ACOSH)
 extern OCTAVE_API double acosh (double);
 #endif
 
-#if !defined (HAVE_ASINH)
+#if ! defined (HAVE_ASINH)
 extern OCTAVE_API double asinh (double);
 #endif
 
-#if !defined (HAVE_ATANH)
+#if ! defined (HAVE_ATANH)
 extern OCTAVE_API double atanh (double);
 #endif
 
-#if !defined (HAVE_ERF)
+#if ! defined (HAVE_ERF)
 extern OCTAVE_API double erf (double);
 #endif
 extern OCTAVE_API Complex erf (const Complex& x);
 extern OCTAVE_API FloatComplex erf (const FloatComplex& x);
 
-#if !defined (HAVE_ERFC)
+#if ! defined (HAVE_ERFC)
 extern OCTAVE_API double erfc (double);
 #endif
 extern OCTAVE_API Complex erfc (const Complex& x);
 extern OCTAVE_API FloatComplex erfc (const FloatComplex& x);
 
-#if !defined (HAVE_ACOSHF)
+#if ! defined (HAVE_ACOSHF)
 extern OCTAVE_API float acoshf (float);
 #endif
 
-#if !defined (HAVE_ASINHF)
+#if ! defined (HAVE_ASINHF)
 extern OCTAVE_API float asinhf (float);
 #endif
 
-#if !defined (HAVE_ATANHF)
+#if ! defined (HAVE_ATANHF)
 extern OCTAVE_API float atanhf (float);
 #endif
 
-#if !defined (HAVE_ERFF)
+#if ! defined (HAVE_ERFF)
 extern OCTAVE_API float erff (float);
 #endif
 
-#if !defined (HAVE_ERFCF)
+#if ! defined (HAVE_ERFCF)
 extern OCTAVE_API float erfcf (float);
 #endif
 
-#if !defined (HAVE_EXPM1)
+#if ! defined (HAVE_EXPM1)
 extern OCTAVE_API double expm1 (double x);
 #endif
 extern OCTAVE_API Complex expm1 (const Complex& x);
 
-#if !defined (HAVE_EXPM1F)
+#if ! defined (HAVE_EXPM1F)
 extern OCTAVE_API float expm1f (float x);
 #endif
 extern OCTAVE_API FloatComplex expm1 (const FloatComplex& x);
 
-#if !defined (HAVE_LOG1P)
+#if ! defined (HAVE_LOG1P)
 extern OCTAVE_API double log1p (double x);
 #endif
 extern OCTAVE_API Complex log1p (const Complex& x);
 
-#if !defined (HAVE_LOG1PF)
+#if ! defined (HAVE_LOG1PF)
 extern OCTAVE_API float log1pf (float x);
 #endif
 extern OCTAVE_API FloatComplex log1p (const FloatComplex& x);
 
-#if !defined (HAVE_CBRT)
+#if ! defined (HAVE_CBRT)
 extern OCTAVE_API double cbrt (double x);
 #endif
 
-#if !defined (HAVE_CBRTF)
+#if ! defined (HAVE_CBRTF)
 extern OCTAVE_API float cbrtf (float x);
 #endif
 
@@ -663,4 +663,24 @@
 ellipj (const Complex& u, double m, Complex& sn, Complex& cn, Complex& dn,
         double& err);
 
+//! Digamma function.
+//!
+//! Only defined for double and float.
+template<class T>
+extern OCTAVE_API T psi (const T& z);
+
+//! Digamma function for complex input.
+//!
+//! Only defined for double and float.
+template<class T>
+extern OCTAVE_API std::complex<T> psi (const std::complex<T>& z);
+
+//! Polygamma function.
+//!
+//! Only defined for double and float.
+//! @param n must be non-negative.  If zero, the digamma function is computed.
+//! @param z must be real and non-negative.
+template<class T>
+extern OCTAVE_API T psi (const octave_idx_type n, const T z);
+
 #endif
--- a/liboctave/numeric/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,187 +1,191 @@
-EXTRA_DIST += \
-  numeric/module.mk \
-  $(OPT_IN)
+LIBOCTAVE_OPT_INC = \
+  liboctave/numeric/DASPK-opts.h \
+  liboctave/numeric/DASRT-opts.h \
+  liboctave/numeric/DASSL-opts.h \
+  liboctave/numeric/LSODE-opts.h \
+  liboctave/numeric/Quad-opts.h
 
-OPT_INC = \
-  numeric/DASPK-opts.h \
-  numeric/DASRT-opts.h \
-  numeric/DASSL-opts.h \
-  numeric/LSODE-opts.h \
-  numeric/Quad-opts.h
-
-OPT_IN = $(OPT_INC:.h=.in)
+LIBOCTAVE_OPT_IN = $(LIBOCTAVE_OPT_INC:.h=.in)
 
 NUMERIC_INC = \
-  numeric/base-aepbal.h \
-  numeric/base-dae.h \
-  numeric/base-de.h \
-  numeric/base-lu.h \
-  numeric/base-min.h \
-  numeric/base-qr.h \
-  numeric/bsxfun-decl.h \
-  numeric/bsxfun.h \
-  numeric/CmplxAEPBAL.h \
-  numeric/CmplxCHOL.h \
-  numeric/CmplxGEPBAL.h \
-  numeric/CmplxHESS.h \
-  numeric/CmplxLU.h \
-  numeric/CmplxQR.h \
-  numeric/CmplxQRP.h \
-  numeric/CmplxSCHUR.h \
-  numeric/CmplxSVD.h \
-  numeric/CollocWt.h \
-  numeric/DAEFunc.h \
-  numeric/DAE.h \
-  numeric/DAERTFunc.h \
-  numeric/DAERT.h \
-  numeric/DASPK.h \
-  numeric/DASRT.h \
-  numeric/DASSL.h \
-  numeric/dbleAEPBAL.h \
-  numeric/dbleCHOL.h \
-  numeric/dbleGEPBAL.h \
-  numeric/dbleHESS.h \
-  numeric/dbleLU.h \
-  numeric/dbleQR.h \
-  numeric/dbleQRP.h \
-  numeric/dbleSCHUR.h \
-  numeric/dbleSVD.h \
-  numeric/DET.h \
-  numeric/EIG.h \
-  numeric/fCmplxAEPBAL.h \
-  numeric/fCmplxCHOL.h \
-  numeric/fCmplxGEPBAL.h \
-  numeric/fCmplxHESS.h \
-  numeric/fCmplxLU.h \
-  numeric/fCmplxQR.h \
-  numeric/fCmplxQRP.h \
-  numeric/fCmplxSCHUR.h \
-  numeric/fCmplxSVD.h \
-  numeric/fEIG.h \
-  numeric/floatAEPBAL.h \
-  numeric/floatCHOL.h \
-  numeric/floatGEPBAL.h \
-  numeric/floatHESS.h \
-  numeric/floatLU.h \
-  numeric/floatQR.h \
-  numeric/floatQRP.h \
-  numeric/floatSCHUR.h \
-  numeric/floatSVD.h \
-  numeric/lo-mappers.h \
-  numeric/lo-specfun.h \
-  numeric/LSODE.h \
-  numeric/oct-convn.h \
-  numeric/oct-fftw.h \
-  numeric/oct-norm.h \
-  numeric/oct-rand.h \
-  numeric/oct-spparms.h \
-  numeric/ODEFunc.h \
-  numeric/ODE.h \
-  numeric/ODESFunc.h \
-  numeric/ODES.h \
-  numeric/Quad.h \
-  numeric/randgamma.h \
-  numeric/randmtzig.h \
-  numeric/randpoisson.h \
-  numeric/sparse-base-chol.h \
-  numeric/sparse-base-lu.h \
-  numeric/SparseCmplxCHOL.h \
-  numeric/SparseCmplxLU.h \
-  numeric/SparseCmplxQR.h \
-  numeric/SparsedbleCHOL.h \
-  numeric/SparsedbleLU.h \
-  numeric/SparseQR.h
+  liboctave/numeric/base-aepbal.h \
+  liboctave/numeric/base-dae.h \
+  liboctave/numeric/base-de.h \
+  liboctave/numeric/base-lu.h \
+  liboctave/numeric/base-min.h \
+  liboctave/numeric/base-qr.h \
+  liboctave/numeric/bsxfun-decl.h \
+  liboctave/numeric/bsxfun.h \
+  liboctave/numeric/CmplxAEPBAL.h \
+  liboctave/numeric/CmplxCHOL.h \
+  liboctave/numeric/CmplxGEPBAL.h \
+  liboctave/numeric/CmplxHESS.h \
+  liboctave/numeric/CmplxLU.h \
+  liboctave/numeric/CmplxQR.h \
+  liboctave/numeric/CmplxQRP.h \
+  liboctave/numeric/CmplxSCHUR.h \
+  liboctave/numeric/CmplxSVD.h \
+  liboctave/numeric/CollocWt.h \
+  liboctave/numeric/DAEFunc.h \
+  liboctave/numeric/DAE.h \
+  liboctave/numeric/DAERTFunc.h \
+  liboctave/numeric/DAERT.h \
+  liboctave/numeric/DASPK.h \
+  liboctave/numeric/DASRT.h \
+  liboctave/numeric/DASSL.h \
+  liboctave/numeric/dbleAEPBAL.h \
+  liboctave/numeric/dbleCHOL.h \
+  liboctave/numeric/dbleGEPBAL.h \
+  liboctave/numeric/dbleHESS.h \
+  liboctave/numeric/dbleLU.h \
+  liboctave/numeric/dbleQR.h \
+  liboctave/numeric/dbleQRP.h \
+  liboctave/numeric/dbleSCHUR.h \
+  liboctave/numeric/dbleSVD.h \
+  liboctave/numeric/DET.h \
+  liboctave/numeric/EIG.h \
+  liboctave/numeric/fCmplxAEPBAL.h \
+  liboctave/numeric/fCmplxCHOL.h \
+  liboctave/numeric/fCmplxGEPBAL.h \
+  liboctave/numeric/fCmplxHESS.h \
+  liboctave/numeric/fCmplxLU.h \
+  liboctave/numeric/fCmplxQR.h \
+  liboctave/numeric/fCmplxQRP.h \
+  liboctave/numeric/fCmplxSCHUR.h \
+  liboctave/numeric/fCmplxSVD.h \
+  liboctave/numeric/fEIG.h \
+  liboctave/numeric/floatAEPBAL.h \
+  liboctave/numeric/floatCHOL.h \
+  liboctave/numeric/floatGEPBAL.h \
+  liboctave/numeric/floatHESS.h \
+  liboctave/numeric/floatLU.h \
+  liboctave/numeric/floatQR.h \
+  liboctave/numeric/floatQRP.h \
+  liboctave/numeric/floatSCHUR.h \
+  liboctave/numeric/floatSVD.h \
+  liboctave/numeric/lo-mappers.h \
+  liboctave/numeric/lo-specfun.h \
+  liboctave/numeric/LSODE.h \
+  liboctave/numeric/oct-convn.h \
+  liboctave/numeric/oct-fftw.h \
+  liboctave/numeric/oct-norm.h \
+  liboctave/numeric/oct-rand.h \
+  liboctave/numeric/oct-spparms.h \
+  liboctave/numeric/ODEFunc.h \
+  liboctave/numeric/ODE.h \
+  liboctave/numeric/ODESFunc.h \
+  liboctave/numeric/ODES.h \
+  liboctave/numeric/Quad.h \
+  liboctave/numeric/randgamma.h \
+  liboctave/numeric/randmtzig.h \
+  liboctave/numeric/randpoisson.h \
+  liboctave/numeric/sparse-base-chol.h \
+  liboctave/numeric/sparse-base-lu.h \
+  liboctave/numeric/SparseCmplxCHOL.h \
+  liboctave/numeric/SparseCmplxLU.h \
+  liboctave/numeric/SparseCmplxQR.h \
+  liboctave/numeric/SparsedbleCHOL.h \
+  liboctave/numeric/SparsedbleLU.h \
+  liboctave/numeric/SparseQR.h
 
 NUMERIC_C_SRC = \
-  numeric/randgamma.c \
-  numeric/randmtzig.c \
-  numeric/randpoisson.c
+  liboctave/numeric/randgamma.c \
+  liboctave/numeric/randmtzig.c \
+  liboctave/numeric/randpoisson.c
 
 NUMERIC_SRC = \
-  numeric/CmplxAEPBAL.cc \
-  numeric/CmplxCHOL.cc \
-  numeric/CmplxGEPBAL.cc \
-  numeric/CmplxHESS.cc \
-  numeric/CmplxLU.cc \
-  numeric/CmplxQR.cc \
-  numeric/CmplxQRP.cc \
-  numeric/CmplxSCHUR.cc \
-  numeric/CmplxSVD.cc \
-  numeric/CollocWt.cc \
-  numeric/DASPK.cc \
-  numeric/DASRT.cc \
-  numeric/DASSL.cc \
-  numeric/dbleAEPBAL.cc \
-  numeric/dbleCHOL.cc \
-  numeric/dbleGEPBAL.cc \
-  numeric/dbleHESS.cc \
-  numeric/dbleLU.cc \
-  numeric/dbleQR.cc \
-  numeric/dbleQRP.cc \
-  numeric/dbleSCHUR.cc \
-  numeric/dbleSVD.cc \
-  numeric/EIG.cc \
-  numeric/fCmplxAEPBAL.cc \
-  numeric/fCmplxCHOL.cc \
-  numeric/fCmplxGEPBAL.cc \
-  numeric/fCmplxHESS.cc \
-  numeric/fCmplxLU.cc \
-  numeric/fCmplxQR.cc \
-  numeric/fCmplxQRP.cc \
-  numeric/fCmplxSCHUR.cc \
-  numeric/fCmplxSVD.cc \
-  numeric/fEIG.cc \
-  numeric/floatAEPBAL.cc \
-  numeric/floatCHOL.cc \
-  numeric/floatGEPBAL.cc \
-  numeric/floatHESS.cc \
-  numeric/floatLU.cc \
-  numeric/floatQR.cc \
-  numeric/floatQRP.cc \
-  numeric/floatSCHUR.cc \
-  numeric/floatSVD.cc \
-  numeric/lo-mappers.cc \
-  numeric/lo-specfun.cc \
-  numeric/LSODE.cc \
-  numeric/oct-convn.cc \
-  numeric/oct-fftw.cc \
-  numeric/oct-norm.cc \
-  numeric/oct-rand.cc \
-  numeric/oct-spparms.cc \
-  numeric/ODES.cc \
-  numeric/Quad.cc \
-  numeric/SparseCmplxCHOL.cc \
-  numeric/SparseCmplxLU.cc \
-  numeric/SparseCmplxQR.cc \
-  numeric/SparsedbleCHOL.cc \
-  numeric/SparsedbleLU.cc \
-  numeric/SparseQR.cc \
+  liboctave/numeric/CmplxAEPBAL.cc \
+  liboctave/numeric/CmplxCHOL.cc \
+  liboctave/numeric/CmplxGEPBAL.cc \
+  liboctave/numeric/CmplxHESS.cc \
+  liboctave/numeric/CmplxLU.cc \
+  liboctave/numeric/CmplxQR.cc \
+  liboctave/numeric/CmplxQRP.cc \
+  liboctave/numeric/CmplxSCHUR.cc \
+  liboctave/numeric/CmplxSVD.cc \
+  liboctave/numeric/CollocWt.cc \
+  liboctave/numeric/DASPK.cc \
+  liboctave/numeric/DASRT.cc \
+  liboctave/numeric/DASSL.cc \
+  liboctave/numeric/dbleAEPBAL.cc \
+  liboctave/numeric/dbleCHOL.cc \
+  liboctave/numeric/dbleGEPBAL.cc \
+  liboctave/numeric/dbleHESS.cc \
+  liboctave/numeric/dbleLU.cc \
+  liboctave/numeric/dbleQR.cc \
+  liboctave/numeric/dbleQRP.cc \
+  liboctave/numeric/dbleSCHUR.cc \
+  liboctave/numeric/dbleSVD.cc \
+  liboctave/numeric/EIG.cc \
+  liboctave/numeric/fCmplxAEPBAL.cc \
+  liboctave/numeric/fCmplxCHOL.cc \
+  liboctave/numeric/fCmplxGEPBAL.cc \
+  liboctave/numeric/fCmplxHESS.cc \
+  liboctave/numeric/fCmplxLU.cc \
+  liboctave/numeric/fCmplxQR.cc \
+  liboctave/numeric/fCmplxQRP.cc \
+  liboctave/numeric/fCmplxSCHUR.cc \
+  liboctave/numeric/fCmplxSVD.cc \
+  liboctave/numeric/fEIG.cc \
+  liboctave/numeric/floatAEPBAL.cc \
+  liboctave/numeric/floatCHOL.cc \
+  liboctave/numeric/floatGEPBAL.cc \
+  liboctave/numeric/floatHESS.cc \
+  liboctave/numeric/floatLU.cc \
+  liboctave/numeric/floatQR.cc \
+  liboctave/numeric/floatQRP.cc \
+  liboctave/numeric/floatSCHUR.cc \
+  liboctave/numeric/floatSVD.cc \
+  liboctave/numeric/lo-mappers.cc \
+  liboctave/numeric/lo-specfun.cc \
+  liboctave/numeric/LSODE.cc \
+  liboctave/numeric/oct-convn.cc \
+  liboctave/numeric/oct-fftw.cc \
+  liboctave/numeric/oct-norm.cc \
+  liboctave/numeric/oct-rand.cc \
+  liboctave/numeric/oct-spparms.cc \
+  liboctave/numeric/ODES.cc \
+  liboctave/numeric/Quad.cc \
+  liboctave/numeric/SparseCmplxCHOL.cc \
+  liboctave/numeric/SparseCmplxLU.cc \
+  liboctave/numeric/SparseCmplxQR.cc \
+  liboctave/numeric/SparsedbleCHOL.cc \
+  liboctave/numeric/SparsedbleLU.cc \
+  liboctave/numeric/SparseQR.cc \
   $(NUMERIC_C_SRC)
 
-TEMPLATE_SRC += \
-  numeric/base-lu.cc \
-  numeric/base-qr.cc \
-  numeric/bsxfun-defs.cc \
-  numeric/eigs-base.cc \
-  numeric/sparse-base-chol.cc \
-  numeric/sparse-base-lu.cc \
-  numeric/sparse-dmsolve.cc
+LIBOCTAVE_TEMPLATE_SRC += \
+  liboctave/numeric/base-lu.cc \
+  liboctave/numeric/base-qr.cc \
+  liboctave/numeric/bsxfun-defs.cc \
+  liboctave/numeric/eigs-base.cc \
+  liboctave/numeric/sparse-base-chol.cc \
+  liboctave/numeric/sparse-base-lu.cc \
+  liboctave/numeric/sparse-dmsolve.cc
 
 ## Special rules for sources which must be built before rest of compilation.
-$(OPT_INC) : %.h : %.in
+$(LIBOCTAVE_OPT_INC) : %.h : %.in
 	$(AM_V_GEN)rm -f $@-t $@ && \
 	$(PERL) $(top_srcdir)/build-aux/mk-opts.pl --opt-class-header $< > $@-t && \
 	mv $@-t $@
 
-$(OPT_INC) : $(top_srcdir)/build-aux/mk-opts.pl
+$(LIBOCTAVE_OPT_INC) : $(top_srcdir)/build-aux/mk-opts.pl
 
-noinst_LTLIBRARIES += numeric/libnumeric.la
+noinst_LTLIBRARIES += liboctave/numeric/libnumeric.la
 
-numeric_libnumeric_la_SOURCES = $(NUMERIC_SRC)
-numeric_libnumeric_la_CPPFLAGS = \
-  $(liboctave_la_CPPFLAGS) \
-  -I$(srcdir)/cruft/Faddeeva \
+liboctave_numeric_libnumeric_la_SOURCES = $(NUMERIC_SRC)
+
+liboctave_numeric_libnumeric_la_CPPFLAGS = \
+  $(liboctave_liboctave_la_CPPFLAGS) \
+  -I$(srcdir)/liboctave/cruft/Faddeeva \
   $(FFTW_XCPPFLAGS) \
   $(SPARSE_XCPPFLAGS)
 
-liboctave_la_LIBADD += numeric/libnumeric.la
+liboctave_numeric_libnumeric_la_CFLAGS = $(liboctave_liboctave_la_CFLAGS)
+
+liboctave_numeric_libnumeric_la_CXXFLAGS = $(liboctave_liboctave_la_CXXFLAGS)
+
+liboctave_liboctave_la_LIBADD += liboctave/numeric/libnumeric.la
+
+liboctave_EXTRA_DIST += $(LIBOCTAVE_OPT_IN)
+
--- a/liboctave/numeric/oct-convn.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/oct-convn.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_oct_convn_h)
+#if ! defined (octave_oct_convn_h)
 #define octave_oct_convn_h 1
 
 #include "dMatrix.h"
--- a/liboctave/numeric/oct-fftw.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/oct-fftw.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_fftw_h)
+#if ! defined (octave_oct_fftw_h)
 #define octave_oct_fftw_h 1
 
 #include <cstddef>
--- a/liboctave/numeric/oct-norm.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/oct-norm.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -459,7 +459,7 @@
 
       z = z.hermitian ();
       x = dual_p (z, q, p);
-      iter ++;
+      iter++;
     }
 
   return gamma;
--- a/liboctave/numeric/oct-norm.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/oct-norm.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 // author: Jaroslav Hajek <highegg@gmail.com>
 
-#if !defined (octave_oct_norm_h)
+#if ! defined (octave_oct_norm_h)
 #define octave_oct_norm_h 1
 
 #include "oct-cmplx.h"
--- a/liboctave/numeric/oct-rand.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/oct-rand.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -513,7 +513,7 @@
     {
       retval.clear (n, 1);
 
-      fill (retval.capacity (), retval.fortran_vec (), a);
+      fill (retval.numel (), retval.fortran_vec (), a);
     }
   else if (n < 0)
     (*current_liboctave_error_handler) ("rand: invalid negative argument");
@@ -530,7 +530,7 @@
     {
       retval.clear (n, 1);
 
-      fill (retval.capacity (), retval.fortran_vec (), a);
+      fill (retval.numel (), retval.fortran_vec (), a);
     }
   else if (n < 0)
     (*current_liboctave_error_handler) ("rand: invalid negative argument");
@@ -547,7 +547,7 @@
     {
       retval.clear (dims);
 
-      fill (retval.capacity (), retval.fortran_vec (), a);
+      fill (retval.numel (), retval.fortran_vec (), a);
     }
 
   return retval;
@@ -562,7 +562,7 @@
     {
       retval.clear (dims);
 
-      fill (retval.capacity (), retval.fortran_vec (), a);
+      fill (retval.numel (), retval.fortran_vec (), a);
     }
 
   return retval;
@@ -690,7 +690,7 @@
 void
 octave_rand::set_internal_state (const ColumnVector& s)
 {
-  octave_idx_type len = s.length ();
+  octave_idx_type len = s.numel ();
   octave_idx_type n = len < MT_N + 1 ? len : MT_N + 1;
 
   OCTAVE_LOCAL_BUFFER (uint32_t, tmp, MT_N + 1);
--- a/liboctave/numeric/oct-rand.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/oct-rand.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_rand_h)
+#if ! defined (octave_oct_rand_h)
 #define octave_oct_rand_h 1
 
 #include <map>
--- a/liboctave/numeric/oct-spparms.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/oct-spparms.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -177,7 +177,7 @@
 bool
 octave_sparse_params::do_set_vals (const NDArray& vals)
 {
-  octave_idx_type len = vals.length ();
+  octave_idx_type len = vals.numel ();
 
   if (len > OCTAVE_SPARSE_CONTROLS_SIZE)
     {
--- a/liboctave/numeric/oct-spparms.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/oct-spparms.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_oct_spparms_h)
+#if ! defined (octave_oct_spparms_h)
 #define octave_oct_spparms_h 1
 
 #include <cassert>
--- a/liboctave/numeric/randmtzig.c	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/randmtzig.c	Thu Dec 10 12:50:06 2015 -0800
@@ -167,7 +167,7 @@
 #include "randmtzig.h"
 
 /* FIXME may want to suppress X86 if sizeof(long) > 4 */
-#if !defined (USE_X86_32)
+#if ! defined (USE_X86_32)
 # if defined (i386) || defined (HAVE_X86_32)
 #  define USE_X86_32 1
 # else
--- a/liboctave/numeric/sparse-base-chol.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/sparse-base-chol.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -280,7 +280,7 @@
   MatrixType mattype (MatrixType::Upper);
   chol_type linv = L ().hermitian ().inverse (mattype, info, rcond2, 1, 0);
 
-  if (perms.length () == n)
+  if (perms.numel () == n)
     {
       p_type Qc = Q ();
       retval = Qc * linv * linv.hermitian () * Qc.transpose ();
--- a/liboctave/numeric/sparse-base-chol.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/sparse-base-chol.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_sparse_base_chol_h)
+#if ! defined (octave_sparse_base_chol_h)
 #define octave_sparse_base_chol_h 1
 
 #include "oct-sparse.h"
--- a/liboctave/numeric/sparse-base-lu.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/sparse-base-lu.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 */
 
 
-#if !defined (octave_sparse_base_lu_h)
+#if ! defined (octave_sparse_base_lu_h)
 #define octave_sparse_base_lu_h 1
 
 #include "MArray.h"
--- a/liboctave/numeric/sparse-dmsolve.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/numeric/sparse-dmsolve.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -109,7 +109,7 @@
   return B;
 }
 
-#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
+#if ! defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
 static MSparse<double>
 dmsolve_extract (const MSparse<double> &A, const octave_idx_type *Pinv,
                  const octave_idx_type *Q, octave_idx_type rst,
@@ -149,7 +149,7 @@
   return result;
 }
 
-#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
+#if ! defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
 static MArray<double>
 dmsolve_extract (const MArray<double> &m, const octave_idx_type *,
                  const octave_idx_type *, octave_idx_type r1,
@@ -185,7 +185,7 @@
     }
 }
 
-#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
+#if ! defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
 static void
 dmsolve_insert (MArray<double> &a, const MArray<double> &b,
                 const octave_idx_type *Q, octave_idx_type r, octave_idx_type c);
@@ -272,7 +272,7 @@
     }
 }
 
-#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
+#if ! defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
 static void
 dmsolve_insert (MSparse<double> &a, const SparseMatrix &b,
                 const octave_idx_type *Q, octave_idx_type r, octave_idx_type c);
@@ -302,7 +302,7 @@
     }
 }
 
-#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
+#if ! defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
 static void
 dmsolve_permute (MArray<double> &a, const MArray<double>& b,
                  const octave_idx_type *p);
@@ -348,7 +348,7 @@
     }
 }
 
-#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
+#if ! defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
 static void
 dmsolve_permute (MSparse<double> &a, const MSparse<double>& b,
                  const octave_idx_type *p);
@@ -489,7 +489,7 @@
 #endif
 }
 
-#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
+#if ! defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
 extern Matrix
 dmsolve (const SparseMatrix &a, const Matrix &b,
          octave_idx_type &info);
--- a/liboctave/operators/Sparse-diag-op-defs.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/operators/Sparse-diag-op-defs.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_Sparse_diag_op_defs_h)
+#if ! defined (octave_Sparse_diag_op_defs_h)
 #define octave_Sparse_diag_op_defs_h 1
 
 // Matrix multiplication
--- a/liboctave/operators/Sparse-op-decls.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/operators/Sparse-op-decls.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 */
 
-#if !defined (octave_Sparse_op_decls_h)
+#if ! defined (octave_Sparse_op_decls_h)
 #define octave_Sparse_op_decls_h 1
 
 class SparseBoolMatrix;
--- a/liboctave/operators/Sparse-op-defs.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/operators/Sparse-op-defs.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 */
 
-#if !defined (octave_Sparse_op_defs_h)
+#if ! defined (octave_Sparse_op_defs_h)
 #define octave_Sparse_op_defs_h 1
 
 #include "Array-util.h"
--- a/liboctave/operators/Sparse-perm-op-defs.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/operators/Sparse-perm-op-defs.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_Sparse_perm_op_defs_h)
+#if ! defined (octave_Sparse_perm_op_defs_h)
 #define octave_Sparse_perm_op_defs_h 1
 
 // Matrix multiplication
--- a/liboctave/operators/mk-ops.awk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/operators/mk-ops.awk	Thu Dec 10 12:50:06 2015 -0800
@@ -26,7 +26,7 @@
       print "// DO NOT EDIT -- generated by mk-ops";
       tmp = make_inclusive_header;
       gsub (/[\.-]/, "_", tmp);
-      printf ("#if !defined (octave_%s)\n", tmp);
+      printf ("#if ! defined (octave_%s)\n", tmp);
       printf ("#define octave_%s 1\n", tmp);
     }
 }
@@ -93,13 +93,13 @@
 
           if (list_cc_files)
             {
-              printf (" operators/%s", cc_file);
+              printf (" liboctave/operators/%s", cc_file);
               next;
             }
 
           if (list_h_files)
             {
-              printf (" operators/%s", h_file);
+              printf (" liboctave/operators/%s", h_file);
               next;
             }
 
@@ -135,7 +135,7 @@
 
           print "// DO NOT EDIT -- generated by mk-ops" > h_file;
 
-          printf ("#if !defined (%s)\n", h_guard) >> h_file;
+          printf ("#if ! defined (%s)\n", h_guard) >> h_file;
           printf ("#define %s 1\n", h_guard) >> h_file;
 
           if (result_header)
--- a/liboctave/operators/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/operators/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,78 +1,76 @@
-EXTRA_DIST += \
-  operators/module.mk \
-  operators/config-ops.sh \
-  operators/mk-ops.awk \
-  operators/mx-op-inc.mk \
-  operators/mx-op-src.mk \
-  operators/mx-ops \
-  operators/smx-op-inc.mk \
-  operators/smx-op-src.mk \
-  operators/sparse-mk-ops.awk \
-  operators/smx-ops \
-  operators/vx-op-inc.mk \
-  operators/vx-op-src.mk \
-  operators/vx-ops
+include liboctave/operators/vx-op-inc.mk
+include liboctave/operators/mx-op-inc.mk
+include liboctave/operators/smx-op-inc.mk
 
-include operators/vx-op-inc.mk
-include operators/mx-op-inc.mk
-include operators/smx-op-inc.mk
+include liboctave/operators/vx-op-src.mk
+include liboctave/operators/mx-op-src.mk
+include liboctave/operators/smx-op-src.mk
 
-include operators/vx-op-src.mk
-include operators/mx-op-src.mk
-include operators/smx-op-src.mk
-
-BUILT_LIBOPERATORS_SOURCES = \
+BUILT_LIBOCTAVE_OPERATORS_SOURCES = \
   $(MX_OP_SRC) \
   $(VX_OP_SRC) \
   $(SMX_OP_SRC)
 
-OPERATORS_INC = \
-  operators/mx-base.h \
-  operators/mx-defs.h \
-  operators/mx-ext.h \
-  operators/mx-op-decl.h \
-  operators/mx-op-defs.h \
-  operators/Sparse-diag-op-defs.h \
-  operators/Sparse-op-decls.h \
-  operators/Sparse-op-defs.h \
-  operators/Sparse-perm-op-defs.h
+LIBOCTAVE_OPERATORS_INC = \
+  liboctave/operators/mx-base.h \
+  liboctave/operators/mx-defs.h \
+  liboctave/operators/mx-ext.h \
+  liboctave/operators/mx-op-decl.h \
+  liboctave/operators/mx-op-defs.h \
+  liboctave/operators/Sparse-diag-op-defs.h \
+  liboctave/operators/Sparse-op-decls.h \
+  liboctave/operators/Sparse-op-defs.h \
+  liboctave/operators/Sparse-perm-op-defs.h
 
 ## There are no distributed source files in this directory
-OPERATORS_SRC =
+LIBOCTAVE_OPERATORS_SRC =
 
-TEMPLATE_SRC += \
-  operators/mx-inlines.cc
+LIBOCTAVE_TEMPLATE_SRC += \
+  liboctave/operators/mx-inlines.cc
 
 OP_SRCDIR = $(abs_top_srcdir)/liboctave/operators
 
 define run-mx-ops
-  ( cd operators; \
+  ( cd liboctave/operators; \
     $(AWK) -f $(OP_SRCDIR)/$(2)mk-ops.awk prefix=$(1) $(OP_SRCDIR)/$(1)-ops \
   )
 endef
 
 ## Special rules for sources which must be built before rest of compilation.
-$(VX_OP_INC) $(VX_OP_SRC) : operators/mk-ops.awk operators/vx-ops
+$(VX_OP_INC) $(VX_OP_SRC) : liboctave/operators/mk-ops.awk liboctave/operators/vx-ops
 	$(AM_V_GEN)$(call run-mx-ops,vx)
 
-$(MX_OP_INC) $(MX_OP_SRC) : operators/mk-ops.awk operators/mx-ops
+$(MX_OP_INC) $(MX_OP_SRC) : liboctave/operators/mk-ops.awk liboctave/operators/mx-ops
 	$(AM_V_GEN)$(call run-mx-ops,mx)
 
-$(SMX_OP_INC) $(SMX_OP_SRC) : operators/sparse-mk-ops.awk operators/smx-ops
+$(SMX_OP_INC) $(SMX_OP_SRC) : liboctave/operators/sparse-mk-ops.awk liboctave/operators/smx-ops
 	$(AM_V_GEN)$(call run-mx-ops,smx,sparse-)
 
-operators/mx-ops.h : operators/mk-ops.awk operators/mx-ops
+liboctave/operators/mx-ops.h : liboctave/operators/mk-ops.awk liboctave/operators/mx-ops
 	$(AM_V_GEN)rm -f $@-t $@ && \
 	$(AWK) -f $(OP_SRCDIR)/mk-ops.awk prefix=mx make_inclusive_header=mx-ops.h $(OP_SRCDIR)/mx-ops > $@-t && \
 	mv $@-t $@
 
-noinst_LTLIBRARIES += operators/liboperators.la
+noinst_LTLIBRARIES += liboctave/operators/liboperators.la
+
+liboctave_operators_liboperators_la_SOURCES = $(LIBOCTAVE_OPERATORS_SRC)
+
+nodist_liboctave_operators_liboperators_la_SOURCES = $(BUILT_LIBOCTAVE_OPERATORS_SOURCES)
 
-operators_liboperators_la_SOURCES = $(OPERATORS_SRC)
-nodist_operators_liboperators_la_SOURCES = $(BUILT_LIBOPERATORS_SOURCES)
+liboctave_operators_liboperators_la_CPPFLAGS = $(liboctave_liboctave_la_CPPFLAGS)
+
+liboctave_operators_liboperators_la_CFLAGS = $(liboctave_liboctave_la_CFLAGS)
+
+liboctave_operators_liboperators_la_CXXFLAGS = $(liboctave_liboctave_la_CXXFLAGS)
 
-operators_liboperators_la_CPPFLAGS = $(liboctave_la_CPPFLAGS)
+liboctave_liboctave_la_LIBADD += liboctave/operators/liboperators.la
 
-DISTCLEANFILES += $(BUILT_LIBOPERATORS_SOURCES)
+liboctave_EXTRA_DIST += \
+  liboctave/operators/config-ops.sh \
+  liboctave/operators/mk-ops.awk \
+  liboctave/operators/mx-ops \
+  liboctave/operators/sparse-mk-ops.awk \
+  liboctave/operators/smx-ops \
+  liboctave/operators/vx-ops
 
-liboctave_la_LIBADD += operators/liboperators.la
+liboctave_DISTCLEANFILES += $(BUILT_LIBOCTAVE_OPERATORS_SOURCES)
--- a/liboctave/operators/mx-base.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/operators/mx-base.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_mx_base_h)
+#if ! defined (octave_mx_base_h)
 #define octave_mx_base_h 1
 
 // Matrix Type class
--- a/liboctave/operators/mx-defs.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/operators/mx-defs.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_mx_defs_h)
+#if ! defined (octave_mx_defs_h)
 #define octave_mx_defs_h 1
 
 // Classes we declare.
--- a/liboctave/operators/mx-ext.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/operators/mx-ext.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_mx_ext_h)
+#if ! defined (octave_mx_ext_h)
 #define octave_mx_ext_h 1
 
 // Result of a AEP Balance operation.
--- a/liboctave/operators/mx-inlines.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/operators/mx-inlines.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 */
 
-#if !defined (octave_mx_inlines_h)
+#if ! defined (octave_mx_inlines_h)
 #define octave_mx_inlines_h 1
 
 #include <cstddef>
@@ -371,7 +371,7 @@
   if (dx == dy)
     {
       Array<R> r (dx);
-      op (r.length (), r.fortran_vec (), x.data (), y.data ());
+      op (r.numel (), r.fortran_vec (), x.data (), y.data ());
       return r;
     }
   else if (is_valid_bsxfun (opname, dx, dy))
@@ -391,7 +391,7 @@
                  void (*op) (size_t, R *, const X *, Y) throw ())
 {
   Array<R> r (x.dims ());
-  op (r.length (), r.fortran_vec (), x.data (), y);
+  op (r.numel (), r.fortran_vec (), x.data (), y);
   return r;
 }
 
@@ -401,7 +401,7 @@
                  void (*op) (size_t, R *, X, const Y *) throw ())
 {
   Array<R> r (y.dims ());
-  op (r.length (), r.fortran_vec (), x, y.data ());
+  op (r.numel (), r.fortran_vec (), x, y.data ());
   return r;
 }
 
@@ -416,7 +416,7 @@
   dim_vector dx = x.dims ();
   if (dr == dx)
     {
-      op (r.length (), r.fortran_vec (), x.data ());
+      op (r.numel (), r.fortran_vec (), x.data ());
     }
   else if (is_valid_inplace_bsxfun (opname, dr, dx))
     {
@@ -432,7 +432,7 @@
 do_ms_inplace_op (Array<R>& r, const X& x,
                   void (*op) (size_t, R *, X) throw ())
 {
-  op (r.length (), r.fortran_vec (), x);
+  op (r.numel (), r.fortran_vec (), x);
   return r;
 }
 
@@ -1179,9 +1179,9 @@
       // calculate extent triplet.
       l = 1, n = dims(dim), u = 1;
       for (octave_idx_type i = 0; i < dim; i++)
-        l *= dims (i);
+        l *= dims(i);
       for (octave_idx_type i = dim + 1; i < ndims; i++)
-        u *= dims (i);
+        u *= dims(i);
     }
 }
 
@@ -1199,7 +1199,7 @@
   dim_vector dims = src.dims ();
   // M*b inconsistency: sum ([]) = 0 etc.
   if (dims.length () == 2 && dims(0) == 0 && dims(1) == 0)
-    dims (1) = 1;
+    dims(1) = 1;
 
   get_extent_triplet (dims, dim, l, n, u);
 
@@ -1327,7 +1327,7 @@
 
   if (dims(dim) <= order)
     {
-      dims (dim) = 0;
+      dims(dim) = 0;
       return Array<R> (dims);
     }
   else
--- a/liboctave/operators/mx-op-decl.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/operators/mx-op-decl.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 */
 
-#if !defined (octave_mx_op_decl_h)
+#if ! defined (octave_mx_op_decl_h)
 #define octave_mx_op_decl_h 1
 
 #define BIN_OP_DECL(R, OP, X, Y, API) \
--- a/liboctave/operators/mx-op-defs.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/operators/mx-op-defs.h	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 
 */
 
-#if !defined (octave_mx_op_defs_h)
+#if ! defined (octave_mx_op_defs_h)
 #define octave_mx_op_defs_h 1
 
 #include "lo-array-gripes.h"
--- a/liboctave/operators/sparse-mk-ops.awk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/operators/sparse-mk-ops.awk	Thu Dec 10 12:50:06 2015 -0800
@@ -26,7 +26,7 @@
       print "// DO NOT EDIT -- generated by sparse-mk-ops";
       tmp = make_inclusive_header;
       gsub (/[\.-]/, "_", tmp);
-      printf ("#if !defined (octave_%s)\n", tmp);
+      printf ("#if ! defined (octave_%s)\n", tmp);
       printf ("#define octave_%s 1\n", tmp);
     }
 }
@@ -92,13 +92,13 @@
 
           if (list_cc_files)
             {
-              printf (" operators/%s", cc_file);
+              printf (" liboctave/operators/%s", cc_file);
               next;
             }
 
           if (list_h_files)
             {
-              printf (" operators/%s", h_file);
+              printf (" liboctave/operators/%s", h_file);
               next;
             }
 
@@ -135,7 +135,7 @@
 
           print "// DO NOT EDIT -- generated by sparse-mk-ops" > h_file;
 
-          printf ("#if !defined (%s)\n", h_guard) >> h_file;
+          printf ("#if ! defined (%s)\n", h_guard) >> h_file;
           printf ("#define %s 1\n", h_guard) >> h_file;
 
           if (result_header_1)
--- a/liboctave/system/dir-ops.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/dir-ops.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -61,7 +61,7 @@
         errmsg = gnulib::strerror (errno);
     }
   else
-    errmsg = "dir_entry::open: empty file name";
+    errmsg = "dir_entry::open: empty filename";
 
   return ! fail;
 }
--- a/liboctave/system/dir-ops.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/dir-ops.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_dir_ops_h)
+#if ! defined (octave_dir_ops_h)
 #define octave_dir_ops_h 1
 
 #include <string>
--- a/liboctave/system/file-ops.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/file-ops.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -156,7 +156,7 @@
     {
       for (size_t i = 0; i < s_len; i++)
         {
-          for (int j = 0; j < prefixes.length (); j++)
+          for (int j = 0; j < prefixes.numel (); j++)
             {
               size_t pfx_len = prefixes[j].length ();
 
@@ -191,7 +191,7 @@
 
       if (! suffixes.empty ())
         {
-          for (int j = 0; j < suffixes.length (); j++)
+          for (int j = 0; j < suffixes.numel (); j++)
             {
               size_t sfx_len = suffixes[j].length ();
 
@@ -350,7 +350,7 @@
 {
   string_vector retval;
 
-  int n = names.length ();
+  int n = names.numel ();
 
   retval.resize (n);
 
@@ -584,7 +584,7 @@
     {
       string_vector dirlist = dir.read ();
 
-      for (octave_idx_type i = 0; i < dirlist.length (); i++)
+      for (octave_idx_type i = 0; i < dirlist.numel (); i++)
         {
           octave_quit ();
 
--- a/liboctave/system/file-ops.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/file-ops.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_file_ops_h)
+#if ! defined (octave_file_ops_h)
 #define octave_file_ops_h 1
 
 #include <string>
@@ -82,7 +82,7 @@
 
   static std::string concat (const std::string&, const std::string&);
 
-  // Return the tail member of a file name.
+  // Return the tail member of a filename.
   static std::string tail (const std::string& path)
   {
     size_t ipos = path.find_last_of (dir_sep_chars ());
--- a/liboctave/system/file-stat.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/file-stat.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_file_stat_h)
+#if ! defined (octave_file_stat_h)
 #define octave_file_stat_h 1
 
 #include <string>
@@ -235,7 +235,7 @@
 
   void get_stats (const std::string& n, bool force = false)
   {
-    if (n != file_name || ! initialized  || force)
+    if (n != file_name || ! initialized || force)
       {
         initialized = false;
 
@@ -293,7 +293,7 @@
 
   void get_stats (int n, bool force = false)
   {
-    if (n != fid || ! initialized  || force)
+    if (n != fid || ! initialized || force)
       {
         initialized = false;
 
--- a/liboctave/system/lo-sysdep.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/lo-sysdep.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_lo_sysdep_h)
+#if ! defined (octave_lo_sysdep_h)
 #define octave_lo_sysdep_h 1
 
 #include <string>
--- a/liboctave/system/mach-info.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/mach-info.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_mach_info_h)
+#if ! defined (octave_mach_info_h)
 #define octave_mach_info_h 1
 
 #include <string>
--- a/liboctave/system/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,39 +1,41 @@
-EXTRA_DIST += \
-  system/module.mk
-
 SYSTEM_INC = \
-  system/dir-ops.h \
-  system/file-ops.h \
-  system/file-stat.h \
-  system/lo-sysdep.h \
-  system/mach-info.h \
-  system/oct-env.h \
-  system/oct-group.h \
-  system/oct-openmp.h \
-  system/oct-passwd.h \
-  system/oct-syscalls.h \
-  system/oct-time.h \
-  system/oct-uname.h \
-  system/pathlen.h \
-  system/sysdir.h \
-  system/syswait.h
+  liboctave/system/dir-ops.h \
+  liboctave/system/file-ops.h \
+  liboctave/system/file-stat.h \
+  liboctave/system/lo-sysdep.h \
+  liboctave/system/mach-info.h \
+  liboctave/system/oct-env.h \
+  liboctave/system/oct-group.h \
+  liboctave/system/oct-openmp.h \
+  liboctave/system/oct-passwd.h \
+  liboctave/system/oct-syscalls.h \
+  liboctave/system/oct-time.h \
+  liboctave/system/oct-uname.h \
+  liboctave/system/pathlen.h \
+  liboctave/system/sysdir.h \
+  liboctave/system/syswait.h
 
 SYSTEM_SRC = \
-  system/dir-ops.cc \
-  system/file-ops.cc \
-  system/file-stat.cc \
-  system/lo-sysdep.cc \
-  system/mach-info.cc \
-  system/oct-env.cc \
-  system/oct-group.cc \
-  system/oct-passwd.cc \
-  system/oct-syscalls.cc \
-  system/oct-time.cc \
-  system/oct-uname.cc
+  liboctave/system/dir-ops.cc \
+  liboctave/system/file-ops.cc \
+  liboctave/system/file-stat.cc \
+  liboctave/system/lo-sysdep.cc \
+  liboctave/system/mach-info.cc \
+  liboctave/system/oct-env.cc \
+  liboctave/system/oct-group.cc \
+  liboctave/system/oct-passwd.cc \
+  liboctave/system/oct-syscalls.cc \
+  liboctave/system/oct-time.cc \
+  liboctave/system/oct-uname.cc
 
-noinst_LTLIBRARIES += system/libsystem.la
+noinst_LTLIBRARIES += liboctave/system/libsystem.la
+
+liboctave_system_libsystem_la_SOURCES = $(SYSTEM_SRC)
+
+liboctave_system_libsystem_la_CPPFLAGS = $(liboctave_liboctave_la_CPPFLAGS)
 
-system_libsystem_la_SOURCES = $(SYSTEM_SRC)
-system_libsystem_la_CPPFLAGS = $(liboctave_la_CPPFLAGS)
+liboctave_system_libsystem_la_CFLAGS = $(liboctave_liboctave_la_CFLAGS)
 
-liboctave_la_LIBADD += system/libsystem.la
+liboctave_system_libsystem_la_CXXFLAGS = $(liboctave_liboctave_la_CXXFLAGS)
+
+liboctave_liboctave_la_LIBADD += liboctave/system/libsystem.la
--- a/liboctave/system/oct-env.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/oct-env.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_env_h)
+#if ! defined (octave_oct_env_h)
 #define octave_oct_env_h 1
 
 #include <string>
--- a/liboctave/system/oct-group.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/oct-group.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_group_h)
+#if ! defined (octave_oct_group_h)
 #define octave_oct_group_h 1
 
 #include <string>
--- a/liboctave/system/oct-openmp.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/oct-openmp.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_openmp_h)
+#if ! defined (octave_oct_openmp_h)
 #define octave_oct_openmp_h 1
 
 /* A macro to make using OpenMP easier, and easier to disable */
--- a/liboctave/system/oct-passwd.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/oct-passwd.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_passwd_h)
+#if ! defined (octave_oct_passwd_h)
 #define octave_oct_passwd_h 1
 
 #include <string>
--- a/liboctave/system/oct-syscalls.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/oct-syscalls.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_syscalls_h)
+#if ! defined (octave_oct_syscalls_h)
 #define octave_oct_syscalls_h 1
 
 #include <string>
--- a/liboctave/system/oct-time.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/oct-time.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -55,7 +55,7 @@
   t.tm_yday = tm.yday ();
   t.tm_isdst = tm.isdst ();
 
-#if defined (HAVE_STRUCT_TM_GMTOFF)
+#if defined (HAVE_TM_GMTOFF)
   t.tm_gmtoff = tm.gmtoff ();
 #endif
 
@@ -136,7 +136,7 @@
   return *this;
 }
 
-#if !defined STRFTIME_BUF_INITIAL_SIZE
+#if ! defined STRFTIME_BUF_INITIAL_SIZE
 #define STRFTIME_BUF_INITIAL_SIZE 128
 #endif
 
@@ -159,7 +159,7 @@
       t.tm_yday = tm_yday;
       t.tm_isdst = tm_isdst;
 
-#if defined (HAVE_STRUCT_TM_GMTOFF)
+#if defined (HAVE_TM_GMTOFF)
       t.tm_gmtoff = tm_gmtoff;
 #endif
 
@@ -215,7 +215,7 @@
   tm_yday = t->tm_yday;
   tm_isdst = t->tm_isdst;
 
-#if defined (HAVE_STRUCT_TM_GMTOFF)
+#if defined (HAVE_TM_GMTOFF)
   tm_gmtoff = t->tm_gmtoff;
 #endif
 
@@ -263,7 +263,7 @@
   t.tm_yday = 0;
   t.tm_isdst = 0;
 
-#if defined (HAVE_STRUCT_TM_GMTOFF)
+#if defined (HAVE_TM_GMTOFF)
   t.tm_gmtoff = 0;
 #endif
 
--- a/liboctave/system/oct-time.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/oct-time.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_time_h)
+#if ! defined (octave_oct_time_h)
 #define octave_oct_time_h 1
 
 #include <ctime>
--- a/liboctave/system/oct-uname.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/oct-uname.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_uname_h)
+#if ! defined (octave_oct_uname_h)
 #define octave_uname_h 1
 
 #include <string>
--- a/liboctave/system/pathlen.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/pathlen.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pathlen_h)
+#if ! defined (octave_pathlen_h)
 #define octave_pathlen_h 1
 
 #ifdef HAVE_SYS_PARAM_H
--- a/liboctave/system/sysdir.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/sysdir.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_sysdir_h)
+#if ! defined (octave_sysdir_h)
 #define octave_sysdir_h 1
 
 // This mess suggested by the autoconf manual.
--- a/liboctave/system/syswait.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/system/syswait.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_syswait_h)
+#if ! defined (octave_syswait_h)
 #define octave_syswait_h 1
 
 #ifdef __cplusplus
--- a/liboctave/util/action-container.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/action-container.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_action_container_h)
+#if ! defined (octave_action_container_h)
 #define octave_action_container_h 1
 
 // This class allows registering actions in a list for later
--- a/liboctave/util/base-list.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/base-list.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_base_list_h)
+#if ! defined (octave_base_list_h)
 #define octave_base_list_h 1
 
 #include <cstdlib>
--- a/liboctave/util/byte-swap.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/byte-swap.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_byte_swap_h)
+#if ! defined (octave_byte_swap_h)
 #define octave_byte_swap_h 1
 
 static inline void
--- a/liboctave/util/caseless-str.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/caseless-str.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_caseless_str_h)
+#if ! defined (octave_caseless_str_h)
 #define octave_caseless_str_h 1
 
 #include <cctype>
--- a/liboctave/util/cmd-edit.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/cmd-edit.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -1668,7 +1668,7 @@
                   {
                     temp = octave_env::get_current_directory ();
                   }
-                catch (octave_execution_exception)
+                catch (const octave_execution_exception&)
                   {
                     temp = "";
                   }
--- a/liboctave/util/cmd-edit.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/cmd-edit.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_cmd_edit_h)
+#if ! defined (octave_cmd_edit_h)
 #define octave_cmd_edit_h 1
 
 #include <cstdio>
--- a/liboctave/util/cmd-hist.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/cmd-hist.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -317,7 +317,7 @@
         }
     }
   else
-    error ("gnu_history::read: missing file name");
+    error ("gnu_history::read: missing filename");
 }
 
 void
@@ -347,7 +347,7 @@
         }
     }
   else
-    error ("gnu_history::read_range: missing file name");
+    error ("gnu_history::read_range: missing filename");
 }
 
 void
@@ -372,7 +372,7 @@
             }
         }
       else
-        error ("gnu_history::write: missing file name");
+        error ("gnu_history::write: missing filename");
     }
 }
 
@@ -419,7 +419,7 @@
                   lines_this_session = 0;
                 }
               else
-                error ("gnu_history::append: missing file name");
+                error ("gnu_history::append: missing filename");
             }
         }
     }
@@ -438,7 +438,7 @@
       if (! f.empty ())
         ::octave_history_truncate_file (f.c_str (), n);
       else
-        error ("gnu_history::truncate_file: missing file name");
+        error ("gnu_history::truncate_file: missing filename");
     }
 }
 
@@ -492,7 +492,7 @@
           do_write (f.c_str ());
         }
       else
-        error ("gnu_history::clean_up_and_save: missing file name");
+        error ("gnu_history::clean_up_and_save: missing filename");
     }
 }
 
@@ -920,14 +920,14 @@
 command_history::do_read (const std::string& f, bool)
 {
   if (f.empty ())
-    error ("command_history::read: missing file name");
+    error ("command_history::read: missing filename");
 }
 
 void
 command_history::do_read_range (const std::string& f, int, int, bool)
 {
   if (f.empty ())
-    error ("command_history::read_range: missing file name");
+    error ("command_history::read_range: missing filename");
 }
 
 void
@@ -941,7 +941,7 @@
         f = xfile;
 
       if (f.empty ())
-        error ("command_history::write: missing file name");
+        error ("command_history::write: missing filename");
     }
 }
 
@@ -962,7 +962,7 @@
                 f = xfile;
 
               if (f.empty ())
-                error ("command_history::append: missing file name");
+                error ("command_history::append: missing filename");
             }
         }
     }
@@ -979,7 +979,7 @@
         f = xfile;
 
       if (f.empty ())
-        error ("command_history::truncate_file: missing file name");
+        error ("command_history::truncate_file: missing filename");
     }
 }
 
@@ -1011,7 +1011,7 @@
         f = xfile;
 
       if (f.empty ())
-        error ("command_history::clean_up_and_save: missing file name");
+        error ("command_history::clean_up_and_save: missing filename");
     }
 }
 
--- a/liboctave/util/cmd-hist.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/cmd-hist.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_cmd_hist_h)
+#if ! defined (octave_cmd_hist_h)
 #define octave_cmd_hist_h 1
 
 #include <string>
@@ -205,7 +205,7 @@
 
   void error (const std::string&) const;
 
-  // TRUE means we have initialized the history file name and number of
+  // TRUE means we have initialized the history filename and number of
   // lines to save.
   bool initialized;
 
--- a/liboctave/util/data-conv.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/data-conv.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_data_conv_h)
+#if ! defined (octave_data_conv_h)
 #define octave_data_conv_h 1
 
 #include <limits>
--- a/liboctave/util/f2c-main.c	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/f2c-main.c	Thu Dec 10 12:50:06 2015 -0800
@@ -20,6 +20,10 @@
 
 */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <assert.h>
 
 
--- a/liboctave/util/functor.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/functor.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_functor_h)
+#if ! defined (octave_functor_h)
 #define octave_functor_h 1
 
 template <typename RT, typename PT>
--- a/liboctave/util/glob-match.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/glob-match.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_glob_match_h)
+#if ! defined (octave_glob_match_h)
 #define octave_glob_match_h 1
 
 #include <string>
@@ -72,7 +72,7 @@
 
   Array<bool> match (const string_vector& str) const
   {
-    int n = str.length ();
+    int n = str.numel ();
 
     Array<bool> retval (dim_vector (n, 1));
 
--- a/liboctave/util/kpse.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/kpse.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -234,7 +234,7 @@
 static unsigned int kpathsea_debug = 0;
 #endif
 
-#if defined (WIN32) && !defined (__MINGW32__)
+#if defined (WIN32) && ! defined (__MINGW32__)
 
 /* System description file for Windows NT.  */
 
@@ -427,7 +427,7 @@
         gnulib::fputs (" (nil)\n", stderr);
       else
         {
-          int len = ret.length ();
+          int len = ret.numel ();
           for (int i = 0; i < len; i++)
             {
               gnulib::putc (' ', stderr);
@@ -485,9 +485,7 @@
       {
         /* Find the next colon not enclosed by braces (or the end of
            the path).  */
-
-        int brace_level = 0;
-        while (e < len && ! (brace_level == 0 && kpse_is_env_sep (path[e])))
+        while (e < len && ! kpse_is_env_sep (path[e]))
           e++;
       }
   }
@@ -704,7 +702,7 @@
   if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH) || log_file)
     {
       /* FILENAMES should never be null, but safety doesn't hurt.  */
-      for (int e = 0; e < filenames.length () && ! filenames[e].empty (); e++)
+      for (int e = 0; e < filenames.numel () && ! filenames[e].empty (); e++)
         {
           std::string filename = filenames[e];
 
@@ -1010,7 +1008,7 @@
         {
           const std::string dir = STR_LLIST (*dirs_elt);
 
-          int len = names.length ();
+          int len = names.numel ();
           for (int i = 0; i < len && !done; i++)
             {
               std::string name = names[i];
@@ -1076,7 +1074,7 @@
     {
       gnulib::fputs ("start find_first_of ((", stderr);
 
-      int len = names.length ();
+      int len = names.numel ();
 
       for (int i = 0; i < len; i++)
         {
@@ -1090,7 +1088,7 @@
                        path.c_str (), must_exist);
     }
 
-  for (int i = 0; i < names.length (); i++)
+  for (int i = 0; i < names.numel (); i++)
     {
       std::string name = names[i];
 
@@ -1125,7 +1123,7 @@
         {
           gnulib::fputs ("find_first_of (", stderr);
 
-          int len = names.length ();
+          int len = names.numel ();
 
           for (int i = 0; i < len; i++)
             {
@@ -1337,7 +1335,7 @@
 
   string_vector expansions = brace_expand (elt);
 
-  for (int i = 0; i < expansions.length (); i++)
+  for (int i = 0; i < expansions.numel (); i++)
     {
       /* Do $ and ~ expansion on each element.  */
       std::string x = kpse_expand (expansions[i]);
@@ -1511,8 +1509,8 @@
     result = arr1;
   else
     {
-      int len1 = arr1.length ();
-      int len2 = arr2.length ();
+      int len1 = arr1.numel ();
+      int len2 = arr2.numel ();
 
       result = string_vector (len1 * len2);
 
@@ -1886,7 +1884,7 @@
      extra couple of hash lookups matter -- they don't -- but rather
      because we want to return NULL in this case, so path_search can
      know to do a disk search.  */
-  for (int e = 0; ! relevant && e < db_dir_list.length (); e++)
+  for (int e = 0; ! relevant && e < db_dir_list.numel (); e++)
     relevant = elt_in_db (db_dir_list[e], path_elt);
 
   if (! relevant)
@@ -1897,14 +1895,14 @@
     aliases = hash_lookup (alias_db, name);
 
   /* Push aliases up by one and insert the original name at the front.  */
-  int len = aliases.length ();
+  int len = aliases.numel ();
   aliases.resize (len+1);
   for (int i = len; i > 0; i--)
     aliases[i] = aliases[i - 1];
   aliases[0] = name;
 
   done = false;
-  len = aliases.length ();
+  len = aliases.numel ();
   for (int i = 0; i < len && !done; i++)
     {
       std::string atry = aliases[i];
@@ -1916,7 +1914,7 @@
          example, if we have .../cx/cmr10.300pk and .../ricoh/cmr10.300pk,
          and the path looks like .../cx, we don't want the ricoh file.  */
 
-      int db_dirs_len = db_dirs.length ();
+      int db_dirs_len = db_dirs.numel ();
       for (int j = 0; j < db_dirs_len && !done; j++)
         {
           std::string db_file = db_dirs[j] + atry;
@@ -1946,7 +1944,7 @@
                      and shouldn't hurt.  The upshot is that if one of
                      the aliases actually exists, we use that.  */
 
-                  int aliases_len = aliases.length ();
+                  int aliases_len = aliases.numel ();
 
                   for (int k = 1; k < aliases_len && found.empty (); k++)
                     {
--- a/liboctave/util/lo-array-gripes.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/lo-array-gripes.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -25,6 +25,8 @@
 #include <config.h>
 #endif
 
+#include <sstream>
+
 #include "lo-array-gripes.h"
 #include "lo-error.h"
 
@@ -90,63 +92,215 @@
 }
 
 void
-gripe_index_out_of_range (int nd, int dim, octave_idx_type idx,
-                          octave_idx_type ext)
-{
-  const char *err_id = error_id_index_out_of_bounds;
-
-  switch (nd)
-    {
-    case 1:
-      (*current_liboctave_error_with_id_handler)
-        (err_id, "A(I): index out of bounds; value %d out of bound %d",
-         idx, ext);
-      break;
-
-    case 2:
-      (*current_liboctave_error_with_id_handler)
-        (err_id, "A(I,J): %s index out of bounds; value %d out of bound %d",
-         (dim == 1) ? "row" : "column", idx, ext);
-      break;
-
-    default:
-      (*current_liboctave_error_with_id_handler)
-        (err_id, "A(I,J,...): index to dimension %d out of bounds; value %d out of bound %d",
-         dim, idx, ext);
-      break;
-    }
-}
-
-void
 gripe_del_index_out_of_range (bool is1d, octave_idx_type idx,
                               octave_idx_type ext)
 {
   const char *err_id = error_id_index_out_of_bounds;
 
   (*current_liboctave_error_with_id_handler)
-    (err_id, "A(%s) = []: index out of bounds; value %d out of bound %d",
+    (err_id, "A(%s) = []: index out of bounds: value %d out of bound %d",
      is1d ? "I" : "..,I,..", idx, ext);
 }
 
+
+
+// Common procedures of base class index_exception, thrown whenever an
+// object is indexed incorrectly, such as by an index that is out of
+// range, negative, fractional, complex, or of a non-numeric type.
+
+std::string
+index_exception::message (void) const
+{
+  std::string msg = expression () + ": " + details ();
+  return msg.c_str ();
+}
+
+// Show the expression that caused the error, e.g.,  "A(-1,_)",
+// "A(0+1i)", "A(_,3)".  Show how many indices come before/after the
+// offending one, e.g., (<error>), (<error>,_), or (_,<error>,...[x5]...)
+
+std::string
+index_exception::expression (void) const
+{
+  std::ostringstream buf;
+
+  if (var.empty () || var == "<unknown>")
+    buf << "index ";
+  else
+    buf << var;
+
+  bool show_parens = dim > 0;
+
+  if (show_parens)
+    {
+      if (dim < 5)
+        {
+          buf << "(";
+
+          for (octave_idx_type i = 1; i < dim; i++)
+            buf << "_,";
+        }
+      else
+        buf << "(...[x" << dim - 1 << "]...";
+    }
+
+  buf << idx ();
+
+  if (show_parens)
+    {
+      if (nd - dim < 5)
+        {
+          for (octave_idx_type i = 0; i < nd - dim; i++)
+            buf << ",_";
+
+          if (nd >= dim)
+            buf << ")";
+        }
+      else
+        buf << "...[x" << nd - dim << "]...)";
+    }
+
+  return buf.str ();
+}
+
+class invalid_index : public index_exception
+{
+public:
+
+  invalid_index (const std::string& value, octave_idx_type ndim,
+                 octave_idx_type dimen)
+    : index_exception (value, ndim, dimen)
+  { }
+
+  std::string details (void) const
+  {
+#ifdef USE_64_BIT_IDX_T
+    return "subscripts must be either integers 1 to (2^63)-1 or logicals";
+#else
+    return "subscripts must be either integers 1 to (2^31)-1 or logicals";
+#endif
+  }
+
+  // ID of error to throw
+  const char *err_id (void) const
+  {
+    return error_id_invalid_index;
+  }
+};
+
+// Complain if an index is negative, fractional, or too big.
+
+void
+gripe_invalid_index (const std::string& idx, octave_idx_type nd,
+                     octave_idx_type dim, const std::string&)
+{
+    invalid_index e (idx, nd, dim);
+
+    throw e;
+}
+
 void
-gripe_invalid_index (void)
+gripe_invalid_index (octave_idx_type n, octave_idx_type nd,
+                     octave_idx_type dim, const std::string& var)
 {
-  const char *err_id = error_id_invalid_index;
+  std::ostringstream buf;
+  buf << n + 1;
+  gripe_invalid_index (buf.str (), nd, dim, var);
+}
 
-  (*current_liboctave_error_with_id_handler)
-#ifdef USE_64_BIT_IDX_T
-    (err_id, "subscript indices must be either positive integers less than 2^63 or logicals");
-#else
-    (err_id, "subscript indices must be either positive integers less than 2^31 or logicals");
-#endif
+void
+gripe_invalid_index (double n, octave_idx_type nd, octave_idx_type dim,
+                     const std::string& var)
+{
+  std::ostringstream buf;
+  buf << n + 1;
+  gripe_invalid_index (buf.str (), nd, dim, var);
 }
 
-// FIXME: the following is a common error message to resize,
-// regardless of whether it's called from assign or elsewhere.  It
-// seems OK to me, but eventually the gripe can be specialized.
-// Anyway, propagating various error messages into procedure is, IMHO,
-// a nonsense.  If anything, we should change error handling here (and
-// throughout liboctave) to allow custom handling of errors
+
+// Gripe and exception for read access beyond the bounds of an array.
+
+class out_of_range : public index_exception
+{
+public:
+
+  out_of_range (const std::string& value, octave_idx_type nd_in,
+                octave_idx_type dim_in)
+    : index_exception (value, nd_in, dim_in), extent (0)
+  { }
+
+  std::string details (void) const
+  {
+    std::string expl;
+
+    if (nd >= size.length ())   // if not an index slice
+      {
+        if (var != "")
+          expl = "but " + var + " has size ";
+        else
+          expl = "but object has size ";
+
+        expl = expl + size.str ('x');
+      }
+    else
+      {
+        std::ostringstream buf;
+        buf << extent;
+        expl = "out of bound " + buf.str ();
+      }
+
+    return expl;
+  }
+
+  // ID of error to throw.
+  const char *err_id (void) const
+  {
+    return error_id_index_out_of_bounds;
+  }
+
+  void set_size (const dim_vector& size_in) { size = size_in; }
+
+  void set_extent (octave_idx_type ext) { extent = ext; }
+
+private:
+
+  // Dimension of object being accessed.
+  dim_vector size;
+
+  // Length of dimension being accessed.
+  octave_idx_type extent;
+};
+
+// Complain of an index that is out of range, but we don't know matrix size
+void
+gripe_index_out_of_range (int nd, int dim, octave_idx_type idx,
+                          octave_idx_type ext)
+{
+  std::ostringstream buf;
+  buf << idx;
+  out_of_range e (buf.str (), nd, dim);
+
+  e.set_extent (ext);
+  // ??? Make details method give extent not size.
+  e.set_size (dim_vector (1, 1, 1, 1, 1, 1,1));
+
+  throw e;
+}
+
+// Complain of an index that is out of range
+void
+gripe_index_out_of_range (int nd, int dim, octave_idx_type idx,
+                          octave_idx_type ext, const dim_vector& d)
+{
+  std::ostringstream buf;
+  buf << idx;
+  out_of_range e (buf.str (), nd, dim);
+
+  e.set_extent (ext);
+  e.set_size (d);
+
+  throw e;
+}
 
 void
 gripe_invalid_resize (void)
@@ -157,20 +311,6 @@
 }
 
 void
-gripe_invalid_assignment_size (void)
-{
-  (*current_liboctave_error_handler)
-    ("A(I) = X: X must have the same size as I");
-}
-
-void
-gripe_assignment_dimension_mismatch (void)
-{
-  (*current_liboctave_error_handler)
-    ("A(I,J,...) = X: dimensions mismatch");
-}
-
-void
 gripe_singular_matrix (double rcond)
 {
   if (rcond == 0.0)
@@ -186,3 +326,5 @@
          "matrix singular to machine precision, rcond = %g", rcond);
     }
 }
+
+/* Tests in test/index.tst */
--- a/liboctave/util/lo-array-gripes.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/lo-array-gripes.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,10 +20,84 @@
 
 */
 
-#if !defined (octave_lo_array_gripes_h)
+#if ! defined (octave_lo_array_gripes_h)
 #define octave_lo_array_gripes_h 1
 
 #include "dim-vector.h"
+#include "quit.h"
+
+// Exception thrown by gripe_invalid_index
+// This is thrown when the invalid index is detected, at which point nd and dim
+// are usually not known.  It is caught at the place they are known, where a
+// new  gripe_invalid_index  is called.
+//
+// Typically, this should be caught after any call to
+// octave_value_list::index_vector()
+class index_exception : public octave_execution_exception
+{
+public:
+
+  index_exception (const std::string& index_arg, octave_idx_type nd_arg = 0,
+                   octave_idx_type dim_arg = -1, const char *var_arg = "")
+    : index (index_arg), nd (nd_arg), dim (dim_arg), var (var_arg)
+  { }
+
+  ~index_exception (void) { }
+
+  // Erroneous index value.  Called in what, and by external code
+  // (e.g., nth_element) to make a custom error message.
+  std::string idx (void) const { return index; }
+
+  // details set by subclass.
+  virtual std::string details (void) const = 0;
+
+  // ID of error to throw.
+  virtual const char *err_id (void) const = 0;
+
+  virtual std::string message (void) const;
+
+  // Position of error: dimension in error, and number of dimensions.
+  void set_pos (octave_idx_type nd_arg, octave_idx_type dim_arg)
+  {
+    nd = nd_arg;
+    dim = dim_arg;
+  }
+
+  void set_pos_if_unset (octave_idx_type nd_arg, octave_idx_type dim_arg)
+  {
+    if (nd == 0)
+      {
+        nd  = nd_arg;
+        dim = dim_arg;
+      }
+  }
+
+  // Name of variable being indexed.  eye(2)(1,1) gives "<unknown>".
+  void set_var (const std::string& var_arg = std::string ())
+  {
+    var = var_arg;
+  }
+
+private:
+
+  // Value of invalid index.
+  std::string index;
+
+protected:
+
+  // Show what's wrong, e.g.,  A(-1,_), A(0+1i).
+  std::string expression (void) const;
+
+  // Number of dimensions of indexed object.
+  octave_idx_type nd;
+
+  // Dimension number in which invalid index occurred.
+  octave_idx_type dim;
+
+  // Name of variable being indexed.
+  std::string var;
+
+};
 
 extern OCTAVE_API const char *error_id_nonconformant_args;
 
@@ -57,6 +131,11 @@
 
 extern void OCTAVE_API
 gripe_index_out_of_range (int nd, int dim,
+                          octave_idx_type iext, octave_idx_type ext,
+                          const dim_vector& d);
+
+extern void OCTAVE_API
+gripe_index_out_of_range (int nd, int dim,
                           octave_idx_type iext, octave_idx_type ext);
 
 extern void OCTAVE_API
@@ -64,18 +143,24 @@
                               octave_idx_type ext);
 
 extern void OCTAVE_API
-gripe_invalid_index (void);
+gripe_invalid_index (double, octave_idx_type nd = 0,
+                     octave_idx_type dim = 0,
+                     const std::string& var = std::string ());
+
+extern void OCTAVE_API
+gripe_invalid_index (octave_idx_type n, octave_idx_type nd = 0,
+                     octave_idx_type dim = 0,
+                     const std::string& var = std::string ());
+
+extern void OCTAVE_API
+gripe_invalid_index (const std::string& idx, octave_idx_type nd = 0,
+                     octave_idx_type dim = 0,
+                     const std::string& var = std::string ());
 
 extern void OCTAVE_API
 gripe_invalid_resize (void);
 
 extern void OCTAVE_API
-gripe_invalid_assignment_size (void);
-
-extern void OCTAVE_API
-gripe_assignment_dimension_mismatch (void);
-
-extern void OCTAVE_API
 gripe_singular_matrix (double rcond = 0.0);
 
 #endif
--- a/liboctave/util/lo-cutils.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/lo-cutils.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_lo_cutils_h)
+#if ! defined (octave_lo_cutils_h)
 #define octave_lo_cutils_h 1
 
 #include <sys/types.h>
--- a/liboctave/util/lo-ieee.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/lo-ieee.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_lo_ieee_h)
+#if ! defined (octave_lo_ieee_h)
 #define octave_lo_ieee_h 1
 
 #ifdef  __cplusplus
--- a/liboctave/util/lo-macros.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/lo-macros.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_lo_macros_h)
+#if ! defined (octave_lo_macros_h)
 #define octave_lo_macros_h 1
 
 // Core macros. Iteration is supported up to count 10.
--- a/liboctave/util/lo-math.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/lo-math.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_lo_math_h)
+#if ! defined (octave_lo_math_h)
 #define octave_lo_math_h 1
 
 #if defined (__cplusplus)
--- a/liboctave/util/lo-regexp.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/lo-regexp.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -434,11 +434,11 @@
 Array<bool>
 regexp::is_match (const string_vector& buffer)
 {
-  octave_idx_type len = buffer.length ();
+  octave_idx_type len = buffer.numel ();
 
   Array<bool> retval (dim_vector (len, 1));
 
-  for (octave_idx_type i = 0; i < buffer.length (); i++)
+  for (octave_idx_type i = 0; i < buffer.numel (); i++)
     retval(i) = is_match (buffer(i));
 
   return retval;
--- a/liboctave/util/lo-regexp.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/lo-regexp.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_lo_regexp_h)
+#if ! defined (octave_lo_regexp_h)
 #define octave_lo_regexp_h 1
 
 #include <list>
--- a/liboctave/util/lo-traits.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/lo-traits.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_lo_traits_h)
+#if ! defined (octave_lo_traits_h)
 #define octave_lo_traits_h 1
 
 // Ideas for these classes taken from C++ Templates, The Complete
--- a/liboctave/util/lo-utils.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/lo-utils.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_lo_utils_h)
+#if ! defined (octave_lo_utils_h)
 #define octave_lo_utils_h 1
 
 #include <cstdio>
--- a/liboctave/util/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,93 +1,95 @@
-EXTRA_DIST += \
-  util/module.mk
-
 UTIL_INC = \
-  util/action-container.h \
-  util/base-list.h \
-  util/byte-swap.h \
-  util/caseless-str.h \
-  util/cmd-edit.h \
-  util/cmd-hist.h \
-  util/data-conv.h \
-  util/functor.h \
-  util/glob-match.h \
-  util/lo-array-gripes.h \
-  util/lo-cutils.h \
-  util/lo-ieee.h \
-  util/lo-macros.h \
-  util/lo-math.h \
-  util/lo-traits.h \
-  util/lo-utils.h \
-  util/oct-alloc.h \
-  util/oct-base64.h \
-  util/oct-binmap.h \
-  util/oct-cmplx.h \
-  util/oct-glob.h \
-  util/oct-inttypes.h \
-  util/oct-locbuf.h \
-  util/oct-md5.h \
-  util/oct-mutex.h \
-  util/oct-refcount.h \
-  util/oct-rl-edit.h \
-  util/oct-rl-hist.h \
-  util/oct-shlib.h \
-  util/oct-sort.h \
-  util/oct-sparse.h \
-  util/pathsearch.h \
-  util/lo-regexp.h \
-  util/singleton-cleanup.h \
-  util/sparse-sort.h \
-  util/sparse-util.h \
-  util/statdefs.h \
-  util/str-vec.h \
-  util/sun-utils.h \
-  util/unwind-prot.h \
-  util/url-transfer.h
+  liboctave/util/action-container.h \
+  liboctave/util/base-list.h \
+  liboctave/util/byte-swap.h \
+  liboctave/util/caseless-str.h \
+  liboctave/util/cmd-edit.h \
+  liboctave/util/cmd-hist.h \
+  liboctave/util/data-conv.h \
+  liboctave/util/functor.h \
+  liboctave/util/glob-match.h \
+  liboctave/util/lo-array-gripes.h \
+  liboctave/util/lo-cutils.h \
+  liboctave/util/lo-ieee.h \
+  liboctave/util/lo-macros.h \
+  liboctave/util/lo-math.h \
+  liboctave/util/lo-traits.h \
+  liboctave/util/lo-utils.h \
+  liboctave/util/oct-alloc.h \
+  liboctave/util/oct-base64.h \
+  liboctave/util/oct-binmap.h \
+  liboctave/util/oct-cmplx.h \
+  liboctave/util/oct-glob.h \
+  liboctave/util/oct-inttypes.h \
+  liboctave/util/oct-locbuf.h \
+  liboctave/util/oct-md5.h \
+  liboctave/util/oct-mutex.h \
+  liboctave/util/oct-refcount.h \
+  liboctave/util/oct-rl-edit.h \
+  liboctave/util/oct-rl-hist.h \
+  liboctave/util/oct-shlib.h \
+  liboctave/util/oct-sort.h \
+  liboctave/util/oct-sparse.h \
+  liboctave/util/pathsearch.h \
+  liboctave/util/lo-regexp.h \
+  liboctave/util/singleton-cleanup.h \
+  liboctave/util/sparse-sort.h \
+  liboctave/util/sparse-util.h \
+  liboctave/util/statdefs.h \
+  liboctave/util/str-vec.h \
+  liboctave/util/sun-utils.h \
+  liboctave/util/unwind-prot.h \
+  liboctave/util/url-transfer.h
 
 UTIL_C_SRC = \
-  util/f2c-main.c \
-  util/lo-cutils.c \
-  util/oct-rl-edit.c \
-  util/oct-rl-hist.c
+  liboctave/util/f2c-main.c \
+  liboctave/util/lo-cutils.c \
+  liboctave/util/oct-rl-edit.c \
+  liboctave/util/oct-rl-hist.c
 
 UTIL_SRC = \
-  util/cmd-edit.cc \
-  util/cmd-hist.cc \
-  util/data-conv.cc \
-  util/glob-match.cc \
-  util/lo-array-gripes.cc \
-  util/lo-ieee.cc \
-  util/lo-utils.cc \
-  util/oct-base64.cc \
-  util/oct-glob.cc \
-  util/oct-inttypes.cc \
-  util/oct-locbuf.cc \
-  util/oct-md5.cc \
-  util/oct-mutex.cc \
-  util/oct-shlib.cc \
-  util/pathsearch.cc \
-  util/lo-regexp.cc \
-  util/singleton-cleanup.cc \
-  util/sparse-sort.cc \
-  util/sparse-util.cc \
-  util/str-vec.cc \
-  util/unwind-prot.cc \
-  util/url-transfer.cc \
+  liboctave/util/cmd-edit.cc \
+  liboctave/util/cmd-hist.cc \
+  liboctave/util/data-conv.cc \
+  liboctave/util/glob-match.cc \
+  liboctave/util/lo-array-gripes.cc \
+  liboctave/util/lo-ieee.cc \
+  liboctave/util/lo-utils.cc \
+  liboctave/util/oct-base64.cc \
+  liboctave/util/oct-glob.cc \
+  liboctave/util/oct-inttypes.cc \
+  liboctave/util/oct-locbuf.cc \
+  liboctave/util/oct-md5.cc \
+  liboctave/util/oct-mutex.cc \
+  liboctave/util/oct-shlib.cc \
+  liboctave/util/pathsearch.cc \
+  liboctave/util/lo-regexp.cc \
+  liboctave/util/singleton-cleanup.cc \
+  liboctave/util/sparse-sort.cc \
+  liboctave/util/sparse-util.cc \
+  liboctave/util/str-vec.cc \
+  liboctave/util/unwind-prot.cc \
+  liboctave/util/url-transfer.cc \
   $(UTIL_C_SRC)
 
-TEMPLATE_SRC += \
-  util/oct-sort.cc
+LIBOCTAVE_TEMPLATE_SRC += \
+  liboctave/util/oct-sort.cc
 
-OTHER_INC += \
-  util/kpse.cc
+EXTRA_DIST += \
+  liboctave/util/kpse.cc
 
-noinst_LTLIBRARIES += util/libutil.la
+noinst_LTLIBRARIES += liboctave/util/libutil.la
 
-util_libutil_la_SOURCES = $(UTIL_SRC)
-util_libutil_la_CPPFLAGS = \
-  $(liboctave_la_CPPFLAGS) \
+liboctave_util_libutil_la_SOURCES = $(UTIL_SRC)
+
+liboctave_util_libutil_la_CPPFLAGS = \
+  $(liboctave_liboctave_la_CPPFLAGS) \
   $(CURL_CPPFLAGS) \
   $(PCRE_CPPFLAGS) \
   $(SPARSE_XCPPFLAGS)
 
-liboctave_la_LIBADD += util/libutil.la
+liboctave_util_libutil_la_CFLAGS = $(liboctave_liboctave_la_CFLAGS)
+
+liboctave_util_libutil_la_CXXFLAGS = $(liboctave_liboctave_la_CXXFLAGS)
+
+liboctave_liboctave_la_LIBADD += liboctave/util/libutil.la
--- a/liboctave/util/oct-alloc.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-alloc.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_alloc_h)
+#if ! defined (octave_oct_alloc_h)
 #define octave_oct_alloc_h 1
 
 #warning "the octave_allocator class has been deprecated and will be removed in a future release of Octave"
--- a/liboctave/util/oct-base64.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-base64.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_base64_h)
+#if ! defined (octave_oct_base64_h)
 #define octave_oct_base64_h 1
 
 #include <string>
--- a/liboctave/util/oct-binmap.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-binmap.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_binmap_h)
+#if ! defined (octave_oct_binmap_h)
 #define octave_oct_binmap_h 1
 
 #include "Array.h"
--- a/liboctave/util/oct-cmplx.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-cmplx.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_oct_cmplx_h)
+#if ! defined (octave_oct_cmplx_h)
 #define octave_oct_cmplx_h 1
 
 #include <complex>
--- a/liboctave/util/oct-glob.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-glob.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -51,7 +51,7 @@
 octave_fnmatch (const string_vector& pat, const std::string& str,
                 int fnmatch_flags)
 {
-  int npat = pat.length ();
+  int npat = pat.numel ();
 
   const char *cstr = str.c_str ();
 
@@ -67,7 +67,7 @@
 {
   string_vector retval;
 
-  int npat = pat.length ();
+  int npat = pat.numel ();
 
   int k = 0;
 
--- a/liboctave/util/oct-glob.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-glob.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_glob_h)
+#if ! defined (octave_oct_glob_h)
 #define octave_oct_glob_h 1
 
 #include "str-vec.h"
--- a/liboctave/util/oct-inttypes.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-inttypes.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_oct_inttypes_h)
+#if ! defined (octave_oct_inttypes_h)
 #define octave_oct_inttypes_h 1
 
 #include <cstdlib>
--- a/liboctave/util/oct-locbuf.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-locbuf.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_locbuf_h)
+#if ! defined (octave_oct_locbuf_h)
 #define octave_oct_locbuf_h 1
 
 #include <cstddef>
--- a/liboctave/util/oct-mutex.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-mutex.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_mutex_h)
+#if ! defined (octave_oct_mutex_h)
 #define octave_oct_mutex_h 1
 
 #include "oct-refcount.h"
--- a/liboctave/util/oct-refcount.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-refcount.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_refcount_h)
+#if ! defined (octave_oct_refcount_h)
 #define octave_oct_refcount_h 1
 
 #ifndef OCTAVE_CONFIG_INCLUDED
--- a/liboctave/util/oct-rl-edit.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-rl-edit.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_rl_edit_h)
+#if ! defined (octave_oct_rl_edit_h)
 #define octave_oct_rl_edit_h 1
 
 typedef int (*rl_startup_hook_fcn_ptr) (void);
--- a/liboctave/util/oct-rl-hist.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-rl-hist.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_rl_hist_h)
+#if ! defined (octave_oct_rl_hist_h)
 #define octave_oct_rl_hist_h 1
 
 #ifdef __cplusplus
--- a/liboctave/util/oct-shlib.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-shlib.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -195,6 +195,12 @@
   flags |= RTLD_NOW;
 #endif
 
+  // Use RTLD_GLOBAL to export symbols from loaded objects so they are
+  // available to other subsequently loaded libraries.
+#if defined (RTLD_GLOBAL)
+  flags |= RTLD_GLOBAL;
+#endif
+
   library = dlopen (file.c_str (), flags);
 
   if (! library)
--- a/liboctave/util/oct-shlib.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-shlib.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_oct_shlib_h)
+#if ! defined (octave_oct_shlib_h)
 #define octave_oct_shlib_h 1
 
 #include <string>
--- a/liboctave/util/oct-sort.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-sort.h	Thu Dec 10 12:50:06 2015 -0800
@@ -80,7 +80,7 @@
   Agreement.
 */
 
-#if !defined (octave_oct_sort_h)
+#if ! defined (octave_oct_sort_h)
 #define octave_oct_sort_h 1
 
 #include "lo-traits.h"
--- a/liboctave/util/oct-sparse.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/oct-sparse.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_oct_sparse_h)
+#if ! defined (octave_oct_sparse_h)
 #define octave_oct_sparse_h 1
 
 #if defined (HAVE_SUITESPARSE_AMD_H)
--- a/liboctave/util/pathsearch.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/pathsearch.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -79,7 +79,7 @@
 
   if (initialized)
     {
-      int len = pv.length ();
+      int len = pv.numel ();
 
       int nmax = len > 32 ? len : 32;
 
--- a/liboctave/util/pathsearch.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/pathsearch.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_pathsearch_h)
+#if ! defined (octave_pathsearch_h)
 #define octave_pathsearch_h 1
 
 #include <string>
--- a/liboctave/util/singleton-cleanup.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/singleton-cleanup.h	Thu Dec 10 12:50:06 2015 -0800
@@ -1,4 +1,4 @@
-#if !defined (octave_singleton_cleanup_h)
+#if ! defined (octave_singleton_cleanup_h)
 #define octave_singleton_cleanup_h 1
 
 #include <set>
--- a/liboctave/util/sparse-sort.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/sparse-sort.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_sparse_sort_h)
+#if ! defined (octave_sparse_sort_h)
 #define octave_sparse_sort_h
 
 #include "oct-sort.h"
--- a/liboctave/util/sparse-util.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/sparse-util.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -33,14 +33,14 @@
 
 // FIXME: this overload is here due to API change in SuiteSparse (3.1 -> 3.2)
 
-#ifdef HAVE_CHOLMOD
-
 void
 SparseCholError (int status, char *file, int line, char *message)
 {
   SparseCholError (status, file, line, message);
 }
 
+#ifdef HAVE_CHOLMOD
+
 void
 SparseCholError (int status, const char *file, int line, const char *message)
 {
@@ -53,6 +53,15 @@
        status, line, file, message);
 }
 
+#else
+
+void
+SparseCholError (int status, const char *, int, const char *)
+{
+}
+
+#endif //HAVE_CHOLMOD
+
 int
 SparseCholPrint (const char *fmt, ...)
 {
@@ -64,8 +73,6 @@
   return ret;
 }
 
-#endif //HAVE_CHOLMOD
-
 bool
 sparse_indices_ok (octave_idx_type *r, octave_idx_type *c,
                    octave_idx_type nrows, octave_idx_type ncols,
--- a/liboctave/util/sparse-util.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/sparse-util.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,19 +21,21 @@
 
 */
 
-#if !defined (octave_sparse_util_h)
+#if ! defined (octave_sparse_util_h)
 #define octave_sparse_util_h 1
 
-#ifdef HAVE_CHOLMOD
+// The next two functions don't do anything unless CHOLMOD is
+// available
 
 // FIXME this overload is here due to API change in SuiteSparse (3.1 -> 3.2)
-extern OCTAVE_API void SparseCholError (int status, char *file,
-                                        int line, char *message);
-extern OCTAVE_API void SparseCholError (int status, const char *file,
-                                        int line, const char *message);
-extern OCTAVE_API int SparseCholPrint (const char *fmt, ...);
+extern OCTAVE_API void
+SparseCholError (int status, char *file, int line, char *message);
 
-#endif //HAVE_CHOLMOD
+extern OCTAVE_API void
+SparseCholError (int status, const char *file, int line, const char *message);
+
+extern OCTAVE_API int
+SparseCholPrint (const char *fmt, ...);
 
 extern OCTAVE_API bool
 sparse_indices_ok (octave_idx_type *r, octave_idx_type *c,
--- a/liboctave/util/statdefs.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/statdefs.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_statdefs_h)
+#if ! defined (octave_statdefs_h)
 #define octave_statdefs_h 1
 
 #include <sys/types.h>
@@ -34,32 +34,32 @@
 #define mode_t unsigned short
 #endif
 #endif
-#if !defined(S_ISBLK) && defined(S_IFBLK)
+#if ! defined (S_ISBLK) && defined (S_IFBLK)
 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
 #endif
-#if !defined(S_ISCHR) && defined(S_IFCHR)
+#if ! defined (S_ISCHR) && defined (S_IFCHR)
 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
 #endif
-#if !defined(S_ISDIR) && defined(S_IFDIR)
+#if ! defined (S_ISDIR) && defined (S_IFDIR)
 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
 #endif
-#if !defined(S_ISREG) && defined(S_IFREG)
+#if ! defined (S_ISREG) && defined (S_IFREG)
 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
 #endif
-#if !defined(S_ISFIFO) && defined(S_IFIFO)
+#if ! defined (S_ISFIFO) && defined (S_IFIFO)
 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
 #endif
-#if !defined(S_ISLNK) && defined(S_IFLNK)
+#if ! defined (S_ISLNK) && defined (S_IFLNK)
 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
 #endif
-#if !defined(S_ISSOCK) && defined(S_IFSOCK)
+#if ! defined (S_ISSOCK) && defined (S_IFSOCK)
 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
 #endif
-#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
+#if ! defined (S_ISMPB) && defined (S_IFMPB) /* V7 */
 #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
 #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
 #endif
-#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
+#if ! defined (S_ISNWK) && defined (S_IFNWK) /* HP/UX */
 #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
 #endif
 
--- a/liboctave/util/str-vec.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/str-vec.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -108,7 +108,7 @@
 {
   // Don't use Array<std::string>::sort () to allow sorting in place.
   octave_sort<std::string> lsort;
-  lsort.sort (Array<std::string>::fortran_vec (), length ());
+  lsort.sort (Array<std::string>::fortran_vec (), numel ());
 
   if (make_uniq)
     uniq ();
@@ -118,7 +118,7 @@
 string_vector&
 string_vector::uniq (void)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -139,7 +139,7 @@
 string_vector&
 string_vector::append (const std::string& s)
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   resize (len + 1);
 
@@ -151,8 +151,8 @@
 string_vector&
 string_vector::append (const string_vector& sv)
 {
-  octave_idx_type len = length ();
-  octave_idx_type sv_len = sv.length ();
+  octave_idx_type len = numel ();
+  octave_idx_type sv_len = sv.numel ();
   octave_idx_type new_len = len + sv_len;
 
   resize (new_len);
@@ -168,7 +168,7 @@
 {
   std::string retval;
 
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   if (len > 0)
     {
@@ -186,7 +186,7 @@
 char **
 string_vector::c_str_vec (void) const
 {
-  octave_idx_type len = length ();
+  octave_idx_type len = numel ();
 
   char **retval = new char * [len + 1];
 
@@ -218,7 +218,7 @@
   // Compute the maximum name length.
 
   octave_idx_type max_name_length = 0;
-  octave_idx_type total_names = length ();
+  octave_idx_type total_names = numel ();
 
   if (total_names == 0)
     {
--- a/liboctave/util/str-vec.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/str-vec.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_str_vec_h)
+#if ! defined (octave_str_vec_h)
 #define octave_str_vec_h 1
 
 #include <iosfwd>
@@ -70,11 +70,11 @@
 
   ~string_vector (void) { }
 
-  bool empty (void) const { return length () == 0; }
+  bool empty (void) const { return numel () == 0; }
 
   octave_idx_type max_length (void) const
   {
-    octave_idx_type n = length ();
+    octave_idx_type n = numel ();
     octave_idx_type longest = 0;
 
     for (octave_idx_type i = 0; i < n; i++)
--- a/liboctave/util/sun-utils.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/sun-utils.h	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 
 */
 
-#if !defined (octave_sun_utils_h)
+#if ! defined (octave_sun_utils_h)
 #define octave_sun_utils_h 1
 
 // This is only needed to dereference pointers to doubles if mixing
--- a/liboctave/util/unwind-prot.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/unwind-prot.h	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 
 */
 
-#if !defined (octave_unwind_prot_h)
+#if ! defined (octave_unwind_prot_h)
 #define octave_unwind_prot_h 1
 
 #include <cstddef>
@@ -40,8 +40,8 @@
   unwind_protect (void) : lifo () { }
 
   // Destructor should not raise an exception, so all actions
-  // registered should be exception-safe (but setting error_state is
-  // allowed). If you're not sure, see unwind_protect_safe.
+  // registered should be exception-safe.  If you're not sure, see
+  // unwind_protect_safe.
 
   ~unwind_protect (void) { run (); }
 
--- a/liboctave/util/url-transfer.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/url-transfer.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -82,7 +82,7 @@
 
       string_vector sv = list ();
 
-      for (octave_idx_type i = 0; i < sv.length (); i++)
+      for (octave_idx_type i = 0; i < sv.numel (); i++)
         {
           time_t ftime;
           bool fisdir;
@@ -153,7 +153,7 @@
         {
           string_vector files = dirlist.read ();
 
-          for (octave_idx_type i = 0; i < files.length (); i++)
+          for (octave_idx_type i = 0; i < files.numel (); i++)
             {
               std::string file = files (i);
 
--- a/liboctave/util/url-transfer.h	Tue Dec 08 07:49:49 2015 -0800
+++ b/liboctave/util/url-transfer.h	Thu Dec 10 12:50:06 2015 -0800
@@ -25,7 +25,7 @@
 // Author: Alexander Barth <abarth@marine.usf.edu>
 // Author: jwe
 
-#if !defined (octave_url_transfer_h)
+#if ! defined (octave_url_transfer_h)
 #define octave_url_transfer_h 1
 
 #include <iosfwd>
--- a/m4/acinclude.m4	Tue Dec 08 07:49:49 2015 -0800
+++ b/m4/acinclude.m4	Thu Dec 10 12:50:06 2015 -0800
@@ -291,7 +291,7 @@
     [AC_LANG_PUSH(C++)
     ac_octave_save_CPPFLAGS="$CPPFLAGS"
     CPPFLAGS="$QT_CPPFLAGS $CPPFLAGS"
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+    AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
         #include <Qsci/qsciglobal.h>
         ]], [[
         #if QSCINTILLA_VERSION < 0x020600
@@ -417,7 +417,7 @@
     [AC_LANG_PUSH(C++)
     ac_octave_save_CPPFLAGS="$CPPFLAGS"
     CPPFLAGS="$QT_CPPFLAGS $CPPFLAGS"
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+    AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
         #include <Qt/qglobal.h>
         ]], [[
         #if QT_VERSION < 0x040700
@@ -1059,7 +1059,7 @@
     :
   fi
 ])
-dnl 
+dnl
 dnl Check whether sndfile library is modern enough to include things like Ogg
 dnl
 AC_DEFUN([OCTAVE_CHECK_LIB_SNDFILE_OK], [
@@ -1158,6 +1158,52 @@
   fi
 ])
 dnl
+dnl Check whether Qt works with full OpenGL support
+dnl
+AC_DEFUN([OCTAVE_CHECK_QT_OPENGL_OK], [
+  AC_CACHE_CHECK([whether Qt works with OpenGL and GLU],
+    [octave_cv_qt_opengl_ok],
+    [AC_LANG_PUSH(C++)
+     ac_octave_save_CPPFLAGS="$CPPFLAGS"
+     CPPFLAGS="$QT_CPPFLAGS $CPPFLAGS"
+     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+         #if HAVE_WINDOWS_H
+         # include <windows.h>
+         #endif
+         #if defined (HAVE_GL_GL_H)
+         # include <GL/gl.h>
+         #elif defined (HAVE_OPENGL_GL_H)
+         # include <OpenGL/gl.h>
+         #endif
+         #ifdef HAVE_GL_GLU_H
+         # include <GL/glu.h>
+         #elif defined HAVE_OPENGL_GLU_H || defined HAVE_FRAMEWORK_OPENGL
+         # include <OpenGL/glu.h>
+         #endif
+         #include <QGLWidget>
+         class gl_widget : public QGLWidget
+         {
+         public:
+           gl_widget (QWidget *parent = 0) : QGLWidget (parent) {}
+           ~gl_widget () {}
+         };
+         ]], [[
+         gl_widget widget;
+       ]])],
+       octave_cv_qt_opengl_ok=yes,
+       octave_cv_qt_opengl_ok=no)
+     CPPFLAGS="$ac_octave_save_CPPFLAGS"
+     AC_LANG_POP(C++)
+  ])
+  if test $octave_cv_qt_opengl_ok = yes; then
+    $1
+    :
+  else
+    $2
+    :
+  fi
+])
+dnl
 dnl Check if the default Fortran INTEGER is 64 bits wide.
 dnl
 AC_DEFUN([OCTAVE_CHECK_SIZEOF_FORTRAN_INTEGER], [
@@ -2274,7 +2320,6 @@
 "
     OCTAVE_CONFIGURE_WARNING([warn_texi2dvi])
   fi
-  TEXI2DVI="$TEXI2DVI"' --build-dir=t2d_cache'
   AC_SUBST(TEXI2DVI)
 ])
 dnl
@@ -2301,7 +2346,6 @@
 "
     OCTAVE_CONFIGURE_WARNING([warn_texi2pdf])
   fi
-  TEXI2PDF="$TEXI2PDF"' --build-dir=t2d_cache'
   AC_SUBST(TEXI2PDF)
 ])
 dnl
--- a/run-octave.in	Tue Dec 08 07:49:49 2015 -0800
+++ b/run-octave.in	Thu Dec 10 12:50:06 2015 -0800
@@ -20,9 +20,10 @@
 ## along with Octave; see the file COPYING.  If not, see
 ## <http://www.gnu.org/licenses/>.
 
-AWK=%AWK%
-FIND=%FIND%
-SED=%SED%
+: ${AWK=%AWK%}
+: ${FIND=%FIND%}
+: ${SED=%SED%}
+: ${ADDRESS_SANITIZER_OPTIONS="%ADRESS_SANITIZER_OPTIONS%"}
 
 # FIXME -- is there a better way to handle the possibility of spaces
 # in these names?
@@ -89,14 +90,20 @@
 ## need Octave to find other things in ARCHLIBDIR that are not built
 ## in the $builddir/src directory.
 
-OCTAVE_BINDIR="$builddir/src" \
-OCTAVE_ARCHLIBDIR="$builddir/src" \
-OCTAVE_SITE_INITFILE="$top_srcdir/scripts/startup/main-rcfile" \
-OCTAVE_DEFAULT_QT_SETTINGS="$builddir/libgui/default-qt-settings" \
-OCTAVE_LOCALE_DIR="$builddir/libgui/languages" \
-OCTAVE_JAVA_DIR="$builddir/scripts/java" \
-  exec $builddir/libtool --mode=execute $driver \
-    "$octave_executable" --no-init-path --path="$LOADPATH" \
-    --image-path="$IMAGEPATH" --doc-cache-file="$DOCFILE" \
-    --built-in-docstrings-file="$BUILT_IN_DOCSTRINGS_FILE" \
-    --texi-macros-file="$TEXIMACROSFILE" --info-file="$INFOFILE" "$@"
+OCTAVE_ARCHLIBDIR="$builddir/src"; export OCTAVE_ARCHLIBDIR
+OCTAVE_BINDIR="$builddir/src"; export OCTAVE_BINDIR
+OCTAVE_DEFAULT_QT_SETTINGS="$builddir/libgui/default-qt-settings"; export OCTAVE_DEFAULT_QT_SETTINGS
+OCTAVE_JAVA_DIR="$builddir/scripts/java"; export OCTAVE_JAVA_DIR
+OCTAVE_LOCALE_DIR="$builddir/libgui/languages"; export OCTAVE_LOCALE_DIR
+OCTAVE_SITE_INITFILE="$top_srcdir/scripts/startup/site-rcfile"; export OCTAVE_SITE_INITFILE
+OCTAVE_VERSION_INITFILE="$top_srcdir/scripts/startup/version-rcfile"; export OCTAVE_VERSION_INITFILE
+
+if [ "$ADDRESS_SANITIZER_ENABLED" = yes ]; then
+  ASAN_OPTIONS=symbolize=1; export ASAN_OPTIONS
+fi
+
+exec $builddir/libtool --mode=execute $driver \
+  "$octave_executable" --no-init-path --path="$LOADPATH" \
+  --image-path="$IMAGEPATH" --doc-cache-file="$DOCFILE" \
+  --built-in-docstrings-file="$BUILT_IN_DOCSTRINGS_FILE" \
+  --texi-macros-file="$TEXIMACROSFILE" --info-file="$INFOFILE" "$@"
--- a/scripts/@ftp/loadobj.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/@ftp/loadobj.m	Thu Dec 10 12:50:06 2015 -0800
@@ -29,7 +29,7 @@
     b = rmfield (b, "dir");
   elseif (isfield (b, "remotePwd"))
     ## FIXME: Can we read matlab java stringBuffer objects?
-    warning ("can not change remote directory in loaded FTP object");
+    warning ("@ftp/loadobj: can not change remote directory in loaded FTP object");
     b = rmfield (b, "remotePwd");
   endif
 endfunction
--- a/scripts/@ftp/mget.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/@ftp/mget.m	Thu Dec 10 12:50:06 2015 -0800
@@ -28,13 +28,13 @@
 ## The arguments @var{file} and @var{dir} can include wildcards and any
 ## 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 to the local directory and the local name
-## will be changed to @var{target}.
+## If a third string argument @var{target} is given, then it must indicate
+## the path to the local destination directory.  @var{target} may be a
+## relative or absolute path.
 ## @end deftypefn
 
-function mget (f, file)
-  __ftp_mget__ (f.curlhandle, file);
+function mget (f, file, target = "")
+  __ftp_mget__ (f.curlhandle, file, target);
 endfunction
 
 
--- a/scripts/@ftp/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/@ftp/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,24 +1,4 @@
-FCN_FILE_DIRS += @ftp
-
-@ftp_FCN_FILES = \
-  @ftp/ascii.m \
-  @ftp/binary.m  \
-  @ftp/cd.m  \
-  @ftp/close.m  \
-  @ftp/delete.m  \
-  @ftp/dir.m  \
-  @ftp/display.m  \
-  @ftp/ftp.m  \
-  @ftp/loadobj.m  \
-  @ftp/mget.m  \
-  @ftp/mkdir.m  \
-  @ftp/mput.m  \
-  @ftp/rename.m  \
-  @ftp/rmdir.m  \
-  @ftp/saveobj.m
-
-FCN_FILES += $(@ftp_FCN_FILES)
-
-PKG_ADD_FILES += @ftp/PKG_ADD
-
-DIRSTAMP_FILES += @ftp/$(octave_dirstamp)
+## FIXME -- including scripts/@ftp/module.mk fails.
+## Is that an automake bug?
+##
+## What should be in this file is in scripts/module.mk.
--- a/scripts/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,535 +0,0 @@
-# Makefile for Octave's scripts directory
-#
-# Copyright (C) 1993-2015 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 $(top_srcdir)/build-aux/common.mk
-
-EXTRA_DIST =
-
-CLEANFILES =
-
-DISTCLEANFILES =
-
-FCN_FILE_DIRS =
-
-FCN_FILES =
-
-GEN_FCN_FILES =
-
-PKG_ADD_FILES =
-
-DIRSTAMP_FILES =
-
-IMAGES =
-
-JAR_FILES =
-
-## Read subdirs to set all variables above
-include @ftp/module.mk
-include audio/module.mk
-include deprecated/module.mk
-include elfun/module.mk
-include general/module.mk
-include geometry/module.mk
-include gui/module.mk
-include help/module.mk
-include image/module.mk
-include io/module.mk
-include java/module.mk
-include linear-algebra/module.mk
-include miscellaneous/module.mk
-include optimization/module.mk
-include path/module.mk
-include pkg/module.mk
-include plot/appearance/module.mk
-include plot/draw/module.mk
-include plot/util/module.mk
-include polynomial/module.mk
-include prefs/module.mk
-include set/module.mk
-include signal/module.mk
-include sparse/module.mk
-include specfun/module.mk
-include special-matrix/module.mk
-include startup/module.mk
-include statistics/base/module.mk
-include statistics/distributions/module.mk
-include statistics/models/module.mk
-include statistics/tests/module.mk
-include strings/module.mk
-include testfun/module.mk
-include time/module.mk
-
-nobase_fcnfile_DATA = $(FCN_FILES) $(GEN_FCN_FILES) $(JAR_FILES)
-
-image_DATA = $(IMAGES)
-
-FCN_FILES_IN = $(GEN_FCN_FILES:.m=.in)
-
-if AMCOND_BUILD_DOCS
-all-local: $(GEN_FCN_FILES) $(PKG_ADD_FILES) $(JAR_FILES) .DOCSTRINGS
-else
-all-local: $(GEN_FCN_FILES) $(PKG_ADD_FILES) $(JAR_FILES)
-endif
-
-octave_dirstamp = $(am__leading_dot)dirstamp
-
-@ftp/PKG_ADD: $(@ftp_FCN_FILES) $(@ftp_GEN_FCN_FILES) @ftp/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(@ftp_FCN_FILES) -- $(@ftp_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-audio/PKG_ADD: $(audio_FCN_FILES) $(audio_GEN_FCN_FILES) audio/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(audio_FCN_FILES) -- $(audio_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-deprecated/PKG_ADD: $(deprecated_FCN_FILES) $(deprecated_GEN_FCN_FILES) deprecated/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(deprecated_FCN_FILES) -- $(deprecated_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-elfun/PKG_ADD: $(elfun_FCN_FILES) $(elfun_GEN_FCN_FILES) elfun/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(elfun_FCN_FILES) -- $(elfun_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-general/PKG_ADD: $(general_FCN_FILES) $(general_GEN_FCN_FILES) general/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(general_FCN_FILES) -- $(general_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-geometry/PKG_ADD: $(geometry_FCN_FILES) $(geometry_GEN_FCN_FILES) geometry/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(geometry_FCN_FILES) -- $(geometry_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-gui/PKG_ADD: $(gui_FCN_FILES) $(gui_GEN_FCN_FILES) gui/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(gui_FCN_FILES) -- $(gui_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-help/PKG_ADD: $(help_FCN_FILES) $(help_GEN_FCN_FILES) help/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(help_FCN_FILES) -- $(help_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-image/PKG_ADD: $(image_FCN_FILES) $(image_GEN_FCN_FILES) image/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(image_FCN_FILES) -- $(image_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-io/PKG_ADD: $(io_FCN_FILES) $(io_GEN_FCN_FILES) io/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(io_FCN_FILES) -- $(io_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-java/PKG_ADD: $(java_FCN_FILES) $(java_GEN_FCN_FILES) java/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(java_FCN_FILES) -- $(java_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-linear-algebra/PKG_ADD: $(linear_algebra_FCN_FILES) $(linear_algebra_GEN_FCN_FILES) linear-algebra/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(linear_algebra_FCN_FILES) -- $(linear_algebra_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-miscellaneous/PKG_ADD: $(miscellaneous_FCN_FILES) $(miscellaneous_GEN_FCN_FILES) miscellaneous/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(miscellaneous_FCN_FILES) -- $(miscellaneous_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-optimization/PKG_ADD: $(optimization_FCN_FILES) $(optimization_GEN_FCN_FILES) optimization/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add "$(srcdir)" $(optimization_FCN_FILES) -- $(optimization_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-path/PKG_ADD: $(path_FCN_FILES) $(path_GEN_FCN_FILES) path/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(path_FCN_FILES) -- $(path_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-pkg/PKG_ADD: $(pkg_FCN_FILES) $(pkg_GEN_FCN_FILES) pkg/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(pkg_FCN_FILES) -- $(pkg_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-plot/appearance/PKG_ADD: $(plot_appearance_FCN_FILES) $(plot_appearance_GEN_FCN_FILES) plot/appearance/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(plot_appearance_FCN_FILES) -- $(plot_appearance_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-plot/draw/PKG_ADD: $(plot_draw_FCN_FILES) $(plot_draw_GEN_FCN_FILES) plot/draw/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(plot_draw_FCN_FILES) -- $(plot_draw_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-plot/util/PKG_ADD: $(plot_util_FCN_FILES) $(plot_util_GEN_FCN_FILES) plot/util/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(plot_util_FCN_FILES) -- $(plot_util_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-polynomial/PKG_ADD: $(polynomial_FCN_FILES) $(polynomial_GEN_FCN_FILES) polynomial/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(polynomial_FCN_FILES) -- $(polynomial_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-prefs/PKG_ADD: $(prefs_FCN_FILES) $(prefs_GEN_FCN_FILES) prefs/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(prefs_FCN_FILES) -- $(prefs_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-set/PKG_ADD: $(set_FCN_FILES) $(set_GEN_FCN_FILES) set/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(set_FCN_FILES) -- $(set_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-signal/PKG_ADD: $(signal_FCN_FILES) $(signal_GEN_FCN_FILES) signal/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(signal_FCN_FILES) -- $(signal_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-sparse/PKG_ADD: $(sparse_FCN_FILES) $(sparse_GEN_FCN_FILES) sparse/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(sparse_FCN_FILES) -- $(sparse_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-specfun/PKG_ADD: $(specfun_FCN_FILES) $(specfun_GEN_FCN_FILES) specfun/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(specfun_FCN_FILES) -- $(specfun_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-special-matrix/PKG_ADD: $(special_matrix_FCN_FILES) $(special_matrix_GEN_FCN_FILES) special-matrix/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(special_matrix_FCN_FILES) -- $(special_matrix_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-startup/PKG_ADD: $(startup_FCN_FILES) $(startup_GEN_FCN_FILES) startup/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(startup_FCN_FILES) -- $(startup_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-statistics/base/PKG_ADD: $(statistics_base_FCN_FILES) $(statistics_base_GEN_FCN_FILES) statistics/base/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(statistics_base_FCN_FILES) -- $(statistics_base_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-statistics/distributions/PKG_ADD: $(statistics_distributions_FCN_FILES) $(statistics_distributions_GEN_FCN_FILES) statistics/distributions/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(statistics_distributions_FCN_FILES) -- $(statistics_distributions_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-statistics/models/PKG_ADD: $(statistics_models_FCN_FILES) $(statistics_models_GEN_FCN_FILES) statistics/models/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(statistics_models_FCN_FILES) -- $(statistics_models_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-statistics/tests/PKG_ADD: $(statistics_tests_FCN_FILES) $(statistics_tests_GEN_FCN_FILES) statistics/tests/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(statistics_tests_FCN_FILES) -- $(statistics_tests_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-strings/PKG_ADD: $(strings_FCN_FILES) $(strings_GEN_FCN_FILES) strings/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(strings_FCN_FILES) -- $(strings_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-testfun/PKG_ADD: $(testfun_FCN_FILES) $(testfun_GEN_FCN_FILES) testfun/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(testfun_FCN_FILES) -- $(testfun_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-time/PKG_ADD: $(time_FCN_FILES) $(time_GEN_FCN_FILES) time/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(time_FCN_FILES) -- $(time_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-ui/PKG_ADD: $(ui_FCN_FILES) $(ui_GEN_FCN_FILES) ui/$(octave_dirstamp) mk-pkg-add
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	$(srcdir)/mk-pkg-add $(srcdir) $(ui_FCN_FILES) -- $(ui_GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@
-
-$(@ftp_GEN_FCN_FILES): @ftp/$(octave_dirstamp)
-$(audio_GEN_FCN_FILES): audio/$(octave_dirstamp)
-$(deprecated_GEN_FCN_FILES): deprecated/$(octave_dirstamp)
-$(elfun_GEN_FCN_FILES): elfun/$(octave_dirstamp)
-$(general_GEN_FCN_FILES): general/$(octave_dirstamp)
-$(geometry_GEN_FCN_FILES): geometry/$(octave_dirstamp)
-$(gui_GEN_FCN_FILES): gui/$(octave_dirstamp)
-$(help_GEN_FCN_FILES): help/$(octave_dirstamp)
-$(image_GEN_FCN_FILES): image/$(octave_dirstamp)
-$(io_GEN_FCN_FILES): io/$(octave_dirstamp)
-$(java_GEN_FCN_FILES): java/$(octave_dirstamp)
-$(linear_algebra_GEN_FCN_FILES): linear-algebra/$(octave_dirstamp)
-$(miscellaneous_GEN_FCN_FILES): miscellaneous/$(octave_dirstamp)
-$(optimization_GEN_FCN_FILES): optimization/$(octave_dirstamp)
-$(path_GEN_FCN_FILES): path/$(octave_dirstamp)
-$(pkg_GEN_FCN_FILES): pkg/$(octave_dirstamp)
-$(plot_appearance_GEN_FCN_FILES): plot/appearance/$(octave_dirstamp)
-$(plot_draw_GEN_FCN_FILES): plot/draw/$(octave_dirstamp)
-$(plot_util_GEN_FCN_FILES): plot/util/$(octave_dirstamp)
-$(polynomial_GEN_FCN_FILES): polynomial/$(octave_dirstamp)
-$(prefs_GEN_FCN_FILES): prefs/$(octave_dirstamp)
-$(set_GEN_FCN_FILES): set/$(octave_dirstamp)
-$(signal_GEN_FCN_FILES): signal/$(octave_dirstamp)
-$(sparse_GEN_FCN_FILES): sparse/$(octave_dirstamp)
-$(specfun_GEN_FCN_FILES): specfun/$(octave_dirstamp)
-$(special_matrix_GEN_FCN_FILES): special-matrix/$(octave_dirstamp)
-$(startup_GEN_FCN_FILES): startup/$(octave_dirstamp)
-$(statistics_base_GEN_FCN_FILES): statistics/base/$(octave_dirstamp)
-$(statistics_distributions_GEN_FCN_FILES): statistics/distributions/$(octave_dirstamp)
-$(statistics_models_GEN_FCN_FILES): statistics/models/$(octave_dirstamp)
-$(statistics_tests_GEN_FCN_FILES): statistics/tests/$(octave_dirstamp)
-$(strings_GEN_FCN_FILES): strings/$(octave_dirstamp)
-$(testfun_GEN_FCN_FILES): testfun/$(octave_dirstamp)
-$(time_GEN_FCN_FILES): time/$(octave_dirstamp)
-$(ui_GEN_FCN_FILES): ui/$(octave_dirstamp)
-
-@ftp/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) @ftp && \
-	: > @ftp/$(octave_dirstamp)
-audio/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) audio && \
-	: > audio/$(octave_dirstamp)
-deprecated/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) deprecated && \
-	: > deprecated/$(octave_dirstamp)
-elfun/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) elfun && \
-	: > elfun/$(octave_dirstamp)
-general/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) general && \
-	: > general/$(octave_dirstamp)
-geometry/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) geometry && \
-	: > geometry/$(octave_dirstamp)
-gui/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) gui && \
-	: > gui/$(octave_dirstamp)
-help/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) help && \
-	: > help/$(octave_dirstamp)
-image/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) image && \
-	: > image/$(octave_dirstamp)
-io/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) io && \
-	: > io/$(octave_dirstamp)
-java/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) java && \
-	: > java/$(octave_dirstamp)
-linear-algebra/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) linear-algebra && \
-	: > linear-algebra/$(octave_dirstamp)
-miscellaneous/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) miscellaneous && \
-	: > miscellaneous/$(octave_dirstamp)
-optimization/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) optimization && \
-	: > optimization/$(octave_dirstamp)
-path/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) path && \
-	: > path/$(octave_dirstamp)
-pkg/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) pkg && \
-	: > pkg/$(octave_dirstamp)
-plot/appearance/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) plot/appearance && \
-	: > plot/appearance/$(octave_dirstamp)
-plot/draw/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) plot/draw && \
-	: > plot/draw/$(octave_dirstamp)
-plot/util/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) plot/util && \
-	: > plot/util/$(octave_dirstamp)
-polynomial/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) polynomial && \
-	: > polynomial/$(octave_dirstamp)
-prefs/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) prefs && \
-	: > prefs/$(octave_dirstamp)
-set/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) set && \
-	: > set/$(octave_dirstamp)
-signal/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) signal && \
-	: > signal/$(octave_dirstamp)
-sparse/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) sparse && \
-	: > sparse/$(octave_dirstamp)
-specfun/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) specfun && \
-	: > specfun/$(octave_dirstamp)
-special-matrix/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) special-matrix && \
-	: > special-matrix/$(octave_dirstamp)
-startup/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) startup && \
-	: > startup/$(octave_dirstamp)
-statistics/base/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) statistics/base && \
-	: > statistics/base/$(octave_dirstamp)
-statistics/distributions/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) statistics/distributions && \
-	: > statistics/distributions/$(octave_dirstamp)
-statistics/models/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) statistics/models && \
-	: > statistics/models/$(octave_dirstamp)
-statistics/tests/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) statistics/tests && \
-	: > statistics/tests/$(octave_dirstamp)
-strings/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) strings && \
-	: > strings/$(octave_dirstamp)
-testfun/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) testfun && \
-	: > testfun/$(octave_dirstamp)
-time/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) time && \
-	: > time/$(octave_dirstamp)
-ui/$(octave_dirstamp):
-	$(AM_V_GEN)$(MKDIR_P) ui && \
-	: > ui/$(octave_dirstamp)
-
-if AMCOND_BUILD_DOCS
-
-.DOCSTRINGS: $(FCN_FILES) $(GEN_FCN_FILES) mkdoc.pl Makefile
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	if [ "x$(srcdir)" != "x." ] && [ -f $(srcdir)/DOCSTRINGS ] && [ ! -f DOCSTRINGS ]; then \
-		cp $(srcdir)/DOCSTRINGS DOCSTRINGS; \
-		touch -r $(srcdir)/DOCSTRINGS DOCSTRINGS; \
-	fi && \
-	$(PERL) $(srcdir)/mkdoc.pl "$(srcdir)" $(FCN_FILES) -- $(GEN_FCN_FILES) > $@-t && \
-	mv $@-t $@ && \
-	$(top_srcdir)/build-aux/move-if-change $@ DOCSTRINGS && \
-	touch $@
-
-endif
-
-$(GEN_FCN_FILES) : %.m : %.in Makefile
-	$(AM_V_GEN)$(do_subst_config_vals)
-
-check-m-sources:
-	@echo "checking whether files in source tree are listed in module.mk files..."; \
-	for f in $$(find $(srcdir) -name '*.m'); do \
-	  found=false; \
-	  for m in $(FCN_FILES) $(GEN_FCN_FILES); do \
-	    if [ "$$f" = $(srcdir)/"$$m" ]; then \
-	      found=true; \
-	      break; \
-	    fi; \
-	  done; \
-	  if $$found; then \
-	    true; \
-	  else \
-	    missing=$$(echo $$f | $(SED) "s|^$(srcdir)||"); \
-	    echo "$$missing: not listed in SOURCES"; \
-	  fi; \
-	done; \
-	if test -z "$$missing"; then \
-	  echo "yes"; \
-	fi
-.PHONY: check-m-sources
-
-check-missing-semicolon:
-	@echo "checking for missing semicolons in .m files..."
-	( echo "warning on Octave:missing-semicolon;"; \
-	  for m in $(addprefix $(srcdir)/, $(FCN_FILES)) $(GEN_FCN_FILES); do \
-	    echo "source ('$$m');"; \
-	  done ) | ../run-octave -qf
-.PHONY: check-missing-semicolon
-
-## Add rule to generate ctags.
-## Automake would normally generate such a rule, but only if there is a
-## xxx_SOURCES target
-ctags:
-	ctags $(addprefix $(srcdir)/, $(FCN_FILES)) $(GEN_FCN_FILES)
-
-install-data-local: install-startup-files install-pkg-add
-
-uninstall-local: uninstall-startup-files uninstall-pkg-add
-
-install-startup-files:
-	$(MKDIR_P) $(DESTDIR)$(fcnfiledir)/startup
-	if test -f $(DESTDIR)$(fcnfiledir)/startup/octaverc; then true; \
-	else \
-	  $(INSTALL_DATA) $(srcdir)/$(SYSTEM_STARTUP_FILE_SRC) \
-	    $(DESTDIR)$(fcnfiledir)/startup/octaverc; \
-	fi
-	if test -f $(DESTDIR)$(fcnfiledir)/startup/inputrc; then true; \
-	else \
-	  $(INSTALL_DATA) $(srcdir)/$(SYSTEM_INPUTRC_FILE_SRC) \
-	    $(DESTDIR)$(fcnfiledir)/startup/inputrc; \
-	fi
-	$(MKDIR_P) $(DESTDIR)$(localfcnfiledir)/startup
-	if test -f $(DESTDIR)$(localfcnfiledir)/startup/octaverc; \
-	then true; \
-	else \
-	  $(INSTALL_DATA) $(srcdir)/$(LOCAL_STARTUP_FILE_SRC) \
-	    $(DESTDIR)$(localfcnfiledir)/startup/octaverc; \
-	fi
-.PHONY: install-startup-files
-
-uninstall-startup-files:
-	rm -f $(DESTDIR)$(fcnfiledir)/startup/octaverc
-	rm -f $(DESTDIR)$(fcnfiledir)/startup/inputrc
-	rm -f $(DESTDIR)$(localfcnfiledir)/startup/octaverc
-.PHONY: uninstall-startup-files
-
-install-pkg-add:
-	for f in $(PKG_ADD_FILES); do \
-	  if [ -n "`cat $$f`" ]; then \
-	    $(MKDIR_P) $(DESTDIR)$(fcnfiledir)/`echo $$f | $(SED) 's,/[^/]*$$,,'`; \
-	    $(INSTALL_DATA) $$f $(DESTDIR)$(fcnfiledir)/$$f; \
-	  fi \
-	done
-.PHONY: install-pkg-add
-
-uninstall-pkg-add:
-	for f in $(PKG_ADD_FILES); do \
-	  rm -f $(DESTDIR)$(fcnfiledir)/$$f; \
-	done
-.PHONY: uninstall-pkg-add
-
-if AMCOND_HAVE_JAVA
-else
-dist-hook:
-	@echo "Packaging distribution requires Java." ; exit 1;
-endif
-
-EXTRA_DIST += \
-  $(IMAGES) \
-  $(FCN_FILES) \
-  $(FCN_FILES_IN) \
-  $(GEN_FCN_FILES) \
-  DOCSTRINGS \
-  mkdoc.pl \
-  mk-pkg-add
-
-DISTCLEANFILES += \
-  .DOCSTRINGS \
-  DOCSTRINGS \
-  $(PKG_ADD_FILES) \
-  $(DIRSTAMP_FILES) \
-  $(GEN_FCN_FILES)
-
-distclean-local:
-	if [ "x$(srcdir)" != "x." ]; then \
-	  rm -f $(java_JAVA_IMAGES); \
-	fi
--- a/scripts/audio/@audioplayer/set.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/audio/@audioplayer/set.m	Thu Dec 10 12:50:06 2015 -0800
@@ -50,7 +50,7 @@
       index = 1;
       for property = varargin{2}
         setproperty (player, char (property), varargin{3}{index});
-        index = index + 1;
+        index += 1;
       endfor
     else
       setproperty (player, varargin{2}, varargin{3});
--- a/scripts/audio/@audiorecorder/set.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/audio/@audiorecorder/set.m	Thu Dec 10 12:50:06 2015 -0800
@@ -50,7 +50,7 @@
       index = 1;
       for property = varargin{2}
         setproperty (recorder, char (property), varargin{3}{index});
-        index = index + 1;
+        index += 1;
       endfor
     else
       setproperty (recorder, varargin{2}, varargin{3});
--- a/scripts/audio/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/audio/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,45 +1,65 @@
-FCN_FILE_DIRS += audio
+FCN_FILE_DIRS += \
+  scripts/audio \
+  scripts/audio/@audioplayer \
+  scripts/audio/@audiorecorder
+
+scripts_audio_FCN_FILES = \
+  scripts/audio/lin2mu.m \
+  scripts/audio/mu2lin.m \
+  scripts/audio/record.m \
+  scripts/audio/sound.m \
+  scripts/audio/soundsc.m
+
+scripts_audio_@audioplayer_FCN_FILES = \
+  scripts/audio/@audioplayer/__get_properties__.m \
+  scripts/audio/@audioplayer/audioplayer.m \
+  scripts/audio/@audioplayer/display.m \
+  scripts/audio/@audioplayer/get.m \
+  scripts/audio/@audioplayer/isplaying.m \
+  scripts/audio/@audioplayer/pause.m  \
+  scripts/audio/@audioplayer/play.m \
+  scripts/audio/@audioplayer/playblocking.m \
+  scripts/audio/@audioplayer/resume.m \
+  scripts/audio/@audioplayer/set.m \
+  scripts/audio/@audioplayer/stop.m \
+  scripts/audio/@audioplayer/subsasgn.m \
+  scripts/audio/@audioplayer/subsref.m
 
-audio_FCN_FILES = \
-  audio/lin2mu.m \
-  audio/mu2lin.m \
-  audio/record.m \
-  audio/sound.m \
-  audio/soundsc.m \
-  audio/wavread.m \
-  audio/wavwrite.m \
-  audio/@audioplayer/__get_properties__.m \
-  audio/@audioplayer/audioplayer.m \
-  audio/@audioplayer/display.m \
-  audio/@audioplayer/get.m \
-  audio/@audioplayer/isplaying.m \
-  audio/@audioplayer/pause.m  \
-  audio/@audioplayer/play.m \
-  audio/@audioplayer/playblocking.m \
-  audio/@audioplayer/resume.m \
-  audio/@audioplayer/set.m \
-  audio/@audioplayer/stop.m \
-  audio/@audioplayer/subsasgn.m \
-  audio/@audioplayer/subsref.m \
-  audio/@audiorecorder/__get_properties__.m \
-  audio/@audiorecorder/audiorecorder.m \
-  audio/@audiorecorder/display.m \
-  audio/@audiorecorder/get.m \
-  audio/@audiorecorder/getaudiodata.m \
-  audio/@audiorecorder/getplayer.m \
-  audio/@audiorecorder/isrecording.m \
-  audio/@audiorecorder/pause.m \
-  audio/@audiorecorder/play.m \
-  audio/@audiorecorder/record.m \
-  audio/@audiorecorder/recordblocking.m \
-  audio/@audiorecorder/resume.m \
-  audio/@audiorecorder/set.m \
-  audio/@audiorecorder/stop.m \
-  audio/@audiorecorder/subsasgn.m \
-  audio/@audiorecorder/subsref.m
+scripts_audio_@audiorecorder_FCN_FILES = \
+  scripts/audio/@audiorecorder/__get_properties__.m \
+  scripts/audio/@audiorecorder/audiorecorder.m \
+  scripts/audio/@audiorecorder/display.m \
+  scripts/audio/@audiorecorder/get.m \
+  scripts/audio/@audiorecorder/getaudiodata.m \
+  scripts/audio/@audiorecorder/getplayer.m \
+  scripts/audio/@audiorecorder/isrecording.m \
+  scripts/audio/@audiorecorder/pause.m \
+  scripts/audio/@audiorecorder/play.m \
+  scripts/audio/@audiorecorder/record.m \
+  scripts/audio/@audiorecorder/recordblocking.m \
+  scripts/audio/@audiorecorder/resume.m \
+  scripts/audio/@audiorecorder/set.m \
+  scripts/audio/@audiorecorder/stop.m \
+  scripts/audio/@audiorecorder/subsasgn.m \
+  scripts/audio/@audiorecorder/subsref.m
 
-FCN_FILES += $(audio_FCN_FILES)
+scripts_audiodir = $(fcnfiledir)/audio
+
+scripts_audio_DATA = $(scripts_audio_FCN_FILES)
+
+scripts_audio_@audioplayerdir = $(fcnfiledir)/audio/@audioplayer
+
+scripts_audio_@audioplayer_DATA = $(scripts_audio_@audioplayer_FCN_FILES)
+
+scripts_audio_@audiorecorderdir = $(fcnfiledir)/audio/@audiorecorder
 
-PKG_ADD_FILES += audio/PKG_ADD
+scripts_audio_@audiorecorder_DATA = $(scripts_audio_@audiorecorder_FCN_FILES)
 
-DIRSTAMP_FILES += audio/$(octave_dirstamp)
+FCN_FILES += \
+  $(scripts_audio_FCN_FILES) \
+  $(scripts_audio_@audioplayer_FCN_FILES) \
+  $(scripts_audio_@audiorecorder_FCN_FILES)
+
+PKG_ADD_FILES += scripts/audio/PKG_ADD
+
+DIRSTAMP_FILES += scripts/audio/$(octave_dirstamp)
--- a/scripts/audio/mu2lin.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/audio/mu2lin.m	Thu Dec 10 12:50:06 2015 -0800
@@ -69,7 +69,7 @@
   ## Convert to real or 8-bit.
   if (n == 0)
     ## [ -32768, 32767 ] -> [ -1, 1)
-    y = y/32768;
+    y /= 32768;
   elseif (n == 8)
     ld = max (abs (y (:)));
     if (ld < 16384 && ld > 0)
--- a/scripts/audio/wavread.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-## Copyright (C) 2015 Mike Miller
-## Copyright (C) 2005-2015 Michael Zeising
-##
-## 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{y} =} wavread (@var{filename})
-## @deftypefnx {Function File} {[@var{y}, @var{fs}, @var{nbits}] =} wavread (@var{filename})
-## @deftypefnx {Function File} {[@dots{}] =} wavread (@var{filename}, @var{n})
-## @deftypefnx {Function File} {[@dots{}] =} wavread (@var{filename}, [@var{n1} @var{n2}])
-## @deftypefnx {Function File} {[@dots{}] =} wavread (@dots{}, @var{datatype})
-## @deftypefnx {Function File} {@var{sz} =} wavread (@var{filename}, "size")
-## @deftypefnx {Function File} {[@var{n_samp}, @var{n_chan}] =} wavread (@var{filename}, "size")
-## Read the audio signal @var{y} from the RIFF/WAVE sound file @var{filename}.
-##
-## If the file contains multichannel data, then @var{y} is a matrix with the
-## channels represented as columns.
-##
-## If @var{n} is specified, only the first @var{n} samples of the file are
-## returned.  If [@var{n1} @var{n2}] is specified, only the range of samples
-## from @var{n1} to @var{n2} is returned.  A value of @code{Inf} can be used
-## to represent the total number of samples in the file.
-##
-## If the option @qcode{"size"} is given, then the size of the audio signal
-## is returned instead of the data.  The size is returned in a row vector of
-## the form [@var{samples} @var{channels}].  If there are two output arguments,
-## the number of samples is assigned to the first and the number of channels
-## is assigned to the second.
-##
-## The optional return value @var{fs} is the sample rate of the audio file in
-## Hz.  The optional return value @var{nbits} is the number of bits per sample
-## as encoded in the file.
-##
-## @seealso{audioread, audiowrite, wavwrite}
-## @end deftypefn
-
-function [y, fs, nbits] = wavread (filename, varargin)
-
-  if (nargin < 1 || nargin > 3)
-    print_usage ();
-  endif
-
-  if (! ischar (filename))
-    error ("wavread: FILENAME must be a character string");
-  endif
-
-  datatype = "double";
-  samples = [1, Inf];
-  do_file_size = false;
-
-  if (nargin == 3)
-    samples = varargin{1};
-    datatype = varargin{2};
-  elseif (nargin == 2)
-    if (strcmp (varargin{1}, "size"))
-      do_file_size = true;
-    elseif (ischar (varargin{1}))
-      datatype = varargin{1};
-    else
-      samples = varargin{1};
-    endif
-  endif
-
-  if (isscalar (samples))
-    samples = [1, samples];
-  endif
-
-  if (! (isrow (samples) && numel (samples) == 2 && all (samples > 0)
-         && all (fix (samples) == samples)))
-    error ("wavread: SAMPLES must be a 1- or 2-element integer row vector");
-  endif
-
-  if (! (ischar (datatype) && any (strcmp (datatype, {"double", "native"}))))
-    error ('wavread: DATATYPE must be either "double" or "native"');
-  endif
-
-  info = audioinfo (filename);
-
-  if (do_file_size)
-    if (nargout > 1)
-      [y, fs] = deal (info.TotalSamples, info.NumChannels);
-    else
-      y = [info.TotalSamples, info.NumChannels];
-    endif
-  else
-    [y, fs] = audioread (filename, samples, datatype);
-    nbits = info.BitsPerSample;
-  endif
-
-endfunction
-
-
-## Functional tests for wavread/wavwrite pair are in wavwrite.m.
-
-## Test input validation
-%!error wavread ()
-%!error wavread (1)
-%!error wavread ("foo.wav", 2, 3, 4)
-%!error wavread ("foo.wav", "foo")
-%!error wavread ("foo.wav", -1)
-%!error wavread ("foo.wav", [1, Inf], "foo");
-
--- a/scripts/audio/wavwrite.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-## Copyright (C) 2015 Mike Miller
-## Copyright (C) 2005-2015 Michael Zeising
-##
-## 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} {} wavwrite (@var{y}, @var{filename})
-## @deftypefnx {Function File} {} wavwrite (@var{y}, @var{fs}, @var{filename})
-## @deftypefnx {Function File} {} wavwrite (@var{y}, @var{fs}, @var{nbits}, @var{filename})
-## Write the audio signal @var{y} to the RIFF/WAVE sound file @var{filename}.
-##
-## If @var{y} is a matrix, the columns represent multiple audio channels.
-##
-## The optional argument @var{fs} specifies the sample rate of the audio signal
-## in Hz.
-##
-## The optional argument @var{nbits} specifies the number of bits per sample
-## to write to @var{filename}.
-##
-## The default sample rate is 8000 Hz and the default bit depth is 16 bits
-## per sample.
-##
-## @seealso{audiowrite, audioread, wavread}
-## @end deftypefn
-
-function wavwrite (y, varargin)
-
-  if (nargin < 2 || nargin > 4)
-    print_usage ();
-  endif
-
-  ## Defaults.
-  fs = 8000;
-  nbits = 16;
-
-  filename = varargin{end};
-  if (nargin > 2)
-    fs = varargin{1};
-    if (nargin > 3)
-      nbits = varargin{2};
-    endif
-  endif
-
-  ## calculate filesize
-  [n, channels] = size (y);
-
-  ## allow y to be a row vector
-  if (n == 1)
-    y = y(:);
-    n = channels;
-    channels = 1;
-  endif
-
-  ## test arguments
-  if (channels < 1)
-    error ("wavwrite: Y must have at least one column");
-  endif
-
-  if (channels > 0x7FFF)
-    error ("wavwrite: Y must have no more than 32767 columns");
-  endif
-
-  if (! (isscalar (fs) && (fs > 0)))
-    error ("wavwrite: sample rate FS must be a positive number");
-  endif
-
-  if (! isscalar (nbits) || isempty (find (nbits == [8, 16, 24, 32])))
-    error ("wavwrite: bit depth NBITS must be 8, 16, 24, or 32");
-  endif
-
-  audiowrite (filename, y, fs, "BitsPerSample", nbits);
-
-endfunction
-
-
-%!shared fname
-%! fname = [tempname() ".wav"];
-
-%!testif HAVE_SNDFILE
-%! A = [-1:0.1:1; -1:0.1:1]';
-%! unwind_protect
-%!   wavwrite (A, fname);
-%!   [B, samples_per_sec, bits_per_sample] = wavread (fname);
-%!   assert (B, A, 2^-14);
-%!   assert (samples_per_sec, 8000);
-%!   assert (bits_per_sample, 16);
-%! unwind_protect_cleanup
-%!   unlink (fname);
-%! end_unwind_protect
-
-%!testif HAVE_SNDFILE
-%! A = [-1:0.1:1; -1:0.1:1]';
-%! unwind_protect
-%!   wavwrite (A, 4000, fname);
-%!   [B, samples_per_sec, bits_per_sample] = wavread (fname);
-%!   assert (B, A, 2^-14);
-%!   assert (samples_per_sec, 4000);
-%!   assert (bits_per_sample, 16);
-%! unwind_protect_cleanup
-%!   unlink (fname);
-%! end_unwind_protect
-
-%!testif HAVE_SNDFILE
-%! A = [-1:0.1:1; -1:0.1:1]';
-%! unwind_protect
-%!   wavwrite (A, 4000, 8, fname);
-%!   [B, samples_per_sec, bits_per_sample] = wavread (fname);
-%!   assert (B, A, 2^-6);
-%!   assert (samples_per_sec, 4000);
-%!   assert (bits_per_sample, 8);
-%! unwind_protect_cleanup
-%!   unlink (fname);
-%! end_unwind_protect
-
-%!testif HAVE_SNDFILE
-%! A = [-2:2]';
-%! unwind_protect
-%!   wavwrite (A, fname);
-%!   B = wavread (fname);
-%!   B *= 32768;
-%!   assert (B, [-32767 -32767 0 32767 32767]');
-%! unwind_protect_cleanup
-%!   unlink (fname);
-%! end_unwind_protect
-
-%!testif HAVE_SNDFILE
-%! A = [-1:0.1:1];
-%! unwind_protect
-%!   wavwrite (A, fname);
-%!   [B, samples_per_sec, bits_per_sample] = wavread (fname);
-%!   assert (B, A', 2^-14);
-%!   assert (samples_per_sec, 8000);
-%!   assert (bits_per_sample, 16);
-%! unwind_protect_cleanup
-%!   unlink (fname);
-%! end_unwind_protect
-
-%!testif HAVE_SNDFILE
-%! A = [-1:0.1:1; -1:0.1:1]';
-%! unwind_protect
-%!   wavwrite (A, fname);
-%!   B = wavread (fname, 15);
-%!   assert (B, A(1:15,:), 2^-14);
-%!   wavwrite (A, fname);
-%!   B = wavread (fname, [10, 20]);
-%!   assert (B, A(10:20,:), 2^-14);
-%! unwind_protect_cleanup
-%!   unlink (fname);
-%! end_unwind_protect
-
-%!testif HAVE_SNDFILE
-%! A = [-1:0.1:1; -1:0.1:1]';
-%! unwind_protect
-%!   wavwrite (A, fname);
-%!   [nsamp, nchan] = wavread (fname, "size");
-%!   assert (nsamp, 21);
-%!   assert (nchan, 2);
-%! unwind_protect_cleanup
-%!   unlink (fname);
-%! end_unwind_protect
-
-## Test input validation
-%!error wavwrite ()
-%!error wavwrite (1)
-%!error wavwrite (1,2,3,4,5)
-%!error wavwrite ([], "foo.wav");
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/deprecated/bitmax.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,52 @@
+## Copyright (C) 2004-2015 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{r} =} bitmax (@var{precision})
+##
+## @code{bitmax} is deprecated and will be removed in Octave version 4.6.
+## Use @code{flintmax (precision) - 1} for the equivalent functionality.
+##
+## Return the largest integer @var{r} that can be represented within a
+## floating point value.
+##
+## The default class is @qcode{"double"}, but @qcode{"single"} is a valid
+## option.  On IEEE 754 compatible systems, @code{bitmax} is
+## @w{@math{2^{53} - 1}} for @qcode{"double"} and @w{@math{2^{24} - 1}} for
+## @qcode{"single"}.
+##
+## @seealso{flintmax, intmax, realmax, realmin}
+## @end deftypefn
+
+## Deprecated in version 4.2
+
+function r = bitmax (precision)
+
+  persistent warned = false;
+  if (! warned)
+    warned = true;
+    warning ("Octave:deprecated-function",
+             "bitmax is obsolete and will be removed from a future version of Octave, please use flintmax instead");
+  endif
+
+  if (nargin == 0)
+    precision = "double";
+  endif
+  r = flintmax (precision) - 1;
+
+endfunction
--- a/scripts/deprecated/default_save_options.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-## Copyright (C) 2013-2015 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  {Built-in Function} {@var{val} =} default_save_options ()
-## @deftypefnx {Built-in Function} {@var{old_val} =} default_save_options (@var{new_val})
-## @deftypefnx {Built-in Function} {} default_save_options (@var{new_val}, "local")
-## This function has been deprecated.  Use @code{@file{save_default_options}}
-## instead.
-## @seealso{save_default_options}
-## @end deftypefn
-
-## Deprecated in 3.8
-
-function retval = default_save_options (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "default_save_options is obsolete and will be removed from a future version of Octave, please use save_default_options instead");
-  endif
-
-  retval = save_default_options (varargin{:});
-
-endfunction
-
--- a/scripts/deprecated/gen_doc_cache.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-## Copyright (C) 2013-2015 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} {} gen_doc_cache (@var{out_file}, @var{directory})
-## This function has been deprecated.  Use @code{doc_cache_create} instead.
-## @seealso{doc_cache_create}
-## @end deftypefn
-
-## Deprecated in 3.8
-
-function gen_doc_cache (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "gen_doc_cache is obsolete and will be removed from a future version of Octave, please use doc_cache_create instead");
-  endif
-
-  doc_cache_create (varargin{:});
-
-endfunction
-
--- a/scripts/deprecated/interp1q.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-## Copyright (C) 2008-2015 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} {@var{yi} =} interp1q (@var{x}, @var{y}, @var{xi})
-## One-dimensional linear interpolation without error checking.
-## Interpolates @var{y}, defined at the points @var{x}, at the points
-## @var{xi}.  The sample points @var{x} must be a strictly monotonically
-## increasing column vector.  If @var{y} is a matrix or an N-dimensional
-## array, the interpolation is performed on each column of @var{y}.  If
-## @var{y} is a vector, it must be a column vector of the same length as
-## @var{x}.
-##
-## Values of @var{xi} beyond the endpoints of the interpolation result
-## in NA being returned.
-##
-## Note that the error checking is only a significant portion of the
-## execution time of this @code{interp1} if the size of the input arguments
-## is relatively small.  Therefore, the benefit of using @code{interp1q}
-## is relatively small.
-## @seealso{interp1}
-## @end deftypefn
-
-function yi = interp1q (x, y, xi)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "interp1q is obsolete and will be removed from a future version of Octave; use interp1 instead");
-  endif
-
-  x = x(:);
-  nx = rows (x);
-  szy = size (y);
-  y = y(:,:);
-  [ny, nc] = size (y);
-  szx = size (xi);
-  xi = xi (:);
-  dy = diff (y);
-  dx = diff (x);
-  idx = lookup (x, xi, "lr");
-  s = (xi - x(idx)) ./ dx(idx);
-  yi = bsxfun (@times, s, dy(idx,:)) + y(idx,:);
-  range = xi < x(1) | !(xi <= x(nx));
-  yi(range,:) = NA;
-  if (length (szx) == 2 && any (szx == 1))
-    yi = reshape (yi, [max(szx), szy(2:end)]);
-  else
-    yi = reshape (yi, [szx, szy(2:end)]);
-  endif
-endfunction
-
-
-%!shared xp, yp, xi, yi
-%! 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]));
-
--- a/scripts/deprecated/isequalwithequalnans.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-## Copyright (C) 2005-2015 William Poetra Yoga Hadisoeseno
-##
-## 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} {} isequalwithequalnans (@var{x1}, @var{x2}, @dots{})
-## This function has been deprecated.  Use @code{@file{isequaln}} instead.
-## @seealso{isequaln}
-## @end deftypefn
-
-## Deprecated in 3.8
-
-function retval = isequalwithequalnans (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "isequalwithequalnans is obsolete and will be removed from a future version of Octave, please use isequaln instead");
-  endif
-
-  retval = isequaln (varargin{:});
-
-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)
-## 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)
-## 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)
-
--- a/scripts/deprecated/java_convert_matrix.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-## Copyright (C) 2012-2015 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  {Built-in Function} {@var{val} =} java_convert_matrix ()
-## @deftypefnx {Built-in Function} {@var{old_val} =} java_convert_matrix (@var{new_val})
-## @deftypefnx {Built-in Function} {} java_convert_matrix (@var{new_val}, "local")
-## Query or set the internal variable that controls whether Java arrays are
-## automatically converted to Octave matrices.  The default value is false.
-##
-## When called from inside a function with the @qcode{"local"} option, the
-## variable is changed locally for the function and any subroutines it calls.
-##  The original variable value is restored when exiting the function.
-## @seealso{java_matrix_autoconversion, java_unsigned_conversion, java_debug}
-## @end deftypefn
-
-function old_val = java_convert_matrix (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "java_convert_matrix is obsolete and will be removed from a future version of Octave; use java_matrix_autoconversion instead");
-  endif
-
-  if (nargin > 2)
-    print_usage ();
-  endif
-
-  old_val = java_matrix_autoconversion (varargin{:});
-
-endfunction
-
--- a/scripts/deprecated/java_debug.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-## Copyright (C) 2012-2015 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  {Built-in Function} {@var{val} =} java_debug ()
-## @deftypefnx {Built-in Function} {@var{old_val} =} java_debug (@var{new_val})
-## @deftypefnx {Built-in Function} {} java_debug (@var{new_val}, "local")
-## Query or set the internal variable that determines whether extra debugging
-## information regarding the initialization of the JVM and any Java exceptions
-## is printed.
-##
-## When called from inside a function with the @qcode{"local"} option, the
-## variable is changed locally for the function and any subroutines it calls.
-##  The original variable value is restored when exiting the function.
-## @seealso{debug_java, java_convert_matrix, java_unsigned_conversion}
-## @end deftypefn
-
-function old_val = java_debug (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "java_debug is obsolete and will be removed from a future version of Octave; use debug_java instead");
-  endif
-
-  if (nargin > 2)
-    print_usage ();
-  endif
-
-  old_val = debug_java (varargin{:});
-
-endfunction
-
--- a/scripts/deprecated/java_invoke.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-## Copyright (C) 2007, 2013 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  {Built-in Function} {@var{ret} =} java_invoke (@var{obj}, @var{methodname})
-## @deftypefnx {Built-in Function} {@var{ret} =} java_invoke (@var{obj}, @var{methodname}, @var{arg1}, @dots{})
-## Invoke the method @var{methodname} on the Java object @var{obj} with the
-## arguments @var{arg1}, @dots{}  For static methods, @var{obj} can be a
-## string representing the fully qualified name of the corresponding class.
-## The function returns the result of the method invocation.
-##
-## When @var{obj} is a regular Java object, structure-like indexing can be
-## used as a shortcut syntax.  For instance, the two following statements are
-## equivalent
-##
-## @example
-## @group
-##   ret = java_invoke (x, "method1", 1.0, "a string")
-##   ret = x.method1 (1.0, "a string")
-## @end group
-## @end example
-##
-## @seealso{javaMethod, javaObject}
-## @end deftypefn
-
-function retval = java_invoke (obj, methodname, varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "java_invoke is obsolete and will be removed from a future version of Octave, please use javaMethod instead");
-  endif
-
-  if (nargin < 2)
-    print_usage ();
-  endif
-
-  retval = javaMethod (methodname, obj, varargin{:});
-
-endfunction
-
--- a/scripts/deprecated/java_new.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-## Copyright (C) 2012-2015 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  {Loadable Function} {@var{obj} =} java_new (@var{name})
-## @deftypefnx {Loadable Function} {@var{obj} =} java_new (@var{name}, @var{arg1}, @dots{})
-## Create a Java object of class @var{name}, by calling the class constructor
-## with the arguments @var{arg1}, @dots{}
-##
-## @example
-## @group
-##   x = java_new ("java.lang.StringBuffer")
-##   x = java_new ("java.lang.StringBuffer", "Initial string")
-## @end group
-## @end example
-##
-## @seealso{javaObject, javaMethod}
-## @end deftypefn
-
-function retval = java_new (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "java_new is obsolete and will be removed from a future version of Octave; please use javaObject instead");
-  endif
-
-  if (nargin < 1)
-    print_usage ();
-  endif
-
-  retval = javaObject (varargin{:});
-
-endfunction
-
--- a/scripts/deprecated/java_unsigned_conversion.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-## Copyright (C) 2012-2015 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  {Built-in Function} {@var{val} =} java_unsigned_conversion ()
-## @deftypefnx {Built-in Function} {@var{old_val} =} java_unsigned_conversion (@var{new_val})
-## @deftypefnx {Built-in Function} {} java_unsigned_conversion (@var{new_val}, "local")
-## Query or set the internal variable that controls how integer classes are
-## converted when Java matrix autoconversion is enabled.  When enabled, Java
-## arrays of class Byte or Integer are converted to matrices of class uint8 or
-## uint32 respectively.
-##
-## When called from inside a function with the @qcode{"local"} option, the
-## variable is changed locally for the function and any subroutines it calls.
-##  The original variable value is restored when exiting the function.
-## @seealso{java_unsigned_autoconversion, java_convert_matrix, debug_java}
-## @end deftypefn
-
-function old_val = java_unsigned_conversion (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "java_unsigned_conversion is obsolete and will be removed from a future version of Octave; use java_unsigned_autoconversion instead");
-  endif
-
-  if (nargin > 2)
-    print_usage ();
-  endif
-
-  old_val = java_unsigned_autoconversion (varargin{:});
-
-endfunction
-
--- a/scripts/deprecated/javafields.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-## Copyright (C) 2007, 2013 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} {} javafields (@var{javaobj})
-## @deftypefnx {Function File} {} javafields ("@var{classname}")
-## @deftypefnx {Function File} {@var{fld_names} =} javafields (@dots{})
-## Return the fields of a Java object or Java class in the form of a cell
-## array of strings.  If no output is requested, print the result
-## to the standard output.
-## @seealso{fieldnames, methods, javaObject}
-## @end deftypefn
-
-function fld_names = javafields (javaobj)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "javafields is obsolete and will be removed from a future version of Octave, please use fieldnames instead");
-  endif
-
-  if (nargin != 1)
-    print_usage ();
-  endif
-
-  c_methods = javaMethod ("getFields", "org.octave.ClassHelper", javaobj);
-  method_list = ostrsplit (c_methods, ';');
-
-  if (nargout == 0)
-    if (! isempty (method_list))
-      disp (method_list);
-    endif
-  else
-    fld_names = cellstr (method_list);
-  endif
-
-endfunction
-
--- a/scripts/deprecated/javamethods.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-## Copyright (C) 2007, 2013 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} {} javamethods (@var{javaobj})
-## @deftypefnx {Function File} {} javamethods ("@var{classname}")
-## @deftypefnx {Function File} {@var{mtd_names} =} javamethods (@dots{})
-## Return the methods of a Java object or Java class in the form of a cell
-## array of strings.  If no output is requested, print the result to the
-## standard output.
-## @seealso{methods, fieldnames, javaMethod, javaObject}
-## @end deftypefn
-
-function mtd_names = javamethods (classname)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "javamethods is obsolete and will be removed from a future version of Octave, please use methods instead");
-  endif
-
-  if (nargin != 1)
-    print_usage ();
-  endif
-
-  cls_methods = javaMethod ("getMethods", "org.octave.ClassHelper", classname);
-  method_list = ostrsplit (cls_methods, ';');
-
-  if (nargout == 0)
-    if (! isempty (method_list))
-      disp (method_list);
-    endif
-  else
-    mtd_names = cellstr (method_list);
-  endif
-
-endfunction
-
--- a/scripts/deprecated/luinc.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/deprecated/luinc.m	Thu Dec 10 12:50:06 2015 -0800
@@ -16,6 +16,7 @@
 ## along with Octave; see the file COPYING.  If not, see
 ## <http://www.gnu.org/licenses/>.
 
+## -*- texinfo -*-
 ## @deftypefn  {Built-in Function} {[@var{L}, @var{U}, @var{P}, @var{Q}] =} luinc (@var{A}, '0')
 ## @deftypefnx {Built-in Function} {[@var{L}, @var{U}, @var{P}, @var{Q}] =} luinc (@var{A}, @var{droptol})
 ## @deftypefnx {Built-in Function} {[@var{L}, @var{U}, @var{P}, @var{Q}] =} luinc (@var{A}, @var{opts})
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/deprecated/mahalanobis.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,94 @@
+## Copyright (C) 1996-2015 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} {} mahalanobis (@var{x}, @var{y})
+##
+## @code{mahalanobis} is deprecated and will be removed in Octave version 4.6.
+## See the @code{mahal} function in the statistics package from Octave-Forge
+## for equivalent functionality.
+##
+## Return the Mahalanobis' D-square distance between the multivariate
+## samples @var{x} and @var{y}.
+##
+## The data @var{x} and @var{y} must have the same number of components
+## (columns), but may have a different number of observations (rows).
+## @end deftypefn
+
+## Author: Friedrich Leisch <leisch@ci.tuwien.ac.at>
+## Created: July 1993
+## Adapted-By: jwe
+
+function retval = mahalanobis (x, y)
+
+  persistent warned = false;
+  if (! warned)
+    warned = true;
+    warning ("Octave:deprecated-function",
+             "mahalanobis is obsolete and will be removed from a future version of Octave, please use mahal from the statistics package in Octave-Forge instead");
+  endif
+
+  if (nargin != 2)
+    print_usage ();
+  endif
+
+  if (   ! (isnumeric (x) || islogical (x))
+      || ! (isnumeric (y) || islogical (y)))
+    error ("mahalanobis: X and Y must be numeric matrices or vectors");
+  endif
+
+  if (ndims (x) != 2 || ndims (y) != 2)
+    error ("mahalanobis: X and Y must be 2-D matrices or vectors");
+  endif
+
+  [xr, xc] = size (x);
+  [yr, yc] = size (y);
+
+  if (xc != yc)
+    error ("mahalanobis: X and Y must have the same number of columns");
+  endif
+
+  if (isinteger (x))
+    x = double (x);
+  endif
+
+  xm = mean (x);
+  ym = mean (y);
+
+  ## Center data by subtracting means
+  x = bsxfun (@minus, x, xm);
+  y = bsxfun (@minus, y, ym);
+
+  w = (x' * x + y' * y) / (xr + yr - 2);
+
+  winv = inv (w);
+
+  retval = (xm - ym) * winv * (xm - ym)';
+
+endfunction
+
+
+## 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))
+
--- a/scripts/deprecated/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/deprecated/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,42 +1,36 @@
-FCN_FILE_DIRS += deprecated
+FCN_FILE_DIRS += scripts/deprecated
 
-deprecated_FCN_FILES = \
-  deprecated/bicubic.m \
-  deprecated/default_save_options.m \
-  deprecated/delaunay3.m \
-  deprecated/dump_prefs.m \
-  deprecated/find_dir_in_path.m \
-  deprecated/finite.m \
-  deprecated/fmod.m \
-  deprecated/fnmatch.m \
-  deprecated/gen_doc_cache.m \
-  deprecated/gmap40.m \
-  deprecated/interp1q.m \
-  deprecated/isequalwithequalnans.m \
-  deprecated/isstr.m \
-  deprecated/java_convert_matrix.m \
-  deprecated/java_debug.m \
-  deprecated/java_invoke.m \
-  deprecated/java_new.m \
-  deprecated/java_unsigned_conversion.m \
-  deprecated/javafields.m \
-  deprecated/javamethods.m \
-  deprecated/loadaudio.m \
-  deprecated/luinc.m \
-  deprecated/mouse_wheel_zoom.m \
-  deprecated/nfields.m \
-  deprecated/octave_tmp_file_name.m \
-  deprecated/playaudio.m \
-  deprecated/re_read_readline_init_file.m \
-  deprecated/read_readline_init_file.m \
-  deprecated/saveaudio.m \
-  deprecated/saving_history.m \
-  deprecated/setaudio.m \
-  deprecated/syl.m \
-  deprecated/usage.m
+scripts_deprecated_FCN_FILES = \
+  scripts/deprecated/bicubic.m \
+  scripts/deprecated/bitmax.m \
+  scripts/deprecated/delaunay3.m \
+  scripts/deprecated/dump_prefs.m \
+  scripts/deprecated/find_dir_in_path.m \
+  scripts/deprecated/finite.m \
+  scripts/deprecated/fmod.m \
+  scripts/deprecated/fnmatch.m \
+  scripts/deprecated/gmap40.m \
+  scripts/deprecated/isstr.m \
+  scripts/deprecated/loadaudio.m \
+  scripts/deprecated/luinc.m \
+  scripts/deprecated/mahalanobis.m \
+  scripts/deprecated/mouse_wheel_zoom.m \
+  scripts/deprecated/nfields.m \
+  scripts/deprecated/octave_tmp_file_name.m \
+  scripts/deprecated/playaudio.m \
+  scripts/deprecated/saveaudio.m \
+  scripts/deprecated/setaudio.m \
+  scripts/deprecated/syl.m \
+  scripts/deprecated/usage.m \
+  scripts/deprecated/wavread.m \
+  scripts/deprecated/wavwrite.m
 
-FCN_FILES += $(deprecated_FCN_FILES)
+scripts_deprecateddir = $(fcnfiledir)/deprecated
+
+scripts_deprecated_DATA = $(scripts_deprecated_FCN_FILES)
 
-PKG_ADD_FILES += deprecated/PKG_ADD
+FCN_FILES += $(scripts_deprecated_FCN_FILES)
 
-DIRSTAMP_FILES += deprecated/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/deprecated/PKG_ADD
+
+DIRSTAMP_FILES += scripts/deprecated/$(octave_dirstamp)
--- a/scripts/deprecated/octave_tmp_file_name.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/deprecated/octave_tmp_file_name.m	Thu Dec 10 12:50:06 2015 -0800
@@ -24,7 +24,7 @@
 ## @code{octave_tmp_file_name} is deprecated and will be removed in Octave
 ## version 4.4.  Use @code{tempname} for equivalent functionality.
 ##
-## Return a unique temporary file name as a string.
+## Return a unique temporary filename as a string.
 ##
 ## If @var{prefix} is omitted, a value of @qcode{"oct-"} is used.
 ## If @var{dir} is also omitted, the default directory for temporary files
--- a/scripts/deprecated/re_read_readline_init_file.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-## Copyright (C) 2013-2015 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 {Built-in Function} {} re_read_readline_init_file (@var{file})
-## This function has been deprecated.  Use
-## @code{@file{readline_re_read_init_file}} instead.
-## @seealso{readline_read_init_file}
-## @end deftypefn
-
-## Deprecated in 3.8
-
-function re_read_readline_init_file (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "re_read_readline_init_file is obsolete and will be removed from a future version of Octave, please use readline_re_read_init_file instead");
-  endif
-
-  readline_re_read_init_file (varargin{:});
-
-endfunction
-
--- a/scripts/deprecated/read_readline_init_file.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-## Copyright (C) 2013-2015 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 {Built-in Function} {} read_readline_init_file (@var{file})
-## This function has been deprecated.  Use
-## @code{@file{readline_read_init_file}} instead.
-## @seealso{readline_read_init_file}
-## @end deftypefn
-
-## Deprecated in 3.8
-
-function read_readline_init_file (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "read_readline_init_file is obsolete and will be removed from a future version of Octave, please use readline_read_init_file instead");
-  endif
-
-  readline_read_init_file (varargin{:});
-
-endfunction
-
--- a/scripts/deprecated/saving_history.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-## Copyright (C) 2013-2015 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  {Built-in Function} {@var{val} =} saving_history ()
-## @deftypefnx {Built-in Function} {@var{old_val} =} saving_history (@var{new_val})
-## @deftypefnx {Built-in Function} {} saving_history (@var{new_val}, "local")
-## This function has been deprecated.  Use @code{@file{history_save}} instead.
-## @seealso{history_save}
-## @end deftypefn
-
-## Deprecated in 3.8
-
-function retval = saving_history (varargin)
-
-  persistent warned = false;
-  if (! warned)
-    warned = true;
-    warning ("Octave:deprecated-function",
-             "saving_history is obsolete and will be removed from a future version of Octave, please use history_save instead");
-  endif
-
-  retval = save_default_options (varargin{:});
-
-endfunction
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/deprecated/wavread.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,129 @@
+## Copyright (C) 2015 Mike Miller
+## Copyright (C) 2005-2015 Michael Zeising
+##
+## 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{y} =} wavread (@var{filename})
+## @deftypefnx {Function File} {[@var{y}, @var{fs}, @var{nbits}] =} wavread (@var{filename})
+## @deftypefnx {Function File} {[@dots{}] =} wavread (@var{filename}, @var{n})
+## @deftypefnx {Function File} {[@dots{}] =} wavread (@var{filename}, [@var{n1} @var{n2}])
+## @deftypefnx {Function File} {[@dots{}] =} wavread (@dots{}, @var{datatype})
+## @deftypefnx {Function File} {@var{sz} =} wavread (@var{filename}, "size")
+## @deftypefnx {Function File} {[@var{n_samp}, @var{n_chan}] =} wavread (@var{filename}, "size")
+##
+## @code{wavread} is deprecated and will be removed in Octave version 4.6.
+## Use @code{audioread} for the equivalent functionality.
+##
+## Read the audio signal @var{y} from the RIFF/WAVE sound file @var{filename}.
+##
+## If the file contains multichannel data, then @var{y} is a matrix with the
+## channels represented as columns.
+##
+## If @var{n} is specified, only the first @var{n} samples of the file are
+## returned.  If [@var{n1} @var{n2}] is specified, only the range of samples
+## from @var{n1} to @var{n2} is returned.  A value of @code{Inf} can be used
+## to represent the total number of samples in the file.
+##
+## If the option @qcode{"size"} is given, then the size of the audio signal
+## is returned instead of the data.  The size is returned in a row vector of
+## the form [@var{samples} @var{channels}].  If there are two output arguments,
+## the number of samples is assigned to the first and the number of channels
+## is assigned to the second.
+##
+## The optional return value @var{fs} is the sample rate of the audio file in
+## Hz.  The optional return value @var{nbits} is the number of bits per sample
+## as encoded in the file.
+##
+## @seealso{audioread, audiowrite, wavwrite}
+## @end deftypefn
+
+## Deprecated in 4.2
+
+function [y, fs, nbits] = wavread (filename, varargin)
+
+  persistent warned = false;
+  if (! warned)
+    warned = true;
+    warning ("Octave:deprecated-function",
+             "wavread is obsolete and will be removed from a future version of Octave, please use audioread instead");
+  endif
+
+  if (nargin < 1 || nargin > 3)
+    print_usage ();
+  endif
+
+  if (! ischar (filename))
+    error ("wavread: FILENAME must be a character string");
+  endif
+
+  datatype = "double";
+  samples = [1, Inf];
+  do_file_size = false;
+
+  if (nargin == 3)
+    samples = varargin{1};
+    datatype = varargin{2};
+  elseif (nargin == 2)
+    if (strcmp (varargin{1}, "size"))
+      do_file_size = true;
+    elseif (ischar (varargin{1}))
+      datatype = varargin{1};
+    else
+      samples = varargin{1};
+    endif
+  endif
+
+  if (isscalar (samples))
+    samples = [1, samples];
+  endif
+
+  if (! (isrow (samples) && numel (samples) == 2 && all (samples > 0)
+         && all (fix (samples) == samples)))
+    error ("wavread: SAMPLES must be a 1- or 2-element integer row vector");
+  endif
+
+  if (! (ischar (datatype) && any (strcmp (datatype, {"double", "native"}))))
+    error ('wavread: DATATYPE must be either "double" or "native"');
+  endif
+
+  info = audioinfo (filename);
+
+  if (do_file_size)
+    if (nargout > 1)
+      [y, fs] = deal (info.TotalSamples, info.NumChannels);
+    else
+      y = [info.TotalSamples, info.NumChannels];
+    endif
+  else
+    [y, fs] = audioread (filename, samples, datatype);
+    nbits = info.BitsPerSample;
+  endif
+
+endfunction
+
+
+## Functional tests for wavread/wavwrite pair are in wavwrite.m.
+
+## Test input validation
+%!error wavread ()
+%!error wavread (1)
+%!error wavread ("foo.wav", 2, 3, 4)
+%!error wavread ("foo.wav", "foo")
+%!error wavread ("foo.wav", -1)
+%!error wavread ("foo.wav", [1, Inf], "foo");
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/deprecated/wavwrite.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,194 @@
+## Copyright (C) 2015 Mike Miller
+## Copyright (C) 2005-2015 Michael Zeising
+##
+## 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} {} wavwrite (@var{y}, @var{filename})
+## @deftypefnx {Function File} {} wavwrite (@var{y}, @var{fs}, @var{filename})
+## @deftypefnx {Function File} {} wavwrite (@var{y}, @var{fs}, @var{nbits}, @var{filename})
+##
+## @code{wavwrite} is deprecated and will be removed in Octave version 4.6.
+## Use @code{audiowrite} for the equivalent functionality.
+##
+## Write the audio signal @var{y} to the RIFF/WAVE sound file @var{filename}.
+##
+## If @var{y} is a matrix, the columns represent multiple audio channels.
+##
+## The optional argument @var{fs} specifies the sample rate of the audio signal
+## in Hz.
+##
+## The optional argument @var{nbits} specifies the number of bits per sample
+## to write to @var{filename}.
+##
+## The default sample rate is 8000 Hz and the default bit depth is 16 bits
+## per sample.
+##
+## @seealso{audiowrite, audioread, wavread}
+## @end deftypefn
+
+## Deprecated in 4.2
+
+function wavwrite (y, varargin)
+
+  persistent warned = false;
+  if (! warned)
+    warned = true;
+    warning ("Octave:deprecated-function",
+             "wavwrite is obsolete and will be removed from a future version of Octave, please use audiowrite instead");
+  endif
+
+  if (nargin < 2 || nargin > 4)
+    print_usage ();
+  endif
+
+  ## Defaults.
+  fs = 8000;
+  nbits = 16;
+
+  filename = varargin{end};
+  if (nargin > 2)
+    fs = varargin{1};
+    if (nargin > 3)
+      nbits = varargin{2};
+    endif
+  endif
+
+  ## calculate filesize
+  [n, channels] = size (y);
+
+  ## allow y to be a row vector
+  if (n == 1)
+    y = y(:);
+    n = channels;
+    channels = 1;
+  endif
+
+  ## test arguments
+  if (channels < 1)
+    error ("wavwrite: Y must have at least one column");
+  endif
+
+  if (channels > 0x7FFF)
+    error ("wavwrite: Y must have no more than 32767 columns");
+  endif
+
+  if (! (isscalar (fs) && (fs > 0)))
+    error ("wavwrite: sample rate FS must be a positive number");
+  endif
+
+  if (! isscalar (nbits) || isempty (find (nbits == [8, 16, 24, 32])))
+    error ("wavwrite: bit depth NBITS must be 8, 16, 24, or 32");
+  endif
+
+  audiowrite (filename, y, fs, "BitsPerSample", nbits);
+
+endfunction
+
+
+%!shared fname
+%! fname = [tempname() ".wav"];
+
+%!testif HAVE_SNDFILE
+%! A = [-1:0.1:1; -1:0.1:1]';
+%! unwind_protect
+%!   wavwrite (A, fname);
+%!   [B, samples_per_sec, bits_per_sample] = wavread (fname);
+%!   assert (B, A, 2^-14);
+%!   assert (samples_per_sec, 8000);
+%!   assert (bits_per_sample, 16);
+%! unwind_protect_cleanup
+%!   unlink (fname);
+%! end_unwind_protect
+
+%!testif HAVE_SNDFILE
+%! A = [-1:0.1:1; -1:0.1:1]';
+%! unwind_protect
+%!   wavwrite (A, 4000, fname);
+%!   [B, samples_per_sec, bits_per_sample] = wavread (fname);
+%!   assert (B, A, 2^-14);
+%!   assert (samples_per_sec, 4000);
+%!   assert (bits_per_sample, 16);
+%! unwind_protect_cleanup
+%!   unlink (fname);
+%! end_unwind_protect
+
+%!testif HAVE_SNDFILE
+%! A = [-1:0.1:1; -1:0.1:1]';
+%! unwind_protect
+%!   wavwrite (A, 4000, 8, fname);
+%!   [B, samples_per_sec, bits_per_sample] = wavread (fname);
+%!   assert (B, A, 2^-6);
+%!   assert (samples_per_sec, 4000);
+%!   assert (bits_per_sample, 8);
+%! unwind_protect_cleanup
+%!   unlink (fname);
+%! end_unwind_protect
+
+%!testif HAVE_SNDFILE
+%! A = [-2:2]';
+%! unwind_protect
+%!   wavwrite (A, fname);
+%!   B = wavread (fname);
+%!   B *= 32768;
+%!   assert (B, [-32767 -32767 0 32767 32767]');
+%! unwind_protect_cleanup
+%!   unlink (fname);
+%! end_unwind_protect
+
+%!testif HAVE_SNDFILE
+%! A = [-1:0.1:1];
+%! unwind_protect
+%!   wavwrite (A, fname);
+%!   [B, samples_per_sec, bits_per_sample] = wavread (fname);
+%!   assert (B, A', 2^-14);
+%!   assert (samples_per_sec, 8000);
+%!   assert (bits_per_sample, 16);
+%! unwind_protect_cleanup
+%!   unlink (fname);
+%! end_unwind_protect
+
+%!testif HAVE_SNDFILE
+%! A = [-1:0.1:1; -1:0.1:1]';
+%! unwind_protect
+%!   wavwrite (A, fname);
+%!   B = wavread (fname, 15);
+%!   assert (B, A(1:15,:), 2^-14);
+%!   wavwrite (A, fname);
+%!   B = wavread (fname, [10, 20]);
+%!   assert (B, A(10:20,:), 2^-14);
+%! unwind_protect_cleanup
+%!   unlink (fname);
+%! end_unwind_protect
+
+%!testif HAVE_SNDFILE
+%! A = [-1:0.1:1; -1:0.1:1]';
+%! unwind_protect
+%!   wavwrite (A, fname);
+%!   [nsamp, nchan] = wavread (fname, "size");
+%!   assert (nsamp, 21);
+%!   assert (nchan, 2);
+%! unwind_protect_cleanup
+%!   unlink (fname);
+%! end_unwind_protect
+
+## Test input validation
+%!error wavwrite ()
+%!error wavwrite (1)
+%!error wavwrite (1,2,3,4,5)
+%!error wavwrite ([], "foo.wav");
+
--- a/scripts/elfun/cosd.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/elfun/cosd.m	Thu Dec 10 12:50:06 2015 -0800
@@ -34,7 +34,7 @@
 
   I = x / 180;
   y = cos (I .* pi);
-  I = I + 0.5;
+  I += 0.5;
   y(I == fix (I) & isfinite (I)) = 0;
 
 endfunction
--- a/scripts/elfun/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/elfun/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,34 +1,38 @@
-FCN_FILE_DIRS += elfun
+FCN_FILE_DIRS += scripts/elfun
 
-elfun_FCN_FILES = \
-  elfun/acosd.m \
-  elfun/acot.m \
-  elfun/acotd.m \
-  elfun/acoth.m \
-  elfun/acsc.m \
-  elfun/acscd.m \
-  elfun/acsch.m \
-  elfun/asec.m \
-  elfun/asecd.m \
-  elfun/asech.m \
-  elfun/asind.m \
-  elfun/atan2d.m \
-  elfun/atand.m \
-  elfun/cosd.m \
-  elfun/cot.m \
-  elfun/cotd.m \
-  elfun/coth.m \
-  elfun/csc.m \
-  elfun/cscd.m \
-  elfun/csch.m \
-  elfun/sec.m \
-  elfun/secd.m \
-  elfun/sech.m \
-  elfun/sind.m \
-  elfun/tand.m
+scripts_elfun_FCN_FILES = \
+  scripts/elfun/acosd.m \
+  scripts/elfun/acot.m \
+  scripts/elfun/acotd.m \
+  scripts/elfun/acoth.m \
+  scripts/elfun/acsc.m \
+  scripts/elfun/acscd.m \
+  scripts/elfun/acsch.m \
+  scripts/elfun/asec.m \
+  scripts/elfun/asecd.m \
+  scripts/elfun/asech.m \
+  scripts/elfun/asind.m \
+  scripts/elfun/atan2d.m \
+  scripts/elfun/atand.m \
+  scripts/elfun/cosd.m \
+  scripts/elfun/cot.m \
+  scripts/elfun/cotd.m \
+  scripts/elfun/coth.m \
+  scripts/elfun/csc.m \
+  scripts/elfun/cscd.m \
+  scripts/elfun/csch.m \
+  scripts/elfun/sec.m \
+  scripts/elfun/secd.m \
+  scripts/elfun/sech.m \
+  scripts/elfun/sind.m \
+  scripts/elfun/tand.m
 
-FCN_FILES += $(elfun_FCN_FILES)
+scripts_elfundir = $(fcnfiledir)/elfun
+
+scripts_elfun_DATA = $(scripts_elfun_FCN_FILES)
 
-PKG_ADD_FILES += elfun/PKG_ADD
+FCN_FILES += $(scripts_elfun_FCN_FILES)
 
-DIRSTAMP_FILES += elfun/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/elfun/PKG_ADD
+
+DIRSTAMP_FILES += scripts/elfun/$(octave_dirstamp)
--- a/scripts/general/bitcmp.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/bitcmp.m	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 ## @deftypefn {Function File} {} bitcmp (@var{A}, @var{k})
 ## Return the @var{k}-bit complement of integers in @var{A}.
 ##
-## If @var{k} is omitted @code{k = log2 (bitmax) + 1} is assumed.
+## If @var{k} is omitted @code{k = log2 (flintmax) + 1} is assumed.
 ##
 ## @example
 ## @group
@@ -33,7 +33,7 @@
 ## @end group
 ## @end example
 ##
-## @seealso{bitand, bitor, bitxor, bitset, bitget, bitcmp, bitshift, bitmax}
+## @seealso{bitand, bitor, bitxor, bitset, bitget, bitcmp, bitshift, flintmax}
 ## @end deftypefn
 
 ## Liberally based on the version by Kai Habel from octave-forge
@@ -49,10 +49,10 @@
   endif
 
   if (isa (A, "double"))
-    bmax = bitmax;
+    bmax = flintmax - 1;
     amax = ceil (log2 (bmax));
   elseif (isa (A, "single"))
-    bmax = bitmax ("single");
+    bmax = flintmax ("single") - 1;
     amax = ceil (log2 (bmax));
   elseif (isinteger (A))
     amax = sizeof (ones (1, class (A))) * 8;
@@ -76,14 +76,14 @@
 
 %!test
 %! Amax = 53;
-%! Bmax = bitmax;
+%! Bmax = flintmax - 1;
 %! 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 = 24;
-%! Bmax = bitmax ("single");
+%! Bmax = flintmax ("single") - 1;
 %! A = bitshift (Bmax,-2);
 %! assert (bitcmp (A,Amax),bitor (bitshift (single (1),Amax-1), bitshift (single (1),Amax-2)));
 %! assert (bitcmp (A,Amax-1), bitshift (single (1),Amax-2));
--- a/scripts/general/bitget.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/bitget.m	Thu Dec 10 12:50:06 2015 -0800
@@ -28,7 +28,7 @@
 ## @result{} 0  1  1  0  0  1  0  0
 ## @end group
 ## @end example
-## @seealso{bitand, bitor, bitxor, bitset, bitcmp, bitshift, bitmax}
+## @seealso{bitand, bitor, bitxor, bitset, bitcmp, bitshift, intmax, flintmax}
 ## @end deftypefn
 
 ## Liberally based of the version by Kai Habel from octave-forge
@@ -40,10 +40,10 @@
   endif
 
   if (isa (A, "double"))
-    Amax = ceil (log2 (bitmax));
+    Amax = ceil (log2 (flintmax));
     _conv = @double;
   elseif (isa (A, "single"))
-    Amax = ceil (log2 (bitmax ("single")));
+    Amax = ceil (log2 (flintmax ("single")));
     _conv = @single;
   else
     if (isa (A, "uint8"))
--- a/scripts/general/bitset.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/bitset.m	Thu Dec 10 12:50:06 2015 -0800
@@ -32,7 +32,7 @@
 ##   @result{} 1011
 ## @end group
 ## @end example
-## @seealso{bitand, bitor, bitxor, bitget, bitcmp, bitshift, bitmax}
+## @seealso{bitand, bitor, bitxor, bitget, bitcmp, bitshift, intmax, flintmax}
 ## @end deftypefn
 
 function C = bitset (A, n, val)
@@ -54,7 +54,7 @@
   cl = class (A);
 
   if (isfloat (A) && isreal (A))
-    Bmax = bitmax (cl);
+    Bmax = flintmax (cl);
     Amax = ceil (log2 (Bmax));
   elseif (isinteger (A))
     Bmax = intmax (cl);
--- a/scripts/general/cell2mat.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/cell2mat.m	Thu Dec 10 12:50:06 2015 -0800
@@ -114,10 +114,22 @@
 %! m = {1, 2, 3};
 %! assert (cell2mat (mat2cell (m, 1, [1 1 1])), m);
 
+## cell2mat from cell into another cell
+%!assert (cell2mat ({{"foo", "bar", "qux"}}), {"foo", "bar", "qux"})
+%!assert (cell2mat ({{"foo"}, {"bar", "qux"}}), {"foo", "bar", "qux"})
+%!assert (cell2mat ({{"foo"}; {"bar"; "qux"}}), {"foo"; "bar"; "qux"})
+%!assert (cell2mat ({{"foo", "lol"}; {"bar", "qux"}}),
+%!        {"foo", "lol"; "bar", "qux"})
+
+## cell2mat cell strings
+%!assert (cell2mat ({"foo", "lol"; "bar", "qux"}),
+%!        reshape ("fboaorlqoulx", [2 6]))
+
 %!error cell2mat ()
 %!error cell2mat (1,2)
 %!error <C must be a cell array> cell2mat ([1,2])
 %!error <mixed cells, structs, and matrices> cell2mat ({[1], struct()})
 %!error <mixed cells, structs, and matrices> cell2mat ({[1], {1}})
 %!error <mixed cells, structs, and matrices> cell2mat ({struct(), {1}})
-
+%!error <dimension mismatch> cell2mat ({{"foo"}; {"bar", "qux"}})
+%!error <dimension mismatch> cell2mat ({"foox", "lol"; "bar", "qux"})
--- a/scripts/general/circshift.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/circshift.m	Thu Dec 10 12:50:06 2015 -0800
@@ -17,14 +17,20 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {@var{y} =} circshift (@var{x}, @var{n})
+## @deftypefn  {Function File} {@var{y} =} circshift (@var{x}, @var{n})
+## @deftypefnx {Function File} {@var{y} =} circshift (@var{x}, @var{n}, @var{dim})
 ## Circularly shift the values of the array @var{x}.
 ##
-## @var{n} must be a vector of integers no longer than the number of
-## dimensions in @var{x}.  The values of @var{n} can be either positive or
-## negative, which determines the direction in which the values or @var{x}
-## are shifted.  If an element of @var{n} is zero, then the corresponding
-## dimension of @var{x} will not be shifted.  For example:
+## @var{n} must be a vector of integers no longer than the number of dimensions
+## in @var{x}.  The values of @var{n} can be either positive or negative, which
+## determines the direction in which the values of @var{x} are shifted.  If an
+## element of @var{n} is zero, then the corresponding dimension of @var{x} will
+## not be shifted.
+##
+## If a scalar @var{dim} is given then operate along the specified dimension.
+## In this case @var{n} must be a scalar as well.
+##
+## Examples:
 ##
 ## @example
 ## @group
@@ -46,9 +52,9 @@
 ## @seealso{permute, ipermute, shiftdim}
 ## @end deftypefn
 
-function y = circshift (x, n)
+function y = circshift (x, n, dim)
 
-  if (nargin != 2)
+  if (nargin < 2 || nargin > 3)
     print_usage ();
   endif
 
@@ -57,11 +63,18 @@
     return;
   endif
 
+  if (nargin == 3)
+    if (! isscalar (n))
+      error ("circshift: N must be a scalar when DIM is also specified");
+    endif
+    n = [zeros(1, dim-1), n];
+  endif
+
   nd = ndims (x);
   sz = size (x);
 
   if (! isvector (n) || length (n) > nd)
-    error ("circshift: N must be a vector, no longer than the number of dimension in X");
+    error ("circshift: N must be a vector, no longer than the number of dimensions in X");
   elseif (any (n != fix (n)))
     error ("circshift: all values of N must be integers");
   endif
@@ -95,11 +108,15 @@
 %!assert (circshift (eye (3), 1), circshift (eye (3), 1))
 %!assert (circshift (eye (3), 1), [0,0,1;1,0,0;0,1,0])
 
+%!assert (circshift (x, -2, 1), [7, 8, 9; 1, 2, 3; 4, 5, 6])
+%!assert (circshift (x, 1, 2), [3, 1, 2; 6, 4, 5; 9, 7, 8])
+
 ## Test input validation
 %!error circshift ()
 %!error circshift (1)
 %!error circshift (1,2,3)
-%!error circshift (1, ones (2,2))
-%!error circshift (1, [1 2 3])
-%!error circshift (1, 1.5)
+%!error <N must be a scalar> circshift (1, [2 3], 4)
+%!error <N must be a vector> circshift (1, ones (2,2))
+%!error <no longer than the number of dimensions in X> circshift (1, [1 2 3])
+%!error <all values of N must be integers> circshift (1, 1.5)
 
--- a/scripts/general/cplxpair.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/cplxpair.m	Thu Dec 10 12:50:06 2015 -0800
@@ -20,15 +20,17 @@
 ## @deftypefn  {Function File} {} cplxpair (@var{z})
 ## @deftypefnx {Function File} {} cplxpair (@var{z}, @var{tol})
 ## @deftypefnx {Function File} {} cplxpair (@var{z}, @var{tol}, @var{dim})
-## Sort the numbers @var{z} into complex conjugate pairs ordered by
-## increasing real part.
+## Sort the numbers @var{z} into complex conjugate pairs ordered by increasing
+## real part.
 ##
 ## The negative imaginary complex numbers are placed first within each pair.
 ## All real numbers (those with
 ## @code{abs (imag (@var{z}) / @var{z}) < @var{tol}}) are placed after the
 ## complex pairs.
 ##
-## If @var{tol} is unspecified the default value is 100*@code{eps}.
+## @var{tol} is a weighting factor which determines the tolerance of matching.
+## The default value is 100 and the resulting tolerance for a given complex
+## pair is @code{100 * eps (abs (@var{z}(i))}.
 ##
 ## By default the complex pairs are sorted along the first non-singleton
 ## dimension of @var{z}.  If @var{dim} is specified, then the complex pairs are
@@ -46,7 +48,7 @@
 ## @end deftypefn
 
 ## FIXME: subsort returned pairs by imaginary magnitude
-## FIXME: Why doesn't exp (2i*pi*[0:4]'/5) produce exact conjugates.  Does
+## 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.
 
@@ -58,39 +60,30 @@
     print_usage ();
   endif
 
-  if (length (z) == 0)
+  if (isempty (z))
     y = zeros (size (z));
     return;
   endif
 
   if (nargin < 2 || isempty (tol))
-    if (isa (z, "single"))
-      tol = 100 * eps("single");
-    else
-      tol = 100*eps;
-    endif
+    tol = 100;
+  elseif (! isscalar (tol) || tol < 0)
+    error ("cplxpair: TOL must be a positive scalar number")
   endif
 
   nd = ndims (z);
-  orig_dims = size (z);
   if (nargin < 3)
     ## Find the first singleton dimension.
-    dim = 0;
-    while (dim < nd && orig_dims(dim+1) == 1)
-      dim++;
-    endwhile
-    dim++;
-    if (dim > nd)
-      dim = 1;
-    endif
+    sz = size (z);
+    (dim = find (sz > 1, 1)) || (dim = 1);
   else
     dim = floor (dim);
     if (dim < 1 || dim > nd)
-      error ("cplxpair: invalid dimension along which to sort");
+      error ("cplxpair: invalid dimension DIM");
     endif
   endif
 
-  ## Move dimension to treat first, and convert to a 2-D matrix.
+  ## Move dimension to treat to first position, and convert to a 2-D matrix.
   perm = [dim:nd, 1:dim-1];
   z = permute (z, perm);
   sz = size (z);
@@ -103,20 +96,17 @@
   z = z(idx + n * ones (n, 1) * [0:m-1]);
 
   ## Put the purely real values at the end of the returned list.
-  cls = "double";
-  if (isa (z, "single"))
-    cls = "single";
-  endif
-  [idxi, idxj] = find (abs (imag (z)) ./ (abs (z) + realmin (cls)) < tol);
+  cls = ifelse (isa (z, "single"), "single", "double");
+  [idxi, idxj] = find (abs (imag (z)) ./ (abs (z) + realmin (cls)) ...
+                       < tol*eps (abs (z)));
   q = sparse (idxi, idxj, 1, n, m);
   nr = sum (q, 1);
   [q, idx] = sort (q, 1);
   z = z(idx);
   y = z;
 
-  ## For each remaining z, place the value and its conjugate at the
-  ## start of the returned list, and remove them from further
-  ## consideration.
+  ## For each remaining z, place the value and its conjugate at the start of
+  ## the returned list, and remove them from further consideration.
   for j = 1:m
     p = n - nr(j);
     for i = 1:2:p
@@ -124,7 +114,7 @@
         error ("cplxpair: could not pair all complex numbers");
       endif
       [v, idx] = min (abs (z(i+1:p) - conj (z(i))));
-      if (v > tol)
+      if (v > tol*eps (abs (z(i))))
         error ("cplxpair: could not pair all complex numbers");
       endif
       if (imag (z(i)) < 0)
@@ -159,10 +149,21 @@
 %!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.'])
+%!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.'])
+
+## Test tolerance
+%!assert (cplxpair ([2000 * (1+eps) + 4j; 2000 * (1-eps) - 4j]), ...
+%!        [(2000 - 4j); (2000 + 4j)], 100*eps(200))
+%!error <could not pair> cplxpair ([2000 * (1+eps) + 4j; 2000 * (1-eps) - 4j], 0);
 
-## tolerance test
-%!assert (cplxpair ([1i, -1i, 1+(1i*eps)],2*eps), [-1i, 1i, 1+(1i*eps)])
+%!error <could not pair> cplxpair ([2e6 + j; 2e6 - j; 1e-9 * (1 + j); 1e-9 * (1 - 2j)]);
 
+## Test input validation
+%!error cplxpair ()
+%!error cplxpair (1,2,3,4)
+%!error <TOL must be .* positive> cplxpair (1, -1)
+%!error <TOL must be .* scalar number> cplxpair (1, ones (2,2))
+%!error <invalid dimension DIM> cplxpair (1, [], 3)
+
--- a/scripts/general/cumtrapz.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/cumtrapz.m	Thu Dec 10 12:50:06 2015 -0800
@@ -100,7 +100,7 @@
       shape = ones (nd, 1);
       shape(dim) = sz(dim);
       x = reshape (x, shape);
-      z = 0.5 * cumsum (bsxfun (@times, diff (x), y(idx1{:}) + y(idx2{:})), dim);
+      z = 0.5 * cumsum (diff (x) .* (y(idx1{:}) + y(idx2{:})), dim);
     else
       if (! size_equal (x, y))
         error ("cumtrapz: X and Y must have same shape");
--- a/scripts/general/curl.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/curl.m	Thu Dec 10 12:50:06 2015 -0800
@@ -78,7 +78,7 @@
     if (! size_equal (varargin{fidx}, varargin{fidx + 1}))
       error ("curl: size of X and Y must match");
     elseif (ndims (varargin{fidx}) != 2)
-      error ("curl: expected two-dimensional matrices X and Y");
+      error ("curl: X and Y must be 2-D matrices");
     elseif ((length (dx) != columns (varargin{fidx}))
          || (length (dy) != rows (varargin{fidx})))
       error ("curl: size of dx and dy must match the respective dimension of X and Y");
@@ -99,7 +99,7 @@
     if (! size_equal (varargin{fidx}, varargin{fidx + 1}, varargin{fidx + 2}))
       error ("curl: size of X, Y, and Z must match");
     elseif (ndims (varargin{fidx}) != 3)
-      error ("curl: expected two-dimensional matrices X, Y, and Z");
+      error ("curl: X, Y, and Z must be 2-D matrices");
     elseif ((length (dx) != size (varargin{fidx}, 2))
          || (length (dy) != size (varargin{fidx}, 1))
          || (length (dz) != size (varargin{fidx}, 3)))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/general/deg2rad.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,67 @@
+## Copyright (C) 2015 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{rad} =} deg2rad (@var{deg})
+##
+## Convert degrees to radians.
+##
+## The input @var{deg} must be a scalar, vector, or N-dimensional array of
+## double or single floating point values.  @var{deg} may be complex in which
+## case the real and imaginary components are converted separately.
+##
+## The output @var{rad} is the same size and shape as @var{deg} with degrees
+## converted to radians using the conversion constant @code{pi/180}.
+##
+## Example:
+##
+## @example
+## @group
+## deg2rad ([0, 90, 180, 270, 360])
+##   @result{}  0.00000   1.57080   3.14159   4.71239   6.28319
+## @end group
+## @end example
+## @seealso{rad2deg}
+## @end deftypefn
+
+function rad = deg2rad (deg)
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  if (! isfloat (deg))
+    error ("deg2rad: DEG must be a floating point class (double or single)");
+  endif
+
+  rad = deg * (pi / 180);
+
+endfunction
+
+
+%!assert (deg2rad (0), 0)
+%!assert (deg2rad (90), pi/2)
+%!assert (deg2rad (180), pi)
+%!assert (deg2rad ([0, 90, 180, 270, 360]), pi*[0, 1/2, 1, 3/2, 2])
+
+## Test input validation
+%!error deg2rad ()
+%!error deg2rad (1, 2)
+%!error <DEG must be a floating point class> deg2rad (uint8 (1))
+%!error <DEG must be a floating point class> deg2rad ("A")
+
--- a/scripts/general/del2.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/del2.m	Thu Dec 10 12:50:06 2015 -0800
@@ -156,7 +156,7 @@
     endif
   endfor
 
-  D = D ./ nd;
+  D ./= nd;
 endfunction
 
 
--- a/scripts/general/divergence.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/divergence.m	Thu Dec 10 12:50:06 2015 -0800
@@ -77,7 +77,7 @@
     if (! size_equal (varargin{fidx},varargin{fidx + 1}))
       error ("divergence: size of X and Y must match");
     elseif (ndims (varargin{fidx}) != 2)
-      error ("divergence: expected two-dimensional matrices X and Y");
+      error ("divergence: X and Y must be 2-D matrices");
     elseif (length (dx) != columns (varargin{fidx})
             || length (dy) != rows (varargin{fidx}))
       error ("divergence: size of dx and dy must match the respective dimension of X and Y");
@@ -90,7 +90,7 @@
     if (! size_equal (varargin{fidx},varargin{fidx + 1},varargin{fidx + 2}))
       error ("divergence: size of X, Y, and Z must match");
     elseif (ndims (varargin{fidx}) != 3)
-      error ("divergence: expected two-dimensional matrices X, Y, and Z");
+      error ("divergence: X, Y, and Z must be 2-D matrices");
     elseif ((length (dx) != size (varargin{fidx}, 2))
          || (length (dy) != size (varargin{fidx}, 1))
          || (length (dz) != size (varargin{fidx}, 3)))
--- a/scripts/general/inputParser.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/inputParser.m	Thu Dec 10 12:50:06 2015 -0800
@@ -261,7 +261,7 @@
     ## structs with the fields "name", "def" (default), and "val" (validator).
     Required   = cell ();
     Optional   = cell ();
-    ## ParamValue and Swicth are unordered so we have a struct whose fieldnames
+    ## ParamValue and Switch are unordered so we have a struct whose fieldnames
     ## are the argname, and values are a struct with fields "def" and "val"
     ParamValue = struct ();
     Switch     = struct ();
@@ -303,7 +303,6 @@
                 "after ParamValue or Switch"]);
       endif
       this.validate_name ("Optional", name);
-      this.validate_default ("Optional", name, def, val);
       this.Optional{end+1} = struct ("name", name, "def", def, "val", val);
     endfunction
 
@@ -312,7 +311,6 @@
         print_usage ();
       endif
       this.validate_name ("ParamValue", name);
-      this.validate_default ("ParamValue", name, def, val);
       this.ParamValue.(name).def = def;
       this.ParamValue.(name).val = val;
     endfunction
@@ -330,7 +328,7 @@
         if (this.FunctionName)
           print_usage (this.FunctionName);
         else
-          this.error ("not enough input arguments");
+          this.error ("inputParser.parse: not enough input arguments");
         endif
       endif
       pnargin = numel (varargin);
@@ -359,8 +357,8 @@
           ##    2) it's a ParamValue or Switch name and we should use the
           ##       the default for the rest.
           if (ischar (in))
-            idx--;
-            vidx--;
+            idx -= 1;
+            vidx -= 1;
             break
           else
             this.error (sprintf ("failed validation of %s",
@@ -435,13 +433,6 @@
       this.Parameters{end+1} = name;
     endfunction
 
-    function validate_default (this, type, name, def, val)
-      if (! feval (val, def))
-        error ("inputParser.add%s: failed validation for '%s' default value",
-               type, name);
-      endif
-    endfunction
-
     function validate_arg (this, name, val, in)
         if (! val (in))
           this.error (sprintf ("failed validation of %s", toupper (name)));
@@ -582,6 +573,19 @@
 %! assert ({r.req1, r.op1, r.op2, r.verbose, r.line},
 %!         {"file", "foo", 80,    true,      "circle"});
 
+## We must not perform validation of default values (bug #45837)
+%!test
+%! p = inputParser;
+%! p.addParamValue ("Dir", [], @ischar);
+%! p.parse ();
+%! assert (p.Results.Dir, [])
+
+%!test
+%! p = inputParser;
+%! p.addParamValue ("positive", -1, @(x) x > 5);
+%! p.parse ();
+%! assert (p.Results.positive, -1)
+
 ## FIXME: This somehow works in Matlab
 #%!test
 #%! p = inputParser;
--- a/scripts/general/int2str.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/int2str.m	Thu Dec 10 12:50:06 2015 -0800
@@ -105,7 +105,7 @@
       tfw = floor (log10 (double (abs (t)))) + 1 + sep;
       fw = max (tfw);
       if (any (t(tfw == fw) < 0))
-        fw++;
+        fw += 1;
       endif
       fmt = sprintf ("%%%dd", max (fw, min_fw));
     endif
--- a/scripts/general/interp1.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/interp1.m	Thu Dec 10 12:50:06 2015 -0800
@@ -793,5 +793,5 @@
 %!error <discontinuities not supported> interp1 ([1 1],[1 2],1, "pchip")
 %!error <discontinuities not supported> interp1 ([1 1],[1 2],1, "cubic")
 %!error <discontinuities not supported> interp1 ([1 1],[1 2],1, "spline")
-%!error <invalid method 'bogus'> interp1 (1:2,1:2,1, "bogus")
+%!error <invalid method 'invalid'> interp1 (1:2,1:2,1, "invalid")
 
--- a/scripts/general/interp2.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/interp2.m	Thu Dec 10 12:50:06 2015 -0800
@@ -98,7 +98,7 @@
     nargs -= 2;
   elseif (ischar (varargin{end}))
     method = varargin{end};
-    nargs--;
+    nargs -= 1;
   endif
   if (method(1) == "*")
     warning ("interp2: ignoring unsupported '*' flag to METHOD");
--- a/scripts/general/interp3.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/interp3.m	Thu Dec 10 12:50:06 2015 -0800
@@ -101,7 +101,7 @@
     nargs -= 2;
   elseif (ischar (varargin{end}))
     method = varargin{end};
-    nargs--;
+    nargs -= 1;
   endif
 
   if (method(1) == "*")
--- a/scripts/general/interpn.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/interpn.m	Thu Dec 10 12:50:06 2015 -0800
@@ -91,7 +91,7 @@
     nargs -= 2;
   elseif (ischar (varargin{end}))
     method = varargin{end};
-    nargs--;
+    nargs -= 1;
   endif
 
   if (method(1) == "*")
--- a/scripts/general/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,87 +1,100 @@
-FCN_FILE_DIRS += general
+FCN_FILE_DIRS += \
+  scripts/general \
+  scripts/general/private
 
-general_PRIVATE_FCN_FILES = \
-  general/private/__isequal__.m \
-  general/private/__splinen__.m
+scripts_general_PRIVATE_FCN_FILES = \
+  scripts/general/private/__isequal__.m \
+  scripts/general/private/__splinen__.m
 
-general_FCN_FILES = \
-  general/accumarray.m \
-  general/accumdim.m \
-  general/bincoeff.m \
-  general/bitcmp.m \
-  general/bitget.m \
-  general/bitset.m \
-  general/blkdiag.m \
-  general/cart2pol.m \
-  general/cart2sph.m \
-  general/cell2mat.m \
-  general/celldisp.m \
-  general/chop.m \
-  general/circshift.m \
-  general/common_size.m \
-  general/cplxpair.m \
-  general/cumtrapz.m \
-  general/curl.m \
-  general/dblquad.m \
-  general/deal.m \
-  general/del2.m \
-  general/display.m \
-  general/divergence.m \
-  general/fieldnames.m \
-  general/flip.m \
-  general/flipdim.m \
-  general/fliplr.m \
-  general/flipud.m \
-  general/gradient.m \
-  general/idivide.m \
-  general/inputParser.m \
-  general/int2str.m \
-  general/interp1.m \
-  general/interp2.m \
-  general/interp3.m \
-  general/interpft.m \
-  general/interpn.m \
-  general/isdir.m \
-  general/isequal.m \
-  general/isequaln.m \
-  general/loadobj.m \
-  general/logspace.m \
-  general/methods.m \
-  general/nargchk.m \
-  general/narginchk.m \
-  general/nargoutchk.m \
-  general/nextpow2.m \
-  general/nthargout.m \
-  general/num2str.m \
-  general/pol2cart.m \
-  general/polyarea.m \
-  general/postpad.m \
-  general/prepad.m \
-  general/profexplore.m \
-  general/profile.m \
-  general/profshow.m \
-  general/quadgk.m \
-  general/quadl.m \
-  general/quadv.m \
-  general/randi.m \
-  general/rat.m \
-  general/repmat.m \
-  general/rot90.m \
-  general/rotdim.m \
-  general/saveobj.m \
-  general/shift.m \
-  general/shiftdim.m \
-  general/sortrows.m \
-  general/sph2cart.m \
-  general/structfun.m \
-  general/subsindex.m \
-  general/trapz.m \
-  general/triplequad.m \
-  general/validateattributes.m \
-  $(general_PRIVATE_FCN_FILES)
+scripts_general_FCN_FILES = \
+  scripts/general/accumarray.m \
+  scripts/general/accumdim.m \
+  scripts/general/bincoeff.m \
+  scripts/general/bitcmp.m \
+  scripts/general/bitget.m \
+  scripts/general/bitset.m \
+  scripts/general/blkdiag.m \
+  scripts/general/cart2pol.m \
+  scripts/general/cart2sph.m \
+  scripts/general/cell2mat.m \
+  scripts/general/celldisp.m \
+  scripts/general/chop.m \
+  scripts/general/circshift.m \
+  scripts/general/common_size.m \
+  scripts/general/cplxpair.m \
+  scripts/general/cumtrapz.m \
+  scripts/general/curl.m \
+  scripts/general/dblquad.m \
+  scripts/general/deal.m \
+  scripts/general/deg2rad.m \
+  scripts/general/del2.m \
+  scripts/general/display.m \
+  scripts/general/divergence.m \
+  scripts/general/fieldnames.m \
+  scripts/general/flip.m \
+  scripts/general/flipdim.m \
+  scripts/general/fliplr.m \
+  scripts/general/flipud.m \
+  scripts/general/gradient.m \
+  scripts/general/idivide.m \
+  scripts/general/inputParser.m \
+  scripts/general/int2str.m \
+  scripts/general/interp1.m \
+  scripts/general/interp2.m \
+  scripts/general/interp3.m \
+  scripts/general/interpft.m \
+  scripts/general/interpn.m \
+  scripts/general/isdir.m \
+  scripts/general/isequal.m \
+  scripts/general/isequaln.m \
+  scripts/general/loadobj.m \
+  scripts/general/logspace.m \
+  scripts/general/methods.m \
+  scripts/general/nargchk.m \
+  scripts/general/narginchk.m \
+  scripts/general/nargoutchk.m \
+  scripts/general/nextpow2.m \
+  scripts/general/nthargout.m \
+  scripts/general/num2str.m \
+  scripts/general/pol2cart.m \
+  scripts/general/polyarea.m \
+  scripts/general/postpad.m \
+  scripts/general/prepad.m \
+  scripts/general/profexplore.m \
+  scripts/general/profile.m \
+  scripts/general/profshow.m \
+  scripts/general/quadgk.m \
+  scripts/general/quadl.m \
+  scripts/general/quadv.m \
+  scripts/general/rad2deg.m \
+  scripts/general/randi.m \
+  scripts/general/rat.m \
+  scripts/general/repmat.m \
+  scripts/general/rot90.m \
+  scripts/general/rotdim.m \
+  scripts/general/saveobj.m \
+  scripts/general/shift.m \
+  scripts/general/shiftdim.m \
+  scripts/general/sortrows.m \
+  scripts/general/sph2cart.m \
+  scripts/general/structfun.m \
+  scripts/general/subsindex.m \
+  scripts/general/trapz.m \
+  scripts/general/triplequad.m \
+  scripts/general/validateattributes.m
 
-FCN_FILES += $(general_FCN_FILES)
+scripts_generaldir = $(fcnfiledir)/general
+
+scripts_general_DATA = $(scripts_general_FCN_FILES)
+
+scripts_general_privatedir = $(fcnfiledir)/general/private
+
+scripts_general_private_DATA = $(scripts_general_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += general/PKG_ADD
+FCN_FILES += \
+  $(scripts_general_FCN_FILES) \
+  $(scripts_general_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += general/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/general/PKG_ADD
+
+DIRSTAMP_FILES += scripts/general/$(octave_dirstamp)
--- a/scripts/general/narginchk.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/narginchk.m	Thu Dec 10 12:50:06 2015 -0800
@@ -39,19 +39,19 @@
   if (nargin != 2)
     print_usage;
   elseif (! isnumeric (minargs) || ! isscalar (minargs))
-    error ("minargs must be a numeric scalar");
+    error ("narginchk: minargs must be a numeric scalar");
   elseif (! isnumeric (maxargs) || ! isscalar (maxargs))
-    error ("maxargs must be a numeric scalar");
+    error ("narginchk: maxargs must be a numeric scalar");
   elseif (minargs > maxargs)
-    error ("minargs cannot be larger than maxargs");
+    error ("narginchk: minargs cannot be larger than maxargs");
   endif
 
   args = evalin ("caller", "nargin;");
 
   if (args < minargs)
-    error ("not enough input arguments");
+    error ("narginchk: not enough input arguments");
   elseif (args > maxargs)
-    error ("too many input arguments");
+    error ("narginchk: too many input arguments");
   endif
 
 endfunction
--- a/scripts/general/nargoutchk.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/nargoutchk.m	Thu Dec 10 12:50:06 2015 -0800
@@ -84,19 +84,19 @@
   elseif (nargout == 0 && nargin == 2)
 
     if (! isnumeric (minargs) || ! isscalar (minargs))
-      error ("minargs must be a numeric scalar");
+      error ("nargoutchk: minargs must be a numeric scalar");
     elseif (! isnumeric (maxargs) || ! isscalar (maxargs))
-      error ("maxargs must be a numeric scalar");
+      error ("nargoutchk: maxargs must be a numeric scalar");
     elseif (minargs > maxargs)
-      error ("minargs cannot be larger than maxargs");
+      error ("nargoutchk: minargs cannot be larger than maxargs");
     endif
 
     args = evalin ("caller", "nargout;");
 
     if (args < minargs)
-      error ("Not enough output arguments.");
+      error ("nargoutchk: Not enough output arguments.");
     elseif (args > maxargs)
-      error ("Too many output arguments.");
+      error ("nargoutchk: Too many output arguments.");
     endif
 
   else
--- a/scripts/general/num2str.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/num2str.m	Thu Dec 10 12:50:06 2015 -0800
@@ -115,10 +115,15 @@
         fmt = "%3d";
       endif
     endif
-    fmt = [deblank(repmat(fmt, 1, columns(x))), "\n"];
+    fmt = do_string_escapes (fmt);  # required now that '\n' is interpreted.
     nd = ndims (x);
-    tmp = sprintf (fmt, permute (x, [2, 1, 3:nd]));
-    retval = strtrim (char (ostrsplit (tmp(1:end-1), "\n")));
+    nc = columns (x);
+    x  = permute (x, [2, 1, 3:nd]);
+    if (! (sum (fmt == "%") > 1 || any (strcmp (fmt, {"%s", "%c"}))))
+      fmt = [deblank(repmat (fmt, 1, nc)), "\n"];
+    endif
+    tmp    = sprintf (fmt, x);
+    retval = strtrim (char (ostrsplit (tmp, "\n", true)));
   else   # Complex matrix input
     if (nargin == 2)
       if (ischar (arg))
@@ -199,11 +204,17 @@
 %!assert (num2str (complex (NA, 1)), "NA+1i")
 %!assert (num2str (complex (1, NA)), "1+NAi")
 
-## FIXME: Integers greater than bitmax() should be masked to show just
+## FIXME: Integers greater than flintmax() - 1 should be masked to show just
 ##        16 digits of precision.
 %!xtest
 %! assert (num2str (1e23), "100000000000000000000000");
 
+## Test for bug #44864, extra rows generated from newlines in format
+%!assert (rows (num2str (magic (3), '%3d %3d %3d\n')), 3)
+
+## Test for bug #45174
+%!assert (num2str ([65 66 67], '%s'), "ABC")
+
 %!error num2str ()
 %!error num2str (1, 2, 3)
 %!error <X must be a numeric> num2str ({1})
--- a/scripts/general/private/__isequal__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/private/__isequal__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -99,7 +99,7 @@
       idx = 0;
       s_fn_x = sort (fn_x);
       while (t && idx < l_v)
-        idx++;
+        idx += 1;
         ## We'll allow the fieldnames to be in a different order.
         t = all (strcmp (s_fn_x, sort (fn_v{idx})));
       endwhile
@@ -107,7 +107,7 @@
       idx = 0;
       while (t && idx < l_fn_x)
         ## Test that all field values are equal.
-        idx++;
+        idx += 1;
         args = cell (1, 2+l_v);
         args(1:2) = {nans_compare_equal, {x.(fn_x{idx})}};
         for argn = 1:l_v
@@ -122,7 +122,7 @@
       l_x = numel (x);
       idx = 0;
       while (t && idx < l_x)
-        idx++;
+        idx += 1;
         args = cell (1, 2+l_v);
         args(1:2) = {nans_compare_equal, x{idx}};
         args(3:end) = [cellindexmat(varargin, idx){:}];
--- a/scripts/general/profexplore.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/profexplore.m	Thu Dec 10 12:50:06 2015 -0800
@@ -105,7 +105,7 @@
         if (rv == 0)
           return;
         elseif (rv > 1)
-          rv = rv - 1;
+          rv -= 1;
           return;
         else
           assert (rv == 1);
--- a/scripts/general/quadgk.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/quadgk.m	Thu Dec 10 12:50:06 2015 -0800
@@ -59,11 +59,11 @@
 ## @table @code
 ## @item AbsTol
 ## Define the absolute error tolerance for the quadrature.  The default
-## absolute tolerance is 1e-10.
+## absolute tolerance is 1e-10 (1e-5 for single).
 ##
 ## @item RelTol
 ## Define the relative error tolerance for the quadrature.  The default
-## relative tolerance is 1e-5.
+## relative tolerance is 1e-6 (1e-4 for single).
 ##
 ## @item MaxIntervalCount
 ## @code{quadgk} initially subdivides the interval on which to perform the
@@ -124,274 +124,294 @@
 ## @end deftypefn
 
 function [q, err] = quadgk (f, a, b, varargin)
+
   if (nargin < 3)
     print_usage ();
   endif
 
   if (b < a)
+    ## Reverse integration
     [q, err] = quadgk (f, b, a, varargin{:});
     q = -q;
-  else
-    abstol = 1e-10;
-    reltol = 1e-5;
-    waypoints = [];
-    maxint = 650;
-    trace = false;
+    return;
+  endif
+
+  abstol = [];
+  reltol = [];
+  waypoints = [];
+  maxint = 650;
+  trace = false;
 
-    if (nargin > 3)
-      if (! ischar (varargin{1}))
-        if (! isempty (varargin{1}))
-          abstol = varargin{1};
-          reltol = 0;
-        endif
-        if (nargin > 4)
-          trace = varargin{2};
-        endif
-        if (nargin > 5)
-          error ("quadgk: can not pass additional arguments to user function");
+  ## Parse options if present.
+  if (nargin > 3)
+    if (! ischar (varargin{1}))
+      if (! isempty (varargin{1}))
+        abstol = varargin{1};
+        reltol = 0;
+      endif
+      if (nargin > 4)
+        trace = varargin{2};
+      endif
+      if (nargin > 5)
+        error ("quadgk: can not pass additional arguments to user function");
+      endif
+    else
+      if (mod (nargin - 3, 2) != 0)
+        error ("quadgk: property/value options must occur in pairs");
+      endif
+
+      idx = 1;
+      while (idx < nargin - 3)
+        if (! ischar (varargin{idx}))
+          error ("quadgk: property PROP must be a string");
         endif
-      else
-        idx = 1;
-        while (idx < nargin - 3)
-          if (ischar (varargin{idx}))
-            str = varargin{idx++};
-            if (strcmpi (str, "reltol"))
-              reltol = varargin{idx++};
-            elseif (strcmpi (str, "abstol"))
-              abstol = varargin{idx++};
-            elseif (strcmpi (str, "waypoints"))
-              waypoints = varargin{idx++} (:);
-              if (isreal (waypoints))
-                waypoints(waypoints < a | waypoints > b) = [];
-              endif
-            elseif (strcmpi (str, "maxintervalcount"))
-              maxint = varargin{idx++};
-            elseif (strcmpi (str, "trace"))
-              trace = varargin{idx++};
-            else
-              error ("quadgk: unknown property '%s'", str);
+        str = varargin{idx++};
+        switch (tolower (str))
+          case "reltol"
+            reltol = varargin{idx++};
+          case "abstol"
+            abstol = varargin{idx++};
+          case "waypoints"
+            waypoints = varargin{idx++}(:);
+            if (isreal (waypoints))
+              waypoints(waypoints < a | waypoints > b) = [];
             endif
-          else
-            error ("quadgk: property PROP must be a string");
-          endif
-        endwhile
-        if (idx != nargin - 2)
-          error ("quadgk: property/value must occur in pairs");
-        endif
-      endif
+          case "maxintervalcount"
+            maxint = varargin{idx++};
+          case "trace"
+            trace = varargin{idx++};
+          otherwise
+            error ("quadgk: unknown property '%s'", str);
+        endswitch
+      endwhile
+    endif
+  endif
+
+  issingle = (isa (a, "single") || isa (b, "single")
+              || isa (waypoints, "single"));
+
+  if (isempty (abstol))
+    abstol = ifelse (issingle, 1e-5, 1e-10);
+  elseif (! isscalar (abstol) || abstol < 0)
+    error ("quadv: ABSTOL must be a scalar >=0");
+  endif
+
+  if (isempty (reltol))
+    reltol = ifelse (issingle, 1e-4, 1e-6);
+  elseif (! isscalar (reltol) || reltol < 0)
+    error ("quadv: RELTOL must be a scalar >=0");
+  endif
+
+  ## Convert function given as a string to a function handle
+  if (ischar (f))
+    f = @(x) feval (f, x);
+  endif
+
+  ## Use variable substitution to weaken endpoint singularities and
+  ## to perform integration with endpoints at infinity.
+  ## No transform for contour integrals.
+  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))
+    ## Standard infinite to finite integral transformation.
+    ##   \int_{-\infinity_^\infinity f(x) dx = \int_-1^1 f (g(t)) g'(t) dt
+    ## where
+    ##   g(t)  = t / (1 - t^2)
+    ##   g'(t) =  (1 + t^2) / (1 - t^2) ^ 2
+    ## 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));
+      subs = [-1; trans(waypoints); 1];
+    else
+      subs = linspace (-1, 1, 11)';
+    endif
+    h = 2;
+    h0 = b - a;
+    trans = @(t) t ./ (1 - t.^2);
+    f = @(t) f (t ./ (1 - t .^ 2)) .* (1 + t .^ 2) ./ ((1 - t .^ 2) .^ 2);
+  elseif (isinf (a))
+    ## 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
+    ##   \int_{-\infinity}^b f(x) dx =
+    ##               - \int_{-\infinity}^0 f (b - t^2) 2 t dt
+    ## (note minus sign) and the finite interval transform is
+    ##   \int_{-\infinity}^0 f(b - t^2)  2 t dt =
+    ##                  \int_{-1}^0 f (b - g(s) ^ 2) 2 g(s) g'(s) ds
+    ## where
+    ##   g(s)  = s / (1 + s)
+    ##   g'(s) = 1 / (1 + s) ^ 2
+    ## waypoint transform is then
+    ##   t = sqrt (b - x)
+    ##   s =  - t / (t + 1)
+    if (! isempty (waypoints))
+      tmp = sqrt (b - waypoints);
+      trans = @(x) - x ./ (x + 1);
+      subs = [-1; trans(tmp); 0];
+    else
+      subs = linspace (-1, 0, 11)';
     endif
+    h = 1;
+    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))
+    ## 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
+    ##   \int_a^\infinity f(x) dx = \int_0^\infinity f (a + t^2) 2 t dt
+    ## and the finite interval transform is
+    ##  \int_0^\infinity f(a + t^2)  2 t dt =
+    ##           \int_0^1 f (a + g(s) ^ 2) 2 g(s) g'(s) ds
+    ## where
+    ##   g(s)  = s / (1 - s)
+    ##   g'(s) = 1 / (1 - s) ^ 2
+    ## waypoint transform is then
+    ##   t = sqrt (x - a)
+    ##   s = t / (t + 1)
+    if (! isempty (waypoints))
+      tmp = sqrt (waypoints - a);
+      trans = @(x) x ./ (x + 1);
+      subs = [0; trans(tmp); 1];
+    else
+      subs = linspace (0, 1, 11)';
+    endif
+    h = 1;
+    h0 = b - a;
+    trans = @(t) a + (t ./ (1 - t)).^2;
+    f = @(s) 2 * s .* f (a +  (s ./ (1 - s)) .^ 2) ./ ((1 - s) .^ 3);
+  else
+    ## Davis, Rabinowitz, "Methods of Numerical Integration" p441 2ed.
+    ## Presented in section 5 of the Shampine paper as
+    ##   g(t) = ((b - a) / 2) * (t / 2 * (3 - t^2)) + (b + a) / 2
+    ##   g'(t) = ((b-a)/4) * (3 - 3t^2);
+    ## waypoint transform can then be found by solving for t with
+    ## Maxima (solve (c + 3*t -  3^3, t);).  This gives 3 roots, two of
+    ## which are complex for values between a and b and so can be ignored.
+    ## The third is
+    ##  c = (-4*x + 2*(b+a)) / (b-a);
+    ##  k = ((sqrt(c^2 - 4) + c)/2)^(1/3);
+    ##  t = (sqrt(3)* 1i * (1 - k^2) - (1 + k^2)) / 2 / k;
+    if (! isempty (waypoints))
+      trans = @__quadgk_finite_waypoint__;
+      subs = [-1; trans(waypoints, a, b); 1];
+    else
+      subs = linspace (-1, 1, 11)';
+    endif
+    h = 2;
+    h0 = b - a;
+    trans = @(t) ((b - a) ./ 4) * t .* (3 - t.^2) + (b + a) ./ 2;
+    f = @(t) f((b - a) ./ 4 .* t .* (3 - t.^2) + (b + a) ./ 2) .* ...
+         3 .* (b - a) ./ 4 .* (1 - t.^2);
+  endif
 
-    ## Convert function given as a string to a function handle
-    if (ischar (f))
-      f = @(x) feval (f, x);
+  ## Split interval into at least 10 subinterval with a 15 point
+  ## Gauss-Kronrod rule giving a minimum of 150 function evaluations.
+  while (length (subs) < 11)
+    subs = [subs' ; subs(1:end-1)' + diff(subs') ./ 2, NaN](:)(1 : end - 1);
+  endwhile
+  subs = [subs(1:end-1), subs(2:end)];
+
+  ## Singularity will cause divide by zero warnings.
+  ## Turn off warning locally for quadgk function only.
+  warning ("off", "Octave:divide-by-zero", "local");
+
+  warn_id = "Octave:quadgk:warning-termination";
+
+  ## Initial evaluation of the integrand on the subintervals
+  [q_subs, q_errs] = __quadgk_eval__ (f, subs);
+  q0 = sum (q_subs);
+  err0 = sum (q_errs);
+
+  if (issingle)
+    eps = eps ("single");
+  else
+    eps = eps ("double");
+  endif
+
+  first = true;
+  while (true)
+    ## Check for subintervals that are too small.
+    ## Test must be performed in untransformed subintervals.
+    ## What is a good value for this test?  Shampine suggests 100*eps.
+    if (any (abs (diff (trans (subs), [], 2) / h0) < 100 * eps))
+      q = q0;
+      err = err0;
+      break;
     endif
 
-    ## 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))
-      ## contour integral, no transform
-      subs = [a; waypoints; b];
-      h = sum (abs (diff (subs)));
-      h0 = h;
-      trans = @(t) t;
-    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
-      ##   g(t)  = t / (1 - t^2)
-      ##   g'(t) =  (1 + t^2) / (1 - t^2) ^ 2
-      ## 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));
-        subs = [-1; trans(waypoints); 1];
-      else
-        subs = linspace (-1, 1, 11)';
-      endif
-      h = 2;
-      h0 = b - a;
-      trans = @(t) t ./ (1 - t.^2);
-      f = @(t) f (t ./ (1 - t .^ 2)) .* (1 + t .^ 2) ./ ((1 - t .^ 2) .^ 2);
-    elseif (isinf (a))
-      ## 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
-      ##   \int_{-\infinity}^b f(x) dx =
-      ##               - \int_{-\infinity}^0 f (b - t^2) 2 t dt
-      ## (note minus sign) and the finite interval transform is
-      ##   \int_{-\infinity}^0 f(b - t^2)  2 t dt =
-      ##                  \int_{-1}^0 f (b - g(s) ^ 2) 2 g(s) g'(s) ds
-      ## where
-      ##   g(s)  = s / (1 + s)
-      ##   g'(s) = 1 / (1 + s) ^ 2
-      ## waypoint transform is then
-      ##   t = sqrt (b - x)
-      ##   s =  - t / (t + 1)
-      if (! isempty (waypoints))
-        tmp = sqrt (b - waypoints);
-        trans = @(x)  - x ./ (x + 1);
-        subs = [-1; trans(tmp); 0];
-      else
-        subs = linspace (-1, 0, 11)';
-      endif
-      h = 1;
-      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))
-      ## 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
-      ##   \int_a^\infinity f(x) dx = \int_0^\infinity f (a + t^2) 2 t dt
-      ## and the finite interval transform is
-      ##  \int_0^\infinity f(a + t^2)  2 t dt =
-      ##           \int_0^1 f (a + g(s) ^ 2) 2 g(s) g'(s) ds
-      ## where
-      ##   g(s)  = s / (1 - s)
-      ##   g'(s) = 1 / (1 - s) ^ 2
-      ## waypoint transform is then
-      ##   t = sqrt (x - a)
-      ##   s = t / (t + 1)
-      if (! isempty (waypoints))
-        tmp = sqrt (waypoints - a);
-        trans = @(x) x ./ (x + 1);
-        subs = [0; trans(tmp); 1];
-      else
-        subs = linspace (0, 1, 11)';
-      endif
-      h = 1;
-      h0 = b - a;
-      trans = @(t) a + (t ./ (1 - t)).^2;
-      f = @(s) 2 * s .* f (a +  (s ./ (1 - s)) .^ 2) ./ ((1 - s) .^ 3);
-    else
-      ## Davis, Rabinowitz, "Methods of Numerical Integration" p441 2ed.
-      ## Presented in section 5 of the Shampine paper as
-      ##   g(t) = ((b - a) / 2) * (t / 2 * (3 - t^2)) + (b + a) / 2
-      ##   g'(t) = ((b-a)/4) * (3 - 3t^2);
-      ## waypoint transform can then be found by solving for t with
-      ## Maxima (solve (c + 3*t -  3^3, t);). This gives 3 roots, two of
-      ## which are complex for values between a and b and so can be
-      ## ignored. The third is
-      ##  c = (-4*x + 2*(b+a)) / (b-a);
-      ##  k = ((sqrt(c^2 - 4) + c)/2)^(1/3);
-      ##  t = (sqrt(3)* 1i * (1 - k^2) - (1 + k^2)) / 2 / k;
-      if (! isempty (waypoints))
-        trans = @__quadgk_finite_waypoint__;
-        subs = [-1; trans(waypoints, a, b); 1];
-      else
-        subs = linspace (-1, 1, 11)';
-      endif
-      h = 2;
-      h0 = b - a;
-      trans = @(t) ((b - a) ./ 4) * t .* (3 - t.^2) + (b + a) ./ 2;
-      f = @(t) f((b - a) ./ 4 .* t .* (3 - t.^2) + (b + a) ./ 2) .* ...
-           3 .* (b - a) ./ 4 .* (1 - t.^2);
+    ## Quit if any evaluations are not finite (Inf or NaN).
+    if (any (! isfinite (q_subs)))
+      warning (warn_id, "quadgk: non finite integrand encountered");
+      q = q0;
+      err = err0;
+      break;
+    endif
+
+    tol = max (abstol, reltol .* abs (q0));
+
+    ## If the global error estimate is met then exit
+    if (err0 < tol)
+      q = q0;
+      err = err0;
+      break;
     endif
 
-    ## Split interval into at least 10 subinterval with a 15 point
-    ## Gauss-Kronrod rule giving a minimum of 150 function evaluations
-    while (length (subs) < 11)
-      subs = [subs' ; subs(1:end-1)' + diff(subs') ./ 2, NaN](:)(1 : end - 1);
-    endwhile
-    subs = [subs(1:end-1), subs(2:end)];
-
-    ## Singularity will cause divide by zero warnings.
-    ## Turn off warning locally for quadgk function only.
-    warning ("off", "Octave:divide-by-zero", "local");
+    ## Accept the subintervals that meet the convergence criteria.
+    idx = find (abs (q_errs) < tol .* abs (diff (subs, [], 2)) ./ h);
+    if (first)
+      q = sum (q_subs (idx));
+      err = sum (q_errs(idx));
+      first = false;
+    else
+      q0 = q + sum (q_subs);
+      err0 = err + sum (q_errs);
+      q += sum (q_subs (idx));
+      err += sum (q_errs(idx));
+    endif
+    subs(idx,:) = [];
 
-    warn_id = "Octave:quadgk:warning-termination";
+    ## If no remaining subintervals exit
+    if (rows (subs) == 0)
+      break;
+    endif
 
-    ## Initial evaluation of the integrand on the subintervals
-    [q_subs, q_errs] = __quadgk_eval__ (f, subs);
-    q0 = sum (q_subs);
-    err0 = sum (q_errs);
-
-    if (isa (a, "single") || isa (b, "single") || isa (waypoints, "single"))
-      myeps = eps ("single");
-    else
-      myeps = eps;
+    if (trace)
+      disp ([rows(subs), err, q0]);
     endif
 
-    first = true;
-    while (true)
-      ## Check for subintervals that are too small. Test must be
-      ## performed in untransformed subintervals. What is a good
-      ## value for this test. Shampine suggests 100*eps
-      if (any (abs (diff (trans (subs), [], 2) / h0) < 100 * myeps))
-        q = q0;
-        err = err0;
-        break;
-      endif
-
-      ## Quit if any evaluations are not finite (Inf or NaN)
-      if (any (! isfinite (q_subs)))
-        warning (warn_id, "quadgk: non finite integrand encountered");
-        q = q0;
-        err = err0;
-        break;
-      endif
-
-      tol = max (abstol, reltol .* abs (q0));
-
-      ## If the global error estimate is meet exit
-      if (err0 < tol)
-        q = q0;
-        err = err0;
-        break;
-      endif
+    ## Split remaining subintervals in two
+    mid = (subs(:,2) + subs(:,1)) ./ 2;
+    subs = [subs(:,1), mid; mid, subs(:,2)];
 
-      ## Accept the subintervals that meet the convergence criteria
-      idx = find (abs (q_errs) < tol .* abs (diff (subs, [], 2)) ./ h);
-      if (first)
-        q = sum (q_subs (idx));
-        err = sum (q_errs(idx));
-        first = false;
-      else
-        q0 = q + sum (q_subs);
-        err0 = err + sum (q_errs);
-        q += sum (q_subs (idx));
-        err += sum (q_errs(idx));
-      endif
-      subs(idx,:) = [];
-
-      ## If no remaining subintervals exit
-      if (rows (subs) == 0)
-        break;
-      endif
-
-      if (trace)
-        disp ([rows(subs), err, q0]);
-      endif
-
-      ## Split remaining subintervals in two
-      mid = (subs(:,2) + subs(:,1)) ./ 2;
-      subs = [subs(:,1), mid; mid, subs(:,2)];
-
-      ## If the maximum subinterval count is met accept remaining
-      ## subinterval and exit
-      if (rows (subs) > maxint)
-        warning (warn_id, "quadgk: maximum interval count (%d) met", maxint);
-        q += sum (q_subs);
-        err += sum (q_errs);
-        break;
-      endif
-
-      ## Evaluation of the integrand on the remaining subintervals
-      [q_subs, q_errs] = __quadgk_eval__ (f, subs);
-    endwhile
-
-    if (err > max (abstol, reltol * abs (q)))
-      warning (warn_id,
-               "quadgk: Error tolerance not met.  Estimated error %g", err);
+    ## If the maximum subinterval count is met accept remaining subinterval
+    ## and exit
+    if (rows (subs) > maxint)
+      warning (warn_id, "quadgk: maximum interval count (%d) exceeded", maxint);
+      q += sum (q_subs);
+      err += sum (q_errs);
+      break;
     endif
 
+    ## Evaluation of the integrand on the remaining subintervals
+    [q_subs, q_errs] = __quadgk_eval__ (f, subs);
+  endwhile
+
+  if (err > max (abstol, reltol * abs (q)))
+    warning (warn_id,
+             "quadgk: Error tolerance not met.  Estimated error %g", err);
   endif
+
 endfunction
 
 function [q, err] = __quadgk_eval__ (f, subs)
-  ## A (15,7) point pair of Gauss-Konrod quadrature rules. The abscissa
-  ## and weights are copied directly from dqk15w.f from quadpack
+  ## A (15,7) point pair of Gauss-Konrod quadrature rules.
+  ## The abscissa and weights are copied directly from dqk15w.f from quadpack.
 
   persistent abscissa = [-0.9914553711208126e+00, -0.9491079123427585e+00, ...
                          -0.8648644233597691e+00, -0.7415311855993944e+00, ...
@@ -419,13 +439,12 @@
              0.1294849661688697e+00]);
 
   halfwidth = diff (subs, [], 2) ./ 2;
-  center = sum (subs, 2) ./ 2;;
-  x = bsxfun (@plus, halfwidth * abscissa, center);
+  center = sum (subs, 2) ./ 2;
+  x = (halfwidth * abscissa) + center;
   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
-  ## function.
+  ## single BLAS call, rather than rows (sub) calls to the @times function.
   q = sum (y * weights15, 2) .* halfwidth;
   err = abs (sum (y(:,2:2:end) * weights7, 2) .* halfwidth - q);
 endfunction
@@ -453,7 +472,15 @@
 %!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"))
+## Test input validation
+%!error quadgk (@sin)
+%!error quadgk (@sin, 0)
+%!error <can not pass additional arguments> quadgk (@sin, 0, 1, 1e-6, true, 4)
+%!error <options must occur in pairs> quadgk (@sin, 0, 1, "DummyArg")
+%!error <PROP must be a string> quadgk (@sin, 0, 1, "AbsTol", 1e-6, 2, 3)
+%!error <unknown property 'foo'> quadgk (@sin, 0, 1, "foo", 3)
+%!error <ABSTOL must be a scalar> quadgk (@sin, 0, 1, ones (2,2))
+%!error <ABSTOL must be a scalar .=0> quadgk (@sin, 0, 1, -1)
+%!error <RELTOL must be a scalar> quadgk (@sin, 0, 1, "RelTol", ones (2,2))
+%!error <RELTOL must be a scalar> quadgk (@sin, 0, 1, "RelTol", -1)
 
--- a/scripts/general/quadl.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/quadl.m	Thu Dec 10 12:50:06 2015 -0800
@@ -21,6 +21,7 @@
 ## @deftypefnx {Function File} {@var{q} =} quadl (@var{f}, @var{a}, @var{b}, @var{tol})
 ## @deftypefnx {Function File} {@var{q} =} quadl (@var{f}, @var{a}, @var{b}, @var{tol}, @var{trace})
 ## @deftypefnx {Function File} {@var{q} =} quadl (@var{f}, @var{a}, @var{b}, @var{tol}, @var{trace}, @var{p1}, @var{p2}, @dots{})
+## @deftypefnx {Function File} {[@var{q}, @var{nfun}] =} quadl (@dots{})
 ##
 ## Numerically evaluate the integral of @var{f} from @var{a} to @var{b} using
 ## an adaptive Lobatto rule.
@@ -32,142 +33,99 @@
 ## @var{a} and @var{b} are the lower and upper limits of integration.  Both
 ## limits must be finite.
 ##
-## The optional argument @var{tol} defines the relative tolerance with which
-## to perform the integration.  The default value is @code{eps}.
+## The optional argument @var{tol} defines the absolute tolerance with which
+## to perform the integration.  The default value is @math{1e-6}.
 ##
 ## The algorithm used by @code{quadl} involves recursively subdividing the
 ## integration interval.  If @var{trace} is defined then for each subinterval
-## display: (1) the left end of the subinterval, (2) the length of the
-## subinterval, (3) the approximation of the integral over the subinterval.
+## display: (1) the total number of function evaluations, (2) the left end of
+## the subinterval, (3) the length of the subinterval, (4) the approximation of
+## the integral over the subinterval.
 ##
 ## Additional arguments @var{p1}, etc., are passed directly to the function
 ## @var{f}.  To use default values for @var{tol} and @var{trace}, one may pass
 ## empty matrices ([]).
 ##
+## The result of the integration is returned in @var{q}.
+##
+## The optional output @var{nfun} indicates the total number of function
+## evaluations performed.
+##
 ## Reference: @nospell{W. Gander and W. Gautschi}, @cite{Adaptive Quadrature -
 ## Revisited}, BIT Vol. 40, No. 1, March 2000, pp. 84--101.
 ## @url{http://www.inf.ethz.ch/personal/gander/}
 ## @seealso{quad, quadv, quadgk, quadcc, trapz, dblquad, triplequad}
 ## @end deftypefn
 
-##   Author: Walter Gautschi
-##   Date: 08/03/98
-##   Reference: Gander, Computermathematik, Birkhaeuser, 1992.
+## Original Author: Walter Gautschi
+## Date: 08/03/98
+## Reference: Gander, Computermathematik, Birkhaeuser, 1992.
 
 ## 2003-08-05 Shai Ayal
 ##   * permission from author to release as GPL
-## 2004-02-10 Paul Kienzle
-##   * renamed to quadl for compatibility
-##   * replace global variable terminate2 with local function need_warning
-##   * add paper ref to docs
 
-function q = quadl (f, a, b, tol = [], trace = false, varargin)
+function [q, nfun] = quadl (f, a, b, tol = [], trace = false, varargin)
 
   if (nargin < 3)
     print_usage ();
   endif
 
   if (isa (a, "single") || isa (b, "single"))
-    myeps = eps ("single");
+    eps = eps ("single");
   else
-    myeps = eps;
+    eps = eps ("double");
   endif
   if (isempty (tol))
-    tol = myeps;
+    tol = 1e-6;
+  elseif (! isscalar (tol) || tol < 0)
+    error ("quadl: TOL must be a scalar >=0");
+  elseif (tol < eps)
+    tol = eps;
   endif
   if (isempty (trace))
     trace = false;
   endif
-  if (tol < myeps)
-    tol = myeps;
-  endif
 
-  ## Track whether recursion has occurred
-  global __quadl_recurse_done__;
-  __quadl_recurse_done__ = false;
-  ## Track whether warning about machine precision has been issued
-  global __quadl_need_warning__;
-  __quadl_need_warning__ = true;
-
-  m = (a+b)/2;
-  h = (b-a)/2;
-  alpha = sqrt (2/3);
-  beta = 1/sqrt (5);
-
-  x1 = .942882415695480;
-  x2 = .641853342345781;
-  x3 = .236383199662150;
-
-  x = [a, m-x1*h, m-alpha*h, m-x2*h, m-beta*h, m-x3*h, m, m+x3*h, ...
-       m+beta*h, m+x2*h, m+alpha*h, m+x1*h, b];
-
-  y = feval (f, x, varargin{:});
+  y = feval (f, [a, b], varargin{:});
+  nfun = 1;
 
   fa = y(1);
-  fb = y(13);
-
-  i2 = (h/6)*(y(1) + y(13) + 5*(y(5)+y(9)));
+  fb = y(2);
 
-  i1 = (h/1470)*(   77*(y(1)+y(13))
-                 + 432*(y(3)+y(11))
-                 + 625*(y(5)+y(9))
-                 + 672*y(7));
+  h = b - a;
 
-  is = h*( .0158271919734802*(y(1)+y(13))
-          +.0942738402188500*(y(2)+y(12))
-          + .155071987336585*(y(3)+y(11))
-          + .188821573960182*(y(4)+y(10))
-          + .199773405226859*(y(5)+y(9))
-          + .224926465333340*(y(6)+y(8))
-          + .242611071901408*y(7));
+  [q, nfun, hmin] = adaptlobstp (f, a, b, fa, fb, Inf, nfun, abs (h),
+                                 tol, trace, varargin{:});
 
-  s = sign (is);
-  if (s == 0)
-    s = 1;
+  if (nfun > 10_000)
+    warning ("quadl: maximum iteration count reached -- possible singular integral");
+  elseif (any (! isfinite (q(:))))
+    warning ("quadl: infinite or NaN function evaluations were returned");
+  elseif (hmin < (b - a) * eps)
+    warning ("quadl: minimum step size reached -- possible singular integral");
   endif
-  erri1 = abs (i1-is);
-  erri2 = abs (i2-is);
-  if (erri2 != 0)
-    R = erri1/erri2;
-  else
-    R = 1;
-  endif
-  if (R > 0 && R < 1)
-    tol = tol/R;
-  endif
-  is = s * abs (is) * tol/myeps;
-  if (is == 0)
-    is = b-a;
-  endif
-
-  q = adaptlobstp (f, a, b, fa, fb, is, trace, varargin{:});
 
 endfunction
 
-## ADAPTLOBSTP  Recursive function used by QUADL.
-##
-##   Q = ADAPTLOBSTP('F', A, B, FA, FB, IS, TRACE) tries to
-##   approximate the integral of F(X) from A to B to
-##   an appropriate relative error.  The argument 'F' is
-##   a string containing the name of f.  The remaining
-##   arguments are generated by ADAPTLOB or by recursion.
-##
-##   Walter Gautschi, 08/03/98
+function [q, nfun, hmin] = adaptlobstp (f, a, b, fa, fb, q0, nfun, hmin,
+                                        tol, trace, varargin)
+  persistent alpha = sqrt (2/3);
+  persistent beta = 1 / sqrt (5);
 
-function q = adaptlobstp (f, a, b, fa, fb, is, trace, varargin)
-  global __quadl_recurse_done__;
-  global __quadl_need_warning__;
+  if (nfun > 10_000)
+    q = q0;
+    return;
+  endif
 
-  h = (b-a)/2;
-  m = (a+b)/2;
-  alpha = sqrt (2/3);
-  beta = 1 / sqrt (5);
-  mll = m-alpha*h;
-  ml  = m-beta*h;
-  mr  = m+beta*h;
-  mrr = m+alpha*h;
+  h = (b - a) / 2;
+  m = (a + b) / 2;
+  mll = m - alpha*h;
+  ml  = m - beta*h;
+  mr  = m + beta*h;
+  mrr = m + alpha*h;
   x = [mll, ml, m, mr, mrr];
   y = feval (f, x, varargin{:});
+  nfun += 1;
   fmll = y(1);
   fml  = y(2);
   fm   = y(3);
@@ -175,42 +133,60 @@
   fmrr = y(5);
   i2 = (h/6)*(fa + fb + 5*(fml+fmr));
   i1 = (h/1470)*(77*(fa+fb) + 432*(fmll+fmrr) + 625*(fml+fmr) + 672*fm);
-  if ((is+(i1-i2) == is || mll <= a || b <= mrr) && __quadl_recurse_done__)
-    if ((m <= a || b <= m) && __quadl_need_warning__)
-      warning ("quadl: interval contains no more machine number");
-      warning ("quadl: required tolerance may not be met");
-      __quadl_need_warning__ = false;
-    endif
+
+  if (abs (b - a) < hmin)
+    hmin = abs (b - a);
+  endif
+
+  if (trace)
+    disp ([nfun, a, b-a, i1]);
+  endif
+
+  ## Force at least one adaptive step (nfun > 2 test).
+  if ((abs (i1-i2) < tol || mll <= a || b <= mrr) && nfun > 2)
     q = i1;
-    if (trace)
-      disp ([a, b-a, q]);
-    endif
   else
-    __quadl_recurse_done__ = true;
-    q = (  adaptlobstp (f, a  , mll, fa  , fmll, is, trace, varargin{:})
-         + adaptlobstp (f, mll, ml , fmll, fml , is, trace, varargin{:})
-         + adaptlobstp (f, ml , m  , fml , fm  , is, trace, varargin{:})
-         + adaptlobstp (f, m  , mr , fm  , fmr , is, trace, varargin{:})
-         + adaptlobstp (f, mr , mrr, fmr , fmrr, is, trace, varargin{:})
-         + adaptlobstp (f, mrr, b  , fmrr, fb  , is, trace, varargin{:}));
+    q = zeros (6, 1);
+    [q(1), nfun, hmin] = adaptlobstp (f, a  , mll, fa  , fmll, q0/6, nfun, hmin,
+                                      tol, trace, varargin{:});
+    [q(2), nfun, hmin] = adaptlobstp (f, mll, ml , fmll, fml , q0/6, nfun, hmin,
+                                      tol, trace, varargin{:});
+    [q(3), nfun, hmin] = adaptlobstp (f, ml , m  , fml , fm  , q0/6, nfun, hmin,
+                                      tol, trace, varargin{:});
+    [q(4), nfun, hmin] = adaptlobstp (f, m  , mr , fm  , fmr , q0/6, nfun, hmin,
+                                      tol, trace, varargin{:});
+    [q(5), nfun, hmin] = adaptlobstp (f, mr , mrr, fmr , fmrr, q0/6, nfun, hmin,
+                                      tol, trace, varargin{:});
+    [q(6), nfun, hmin] = adaptlobstp (f, mrr, b  , fmrr, fb  , q0/6, nfun, hmin,
+                                      tol, trace, varargin{:});
+    q = sum (q);
   endif
+
 endfunction
 
 
 ## basic functionality
-%!assert (quadl (@(x) sin (x), 0, pi, [], []), 2, -3e-16)
+%!assert (quadl (@(x) sin (x), 0, pi), 2, 5e-15)
 
 ## the values here are very high so it may be unavoidable that this fails
-%!assert (quadl (@(x) sin (3*x).*cosh (x).*sinh (x),10,15),
-%!         2.588424538641647e+10, -1.1e-14)
+%!assert (quadl (@(x) sin (3*x).*cosh (x).*sinh (x),10,15, 1e-3),
+%!        2.588424538641647e+10, 1e-3)
 
 ## extra parameters
 %!assert (quadl (@(x,a,b) sin (a + b*x), 0, 1, [], [], 2, 3),
-%!        cos(2)/3 - cos(5)/3, -3e-16)
+%!        cos(2)/3 - cos(5)/3, 1e-15)
 
 ## test different tolerances.
-%!assert (quadl (@(x) sin (2 + 3*x).^2, 0, 10, 0.3, []),
-%!        (60 + sin(4) - sin(64))/12, -0.3)
-%!assert (quadl (@(x) sin (2 + 3*x).^2, 0, 10, 0.1, []),
-%!        (60 + sin(4) - sin(64))/12, -0.1)
+%!test
+%! [q, nfun1] = quadl (@(x) sin (2 + 3*x).^2, 0, 10, 0.5, []);
+%! assert (q, (60 + sin(4) - sin(64))/12, 0.5);
+%! [q, nfun2] = quadl (@(x) sin (2 + 3*x).^2, 0, 10, 0.1, []);
+%! assert (q, (60 + sin(4) - sin(64))/12, 0.1);
+%! assert (nfun2 > nfun1);
 
+## Test input validation
+%!error quadl ()
+%!error quadl (@sin)
+%!error quadl (@sin,1)
+%!error <TOL must be a scalar> quadl (@sin, 0, 1, ones (2,2))
+
--- a/scripts/general/quadv.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/quadv.m	Thu Dec 10 12:50:06 2015 -0800
@@ -49,9 +49,10 @@
 ## @var{f}.  To use default values for @var{tol} and @var{trace}, one may pass
 ## empty matrices ([]).
 ##
-## The result of the integration is returned in @var{q}
+## The result of the integration is returned in @var{q}.
 ##
-## @var{nfun} indicates the number of function evaluations that were made.
+## The optional output @var{nfun} indicates the total number of function
+## evaluations performed.
 ##
 ## Note: @code{quadv} is written in Octave's scripting language and can be
 ## used recursively in @code{dblquad} and @code{triplequad}, unlike the
@@ -59,64 +60,61 @@
 ## @seealso{quad, quadl, quadgk, quadcc, trapz, dblquad, triplequad}
 ## @end deftypefn
 
-function [q, nfun] = quadv (f, a, b, tol, trace, varargin)
-  ## TODO: Make norm for convergence testing configurable
+function [q, nfun] = quadv (f, a, b, tol = [], trace = [], varargin)
 
   if (nargin < 3)
     print_usage ();
   endif
-  if (nargin < 4)
-    tol = [];
-  endif
-  if (nargin < 5)
-    trace = [];
-  endif
+
   if (isa (a, "single") || isa (b, "single"))
-    myeps = eps ("single");
+    eps = eps ("single");
   else
-    myeps = eps;
+    eps = eps ("double");
   endif
   if (isempty (tol))
     tol = 1e-6;
+  elseif (! isscalar (tol) || tol < 0)
+    error ("quadv: TOL must be a scalar >=0");
   endif
   if (isempty (trace))
-    trace = 0;
+    trace = false;
   endif
 
-  ## Split the interval into 3 abscissa, and apply a 3 point Simpson's rule
+  ## Split the interval into 3 abscissa, and apply a 3-point Simpson's rule
   c = (a + b) / 2;
   fa = feval (f, a, varargin{:});
   fc = feval (f, c, varargin{:});
   fb = feval (f, b, varargin{:});
   nfun = 3;
 
-  ## If have edge singularities, move edge point by eps*(b-a) as
-  ## discussed in Shampine paper used to implement quadgk
+  ## If there are edge singularities, move edge point by eps*(b-a) as
+  ## discussed in Shampine paper used to implement quadgk.
   if (any (isinf (fa(:))))
-    fa = feval (f, a + myeps * (b-a), varargin{:});
+    fa = feval (f, a + eps * (b-a), varargin{:});
   endif
   if (any (isinf (fb(:))))
-    fb = feval (f, b - myeps * (b-a), varargin{:});
+    fb = feval (f, b - eps * (b-a), varargin{:});
   endif
 
   h = (b - a);
-  q = (b - a) / 6 * (fa + 4 * fc + fb);
+  q = h / 6 * (fa + 4 * fc + fb);
 
   [q, nfun, hmin] = simpsonstp (f, a, b, c, fa, fb, fc, q, nfun, abs (h),
                                 tol, trace, varargin{:});
 
-  if (nfun > 10000)
-    warning ("maximum iteration count reached");
+  if (nfun > 10_000)
+    warning ("quadv: maximum iteration count reached -- possible singular integral");
   elseif (any (! isfinite (q(:))))
-    warning ("infinite or NaN function evaluations were returned");
-  elseif (hmin < (b - a) * myeps)
-    warning ("minimum step size reached -- possibly singular integral");
+    warning ("quadv: infinite or NaN function evaluations were returned");
+  elseif (hmin < (b - a) * eps)
+    warning ("quadv: minimum step size reached -- possible singular integral");
   endif
+
 endfunction
 
-function [q, nfun, hmin] = simpsonstp (f, a, b, c, fa, fb, fc, q0,
-                                       nfun, hmin, tol, trace, varargin)
-  if (nfun > 10000)
+function [q, nfun, hmin] = simpsonstp (f, a, b, c, fa, fb, fc, q0, nfun, hmin,
+                                       tol, trace, varargin)
+  if (nfun > 10_000)
     q = q0;
   else
     d = (a + c) / 2;
@@ -128,7 +126,7 @@
     q2 = (b - c) / 6 * (fc + 4 * fe + fb);
     q = q1 + q2;
 
-    if (abs(a -  c) < hmin)
+    if (abs (a - c) < hmin)
       hmin = abs (a - c);
     endif
 
@@ -136,29 +134,37 @@
       disp ([nfun, a, b-a, q]);
     endif
 
-    ## Force at least one adpative step.
+    ## Force at least one adaptive step (nfun == 5 test).
     ## Not vectorizing q-q0 in the norm provides a more rigid criterion for
     ## matrix-valued functions.
-    if (nfun == 5 || norm (q - q0, Inf) > tol)
+    if (norm (q - q0, Inf) > tol || nfun == 5)
       [q1, nfun, hmin] = simpsonstp (f, a, c, d, fa, fc, fd, q1, nfun, hmin,
-                                    tol, trace, varargin{:});
+                                     tol, trace, varargin{:});
       [q2, nfun, hmin] = simpsonstp (f, c, b, e, fc, fb, fe, q2, nfun, hmin,
                                      tol, trace, varargin{:});
       q = q1 + q2;
     endif
   endif
+
 endfunction
 
 
-%!assert (quadv (@sin, 0, 2 * pi), 0, 1e-5)
+%!assert (quadv (@sin, 0, 2*pi), 0, 1e-5)
 %!assert (quadv (@sin, 0, pi), 2, 1e-5)
 
-## Handles weak singularities at the edge
+## Test weak singularities at the edge
 %!assert (quadv (@(x) 1 ./ sqrt (x), 0, 1), 2, 1e-5)
 
-## Handles vector-valued functions
+## Test 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)
+## Test 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)
 
+## Test input validation
+%!error quadv ()
+%!error quadv (@sin)
+%!error quadv (@sin,1)
+%!error <TOL must be a scalar> quadv (@sin,0,1, ones (2,2))
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/general/rad2deg.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,67 @@
+## Copyright (C) 2015 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{deg} =} rad2deg (@var{rad})
+##
+## Convert radians to degrees.
+##
+## The input @var{rad} must be a scalar, vector, or N-dimensional array of
+## double or single floating point values.  @var{rad} may be complex in which
+## case the real and imaginary components are converted separately.
+##
+## The output @var{deg} is the same size and shape as @var{rad} with radians
+## converted to degrees using the conversion constant @code{180/pi}.
+##
+## Example:
+##
+## @example
+## @group
+## rad2deg ([0, pi/2, pi, 3/2*pi, 2*pi])
+##   @result{}  0    90   180   270   360
+## @end group
+## @end example
+## @seealso{deg2rad}
+## @end deftypefn
+
+function deg = rad2deg (rad)
+
+  if (nargin != 1)
+    print_usage ();
+  endif
+
+  if (! isfloat (rad))
+    error ("rad2deg: RAD must be a floating point class (double or single)");
+  endif
+
+  deg = rad * (180/pi);
+
+endfunction
+
+
+%!assert (rad2deg (0), 0)
+%!assert (rad2deg (pi/2), 90)
+%!assert (rad2deg (pi), 180)
+%!assert (rad2deg (pi*[0, 1/2, 1, 3/2, 2]), [0, 90, 180, 270, 360])
+
+## Test input validation
+%!error rad2deg ()
+%!error rad2deg (1, 2)
+%!error <RAD must be a floating point class> rad2deg (uint8 (1))
+%!error <RAD must be a floating point class> rad2deg ("A")
+
--- a/scripts/general/rat.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/rat.m	Thu Dec 10 12:50:06 2015 -0800
@@ -102,7 +102,7 @@
 
   if (nargout == 2)
     ## Move the minus sign to the top.
-    n = n .* sign (d);
+    n .*= sign (d);
     d = abs (d);
 
     ## Return the same shape as you receive.
--- a/scripts/general/rotdim.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/rotdim.m	Thu Dec 10 12:50:06 2015 -0800
@@ -78,7 +78,7 @@
       plane = [];
       dim = 0;
       while (dim < nd)
-        dim = dim + 1;
+        dim += 1;
         if (sz (dim) != 1)
           plane = [plane, dim];
           if (length (plane) == 2)
@@ -104,7 +104,7 @@
 
   n = rem (n, 4);
   if (n < 0)
-    n = n + 4;
+    n += 4;
   endif
   if (n == 0)
     y = x;
--- a/scripts/general/trapz.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/trapz.m	Thu Dec 10 12:50:06 2015 -0800
@@ -114,7 +114,7 @@
       shape = ones (nd, 1);
       shape(dim) = sz(dim);
       x = reshape (x, shape);
-      z = 0.5 * sum (bsxfun (@times, diff (x), y(idx1{:}) + y(idx2{:})), dim);
+      z = 0.5 * sum (diff (x) .* (y(idx1{:}) + y(idx2{:})), dim);
     else
       if (! size_equal (x, y))
         error ("trapz: X and Y must have same shape");
--- a/scripts/general/validateattributes.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/general/validateattributes.m	Thu Dec 10 12:50:06 2015 -0800
@@ -84,6 +84,9 @@
 ## @item @qcode{"decreasing"}
 ## No value is @var{NaN}, and each is less than the preceding one.
 ##
+## @item @qcode{"diag"}
+## Value is a diagonal matrix.
+##
 ## @item @qcode{"even"}
 ## All values are even numbers.
 ##
@@ -117,7 +120,7 @@
 ## @item @qcode{"nonnan"}
 ## No value is a @code{NaN}.
 ##
-## @item @qcode{"nonnegative"}
+## @item @nospell{@qcode{"nonnegative"}}
 ## All values are non negative.
 ##
 ## @item @qcode{"nonsparse"}
@@ -249,6 +252,7 @@
       case "scalar",        problem = ! isscalar (A);
       case "vector",        problem = ! isvector (A);
       case "square",        problem = ! issquare (A);
+      case "diag",          problem = ! isdiag (A);
       case "nonempty",      problem = isempty (A);
       case "nonsparse",     problem = issparse (A);
       case "binary",        problem = ! islogical (A) && ...
@@ -384,6 +388,8 @@
 %!error <greater than> validateattributes ([6 7 8 5], {}, {">=", 6})
 %!error <less than> validateattributes ([6 7 8 5], {}, {"<", 8})
 %!error <less than> validateattributes ([6 7 8 5], {}, {"<=", 7})
+%!error <diag> validateattributes ([0 0 0; 0 0 0; 1 0 0], {}, {"diag"})
+%!error <diag> validateattributes (repmat (eye (3), [1 1 3]), {}, {"diag"})
 
 %!test
 %! validateattributes (rand (5), {"numeric"}, {})
@@ -428,6 +434,9 @@
 %! validateattributes ([4 5 6 7], {}, {">=", 4})
 %! validateattributes ([4 5 6 7], {}, {"<", 8})
 %! validateattributes ([4 5 6 7], {}, {"<=", 7})
+%! validateattributes (eye (3), {}, {"diag"})
+%! validateattributes ([1 0 0; 0 1 0; 0 0 1], {}, {"diag"})
+%! validateattributes (zeros (3), {}, {"diag"})
 
 %!test
 %! validateattributes ([0 1 0 1], {"double", "uint8"}, {"binary", "size", [NaN 4], "nonnan"})
--- a/scripts/geometry/griddata.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/geometry/griddata.m	Thu Dec 10 12:50:06 2015 -0800
@@ -133,14 +133,12 @@
     error ("griddata: unknown interpolation METHOD");
   endif
 
-  if (nargout == 3)
+  if (nargout > 1)
     rx = xi;
     ry = yi;
     rz = zi;
-  elseif (nargout == 1)
+  else
     rx = zi;
-  elseif (nargout == 0)
-    mesh (xi, yi, zi);
   endif
 
 endfunction
@@ -153,7 +151,8 @@
 %! 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);
+%! zz = griddata (x,y,z,xx,yy);
+%! mesh (xx, yy, zz);
 %! title ("nonuniform grid sampled at 100 points");
 
 %!demo
@@ -163,7 +162,8 @@
 %! 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);
+%! zz = griddata (x,y,z,xx,yy);
+%! mesh (xx, yy, zz);
 %! title ("nonuniform grid sampled at 1000 points");
 
 %!demo
@@ -173,7 +173,8 @@
 %! 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");
+%! zz = griddata (x,y,z,xx,yy,"nearest");
+%! mesh (xx, yy, zz);
 %! title ("nonuniform grid sampled at 1000 points with nearest neighbor");
 
 %!testif HAVE_QHULL
--- a/scripts/geometry/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/geometry/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,22 +1,26 @@
-FCN_FILE_DIRS += geometry
+FCN_FILE_DIRS += scripts/geometry
 
-geometry_FCN_FILES = \
-  geometry/convhull.m \
-  geometry/delaunayn.m \
-  geometry/delaunay.m \
-  geometry/dsearch.m \
-  geometry/dsearchn.m \
-  geometry/griddata.m \
-  geometry/griddata3.m \
-  geometry/griddatan.m \
-  geometry/inpolygon.m \
-  geometry/rectint.m \
-  geometry/tsearchn.m \
-  geometry/voronoi.m \
-  geometry/voronoin.m
+scripts_geometry_FCN_FILES = \
+  scripts/geometry/convhull.m \
+  scripts/geometry/delaunayn.m \
+  scripts/geometry/delaunay.m \
+  scripts/geometry/dsearch.m \
+  scripts/geometry/dsearchn.m \
+  scripts/geometry/griddata.m \
+  scripts/geometry/griddata3.m \
+  scripts/geometry/griddatan.m \
+  scripts/geometry/inpolygon.m \
+  scripts/geometry/rectint.m \
+  scripts/geometry/tsearchn.m \
+  scripts/geometry/voronoi.m \
+  scripts/geometry/voronoin.m
 
-FCN_FILES += $(geometry_FCN_FILES)
+scripts_geometrydir = $(fcnfiledir)/geometry
+
+scripts_geometry_DATA = $(scripts_geometry_FCN_FILES)
 
-PKG_ADD_FILES += geometry/PKG_ADD
+FCN_FILES += $(scripts_geometry_FCN_FILES)
 
-DIRSTAMP_FILES += geometry/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/geometry/PKG_ADD
+
+DIRSTAMP_FILES += scripts/geometry/$(octave_dirstamp)
--- a/scripts/geometry/voronoi.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/geometry/voronoi.m	Thu Dec 10 12:50:06 2015 -0800
@@ -83,7 +83,7 @@
     if (! isaxes (hax))
       error ("voronoi: HAX argument must be an axes object");
     endif
-    narg++;
+    narg += 1;
   endif
 
   if (nargin < 1 + narg || nargin > 3 + narg)
@@ -99,7 +99,7 @@
       opts = varargin(narg++);
     elseif (isnumeric (varargin{narg}))
       ## Accept, but ignore, the triangulation
-      narg++;
+      narg += 1;
     endif
   endif
 
@@ -209,7 +209,7 @@
 ## Input validation tests
 %!error voronoi ()
 %!error voronoi (ones (3,1))
-%!error voronoi (ones (3,1), ones (3,1), "bogus1", "bogus2", "bogus3")
+%!error voronoi (ones (3,1), ones (3,1), "invalid1", "invalid2", "invalid3")
 %!error <HAX argument must be an axes object> voronoi (0, ones (3,1), ones (3,1))
 %!error <X and Y must be vectors of the same length> voronoi (ones (3,1), ones (4,1))
 %!error <minimum of 2 points needed> voronoi (2.5, 3.5)
--- a/scripts/gui/listdlg.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/listdlg.m	Thu Dec 10 12:50:06 2015 -0800
@@ -85,7 +85,7 @@
   endif
 
   listcell = {""};
-  selmode = "Multiple";
+  selmode = "multiple";
   listsize = [160, 300];
   initialvalue = 1;
   name = "";
@@ -127,7 +127,7 @@
   endif
 
   ## make sure valid selection mode
-  if (! strcmpi (selmode, "multiple") && ! strcmpi (selmode, "single"))
+  if (! strcmp (selmode, "multiple") && ! strcmp (selmode, "single"))
     error ("listdlg: invalid SelectionMode");
   endif
 
--- a/scripts/gui/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,44 +1,55 @@
-FCN_FILE_DIRS += gui
+FCN_FILE_DIRS += \
+  scripts/gui \
+  scripts/gui/private
 
-gui_PRIVATE_FCN_FILES = \
-  gui/private/__file_filter__.m \
-  gui/private/__fltk_file_filter__.m \
-  gui/private/__get_funcname__.m \
-  gui/private/__is_function__.m \
-  gui/private/__uigetdir_fltk__.m \
-  gui/private/__uigetfile_fltk__.m \
-  gui/private/__uiobject_split_args__.m \
-  gui/private/__uiputfile_fltk__.m \
-  gui/private/message_dialog.m
+scripts_gui_PRIVATE_FCN_FILES = \
+  scripts/gui/private/__file_filter__.m \
+  scripts/gui/private/__fltk_file_filter__.m \
+  scripts/gui/private/__get_funcname__.m \
+  scripts/gui/private/__is_function__.m \
+  scripts/gui/private/__uigetdir_fltk__.m \
+  scripts/gui/private/__uigetfile_fltk__.m \
+  scripts/gui/private/__uiobject_split_args__.m \
+  scripts/gui/private/__uiputfile_fltk__.m \
+  scripts/gui/private/message_dialog.m
 
-gui_FCN_FILES = \
-  gui/errordlg.m \
-  gui/guidata.m \
-  gui/guihandles.m \
-  gui/helpdlg.m \
-  gui/inputdlg.m \
-  gui/listdlg.m \
-  gui/msgbox.m \
-  gui/questdlg.m \
-  gui/uicontextmenu.m \
-  gui/uicontrol.m \
-  gui/uigetdir.m \
-  gui/uigetfile.m \
-  gui/uimenu.m \
-  gui/uipanel.m \
-  gui/uipushtool.m \
-  gui/uiputfile.m \
-  gui/uiresume.m \
-  gui/uitoggletool.m \
-  gui/uitoolbar.m \
-  gui/uiwait.m \
-  gui/waitbar.m \
-  gui/waitforbuttonpress.m \
-  gui/warndlg.m \
-  $(gui_PRIVATE_FCN_FILES)
+scripts_gui_FCN_FILES = \
+  scripts/gui/errordlg.m \
+  scripts/gui/guidata.m \
+  scripts/gui/guihandles.m \
+  scripts/gui/helpdlg.m \
+  scripts/gui/inputdlg.m \
+  scripts/gui/listdlg.m \
+  scripts/gui/msgbox.m \
+  scripts/gui/questdlg.m \
+  scripts/gui/uicontextmenu.m \
+  scripts/gui/uicontrol.m \
+  scripts/gui/uigetdir.m \
+  scripts/gui/uigetfile.m \
+  scripts/gui/uimenu.m \
+  scripts/gui/uipanel.m \
+  scripts/gui/uipushtool.m \
+  scripts/gui/uiputfile.m \
+  scripts/gui/uiresume.m \
+  scripts/gui/uitoggletool.m \
+  scripts/gui/uitoolbar.m \
+  scripts/gui/uiwait.m \
+  scripts/gui/waitbar.m \
+  scripts/gui/waitforbuttonpress.m \
+  scripts/gui/warndlg.m
 
-FCN_FILES += $(gui_FCN_FILES)
+scripts_guidir = $(fcnfiledir)/gui
+
+scripts_gui_DATA = $(scripts_gui_FCN_FILES)
+
+scripts_gui_privatedir = $(fcnfiledir)/gui/private
+
+scripts_gui_private_DATA = $(scripts_gui_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += gui/PKG_ADD
+FCN_FILES += \
+  $(scripts_gui_FCN_FILES) \
+  $(scripts_gui_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += gui/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/gui/PKG_ADD
+
+DIRSTAMP_FILES += scripts/gui/$(octave_dirstamp)
--- a/scripts/gui/private/__file_filter__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/private/__file_filter__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -51,10 +51,10 @@
   elseif (ischar (file_filter))
     [defdir, fname, fext] = fileparts (file_filter);
     if (! strcmp (fname, "*"))
-      defname = strcat (fname, fext);
+      defname = [fname, fext];
     endif
-    if ((length (fext) > 0) && (! strcmp(fext, '.*')))
-      fext = strcat ("*", fext);
+    if ((length (fext) > 0) && (! strcmp (fext, ".*")))
+      fext = ["*" fext];
       retval = {fext, __default_filtername__(fext)};
     endif
   endif
--- a/scripts/gui/private/__fltk_file_filter__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/private/__fltk_file_filter__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -28,7 +28,7 @@
   retval = "";
   [r, c] = size (file_filter);
   if ((c == 0) || (c > 2))
-    error ("expecting 1 or to 2 columns for file filter cell");
+    error ("file filter cell must have 1 or 2 columns");
   endif
   fltk_str = "";
   for idx = 1 : r
@@ -37,7 +37,7 @@
     curr_ext = ostrsplit (curr_ext, ";");
 
     if (length (curr_ext) > 1)
-      curr_ext = regexprep (curr_ext, '\*\.', ',');
+      curr_ext = strrep (curr_ext, '*.', ',');
       curr_ext = strcat (curr_ext{:})(2 : end);
       curr_ext = strcat ("*.{", curr_ext, "}");
     else
@@ -48,8 +48,8 @@
 
     if (c == 2)
       curr_desc = file_filter{idx, 2};
-      curr_desc = regexprep (curr_desc, '\(', '<');
-      curr_desc = regexprep (curr_desc, '\)', '>');
+      curr_desc = strrep (curr_desc, '(', '<');
+      curr_desc = strrep (curr_desc, ')', '>');
     endif
 
     if (length (fltk_str) > 0)
--- a/scripts/gui/private/__get_funcname__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/private/__get_funcname__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -30,13 +30,13 @@
 
   if (! __octave_link_enabled__ ())
     tk = graphics_toolkit ();
-    funcname = strcat ("__", basename, "_", tk, "__");
+    funcname = [ "__" basename "_" tk "__"];
     if (numel (tk) > 0 && ! strcmp (tk, "fltk")
         && ! __is_function__ (funcname))
       warning ("%s: no implementation for toolkit '%s', using 'fltk' instead",
                basename, tk);
     endif
-    funcname = strcat ("__", basename, "_fltk__");
+    funcname = ["__" basename "_fltk__"];
   else
     funcname = "";
   endif
--- a/scripts/gui/private/__uiobject_split_args__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/private/__uiobject_split_args__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -41,7 +41,7 @@
   endif
 
   if (rem (length (args), 2))
-    error ("%s: expecting PROPERTY/VALUE pairs", who);
+    error ("%s: PROPERTY/VALUE arguments must occur in pairs", who);
   endif
 
   if (! isempty (args))
--- a/scripts/gui/uicontextmenu.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/uicontextmenu.m	Thu Dec 10 12:50:06 2015 -0800
@@ -17,18 +17,20 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {@var{hui} =} uicontextmenu (@var{property}, @var{value}, @dots{})
+## @deftypefn  {Function File} {@var{hui} =} uicontextmenu (@var{property}, @var{value}, @dots{})
 ## @deftypefnx {Function File} {@var{hui} =} uicontextmenu (@var{h}, @var{property}, @var{value}, @dots{})
 ##
 ## Create a uicontextmenu object and return a handle to it.
 ##
 ## If @var{h} is omitted then a uicontextmenu for the current figure is
-## created. If no figure is available, a new figure is created first. 
+## created.  If no figure is available, a new figure is created first.
+##
+## If @var{h} is given then a uicontextmenu relative to @var{h} is created.
 ##
-## If @var{h} is given then a uicontextmenu relative to @var{h} is created. 
-## 
-## Any provided property value pairs will override the default values of the created 
-## uicontextmenu object.
+## Any provided property value pairs will override the default values of the
+## created uicontextmenu object.
+##
+## Uicontextmenu properties are documented at @ref{Uicontextmenu Properties}.
 ##
 ## Examples:
 ##
--- a/scripts/gui/uicontrol.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/uicontrol.m	Thu Dec 10 12:50:06 2015 -0800
@@ -23,18 +23,23 @@
 ##
 ## Create a uicontrol object and return a handle to it.
 ##
-## uicontrols are used to create simple interactive controls such as push buttons, checkboxes, edit and list controls.
+## uicontrols are used to create simple interactive controls such as push
+## buttons, checkboxes, edit and list controls.
 ##
 ## If @var{parent} is omitted then a uicontrol for the current figure is
-## created. If no figure is available, a new figure is created first. 
+## created.  If no figure is available, a new figure is created first.
+##
+## If @var{parent} is given then a uicontrol relative to @var{parent} is
+## created.
 ##
-## If @var{parent} is given then a uicontrol relative to @var{parent} is created. 
-## 
-## Any provided property value pairs will override the default values of the created 
-## uicontrol object. 
+## Any provided property value pairs will override the default values of the
+## created uicontrol object.
 ##
-## Control of the type of uicontrol created is through the use of the @var{style} property.
-## If no style property is provided, a push button will be created.
+## Uicontrol properties are documented at @ref{Uicontrol Properties}.
+##
+## Control of the type of uicontrol created is through the use of the
+## @var{style} property.  If no style property is provided, a push button will
+## be created.
 ##
 ## Valid styles for uicontrol are:
 ##
@@ -43,33 +48,34 @@
 ## Create a checkbox control that allows user on/off selection.
 ##
 ## @item @qcode{"edit"}
-## Create a edit control that allows user input of single or multiple lines of text.
+## Create an edit control that allows user input of single or multiple lines
+## of text.
 ##
 ## @item @qcode{"listbox"}
-## Create a listbox control that displays a lit of items and allows user slelection of 
-## single or multiple items.
+## Create a listbox control that displays a lit of items and allows user
+## selection of single or multiple items.
 ##
 ## @item @qcode{"popupmenu"}
-## Create a popupmenu control that displays a list of options that can be selected 
-## when the user clicks on the control.
+## Create a popupmenu control that displays a list of options that can be
+## selected when the user clicks on the control.
 ##
 ## @item @qcode{"pushbutton"}
 ## Create a push button control that allows user to press to cause an action.
 ##
 ## @item @qcode{"radiobutton"}
-## Create a radio button control intended to be used for mutually exclusive input in a group of
-## of radiobutton controls.
+## Create a radio button control intended to be used for mutually exclusive
+## input in a group of radiobutton controls.
 ##
 ## @item @qcode{"slider"}
-## Create a slider control that allows user selection from a range of values by sliding 
-## knob on the control.
+## Create a slider control that allows user selection from a range of values
+## by sliding knob on the control.
 ##
 ## @item @qcode{"text"}
 ## Create a static text control to display single or multiple lines of text.
 ##
 ## @item @qcode{"togglebutton"}
-## Create a toggle button control that appears like a push button but allows the user to 
-## select between two states.
+## Create a toggle button control that appears like a push button but allows
+## the user to select between two states.
 ##
 ## @end table
 ##
@@ -96,7 +102,7 @@
 
   if (nargin == 1 && ishandle (varargin{1})
       && strcmpi (get (varargin{1}, "type"), "uicontrol"))
-    error ("uicontrol focusing not implemented yet.");
+    error ("uicontrol: focusing not implemented yet");
   endif
 
   [h, args] = __uiobject_split_args__ ("uicontrol", varargin,
--- a/scripts/gui/uigetfile.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/uigetfile.m	Thu Dec 10 12:50:06 2015 -0800
@@ -75,7 +75,7 @@
   ## Preset default values
   outargs = {cell(0, 2),         # File Filter
              "Open File",        # Dialog Title
-             "",                 # Default file name
+             "",                 # Default filename
              [240, 120],         # Dialog Position (pixel x/y)
              "off",              # MultiSelect on/off
              pwd};               # Default directory
@@ -138,7 +138,7 @@
         outargs{6} = fdir;
       endif
       if (length (fname) > 0 || length (fext) > 0)
-        outargs{3} = strcat (fname, fext);
+        outargs{3} = [fname fext];
       endif
     elseif (! isempty (args{3}))
       print_usage ();
@@ -150,7 +150,7 @@
 
     ## check for even number of remaining arguments, prop/value pair(s)
     if (rem (nargin - stridx + 1, 2))
-      error ("uigetfile: expecting property/value pairs");
+      error ("uigetfile: PROPERTY/VALUE arguments must occur in pairs");
     endif
 
     for i = stridx : 2 : nargin
@@ -160,13 +160,13 @@
         if (ismatrix (val) && length (val) == 2)
           outargs{4} = val;
         else
-          error ("uigetfile: expecting 2-element vector for position argument");
+          error ('uigetfile: "Position" must be a 2-element vector');
         endif
       elseif (strcmpi (prop, "multiselect"))
         if (ischar (val))
           outargs{5} = tolower (val);
         else
-          error ("uigetfile: expecting string argument (on/off) for multiselect");
+          error ('uigetfile: MultiSelect value must be a string ("on"/"off")');
         endif
       else
         error ("uigetfile: unknown argument");
--- a/scripts/gui/uipanel.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/uipanel.m	Thu Dec 10 12:50:06 2015 -0800
@@ -25,12 +25,14 @@
 ## uipanels are used as containers to group other uicontrol objects.
 ##
 ## If @var{parent} is omitted then a uipanel for the current figure is
-## created. If no figure is available, a new figure is created first. 
+## created.  If no figure is available, a new figure is created first.
+##
+## If @var{parent} is given then a uipanel relative to @var{parent} is created.
 ##
-## If @var{parent} is given then a uipanel relative to @var{parent} is created. 
-## 
-## Any provided property value pairs will override the default values of the created 
-## uipanel object.
+## Any provided property value pairs will override the default values of the
+## created uipanel object.
+##
+## Uipanel properties are documented at @ref{Uipanel Properties}.
 ##
 ## Examples:
 ##
--- a/scripts/gui/uipushtool.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/uipushtool.m	Thu Dec 10 12:50:06 2015 -0800
@@ -22,17 +22,22 @@
 ##
 ## Create a uipushtool object and return a handle to it.
 ##
-## uipushtools are buttons that appear on a figure toolbar. The button is created with a border that
-## is shown when the user hovers over the button. An image can be set using the cdata property.
+## uipushtools are buttons that appear on a figure toolbar.  The button is
+## created with a border that is shown when the user hovers over the button.
+## An image can be set using the cdata property.
 ##
 ## If @var{parent} is omitted then a uipushtool for the current figure is
-## created. If no figure is available, a new figure is created first.  If a figure is
-## available, but does not contain a uitoolbar, a uitoolbar will be created.
+## created.  If no figure is available, a new figure is created first.  If a
+## figure is available, but does not contain a uitoolbar, a uitoolbar will be
+## created.
 ##
-## If @var{parent} is given then a uipushtools is created on the @var{parent} uitoolbar. 
-## 
-## Any provided property value pairs will override the default values of the created 
-## uipushtool object.
+## If @var{parent} is given then an uipushtools is created on the
+## @var{parent} uitoolbar.
+##
+## Any provided property value pairs will override the default values of the
+## created uipushtool object.
+##
+## Uipushtool properties are documented at @ref{Uipushtool Properties}.
 ##
 ## Examples:
 ##
--- a/scripts/gui/uiputfile.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/uiputfile.m	Thu Dec 10 12:50:06 2015 -0800
@@ -65,7 +65,7 @@
   ## Preset default values
   outargs = {cell(0, 2),     # File Filter
              "Save File",    # Dialog Title
-             "",             # Default file name
+             "",             # Default filename
              [240, 120],     # Dialog Position (pixel x/y)
              "create",
              pwd};           # Default directory
@@ -100,7 +100,7 @@
         outargs{6} = fdir;
       endif
       if (! isempty (fname) || ! isempty (fext))
-        outargs{3} = strcat (fname, fext);
+        outargs{3} = [fname fext];
       endif
     elseif (! isempty (varargin{3}))
       print_usage ();
--- a/scripts/gui/uitoggletool.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/uitoggletool.m	Thu Dec 10 12:50:06 2015 -0800
@@ -22,17 +22,22 @@
 ##
 ## Create a uitoggletool object and return a handle to it.
 ##
-## uitoggletool are togglebuttons that appear on a figure toolbar. The button is created with a border that
-## is shown when the user hovers over the button. An image can be set using the cdata property.
+## uitoggletool are togglebuttons that appear on a figure toolbar.  The
+## button is created with a border that is shown when the user hovers over
+## the button.  An image can be set using the cdata property.
 ##
 ## If @var{parent} is omitted then a uitoggletool for the current figure is
-## created. If no figure is available, a new figure is created first.  If a figure is
-## available, but does not contain a uitoolbar, a uitoolbar will be created.
+## created.  If no figure is available, a new figure is created first.  If a
+## figure is available, but does not contain a uitoolbar, a uitoolbar will be
+## created.
 ##
-## If @var{parent} is given then a uitoggletool is created on the @var{parent} uitoolbar. 
-## 
-## Any provided property value pairs will override the default values of the created 
-## uitoggletool object.
+## If @var{parent} is given then a uitoggletool is created on the
+## @var{parent} uitoolbar.
+##
+## Any provided property value pairs will override the default values of the
+## created uitoggletool object.
+##
+## Uitoggletool properties are documented at @ref{Uitoggletool Properties}.
 ##
 ## Examples:
 ##
--- a/scripts/gui/uitoolbar.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/uitoolbar.m	Thu Dec 10 12:50:06 2015 -0800
@@ -20,21 +20,25 @@
 ## @deftypefn  {Function File} {@var{hui} =} uitoolbar (@var{property}, @var{value}, @dots{})
 ## @deftypefnx {Function File} {@var{hui} =} uitoolbar (@var{parent}, @var{property}, @var{value}, @dots{})
 ##
-## Create a uitoolbar object and return a handle to it. A uitoolbar displays uitoggletool and uipushtool buttons.
+## Create a uitoolbar object and return a handle to it.  A uitoolbar displays
+## uitoggletool and uipushtool buttons.
 ##
 ## If @var{parent} is omitted then a uitoolbar for the current figure is
-## created. If no figure is available, a new figure is created first. 
+## created.  If no figure is available, a new figure is created first.
+##
+## If @var{parent} is given then a uitoolbar relative to @var{parent} is
+## created.
 ##
-## If @var{parent} is given then a uitoolbar relative to @var{parent} is created. 
-## 
-## Any provided property value pairs will override the default values of the created 
-## uitoolbar object. 
+## Any provided property value pairs will override the default values of the
+## created uitoolbar object.
+##
+## Uitoolbar properties are documented at @ref{Uitoolbar Properties}.
 ##
 ## Examples:
 ##
 ## @example
 ## @group
-## % create figure without a default toolbar 
+## % create figure without a default toolbar
 ## f = figure ("toolbar", "none");
 ## % create empty toolbar
 ## t = uitoolbar (f);
--- a/scripts/gui/waitbar.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/gui/waitbar.m	Thu Dec 10 12:50:06 2015 -0800
@@ -19,7 +19,8 @@
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {@var{h} =} waitbar (@var{frac})
 ## @deftypefnx {Function File} {@var{h} =} waitbar (@var{frac}, @var{msg})
-## @deftypefnx {Function File} {@var{h} =} waitbar (@dots{}, "FigureProperty", "Value", @dots{})
+## @deftypefnx {Function File} {@var{h} =} waitbar (@dots{}, "createcancelbtn", @var{fcn}, @dots{})
+## @deftypefnx {Function File} {@var{h} =} waitbar (@dots{}, @var{prop}, @var{val}, @dots{})
 ## @deftypefnx {Function File} {} waitbar (@var{frac})
 ## @deftypefnx {Function File} {} waitbar (@var{frac}, @var{hwbar})
 ## @deftypefnx {Function File} {} waitbar (@var{frac}, @var{hwbar}, @var{msg})
@@ -30,8 +31,13 @@
 ##
 ## The optional message @var{msg} is centered and displayed above the waitbar.
 ##
+## A cancel button can be added to the bottom of the waitbar using the
+## @qcode{"createcancelbtn"} property of waitbar figures.  The action to be
+## executed when the user presses the button is specified using a string or
+## function handle @var{fcn}.
+##
 ## The appearance of the waitbar figure window can be configured by passing
-## property/value pairs to the function.
+## @var{prop}/@var{val} pairs to the function.
 ##
 ## When called with a single input the current waitbar, if it exists, is
 ## updated to the new value @var{frac}.  If there are multiple outstanding
@@ -115,14 +121,21 @@
                  "menubar", "none", "toolbar", "none",
                  "integerhandle", "off",
                  "handlevisibility", "callback",
-                 "tag", "waitbar",
-                 varargin{:});
+                 "tag", "waitbar");
 
     ax = axes ("parent", hf,
                "xtick", [], "ytick", [],
                "xlim", [0, 1], "ylim", [0, 1],
                "position", [0.1, 0.3, 0.8, 0.2]);
 
+    ## Add createcancelbtn property
+    addproperty ("createcancelbtn", hf, "figurebuttondownfcn");
+    addlistener (hf, "createcancelbtn", {@updatecancelbutton, ax});
+
+    if (! isempty (varargin))
+      set (hf, varargin{:});
+    endif
+
     hp = patch (ax, [0; frac; frac; 0], [0; 0; 1; 1], [0, 0.35, 0.75]);
 
     ## Cache the axes and patch handles.
@@ -147,6 +160,47 @@
 
 endfunction
 
+function updatecancelbutton (hf, dummy, hax)
+  if (! strcmpi (get (hf, "__graphics_toolkit__"), "qt"))
+    return
+  endif
+
+  hbtn = findobj (hf, "type", "uicontrol", "-and", "style", "pushbutton");
+  cb = get (hf, "createcancelbtn");
+  if (! isempty (cb))
+    if (isempty (hbtn))
+      units =  get (hax, "units");
+      fpos = get (hf, "position");
+      set (hax, "units", "pixels");
+      apos = get (hax, "position");
+
+      fpos (2) -= 40;
+      fpos (4) += 40;
+      apos (2) += 40;
+      set (hf, "position", fpos);
+      set (hax, "position", apos, "units", units);
+
+      hbtn = uicontrol ("style", "pushbutton", "string", "Cancel", ...
+                        "position", [fpos(3)-100 10 60 25],...
+                        "callback", cb, "parent", hf);
+    else
+      set (hbtn, "callback", cb)
+    endif
+  elseif (! isempty (hbtn))
+    delete (hbtn);
+    units =  get (hax, "units");
+    fpos = get (hf, "position");
+    set (hax, "units", "pixels");
+    apos = get (hax, "position");
+
+    fpos (2) += 40;
+    fpos (4) -= 40;
+    apos (2) -= 40;
+    set (hf, "position", fpos);
+    set (hax, "position", apos, "units", units);
+  endif
+endfunction
+
 
 %!demo
 %! h = waitbar (0, '0.00%');
@@ -193,6 +247,51 @@
 %! close (h1);
 %! close (h2);
 
+%!demo
+%! clf ();
+%! niter = 9;
+%! l = 1;
+%! xx = [0 l];
+%! yy = [0 0];
+%! hli = plot (xx, yy);
+%!
+%! disp ("Push the cancel to stop the process.")
+%! hf = waitbar(0,"0","Name","Building Koch curve ...",...
+%!              "createcancelbtn", "setappdata (gcbf,'interrupt', true)");
+%! for ii = 1:niter
+%!   ## Check cancel request
+%!   if (! ishandle (hf))
+%!     break
+%!   elseif (getappdata (hf, "interrupt"))
+%!     delete (hf)
+%!     break
+%!   else
+%!     waitbar (ii/niter, hf, sprintf ("Step %d/%d", ii, niter));
+%!   endif
+%!
+%!   ## Increasingly lengthy computation
+%!   l /= 3;
+%!   theta = angle (complex (diff (xx), diff (yy)));
+%!
+%!   xy = @(th, x0, y0) [cos(th) -sin(th) x0
+%!                       sin(th) cos(th) y0] * [0 l l*3/2      2*l;
+%!                                              0 0 l*(3)^.5/2 0;
+%!                                              1 1 1          1];
+%!   tmp = arrayfun (xy, theta, xx(1:end-1), yy(1:end-1),
+%!                  "uniformoutput", false);
+%!
+%!   tmp = cell2mat (tmp);
+%!   xx = [tmp(1,:) xx(end)];
+%!   yy = [tmp(2,:) yy(end)];
+%!   set (hli, "xdata", xx, "ydata", yy)
+%!   drawnow ();
+%!   pause (0.5)
+%! endfor
+%!
+%! if (ishandle (hf))
+%!   delete (hf)
+%! endif
+
 ## Test input validation
 %!error <FRAC must be between 0 and 1> waitbar (-0.5)
 %!error <FRAC must be between 0 and 1> waitbar (1.5)
--- a/scripts/help/__makeinfo__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/help/__makeinfo__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -77,11 +77,9 @@
   ##       can only be removed when that function has been updated.
   if (nargin < 3)
     if (strcmpi (output_type, "plain text"))
-      fsee_also = @(T) strcat ...
-          ("\nSee also:", sprintf (" %s,", T{:})(1:end-1), "\n");
+      fsee_also = @(T) ["\nSee also:", sprintf(" %s,", T{:})(1:end-1), "\n"];
     else
-      fsee_also = @(T) strcat ...
-          ("\nSee also:", sprintf (" @ref{%s},", T{:})(1:end-1), "\n");
+      fsee_also = @(T) ["\nSee also:", sprintf(" @ref{%s},", T{:})(1:end-1), "\n"];
     endif
   endif
 
--- a/scripts/help/__unimplemented__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/help/__unimplemented__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -82,10 +82,9 @@
       txt = ["matlabrc is not implemented.  ", ...
              'Octave uses the file ".octaverc" instead.'];
 
-    case {"ode113", "ode15i", "ode15s", "ode23", "ode23s", "ode23t", ...
-          "ode23tb", "ode45", "odeget", "odeset"}
-      txt = ["Octave provides lsode for solving differential equations.  ", ...
-             "For more information try @code{help lsode}.  ", ...
+    case {"ode113", "ode15i", "ode15s", "ode23", "ode23s", "ode23t", "ode23tb"}
+      txt = ["Octave provides lsode and ode45 for solving differential equations. ", ...
+             "For more information try @code{help lsode}, @code{help ode45}.  ", ...
              "Matlab-compatible ODE functions are provided by the odepkg ", ...
              "package.  See @url{http://octave.sourceforge.net/odepkg/}."];
 
@@ -547,22 +546,20 @@
 
 function list = missing_functions ()
   persistent list = {
-  "MException",
-  "RandStream",
-  "Tiff",
-  "VideoReader",
-  "VideoWriter",
+  "addcats",
   "addCause",
-  "addcats",
   "align",
   "alim",
   "alpha",
   "alphamap",
+  "alphaShape",
+  "animatedLine",
   "array2table",
   "bar3",
   "bar3h",
   "bench",
   "bicgstabl",
+  "boundary",
   "brush",
   "builddocsearchdb",
   "bvp4c",
@@ -571,8 +568,8 @@
   "bvpinit",
   "bvpset",
   "bvpxtend",
+  "calllib",
   "callSoapService",
-  "calllib",
   "camdolly",
   "cameratoolbar",
   "camlight",
@@ -616,6 +613,7 @@
   "createSoapMessage",
   "customverctrl",
   "datacursormode",
+  "datastore",
   "dbmex",
   "dde23",
   "ddeget",
@@ -629,6 +627,8 @@
   "details",
   "deval",
   "dialog",
+  "digraph",
+  "discretize",
   "dither",
   "docsearch",
   "dragrect",
@@ -642,6 +642,7 @@
   "figurepalette",
   "filebrowser",
   "fill3",
+  "findgroups",
   "findprop",
   "fitsdisp",
   "fitsinfo",
@@ -651,11 +652,12 @@
   "freqspace",
   "funm",
   "gammaincinv",
-  "getReport",
   "getframe",
   "getpixelposition",
+  "getReport",
   "gobjects",
   "grabcode",
+  "graph",
   "graymon",
   "griddedInterpolant",
   "gsvd",
@@ -674,6 +676,10 @@
   "hgexport",
   "hgsetget",
   "hgtransform",
+  "histcounts",
+  "histcounts2",
+  "histogram",
+  "histogram2",
   "im2java",
   "imapprox",
   "import",
@@ -684,9 +690,10 @@
   "integral2",
   "integral3",
   "interpstreamspeed",
-  "isKey",
   "iscategorical",
   "iscategory",
+  "isenum",
+  "isKey",
   "ismissing",
   "isocaps",
   "isordinal",
@@ -715,6 +722,7 @@
   "localfunctions",
   "lsqr",
   "makehgtform",
+  "mapreduce",
   "material",
   "matfile",
   "matlabrc",
@@ -722,6 +730,8 @@
   "memory",
   "mergecats",
   "methodsview",
+  "MException",
+  "milliseconds",
   "minres",
   "mlintrpt",
   "mmfileinfo",
@@ -730,6 +740,7 @@
   "movie2avi",
   "multibandread",
   "multibandwrite",
+  "NaT",
   "native2unicode",
   "nccreate",
   "ncdisp",
@@ -739,6 +750,7 @@
   "ncwrite",
   "ncwriteatt",
   "ncwriteschema",
+  "nearestNeighbor",
   "netcdf",
   "noanimate",
   "notebook",
@@ -750,9 +762,6 @@
   "ode23s",
   "ode23t",
   "ode23tb",
-  "ode45",
-  "odeget",
-  "odeset",
   "odextend",
   "openfig",
   "opengl",
@@ -762,6 +771,7 @@
   "outerjoin",
   "padecoef",
   "parseSoapResponse",
+  "partition",
   "pathtool",
   "pcode",
   "pdepe",
@@ -769,6 +779,7 @@
   "plotbrowser",
   "plotedit",
   "plottools",
+  "pointLocation",
   "printdlg",
   "printopt",
   "printpreview",
@@ -779,6 +790,7 @@
   "psi",
   "publish",
   "quad2d",
+  "RandStream",
   "rbbox",
   "readtable",
   "reducepatch",
@@ -798,6 +810,7 @@
   "showplottool",
   "smooth3",
   "snapnow",
+  "splitapply",
   "ss2tf",
   "stack",
   "standardizeMissing",
@@ -824,9 +837,12 @@
   "tfqmr",
   "throw",
   "throwAsCaller",
+  "Tiff",
   "timeit",
+  "timeofday",
   "timer",
   "timeseries",
+  "timezones",
   "todatenum",
   "toolboxdir",
   "triangulation",
@@ -853,12 +869,17 @@
   "userpath",
   "values",
   "varfun",
+  "verctrl",
   "verLessThan",
-  "verctrl",
+  "VideoReader",
+  "VideoWriter",
   "viewmtx",
   "visdiff",
   "volumebounds",
   "web",
+  "webread",
+  "websave",
+  "webwrite",
   "width",
   "winopen",
   "winqueryreg",
--- a/scripts/help/doc.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/help/doc.m	Thu Dec 10 12:50:06 2015 -0800
@@ -35,7 +35,7 @@
 ## Author: Soren Hauberg <soren@hauberg.org>
 ## Adapted-by: jwe
 
-function retval = doc (fname)
+function retval = doc (function_name)
 
   if (nargin == 0 || nargin == 1)
 
@@ -45,22 +45,22 @@
       ## Get the directory where the function lives.
       ## FIXME: Maybe we should have a better way of doing this?
 
-      if (ischar (fname))
-        ftype = exist (fname);
+      if (ischar (function_name))
+        ftype = exist (function_name);
       else
-        error ("doc: expecting argument to be a character string");
+        error ("doc: FUNCTION_NAME must be a string");
       endif
     else
-      fname = "";
+      function_name = "";
     endif
 
     ## if GUI is running, let it display the function
     if (isguirunning ())
-      __octave_link_show_doc__ (fname);
+      __octave_link_show_doc__ (function_name);
     else
 
       if (ftype == 2 || ftype == 3)
-        ffile = which (fname);
+        ffile = which (function_name);
       else
         ffile = "";
       endif
@@ -95,17 +95,17 @@
       cmd = sprintf ("\"%s\" --file \"%s\" --directory \"%s\"",
                      info_program (), info_file_name, info_dir);
 
-      have_fname = ! isempty (fname);
+      have_fname = ! isempty (function_name);
 
       if (have_fname)
-        status = system (sprintf ("%s --index-search \"%s\"", cmd, fname));
+        status = system (sprintf ("%s --index-search \"%s\"", cmd, function_name));
       endif
 
 
       if (! (have_fname && status == 0))
         status = system (cmd);
         if (status == 127)
-          warning ("unable to find info program '%s'", info_program ());
+          warning ("doc: unable to find info program '%s'", info_program ());
         endif
       endif
 
--- a/scripts/help/get_first_help_sentence.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/help/get_first_help_sentence.m	Thu Dec 10 12:50:06 2015 -0800
@@ -117,9 +117,9 @@
     ## Remove the @end ... that corresponds to the @def we removed above
     def1 = def_idx(1);
     space_idx = find (help_text == " ");
-    space_idx = space_idx (find (space_idx > def1, 1));
+    space_idx = space_idx(find (space_idx > def1, 1));
     bracket_idx = find (help_text == "{" | help_text == "}");
-    bracket_idx = bracket_idx (find (bracket_idx > def1, 1));
+    bracket_idx = bracket_idx(find (bracket_idx > def1, 1));
     if (isempty (space_idx) && isempty (bracket_idx))
       error ("get_first_help_sentence: couldn't parse texinfo");
     endif
--- a/scripts/help/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/help/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,25 +1,36 @@
-FCN_FILE_DIRS += help
+FCN_FILE_DIRS += \
+  scripts/help \
+  scripts/help/private
 
-help_PRIVATE_FCN_FILES = \
-  help/private/__additional_help_message__.m \
-  help/private/__strip_html_tags__.m
+scripts_help_PRIVATE_FCN_FILES = \
+  scripts/help/private/__additional_help_message__.m \
+  scripts/help/private/__strip_html_tags__.m
 
-help_FCN_FILES = \
-  help/__gripe_missing_component__.m \
-  help/__makeinfo__.m \
-  help/__unimplemented__.m \
-  help/doc.m \
-  help/doc_cache_create.m \
-  help/get_first_help_sentence.m \
-  help/help.m \
-  help/lookfor.m \
-  help/print_usage.m \
-  help/type.m \
-  help/which.m \
-  $(help_PRIVATE_FCN_FILES)
+scripts_help_FCN_FILES = \
+  scripts/help/__gripe_missing_component__.m \
+  scripts/help/__makeinfo__.m \
+  scripts/help/__unimplemented__.m \
+  scripts/help/doc.m \
+  scripts/help/doc_cache_create.m \
+  scripts/help/get_first_help_sentence.m \
+  scripts/help/help.m \
+  scripts/help/lookfor.m \
+  scripts/help/print_usage.m \
+  scripts/help/type.m \
+  scripts/help/which.m
 
-FCN_FILES += $(help_FCN_FILES)
+scripts_helpdir = $(fcnfiledir)/help
+
+scripts_help_DATA = $(scripts_help_FCN_FILES)
+
+scripts_help_privatedir = $(fcnfiledir)/help/private
+
+scripts_help_private_DATA = $(scripts_help_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += help/PKG_ADD
+FCN_FILES += \
+  $(scripts_help_FCN_FILES) \
+  $(scripts_help_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += help/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/help/PKG_ADD
+
+DIRSTAMP_FILES += scripts/help/$(octave_dirstamp)
--- a/scripts/help/print_usage.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/help/print_usage.m	Thu Dec 10 12:50:06 2015 -0800
@@ -116,9 +116,9 @@
     for k = 1:length (def_idx)
       endl = endl_idx(find (endl_idx > def_idx(k), 1));
       if (isempty (endl))
-        buffer = strcat (buffer, help_text (def_idx(k):end), "\n");
+        buffer = [buffer, help_text(def_idx(k):end), "\n"];
       else
-        buffer = strcat (buffer, help_text (def_idx(k):endl));
+        buffer = [buffer, help_text(def_idx(k):endl)];
       endif
     endfor
   else
--- a/scripts/help/private/__strip_html_tags__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/help/private/__strip_html_tags__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -77,6 +77,6 @@
   endfor
 
   ## Actually remove the elements
-  text = text (keep);
+  text = text(keep);
 endfunction
 
--- a/scripts/help/type.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/help/type.m	Thu Dec 10 12:50:06 2015 -0800
@@ -97,6 +97,19 @@
       txt = sprintf ("%s is a dynamically-linked function", name);
     elseif (e == 5)
       txt = sprintf ("%s is a built-in function", name);
+    elseif (e == 103)
+      contents = __get_cmdline_fcn_txt__ (name);
+      if (isempty (contents))
+        txt = sprintf ("%s is a command-line function with no definition",
+                       name);
+      else
+        if (quiet)
+          txt = contents;
+        else
+          txt = sprintf ("%s is the command-line function:\n\n%s",
+                         name, contents);
+        endif
+      endif
     elseif (any (strcmp (__operators__ (), name)))
       txt = sprintf ("%s is an operator", name);
     elseif (any (strcmp (__keywords__ (), name)))
--- a/scripts/image/autumn.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/autumn.m	Thu Dec 10 12:50:06 2015 -0800
@@ -56,8 +56,9 @@
 
 
 %!demo
-%! ## Show the 'autumn' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (autumn (64));
-
+%! ## Show the 'autumn' colormap profile and as an image
+%! cmap = autumn (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/bone.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/bone.m	Thu Dec 10 12:50:06 2015 -0800
@@ -83,8 +83,9 @@
 
 
 %!demo
-%! ## Show the 'bone' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (bone (64));
-
+%! ## Show the 'bone' colormap profile and as an image
+%! cmap = bone (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/cmpermute.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/cmpermute.m	Thu Dec 10 12:50:06 2015 -0800
@@ -53,7 +53,7 @@
     error ("cmpermute: X must be an indexed image");
   endif
 
-  if (! iscolormap (map))
+  if (! iscolormap (map) || min (map(:)) < 0 || max (map(:)) > 1)
     error ("cmpermute: MAP must be a valid colormap");
   endif
 
--- a/scripts/image/cmunique.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/cmunique.m	Thu Dec 10 12:50:06 2015 -0800
@@ -67,7 +67,7 @@
 
   if (nargin == 2)
     ## (X, map) case
-    if (! iscolormap (map))
+    if (! iscolormap (map) || min (map(:)) < 0 || max (map(:)) > 1)
       error ("cmunique: MAP must be a valid colormap");
     endif
     [newmap,i,j] = unique (map, "rows");  # calculate unique colormap
--- a/scripts/image/colormap.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/colormap.m	Thu Dec 10 12:50:06 2015 -0800
@@ -37,7 +37,7 @@
 ## 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{viridis} map with 64 entries).  The default colormap is returned.
 ##
 ## The map may also be specified by a string, @qcode{"@var{map_name}"}, where
 ## @var{map_name} is the name of a function that returns a colormap.
@@ -52,7 +52,7 @@
 ## colormaps.  The options @qcode{"register"} and @qcode{"unregister"}
 ## add or remove the colormap @var{name} from this list.
 ##
-## @seealso{jet}
+## @seealso{viridis}
 ## @end deftypefn
 
 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
@@ -79,7 +79,7 @@
     map = varargin{1};
     if (ischar (map))
       if (strcmp (map, "default"))
-        map = jet (64);
+        map = viridis (64);
       elseif (strcmp (map, "list"))
         cmap = map_list;
         return;
@@ -132,9 +132,9 @@
 %! ## Create an image for displaying a colormap
 %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
 %! axis ([1, 64, 0, 1], "ticy", "xy");
-%! ## Show 'jet' colormap
-%! colormap (jet (64));
-%! title "colormap (jet (64))"
+%! ## Show 'viridis' colormap
+%! colormap (viridis (64));
+%! title "colormap (viridis (64))"
 %! disp ("Press a key to continue");
 %! pause ();
 %! ## Show 'colorcube' colormap
@@ -152,7 +152,7 @@
 %!   cmap = (get (gcf, "colormap"));
 %!   assert (cmap, cmaptst);
 %!   colormap ("default");
-%!   assert (colormap (), jet (64));
+%!   assert (colormap (), viridis (64));
 %!   colormap ("ocean");
 %!   assert (colormap, ocean (64));
 %! unwind_protect_cleanup
--- a/scripts/image/cool.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/cool.m	Thu Dec 10 12:50:06 2015 -0800
@@ -55,8 +55,9 @@
 
 
 %!demo
-%! ## Show the 'cool' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (cool (64));
-
+%! ## Show the 'cool' colormap profile and as an image
+%! cmap = cool (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/copper.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/copper.m	Thu Dec 10 12:50:06 2015 -0800
@@ -58,8 +58,9 @@
 
 
 %!demo
-%! ## Show the 'copper' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (copper (64));
-
+%! ## Show the 'copper' colormap profile and as an image
+%! cmap = copper (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/cubehelix.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/cubehelix.m	Thu Dec 10 12:50:06 2015 -0800
@@ -62,7 +62,7 @@
 
     fract = ((0:n-1) / (n-1))';
     angle = 2 * pi * (start/3 + 1 + rots*fract);
-    fract = fract .^ gamma;
+    fract .^= gamma;
     amp   = hue * fract .* (1-fract) /2;
     map   = fract + amp .* ([cos(angle) sin(angle)] * coeff);
 
@@ -79,9 +79,12 @@
 endfunction
 
 
+## A better demo of this colormap would be a 3d plot in ntsc instead of
+## rgb values.  That would really show what this colormap is about.
 %!demo
-%! subplot (1, 2, 1)
-%! rgbplot (cubehelix (256), "composite")
-%! subplot (1, 2, 2)
-%! rgbplot (cubehelix (256))
-
+%! ## Show the 'cubehelix' colormap profile and as an image
+%! cmap = cubehelix (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/flag.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/flag.m	Thu Dec 10 12:50:06 2015 -0800
@@ -53,8 +53,9 @@
 
 
 %!demo
-%! ## Show the 'flag' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (flag (64));
-
+%! ## Show the 'flag' colormap profile and as an image
+%! cmap = flag (12);  # 4 colours, therefore cycle 3 times
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/gray.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/gray.m	Thu Dec 10 12:50:06 2015 -0800
@@ -56,8 +56,9 @@
 
 
 %!demo
-%! ## Show the 'gray' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (gray (64));
-
+%! ## Show the 'gray' colormap profile and as an image
+%! cmap = gray (16);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/hot.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/hot.m	Thu Dec 10 12:50:06 2015 -0800
@@ -71,8 +71,9 @@
 
 
 %!demo
-%! ## Show the 'hot' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (hot (64));
-
+%! ## Show the 'hot' colormap profile and as an image
+%! cmap = hot (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/hsv.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/hsv.m	Thu Dec 10 12:50:06 2015 -0800
@@ -57,9 +57,11 @@
 endfunction
 
 
+## A better demo of this colormap would be to plot the hsv values.
 %!demo
-%! ## Show the 'hsv' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (hsv (64));
-
+%! ## Show the 'hsv' colormap profile and as an image
+%! cmap = hsv (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/hsv2rgb.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/hsv2rgb.m	Thu Dec 10 12:50:06 2015 -0800
@@ -1,4 +1,5 @@
 ## Copyright (C) 1999-2015 Kai Habel
+## Copyright (C) 2015 Carnë Draug
 ##
 ## This file is part of Octave.
 ##
@@ -19,22 +20,41 @@
 ## -*- texinfo -*-
 ## @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.
+## Transform a colormap or image from HSV to RGB color space.
 ##
 ## 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.
+## (brightness) levels in a cylindrical coordinate system.  Hue is the
+## azimuth and describes the dominant color.  Saturation is the radial
+## distance and gives the amount of hue mixed into the color.  Value is
+## the height and is the amount of light in the color.
+##
+## The input can be both a colormap or RGB image.  In the case of floating
+## point input, values are expected to be on the [0 1] range.  In the case
+## of hue (azimuth), since the value corresponds to an angle,
+## @code{mod (h, 1)} is used.
 ##
-## A color in the RGB space consists of red, green, and blue intensities.
+## @example
+## @group
+## >> hsv2rgb ([0.5 1 1])
+## @result{} ans = 0 1 1
+##
+## >> hsv2rgb ([2.5 1 1])
+## @result{} ans = 0 1 1
+##
+## >> hsv2rgb ([3.5 1 1])
+## @result{} ans = 0 1 1
+## @end group
+## @end example
+##
+## Output class and size will be the same as input.
+##
 ## @seealso{rgb2hsv, ind2rgb, ntsc2rgb}
 ## @end deftypefn
 
 ## Author: Kai Habel <kai.habel@gmx.de>
 ## Adapted-by: jwe
 
-function rgb_map = hsv2rgb (hsv_map)
+function rgb = hsv2rgb (hsv)
 
   ## Each color value x = (r,g,b) is calculated with
   ## x = (1-sat)*val+sat*val*f_x(hue)
@@ -45,73 +65,59 @@
     print_usage ();
   endif
 
-  cls = class (hsv_map);
-  if (! any (strcmp (cls, {"uint8", "uint16", "single", "double"})))
-    error ("hsv2rgb: invalid data type '%s'", cls);
-  elseif (isfloat (hsv_map) && (any (hsv_map(:) < 0) || any (hsv_map(:) > 1)))
-    error ("hsv2rgb: floating point images may only contain values between 0 and 1");
-  endif
+  [hsv, sz, is_im, is_nd] ...
+    = colorspace_conversion_input_check ("hsv2rgb", "HSV", hsv);
+
+  h = hsv(:,1);
+  s = hsv(:,2);
+  v = hsv(:,3);
 
-  ## If we have an image convert it into a color map.
-  if (isreal (hsv_map) && ndims (hsv_map) == 3)
-    is_image = true;
-    sz = size (hsv_map);
-    hsv_map = [hsv_map(:,:,1)(:), hsv_map(:,:,2)(:), hsv_map(:,:,3)(:)];
-    ## Convert to a double image.
-    if (isinteger (hsv_map))
-      low = double (intmin (cls));
-      high = double (intmax (cls));
-      hsv_map = (double (hsv_map) - low) / (high - low);
-    endif
-  else
-    is_image = false;
-  endif
+  ## Values of Saturation and Value should also be in the [0 1] range.  With
+  ## the exception of hue, values outside this range don't make any sense
+  ## in a cylindrical coordinate system but we must return something for
+  ## Matlab compatibility.  User case is when a function returns an hsv
+  ## image just slightly outside the range due to floating point rounding
+  ## errors.
 
-  if (! isreal (hsv_map) || columns (hsv_map) != 3 || issparse (hsv_map))
-    error ("hsv2rgb: input must be a matrix of size Nx3 or MxNx3");
-  endif
-
-  ## FIXME: Currently input is validated and an error results if values
-  ##        are outside range [0, 1].  We could also simply allow those values
-  ##        and re-instate this code to produce saturating semantics.
-  ## Trim map to range [0, 1]
-  ## hsv_map(hsv_map < 0) = 0;
-  ## hsv_map(hsv_map > 1) = 1;
-
-  h = hsv_map(:,1);
-  s = hsv_map(:,2);
-  v = hsv_map(:,3);
   ## Prefill rgb map with v*(1-s)
-  rgb_map = repmat (v .* (1 - s), 1, 3);
+  rgb = repmat (v .* (1 - s), 1, 3);
 
   ## red = hue-2/3 : green = hue : blue = hue-1/3
-  ## Apply modulo 1 for red and blue to keep within range [0, 1]
-  hue = [mod(h - 2/3, 1), h , mod(h - 1/3, 1)];
+  ## Apply modulo 1 to keep within range [0, 1]
+  hue = mod ([h-2/3  h  h-1/3], 1);
 
   ## factor s*v -> f
   f = repmat (s .* v, 1, 3);
 
   ## add s*v*hue-function to rgb map
-  rgb_map += f .* (6 * (hue < 1/6) .* hue
-             + (hue >= 1/6 & hue < 1/2)
-             + (hue >= 1/2 & hue < 2/3) .* (4 - 6 * hue));
+  rgb += f .* (6 * (hue < 1/6) .* hue
+               + (hue >= 1/6 & hue < 1/2)
+               + (hue >= 1/2 & hue < 2/3) .* (4 - 6 * hue));
 
-  ## FIXME: hsv2rgb does not preserve class of image.
-  ##        Should it also convert back to uint8, uint16 for integer images?
-  ## If input was an image, convert it back into one.
-  if (is_image)
-    rgb_map = reshape (rgb_map, sz);
-  endif
+  rgb = colorspace_conversion_revert (rgb, sz, is_im, is_nd);
 
 endfunction
 
-
 ## Test pure colors
+%!assert (hsv2rgb ([0 0 1]), [1 1 1])
+%!assert (hsv2rgb ([1 1 0]), [0 0 0])
 %!assert (hsv2rgb ([0 1 1]), [1 0 0])
 %!assert (hsv2rgb ([1 1 1]), [1 0 0])
 %!assert (hsv2rgb ([1/3 1 1]), [0 1 0])
 %!assert (hsv2rgb ([2/3 1 1]), [0 0 1])
 
+%!assert (hsv2rgb ([0 0.5 0.5]), hsv2rgb ([1 0.5 0.5]))
+
+## Not Matlab compatible (Matlab would return [1/2  1/12  1/12]) but
+## it's also invalid input.  This is, however, the same output as python
+## colorsys module.
+%!assert (hsv2rgb ([0.5 -0.5 0.5]), [0.75 0.5 0.5])
+
+## Not Matlab compatible.  Matlab returns NaN when hue is outside the
+## [0 1] range.  But since it's an angle, we can manage it.
+%!assert (hsv2rgb ([0 0.5 0.5]), hsv2rgb ([2 0.5 0.5]))
+%!assert (hsv2rgb ([0.5 0.5 0.5]), hsv2rgb ([2.5 0.5 0.5]), eps)
+
 %!test
 %! hsv_map = rand (64, 3);
 %! assert (rgb2hsv (hsv2rgb (hsv_map)), hsv_map, 1e-6);
@@ -120,10 +126,74 @@
 %! hsv_img = rand (64, 64, 3);
 %! assert (rgb2hsv (hsv2rgb (hsv_img)), hsv_img, 1e-6);
 
+## support sparse input
+%!assert (hsv2rgb (sparse ([0 0 1])), sparse ([1 1 1]))
+%!assert (hsv2rgb (sparse ([0 1 1])), sparse ([1 0 0]))
+%!assert (hsv2rgb (sparse ([1 1 1])), sparse ([1 0 0]))
+
 ## Test input validation
 %!error hsv2rgb ()
 %!error hsv2rgb (1,2)
 %!error <invalid data type> hsv2rgb ({1})
-%!error <must be a matrix of size Nx3> hsv2rgb (ones (2,2))
-%!error <must be a matrix of size Nx3> hsv2rgb (sparse (ones(1,3)))
+%!error <HSV must be a colormap or HSV image> hsv2rgb (ones (2,2))
+
+## Test ND input
+%!test
+%! hsv = rand (16, 16, 3, 5);
+%! rgb = zeros (size (hsv));
+%! for i = 1:5
+%!   rgb(:,:,:,i) = hsv2rgb (hsv(:,:,:,i));
+%! endfor
+%! assert (hsv2rgb (hsv), rgb)
+
+## Test output class and size for input images.
+## Most of the tests only test for colormap input.
+
+%!test
+%! rgb = hsv2rgb (rand (10, 10, 3));
+%! assert (class (rgb), "double")
+%! assert (size (rgb), [10 10 3])
+
+%!test
+%! rgb = hsv2rgb (rand (10, 10, 3, "single"));
+%! assert (class (rgb), "single")
+%! assert (size (rgb), [10 10 3])
+
+%!test
+%! rgb = (rand (10, 10, 3) * 3 ) - 0.5; # values outside range [0 1]
+%! rgb = hsv2rgb (rgb);
+%! assert (class (rgb), "double")
+%! assert (size (rgb), [10 10 3])
 
+%!test
+%! rgb = (rand (10, 10, 3, "single") * 3 ) - 0.5; # values outside range [0 1]
+%! rgb = hsv2rgb (rgb);
+%! assert (class (rgb), "single")
+%! assert (size (rgb), [10 10 3])
+
+%!test
+%! rgb = hsv2rgb (randi ([0 255], 10, 10, 3, "uint8"));
+%! assert (class (rgb), "double")
+%! assert (size (rgb), [10 10 3])
+
+%!test
+%! rgb = hsv2rgb (randi ([0 65535], 10, 10, 3, "uint16"));
+%! assert (class (rgb), "double")
+%! assert (size (rgb), [10 10 3])
+
+%!test
+%! rgb = hsv2rgb (randi ([-128 127], 10, 10, 3, "uint16"));
+%! assert (class (rgb), "double")
+%! assert (size (rgb), [10 10 3])
+
+%!test
+%! hsv_double = reshape ([2/3 1/3 1 0 1 1 1 0, 1 1 1 1], [2 2 3]);
+%! hsv_uint8  = reshape (uint8 ([170 85 255 0 255 255 255 0 255 255 255 255]),
+%!                       [2 2 3]);
+%! hsv_int16 = int16 (double (hsv_double * uint16 (65535)) -32768);
+%! expected = reshape ([0 0 1 1 0 1 0 1 1 0 0 1], [2 2 3]);
+%!
+%! assert (hsv2rgb (hsv_double), expected)
+%! assert (hsv2rgb (hsv_uint8), expected)
+%! assert (hsv2rgb (hsv_int16), expected)
+%! assert (hsv2rgb (single (hsv_double)), single (expected), eps (single (2)))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/image/im2double.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,130 @@
+## Copyright (C) 2007-2015 Søren Hauberg
+## Copyright (C) 2012-2015 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} {} im2double (@var{img})
+## @deftypefnx {Function File} {} im2double (@var{img}, "indexed")
+## Convert image to double precision.
+##
+## The conversion of @var{img} to double precision, is dependent
+## on the type of input image.  The following input classes are
+## supported:
+##
+## @table @samp
+## @item uint8, uint16, and int16
+## The range of values from the class is scaled to the interval [0 1].
+##
+## @item logical
+## True and false values are assigned a value of 0 and 1 respectively.
+##
+## @item single
+## Values are cast to double.
+##
+## @item double
+## Returns the same image.
+##
+## @end table
+##
+## If @var{img} is an indexed image, then the second argument should be
+## the string @qcode{"indexed"}.  If so, then @var{img} must either be
+## of floating point class, or unsigned integer class  and it will simply
+## be cast to double.  If it is an integer class, a +1 offset is applied.
+##
+## @seealso{double}
+## @end deftypefn
+
+## Author: Søren Hauberg <soren@hauberg.org>
+## Author: Carnë Draug <carandraug@octave.org>
+
+function img = im2double (img, im_type)
+  ## "normal" (non-indexed) images
+  if (nargin () == 1)
+    switch (class (img))
+      case "uint8",   img = double (img) / 255;
+      case "uint16",  img = double (img) / 65535;
+      case "int16",   img = (double (img) + 32768) / 65535;
+      case "single",  img = double (img);
+      case "logical", img = double (img);
+      case "double",  # do nothing
+      otherwise, error ("im2double: IMG is of unsupported class \"%s\"", class (img));
+    endswitch
+
+  ## indexed images
+  elseif (nargin () == 2)
+    if (! strcmpi (im_type, "indexed"))
+      error ("im2double: second input argument must be the string \"indexed\"");
+    elseif (any (isa (img, {"uint8", "uint16"})))
+      img = double (img) + 1;
+    elseif (isfloat (img) || isbool (img))
+      img = double (img);
+    else
+      ## Technically, it could also be of logical class and we do not
+      ## enforce positive integers for floating for Matlab compatibility.
+      ## Still, no need to tell that to the user.
+      error (["im2double: if IMG is indexed, then it must be positive " ...
+              "integer floating points, or unsigned integer class"]);
+    endif
+
+  else
+    print_usage ();
+  endif
+endfunction
+
+%!assert (im2double ([1 2 3]), [1 2 3])
+%!assert (im2double (single ([1 2 3])), [1 2 3])
+%!assert (im2double (uint8 ([0 127 128 255])), [0 127/255 128/255 1])
+%!assert (im2double (uint16 ([0 127 128 65535])), [0 127/65535 128/65535 1])
+%!assert (im2double (int16 ([-32768 -32767 -32766 32767])),
+%!                   [0 1/65535 2/65535 1])
+
+%!assert (im2double (uint8 ([0 1 255]), "indexed"), [1 2 256])
+%!assert (im2double (uint16 ([0 1 2557]), "indexed"), [1 2 2558])
+%!assert (im2double ([3 25], "indexed"), [3 25])
+%!assert (im2double (single ([3 25]), "indexed"), [3 25])
+
+## Test for ND input
+%!function test_im2double_nd (cls, low, high)
+%!  in = rand (2, 4, 2, 3, 2);
+%!  in *= high - low;
+%!  in += low;
+%!  in = cast (in, cls);
+%!  out = zeros (size (in));
+%!  for n = 1:12
+%!    out(:,:,n) = im2double (in(:,:,n));
+%!  endfor
+%!  assert (im2double (in), out)
+%!endfunction
+
+%!test
+%! test_im2double_nd ("double", 0, 1);
+%! test_im2double_nd ("single", 0, 1);
+%! test_im2double_nd ("uint8", 0, 255);
+%! test_im2double_nd ("uint16", 0, 6535);
+%! test_im2double_nd ("int16", -32768, 32767);
+
+## Test lack of input check for Matlab compatibility
+%!assert (im2double ([0 1 2], "indexed"), [0 1 2])
+%!assert (im2double ([0 -1 -2], "indexed"), [0 -1 -2])
+%!assert (im2double ([0 -1.5 -2], "indexed"), [0 -1.5 -2])
+%!assert (im2double ([0 -1.5 -2i], "indexed"), [0 -1.5 -2i])
+%!assert (im2double ([false true], "indexed"), [0 1])
+
+%!error <unsigned integer class> im2double (int16 ([17 8]), "indexed");
+%!error <unsigned integer class> im2double (int16 ([-7 8]), "indexed");
+%!error <must be the string "indexed"> im2double ([1 2 3], "non-indexed");
--- a/scripts/image/imformats.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/imformats.m	Thu Dec 10 12:50:06 2015 -0800
@@ -79,7 +79,7 @@
   persistent formats = default_formats ();
 
   if (nargin == 0 && nargout == 0)
-    error ("imformats: pretty print not yet implemented.");
+    pretty_print_formats (formats);
   elseif (nargin >= 1)
     if (isstruct (arg1))
       arrayfun (@is_valid_format, arg1);
@@ -281,6 +281,40 @@
   end_try_catch
 endfunction
 
+function pretty_print_formats (formats)
+  ## define header names (none should be shorter than 3 characters)
+  headers = {"Extension", "isa", "Info", "Read", "Write", "Alpha", "Description"};
+  cols_length = cellfun (@numel, headers);
+
+  ## Adjust the maximal length of the extensions column
+  extensions = cellfun (@strjoin, {formats.ext}, {", "},
+                        "UniformOutput", false);
+  cols_length(1) = max (max (cellfun (@numel, extensions)), cols_length(1));
+  headers{1} = postpad (headers{1}, cols_length(1), " ");
+
+  ## Print the headers
+  disp (strjoin (headers, " | "));
+  under_headers = cellfun (@(x) repmat ("-", 1, numel (x)), headers,
+                           "UniformOutput", false);
+  disp (strjoin (under_headers, "-+-"));
+
+  template = strjoin (arrayfun (@(x) sprintf ("%%-%is", x), cols_length,
+                                "UniformOutput", false), " | ");
+
+  ## Print the function handle for this things won't be a pretty table.  So
+  ## instead we replace them with "yes" or "no", based on the support it has.
+  yes_no_cols = cat (2, {formats.isa}(:), {formats.info}(:), {formats.read}(:),
+                     {formats.write}(:), {formats.alpha}(:));
+  empty = cellfun (@isempty, yes_no_cols);
+  yes_no_cols(empty) = "no";
+  yes_no_cols(! empty) = "yes";
+
+  descriptions = {formats.description};
+  table = cat (2, extensions(:), yes_no_cols, descriptions(:));
+  printf ([template "\n"], table'{:});
+
+endfunction
+
 ## When imread or imfinfo are called, the file must exist or the
 ## function defined by imformats will never be called.  Because
 ## of this, we must create a file for the tests to work.
--- a/scripts/image/imread.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/imread.m	Thu Dec 10 12:50:06 2015 -0800
@@ -108,7 +108,6 @@
 
 endfunction
 
-
 %!testif HAVE_MAGICK
 %! vpng = [ ...
 %!  137,  80,  78,  71,  13,  10,  26,  10,   0,   0, ...
@@ -140,8 +139,8 @@
 %! 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]));
 
-%!function [r, cmap, a] = write_and_read (w, varargin)
-%!  filename = [tempname() ".tif"];
+%!function [r, cmap, a] = write_and_read (w, f_ext, varargin)
+%!  filename = [tempname() "." f_ext];
 %!  unwind_protect
 %!    imwrite (w, filename);
 %!    [r, cmap, a] = imread (filename, varargin{:});
@@ -153,9 +152,9 @@
 ## test PixelRegion option
 %!testif HAVE_MAGICK
 %! w = randi (255, 100, 100, "uint8");
-%! [r, cmap, a] = write_and_read (w, "PixelRegion", {[50 70] [20 40]});
+%! [r, cmap, a] = write_and_read (w, "tif", "PixelRegion", {[50 70] [20 40]});
 %! assert (r, w(50:70, 20:40))
-%! [r, cmap, a] = write_and_read (w, "PixelRegion", {[50 2 70] [20 3 40]});
+%! [r, cmap, a] = write_and_read (w, "tif", "PixelRegion", {[50 2 70] [20 3 40]});
 %! assert (r, w(50:2:70, 20:3:40))
 
 ## If a file does not exist, it's the job of imread to check the file
@@ -203,3 +202,12 @@
 %!   imformats (def_fmt);
 %! end_unwind_protect
 
+## Test for bug #41584 (some GM coders report saturated channels as binary)
+%!testif HAVE_MAGICK
+%! im = zeros ([16 16 3], "uint8");
+%! im(:,:,1) = 255;
+%! im(:,:,3) = repmat (0:16:255, [16 1]);
+%! [r, cmap, a] = write_and_read (im, "png");
+%! assert (class (r), "uint8");
+%! assert (isempty (cmap))
+%! assert (isempty (a))
--- a/scripts/image/imshow.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/imshow.m	Thu Dec 10 12:50:06 2015 -0800
@@ -35,7 +35,7 @@
 ## If @var{map} is a valid color map, the image will be shown as an indexed
 ## image using the supplied color map.
 ##
-## If a file name is given instead of an image, the file will be read and shown.
+## If a filename is given instead of an image, the file will be read and shown.
 ##
 ## If given, the parameter @var{string_param1} has value @var{value1}.
 ## @var{string_param1} can be any of the following:
@@ -77,6 +77,7 @@
   truecolor = false;
   indexed = false;
   xdata = ydata = [];
+  prop_val_args = {};
 
   ## Get the image.
   if (ischar (im))
@@ -102,7 +103,7 @@
       error ("imshow: TrueColor image must be uint8, uint16, double, or single");
     endif
   else
-    error ("imshow: expecting MxN or MxNx3 matrix for image");
+    error ("imshow: image must be MxN or MxNx3 matrix");
   endif
 
   narg = 1;
@@ -113,7 +114,7 @@
         display_range = arg;
       elseif (columns (arg) == 3)
         indexed = true;
-        if (iscolormap (arg))
+        if (iscolormap (arg) && min (arg) >= 0 || max (arg) <= 1)
           colormap (arg);
         else
           error ("imshow: invalid colormap MAP");
@@ -123,19 +124,29 @@
       endif
     elseif (ischar (arg))
       switch (tolower (arg))
+        case "border"
+          warning ("imshow: border argument is not implemented");
+          narg += 1;
         case "colormap"
           map = varargin{narg++};
-          if (iscolormap (map))
+          if (iscolormap (map) && min (map) >= 0 || max (map) <= 1)
             colormap (map);
           else
             error ("imshow: invalid colormap");
           endif
         case "displayrange"
           display_range = varargin{narg++};
+        case {"initialmagnification"}
+          warning ("imshow: zoom argument ignored -- use GUI features");
+          narg += 1;
         case "parent"
-          warning ("imshow: parent argument is not implemented");
-        case {"truesize", "initialmagnification"}
-          warning ("image: zoom argument ignored -- use GUI features");
+          prop_val_args(end+(1:2)) = {"parent", varargin{narg++}};
+          if (! isaxes (prop_val_args{end}))
+            error ("imshow: parent must be an axes handle");
+          endif
+        case "reduce"
+          warning ("imshow: reduce argument is not implemented");
+          narg += 1;
         case "xdata"
           xdata = varargin{narg++};
           if (! isvector (xdata))
@@ -150,7 +161,7 @@
           ydata = [ydata(1) ydata(end)];
         otherwise
           warning ("imshow: unrecognized property %s", arg);
-          narg++;
+          narg += 1;
       endswitch
     else
       error ("imshow: argument number %d is invalid", narg);
@@ -187,25 +198,14 @@
     endif
   endif
 
-  ## FIXME: Commented out 2014/05/01.  imagesc and 'clim' will automatically
-  ## take care of displaying out-of-range data clamped to the limits.
-  ## Eventually, this can be deleted if no problems arise.
-  ## Clamp the image to the range boundaries
-  ##if (! (truecolor || indexed || islogical (im)))
-  ##  low = display_range(1);
-  ##  high = display_range(2);
-  ##  im(im < low) = low;
-  ##  im(im > high) = high;
-  ##endif
-
   if (truecolor || indexed)
-    htmp = image (xdata, ydata, im);
+    htmp = image (xdata, ydata, im, prop_val_args{:});
   else
-    htmp = imagesc (xdata, ydata, im, display_range);
-    set (gca (), "clim", display_range);
+    htmp = imagesc (xdata, ydata, im, display_range, prop_val_args{:});
+    set (get (htmp, "parent"), "clim", display_range);
   endif
-  set (gca (), "visible", "off", "view", [0, 90],
-               "ydir", "reverse", "layer", "top");
+  set (get (htmp, "parent"), "visible", "off", "view", [0, 90],
+                             "ydir", "reverse", "layer", "top");
   axis ("image");
 
   if (nargout > 0)
@@ -257,14 +257,15 @@
 %!error <IM must be an image> imshow ({"cell"})
 %!error <TrueColor image must be uint8> imshow (ones (3,3,3, "uint32"))
 %!error <TrueColor image must be uint8> imshow (ones (3,3,3, "int16"))
-%!error <expecting MxN or MxNx3 matrix> imshow (ones (4,4,4))
+%!error <image must be MxN or MxNx3 matrix> imshow (ones (4,4,4))
 
 %!test
 %! hf = figure ("visible", "off");
 %! unwind_protect
-%!   fail ("imshow ([1,1], [2 0 0])", "invalid colormap MAP");
+%!   fail ("imshow ([1,1], [2 0 0])", "all MAP values must be in the range");
 %!   fail ("imshow ([1,1], [1 0 0 0])", "argument number 2 is invalid");
-%!   fail ('imshow ([1,1], "colormap", [2 0 0])', "invalid colormap");
+%!   fail ('imshow ([1,1], "colormap", [2 0 0])', "all MAP values must be in the range");
+%!   fail ('imshow ([1,1], "parent", -1)', "must be an axes handle");
 %!   fail ('imshow ([1,1], "xdata", ones (2,2))', "xdata must be a vector");
 %!   fail ('imshow ([1,1], "ydata", ones (2,2))', "ydata must be a vector");
 %!   fail ('imshow ([1,1], "foobar")', "warning", "unrecognized property foobar")
--- a/scripts/image/imwrite.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/imwrite.m	Thu Dec 10 12:50:06 2015 -0800
@@ -46,6 +46,12 @@
 ## multipage image, the size of the 4th dimension must also match and the third
 ## dimension must be a singleton.  By default, image will be completely opaque.
 ##
+## @item Compression
+## Compression to use one the image.  Can be one of the following: "none"
+## (default), "bzip", "fax3", "fax4", "jpeg", "lzw", "rle", or "deflate".
+## Note that not all compression types are available for all image formats
+## in which it defaults to your @nospell{Magick} library.
+##
 ## @item DelayTime
 ## For formats that accept animations (such as GIF), controls for how long a
 ## frame is displayed until it moves to the next one.  The value must be scalar
@@ -200,3 +206,32 @@
 %! [g] = write_and_read (".jpeg", gray, "quality", 100);
 %! assert (g, gray)
 
+%!function [compression] = get_bmp_compression (ext, cmap = [], varargin)
+%!  gray = repmat (uint8 (0:255), 100, 1);
+%!  filename = [tempname() ext];
+%!  unwind_protect
+%!    if (isempty (cmap))
+%!      imwrite (gray, filename, varargin{1:end});
+%!    else
+%!      imwrite (gray, cmap, filename, varargin{1:end});
+%!    endif
+%!    fid = fopen (filename);
+%!    unwind_protect
+%!      compression = fread (fid, 31)(end);
+%!    unwind_protect_cleanup
+%!      fclose (fid);
+%!    end_unwind_protect
+%!  unwind_protect_cleanup
+%!    unlink (filename);
+%!  end_unwind_protect
+%!endfunction
+
+## BMP images must be saved uncompressed by default (bug #45565)
+%!testif HAVE_MAGICK
+%! assert (get_bmp_compression ("", [], "BMP"), 0)
+%! assert (get_bmp_compression ("", [], "bmp"), 0)
+%! assert (get_bmp_compression (".BMP"), 0)
+%! assert (get_bmp_compression (".bmp"), 0)
+%! assert (get_bmp_compression (".bmp", [], "bmp"), 0)
+%! assert (get_bmp_compression ("", gray (256), "bmp"), 0)
+%! assert (get_bmp_compression (".bmp", gray (256), "Compression", "rle"), 1)
--- a/scripts/image/iscolormap.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/iscolormap.m	Thu Dec 10 12:50:06 2015 -0800
@@ -20,9 +20,14 @@
 ## @deftypefn {Function File} {} iscolormap (@var{cmap})
 ## Return true if @var{cmap} is a colormap.
 ##
-## A colormap is a real matrix with @var{n} rows and 3 columns.  Each row
-## represents a single color.  The columns contain red, green, and blue
-## intensities respectively.  All entries must be between 0 and 1 inclusive.
+## A colormap is a real matrix, of class single or double, with 3 columns.
+## Each row represents a single color.  The 3 columns contain red, green,
+## and blue intensities respectively.
+##
+## All values in a colormap should be in the [0 1] range but this is not
+## enforced.  Each function must decide what to do for values outside this
+## range.
+##
 ## @seealso{colormap, rgbplot}
 ## @end deftypefn
 
@@ -34,19 +39,14 @@
     print_usage;
   endif
 
-  retval = (isnumeric (cmap) && isreal (cmap) && ndims (cmap) == 2
-            && columns (cmap) == 3 && isa (cmap, "double")
-            && min (cmap(:)) >= 0 && max (cmap(:)) <= 1);
+  retval = (isnumeric (cmap) && isreal (cmap)
+            && ndims (cmap) == 2 && columns (cmap) == 3
+            && isfloat (cmap));
 
 endfunction
 
-
 %!assert (iscolormap (jet (64)))
 %!assert (iscolormap ({0 1 0}), false)
 %!assert (iscolormap ([0 1i 0]), false)
 %!assert (iscolormap (ones (3,3,3)), false)
 %!assert (iscolormap (ones (3,4)), false)
-%!assert (iscolormap (single (jet (64))), false)
-%!assert (iscolormap ([0 0 -2]), false)
-%!assert (iscolormap ([0 0 2]), false)
-
--- a/scripts/image/jet.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/jet.m	Thu Dec 10 12:50:06 2015 -0800
@@ -49,7 +49,7 @@
     nel = ceil (n/4);           # number of elements
     idx1 = ceil (3/8 * n) + 1;  # ~3/8*n for large n
     if (mod (n, 8) == 2)
-      idx1++;
+      idx1 += 1;
     endif
     idx2 = idx1 + nel - 1;      # ~5/8*n for large n
     idx3 = min (idx2 + nel, n); # ~7/8*n for large n
@@ -90,8 +90,9 @@
 
 
 %!demo
-%! ## Show the 'jet' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (jet (64));
-
+%! ## Show the 'jet' colormap profile and as an image
+%! cmap = jet (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/lines.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/lines.m	Thu Dec 10 12:50:06 2015 -0800
@@ -53,8 +53,9 @@
 
 
 %!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));
-
+%! ## Show the 'lines' colormap profile and as an image
+%! cmap = lines (21); # default has 7 colours, therefore cycle 3 times
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,64 +1,79 @@
-FCN_FILE_DIRS += image
+FCN_FILE_DIRS += \
+  scripts/image \
+  scripts/image/private
 
-image_PRIVATE_FCN_FILES = \
-  image/private/__imfinfo__.m \
-  image/private/__imread__.m \
-  image/private/__imwrite__.m \
-  image/private/imageIO.m \
-  image/private/imwrite_filename.m \
-  image/private/ind2x.m
+scripts_image_PRIVATE_FCN_FILES = \
+  scripts/image/private/__imfinfo__.m \
+  scripts/image/private/__imread__.m \
+  scripts/image/private/__imwrite__.m \
+  scripts/image/private/colorspace_conversion_input_check.m \
+  scripts/image/private/colorspace_conversion_revert.m \
+  scripts/image/private/imageIO.m \
+  scripts/image/private/imwrite_filename.m \
+  scripts/image/private/ind2x.m
 
-image_FCN_FILES = \
-  image/autumn.m \
-  image/bone.m \
-  image/brighten.m \
-  image/cmpermute.m \
-  image/cmunique.m \
-  image/colorcube.m \
-  image/colormap.m \
-  image/contrast.m \
-  image/cool.m \
-  image/copper.m \
-  image/cubehelix.m \
-  image/flag.m \
-  image/gray.m \
-  image/gray2ind.m \
-  image/hot.m \
-  image/hsv.m \
-  image/hsv2rgb.m \
-  image/iscolormap.m \
-  image/image.m \
-  image/imagesc.m \
-  image/imfinfo.m \
-  image/imformats.m \
-  image/imread.m \
-  image/imshow.m \
-  image/imwrite.m \
-  image/ind2gray.m \
-  image/ind2rgb.m \
-  image/jet.m \
-  image/lines.m \
-  image/ntsc2rgb.m \
-  image/ocean.m \
-  image/pink.m \
-  image/prism.m \
-  image/rainbow.m \
-  image/rgb2hsv.m \
-  image/rgb2ind.m \
-  image/rgb2ntsc.m \
-  image/rgbplot.m \
-  image/spinmap.m \
-  image/spring.m \
-  image/summer.m \
-  image/white.m \
-  image/winter.m \
-  $(image_PRIVATE_FCN_FILES)
+scripts_image_FCN_FILES = \
+  scripts/image/autumn.m \
+  scripts/image/bone.m \
+  scripts/image/brighten.m \
+  scripts/image/cmpermute.m \
+  scripts/image/cmunique.m \
+  scripts/image/colorcube.m \
+  scripts/image/colormap.m \
+  scripts/image/contrast.m \
+  scripts/image/cool.m \
+  scripts/image/copper.m \
+  scripts/image/cubehelix.m \
+  scripts/image/flag.m \
+  scripts/image/gray.m \
+  scripts/image/gray2ind.m \
+  scripts/image/hot.m \
+  scripts/image/hsv.m \
+  scripts/image/hsv2rgb.m \
+  scripts/image/iscolormap.m \
+  scripts/image/im2double.m \
+  scripts/image/image.m \
+  scripts/image/imagesc.m \
+  scripts/image/imfinfo.m \
+  scripts/image/imformats.m \
+  scripts/image/imread.m \
+  scripts/image/imshow.m \
+  scripts/image/imwrite.m \
+  scripts/image/ind2gray.m \
+  scripts/image/ind2rgb.m \
+  scripts/image/jet.m \
+  scripts/image/lines.m \
+  scripts/image/ntsc2rgb.m \
+  scripts/image/ocean.m \
+  scripts/image/pink.m \
+  scripts/image/prism.m \
+  scripts/image/rainbow.m \
+  scripts/image/rgb2hsv.m \
+  scripts/image/rgb2ind.m \
+  scripts/image/rgb2ntsc.m \
+  scripts/image/rgbplot.m \
+  scripts/image/spinmap.m \
+  scripts/image/spring.m \
+  scripts/image/summer.m \
+  scripts/image/viridis.m \
+  scripts/image/white.m \
+  scripts/image/winter.m
 
-IMAGES += \
-  image/default.img
+SCRIPTS_IMAGES += \
+  scripts/image/default.img
+
+scripts_imagedir = $(fcnfiledir)/image
+
+scripts_image_DATA = $(scripts_image_FCN_FILES)
+
+scripts_image_privatedir = $(fcnfiledir)/image/private
 
-FCN_FILES += $(image_FCN_FILES)
+scripts_image_private_DATA = $(scripts_image_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += image/PKG_ADD
+FCN_FILES += \
+  $(scripts_image_FCN_FILES) \
+  $(scripts_image_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += image/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/image/PKG_ADD
+
+DIRSTAMP_FILES += scripts/image/$(octave_dirstamp)
--- a/scripts/image/ntsc2rgb.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/ntsc2rgb.m	Thu Dec 10 12:50:06 2015 -0800
@@ -45,22 +45,23 @@
     print_usage ();
   endif
 
-  if (! isa (yiq, "double"))
-    error ("ntsc2rgb: YIQ must be of type double");
+  ## Unlike other colorspace conversion functions, we do not accept
+  ## integers as valid input.  We check this before
+  ## colorspace_conversion_input_check() which is general and would
+  ## convert integers to double assuming a [0 1] interval range.
+  ## The reason for not supporting integers here is that there's no
+  ## common such conversion.  If we were to support a conversion
+  ## the most reasonable definition would be to convert the YIQ
+  ## from their integer range into the ranges:
+  ##    Y = [ 0      1.106]
+  ##    I = [-0.797  0.587]
+  ##    Q = [-0.322  0.426]
+  ## See https://savannah.gnu.org/patch/?8709#comment11
+  if (! isfloat (yiq))
+    error ("ntsc2rgb: YIQ must be of floating point class");
   endif
-
-  ## If we have an image convert it into a color map.
-  if (isnumeric (yiq) && ndims (yiq) == 3)
-    is_image = true;
-    sz = size (yiq);
-    yiq = [yiq(:,:,1)(:), yiq(:,:,2)(:), yiq(:,:,3)(:)];
-  else
-    is_image = false;
-  endif
-
-  if (! isreal (yiq) || columns (yiq) != 3 || issparse (yiq))
-    error ("ntsc2rgb: input must be a matrix of size Nx3 or NxMx3");
-  endif
+  [yiq, sz, is_im, is_nd] ...
+    = colorspace_conversion_input_check ("ntsc2rgb", "YIQ", yiq);
 
   ## Conversion matrix constructed from 'inv (rgb2ntsc matrix)'.
   ## See programming notes in rgb2ntsc.m.  Note: Matlab matrix for inverse
@@ -70,16 +71,23 @@
   trans = [ 1.0,      1.0,      1.0;
             0.95617, -0.27269, -1.10374;
             0.62143, -0.64681,  1.70062 ];
-
   rgb = yiq * trans;
+  ## Note that if the input is of class single, we also return an image
+  ## of class single.  This is Matlab incompatible by design, since
+  ## Matlab always returning class double, is a Matlab bug (see patch #8709)
 
-  ## If input was an image, convert it back into one.
-  if (is_image)
-    rgb = reshape (rgb, sz);
-  endif
+  ## truncating / scaling of double rgb values for Matlab compatibility
+  rgb = max (0, rgb);
+  idx = any (rgb > 1, 2);
+  rgb(idx,:) = rgb(idx,:) ./ max (rgb(idx,:), [], 2);
 
+  rgb = colorspace_conversion_revert (rgb, sz, is_im, is_nd);
 endfunction
 
+%!shared trans
+%! trans = [ 1.0,      1.0,      1.0;
+%!          0.95617, -0.27269, -1.10374;
+%!          0.62143, -0.64681,  1.70062 ];
 
 ## Test pure R, G, B colors
 %!assert (ntsc2rgb ([.299  .596  .211]), [1 0 0], 1e-5)
@@ -94,9 +102,85 @@
 %! rgb_img = rand (64, 64, 3);
 %! assert (ntsc2rgb (rgb2ntsc (rgb_img)), rgb_img, 1e-3);
 
+## test cropping of rgb output
+%!assert (ntsc2rgb ([1.5 0 0]), [1   1   1]);
+
+## Test scaling of output.  After conversion, cut of negative values
+## and scaling of all the others relative to the maximum above 1.
+%!test
+%! ntsc = [0.4229  0.0336  0.7184];
+%! rgb = ntsc * trans;    # [0.9014  -0.0509  1.6075]
+%! rgb(1) /= rgb(3); # scaled based on the maximum
+%! rgb(2) = 0; # cut to 0
+%! rgb(3) = 1; # cut to 1
+%! assert (ntsc2rgb (ntsc), rgb)
+
+## test scaling when conversion has more than one value above 1
+## (check that it does pick the maximum)
+%!test
+%! ntsc = [0.8229  0.3336  0.7184];
+%! rgb = ntsc * trans;    # [1.58831   0.26726   1.67642]
+%! rgb /= rgb(3);
+%! assert (ntsc2rgb (ntsc), rgb)
+
+## check scaling for more than 1 row
+%!test
+%! ntsc = [0.4229  0.0336  0.7184
+%!         0.8229  0.3336  0.7184];
+%! rgb = ntsc * trans; # [0.9014  -0.0509  1.6075;  1.58831  0.26726  1.67642]
+%! rgb(1,1) /= rgb(1,3);
+%! rgb(1,2) = 0;
+%! rgb(1,3) = 1;
+%! rgb(2,:) /= rgb(2,3);
+%! assert (ntsc2rgb (ntsc), rgb)
+
 ## Test input validation
 %!error ntsc2rgb ()
 %!error ntsc2rgb (1,2)
-%!error <YIQ must be of type double> ntsc2rgb (uint8 (1))
-%!error <must be a matrix of size Nx3 or NxMx3> ntsc2rgb (ones (2,2))
+%!error <YIQ must be of floating point class> ntsc2rgb (uint8 (1))
+%!error <YIQ must be a colormap or YIQ image> ntsc2rgb (ones (2,2))
+%!error <YIQ must be of floating point class> ntsc2rgb (ones ([10 10 3], "uint8"))
+%!error <YIQ must be of floating point class> ntsc2rgb (ones ([10 10 3], "uint16"))
+%!error <YIQ must be of floating point class> ntsc2rgb (ones ([10 10 3], "int16"))
+
+## Test ND input
+%!test
+%! yiq = rand (16, 16, 3, 5);
+%! rgb = zeros (size (yiq));
+%! for i = 1:5
+%!   rgb(:,:,:,i) = ntsc2rgb (yiq(:,:,:,i));
+%! endfor
+%! assert (ntsc2rgb (yiq), rgb)
+
+## Test output class and size for input images.
+## Most of the tests only test for colormap input.
+
+%!test
+%! rgb = ntsc2rgb (rand (10, 10, 3));
+%! assert (class (rgb), "double")
+%! assert (size (rgb), [10 10 3])
 
+%!test
+%! rgb = ntsc2rgb (rand (10, 10, 3, "single"));
+%! assert (class (rgb), "single")
+%! assert (size (rgb), [10 10 3])
+
+%!test
+%! ntsc = (rand (10, 10, 3) * 3 ) - 0.5; # values outside range [0 1]
+%! rgb = ntsc2rgb (ntsc);
+%! assert (class (rgb), "double")
+%! assert (size (rgb), [10 10 3])
+
+%!test
+%! ntsc = (rand (10, 10, 3, "single") * 3 ) - 0.5; # values outside range [0 1]
+%! rgb = ntsc2rgb (ntsc);
+%! assert (class (rgb), "single")
+%! assert (size (rgb), [10 10 3])
+
+%!test
+%! ntsc_double = reshape ([.299 .587 .114 0 .596 -.274 -.322 0 .211 -.523 .312 0],
+%!                        [2 2 3]);
+%! expected = reshape ([1 0 0 0 0 1 0 0 0 0 1 0], [2 2 3]);
+%!
+%! assert (ntsc2rgb (ntsc_double), expected, 1e-5)
+%! assert (ntsc2rgb (single (ntsc_double)), single (expected), 1e-5)
--- a/scripts/image/ocean.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/ocean.m	Thu Dec 10 12:50:06 2015 -0800
@@ -65,8 +65,9 @@
 
 
 %!demo
-%! ## Show the 'ocean' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (ocean (64));
-
+%! ## Show the 'ocean' colormap profile and as an image
+%! cmap = ocean (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/pink.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/pink.m	Thu Dec 10 12:50:06 2015 -0800
@@ -73,8 +73,9 @@
 
 
 %!demo
-%! ## Show the 'pink' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (pink (64));
-
+%! ## Show the 'pink' colormap profile and as an image
+%! cmap = pink (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/prism.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/prism.m	Thu Dec 10 12:50:06 2015 -0800
@@ -53,8 +53,9 @@
 
 
 %!demo
-%! ## Show the 'prism' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (prism (64));
-
+%! ## Show the 'prism' colormap profile and as an image
+%! cmap = prism (18); # 6 colours, therefore cycle 3 times
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/private/__imread__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/private/__imread__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -59,7 +59,7 @@
       error ("imread: IDX must be a numeric vector");
     endif
     options.index = varargin{offset};
-    offset++;
+    offset += 1;
   endif
 
   if (rem (numel (varargin) - offset + 1, 2) != 0)
--- a/scripts/image/private/__imwrite__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/private/__imwrite__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -46,7 +46,8 @@
                     "quality",   75,
                     "delaytime", ones (1, size (img, 4)) *500, # 0.5 seconds
                     "loopcount", 0, ## this is actually Inf
-                    "alpha",     cast ([], class (img)));
+                    "alpha",     cast ([], class (img)),
+                    "compression", "none");
 
   for idx = 1:2:numel (param_list)
 
@@ -67,6 +68,19 @@
                  param_list{idx});
         endif
 
+      case "compression"
+        options.compression = param_list{idx+1};
+        if (! ischar (options.compression))
+          error ("imwrite: value for %s option must be a string",
+                 param_list{idx});
+        endif
+        options.compression = tolower (options.compression);
+        if (! any (strcmp (options.compression, {"none", "bzip", "fax3", ...
+                                                 "fax4", "jpeg", "lzw", ...
+                                                 "rle", "deflate"})))
+          error ("imwrite: invalid compression `%s'", options.compression);
+        endif
+
       case "delaytime"
         options.delaytime = param_list{idx+1};
         if (! isnumeric (options.delaytime))
@@ -132,7 +146,7 @@
         if (isinf (options.loopcount))
           options.loopcount = 0;
         elseif (options.loopcount == 0 || options.loopcount == 1)
-          options.loopcount++;
+          options.loopcount += 1;
         endif
         options.loopcount = floor (options.loopcount);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/image/private/colorspace_conversion_input_check.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,75 @@
+## Copyright (C) 2015 Carnë Draug <carandraug+dev@gmail.com>
+##
+## 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/>.
+
+## Private function the functions that convert between color spaces, i.e.,
+## rgb2ntsc, rgb2hsv, hsv2rgb, and ntsc2rgb.  All of these functions need to
+## handle input in the same way.  The returned flags are meant to be handled
+## by the complementary private function colorspace_conversion_revert()
+
+function [in_arg, sz, is_im, is_nd] ...
+            = colorspace_conversion_input_check (func, arg_name, in_arg)
+
+  cls = class (in_arg);
+  sz = size (in_arg);
+
+  ## If we have an image convert it into a color map.
+  if (! iscolormap (in_arg))
+    if (! any (strcmp (cls, {"uint8", "int8", "int16", "uint16", ...
+                             "single", "double"})))
+      error ("%s: %s of invalid data type '%s'", func, arg_name, cls);
+    elseif (size (in_arg, 3) != 3)
+      error ("%s: %s must be a colormap or %s image", func, arg_name, arg_name);
+    elseif (! isreal (in_arg) || ! isnumeric (in_arg))
+      error ("%s: %s must be numeric and real", func, arg_name);
+    endif
+    is_im = true;
+
+    ## For floating point values, R, G and B should be in the [0 1] range,
+    ## otherwise they don't make any sense. We accept those values
+    ## anyways because we must return something for Matlab compatibility.
+    ## User case is when a function returns an RGB image just slightly outside
+    ## the range due to floating point rounding errors.
+
+    ## Allow for ND images, i.e., multiple images on the 4th dimension.
+    nd = ndims (in_arg);
+    if (nd == 3)
+      is_nd = false;
+    elseif (nd == 4)
+      is_nd = true;
+      in_arg = permute (in_arg, [1 2 4 3]);
+    elseif (nd > 4)
+      error ("%s: invalid %s with more than 4 dimensions", func, arg_name);
+    endif
+    in_arg = reshape (in_arg, [numel(in_arg)/3 3]);
+  else
+    is_im = false;
+    is_nd = false;
+  endif
+
+  ## Convert to floating point (remember to leave class single alone)
+  if (isinteger (in_arg))
+    int_max = double (intmax (cls));
+    int_min = double (intmin (cls));
+    if (int_min < 0)
+      in_arg = (double (in_arg) - int_min) / (int_max - int_min);
+    else
+      in_arg = double (in_arg) / int_max;
+    endif
+  endif
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/image/private/colorspace_conversion_revert.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,34 @@
+## Copyright (C) 2015 Carnë Draug <carandraug+dev@gmail.com>
+##
+## 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/>.
+
+## Private function the functions that convert between color spaces, i.e.,
+## rgb2ntsc, rgb2hsv, hsv2rgb, and ntsc2rgb.  This reverts a colormap type
+## into the same shape and class as it was in the input.  The flags are meant
+## to come from  complementary private function
+## colorspace_conversion_input_check()
+
+function rv = colorspace_conversion_revert (rv, sz, is_im, is_nd)
+  if (is_im)
+    if (is_nd)
+      rv = reshape (rv, [sz(1:2) sz(4) sz(3)]);
+      rv = permute (rv, [1 2 4 3]);
+    else
+      rv = reshape (rv, sz);
+    endif
+  endif
+endfunction
--- a/scripts/image/private/imageIO.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/private/imageIO.m	Thu Dec 10 12:50:06 2015 -0800
@@ -96,7 +96,7 @@
       endif
     endif
 
-    ## try extension from file name
+    ## try extension from filename
     if (isempty (foo))
       [~, ~, ext] = fileparts (fn);
       if (! isempty (ext))
--- a/scripts/image/private/imwrite_filename.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/private/imwrite_filename.m	Thu Dec 10 12:50:06 2015 -0800
@@ -52,7 +52,7 @@
       && rem (length (varargin) - filename_idx, 2) != 0
       && ischar (varargin{filename_idx + 1}))
     ext = varargin{filename_idx + 1};
-    options_idx++;
+    options_idx += 1;
   else
     [~, ~, ext] = fileparts (filename);
     if (! isempty (ext))
--- a/scripts/image/rainbow.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/rainbow.m	Thu Dec 10 12:50:06 2015 -0800
@@ -69,8 +69,9 @@
 
 
 %!demo
-%! ## Show the 'rainbow' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (rainbow (64));
-
+%! ## Show the 'rainbow' colormap profile and as an image
+%! cmap = rainbow (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/rgb2hsv.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/rgb2hsv.m	Thu Dec 10 12:50:06 2015 -0800
@@ -19,52 +19,32 @@
 ## -*- texinfo -*-
 ## @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.
+## Transform a colormap or image from RGB to HSV color space.
 ##
 ## 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.
+## A color in HSV space is represented by hue, saturation and value
+## (brightness) levels in a cylindrical coordinate system.  Hue is the
+## azimuth and describes the dominant color.  Saturation is the radial
+## distance and gives the amount of hue mixed into the color.  Value is
+## the height and is the amount of light in the color.
+##
+## Output class and size will be the same as input.
+##
 ## @seealso{hsv2rgb, rgb2ind, rgb2ntsc}
 ## @end deftypefn
 
 ## Author: Kai Habel <kai.habel@gmx.de>
 ## Adapted-by: jwe
 
-function hsv_map = rgb2hsv (rgb)
+function hsv = rgb2hsv (rgb)
 
   if (nargin != 1)
     print_usage ();
   endif
 
-  cls = class (rgb);
-  if (! any (strcmp (cls, {"uint8", "uint16", "single", "double"})))
-    error ("rgb2hsv: invalid data type '%s'", cls);
-  elseif (isfloat (rgb) && (any (rgb(:) < 0) || any (rgb(:) > 1)))
-    error ("rgb2hsv: floating point images may only contain values between 0 and 1");
-  endif
-
-  ## If we have an image convert it into a color map.
-  if (isreal (rgb) && ndims (rgb) == 3)
-    is_image = true;
-    sz = size (rgb);
-    rgb = [rgb(:,:,1)(:), rgb(:,:,2)(:), rgb(:,:,3)(:)];
-    ## Convert to a double image.
-    if (isinteger (rgb))
-      low = double (intmin (cls));
-      high = double (intmax (cls));
-      rgb = (double (rgb) - low) / (high - low);
-    endif
-  else
-    is_image = false;
-  endif
-
-  if (! ismatrix (rgb) || columns (rgb) != 3 || issparse (rgb))
-    error ("rgb2hsv: input must be a matrix of size Nx3 or MxNx3");
-  endif
+  [rgb, sz, is_im, is_nd] ...
+    = colorspace_conversion_input_check ("rgb2hsv", "RGB", rgb);
 
   ## get the max and min for each row
   s = min (rgb, [], 2);
@@ -97,24 +77,23 @@
   s(! notgray) = 0;
   s(notgray) = 1 - s(notgray) ./ v(notgray);
 
-  hsv_map = [h, s, v];
-
-  ## FIXME: rgb2hsv does not preserve class of image.
-  ##        Should it also convert back to uint8, uint16 for integer images?
-  ## If input was an image, convert it back into one.
-  if (is_image)
-    hsv_map = reshape (hsv_map, sz);
-  endif
+  hsv = [h, s, v];
+  hsv = colorspace_conversion_revert (hsv, sz, is_im, is_nd);
 
 endfunction
 
-
 ## Test pure colors and gray
 %!assert (rgb2hsv ([1 0 0]), [0 1 1])
 %!assert (rgb2hsv ([0 1 0]), [1/3 1 1])
 %!assert (rgb2hsv ([0 0 1]), [2/3 1 1])
+%!assert (rgb2hsv ([1 1 0]), [1/6 1 1])
+%!assert (rgb2hsv ([0 1 1]), [1/2 1 1])
+%!assert (rgb2hsv ([1 0 1]), [5/6 1 1])
 %!assert (rgb2hsv ([0.5 0.5 0.5]), [0 0 0.5])
 
+## Test tolarant input checking on floats
+%!assert (rgb2hsv ([1.5 1 1]), [0 1/3 1.5], eps)
+
 %!test
 %! rgb_map = rand (64, 3);
 %! assert (hsv2rgb (rgb2hsv (rgb_map)), rgb_map, 1e-6);
@@ -123,9 +102,73 @@
 %! rgb_img = rand (64, 64, 3);
 %! assert (hsv2rgb (rgb2hsv (rgb_img)), rgb_img, 1e-6);
 
+## support sparse input
+%!assert (rgb2hsv (sparse ([0 0 1])), sparse ([2/3 1 1]))
+%!assert (rgb2hsv (sparse ([0 1 1])), sparse ([1/2 1 1]))
+%!assert (rgb2hsv (sparse ([1 1 1])), sparse ([0 0 1]))
+
 ## Test input validation
 %!error rgb2hsv ()
 %!error rgb2hsv (1,2)
 %!error <invalid data type 'cell'> rgb2hsv ({1})
-%!error <must be a matrix of size Nx3> rgb2hsv (ones (2,2))
+%!error <RGB must be a colormap or RGB image> rgb2hsv (ones (2,2))
+
+## Test ND input
+%!test
+%! rgb = rand (16, 16, 3, 5);
+%! hsv = zeros (size (rgb));
+%! for i = 1:5
+%!   hsv(:,:,:,i) = rgb2hsv (rgb(:,:,:,i));
+%! endfor
+%! assert (rgb2hsv (rgb), hsv)
+
+## Test output class and size for input images.
+## Most of the tests only test for colormap input.
+
+%!test
+%! hsv = rgb2hsv (rand (10, 10, 3));
+%! assert (class (hsv), "double")
+%! assert (size (hsv), [10 10 3])
+
+%!test
+%! hsv = rgb2hsv (rand (10, 10, 3, "single"));
+%! assert (class (hsv), "single")
+%! assert (size (hsv), [10 10 3])
+
+%!test
+%! rgb = (rand (10, 10, 3) * 3 ) - 0.5; # values outside range [0 1]
+%! hsv = rgb2hsv (rgb);
+%! assert (class (hsv), "double")
+%! assert (size (hsv), [10 10 3])
 
+%!test
+%! rgb = (rand (10, 10, 3, "single") * 3 ) - 0.5; # values outside range [0 1]
+%! hsv = rgb2hsv (rgb);
+%! assert (class (hsv), "single")
+%! assert (size (hsv), [10 10 3])
+
+%!test
+%! hsv = rgb2hsv (randi ([0 255], 10, 10, 3, "uint8"));
+%! assert (class (hsv), "double")
+%! assert (size (hsv), [10 10 3])
+
+%!test
+%! hsv = rgb2hsv (randi ([0 65535], 10, 10, 3, "uint16"));
+%! assert (class (hsv), "double")
+%! assert (size (hsv), [10 10 3])
+
+%!test
+%! hsv = rgb2hsv (randi ([-128 127], 10, 10, 3, "uint16"));
+%! assert (class (hsv), "double")
+%! assert (size (hsv), [10 10 3])
+
+%!test
+%! rgb_double = reshape ([1 0 1 .5 1 1 0 .5 0 1 1 .5], [2 2 3]);
+%! rgb_uint8  = reshape (uint8 ([255 0 255 128 255 255 0 128 0 255 255 128]),
+%!                       [2 2 3]);
+%! rgb_int16 = int16 (double (rgb_double * uint16 (65535)) -32768);
+%! expected = reshape ([1/6 1/2 5/6 0 1 1 1 0 1 1 1 .5], [2 2 3]);
+%!
+%! assert (rgb2hsv (rgb_double), expected)
+%! assert (rgb2hsv (rgb_uint8), expected, 0.005)
+%! assert (rgb2hsv (single (rgb_double)), single (expected))
--- a/scripts/image/rgb2ind.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/rgb2ind.m	Thu Dec 10 12:50:06 2015 -0800
@@ -82,7 +82,7 @@
     case "int16"
       map = (double (im) + 32768) / 65535;
     otherwise
-      error ("unsupported image class %s", im_class);
+      error ("rgb2ind: unsupported image class %s", im_class);
   endswitch
 
   ## we convert to the smallest class necessary to encode the image. Matlab
--- a/scripts/image/rgb2ntsc.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/rgb2ntsc.m	Thu Dec 10 12:50:06 2015 -0800
@@ -51,33 +51,8 @@
     print_usage ();
   endif
 
-  cls = class (rgb);
-  if (! any (strcmp (cls, {"uint8", "uint16", "single", "double"})))
-    error ("rgb2ntsc: invalid data type '%s'", cls);
-  elseif (isfloat (rgb) && (any (rgb(:) < 0) || any (rgb(:) > 1)))
-    error ("rgb2ntsc: floating point images may only contain values between 0 and 1");
-  endif
-
-  ## If we have an image convert it into a color map.
-  if (isreal (rgb) && ndims (rgb) == 3)
-    is_image = true;
-    sz = size (rgb);
-    rgb = [rgb(:,:,1)(:), rgb(:,:,2)(:), rgb(:,:,3)(:)];
-    ## Convert to a double image.
-    if (isinteger (rgb))
-      low = double (intmin (cls));
-      high = double (intmax (cls));
-      rgb = (double (rgb) - low) / (high - low);
-    elseif (isa (rgb, "single"))
-      rgb = double (rgb);
-    endif
-  else
-    is_image = false;
-  endif
-
-  if (! isreal (rgb) || columns (rgb) != 3 || issparse (rgb))
-    error ("rgb2ntsc: input must be a matrix of size Nx3 or NxMx3");
-  endif
+  [rgb, sz, is_im, is_nd] ...
+    = colorspace_conversion_input_check ("rgb2ntsc", "RGB", rgb);
 
   ## Reference matrix for transformation from http://en.wikipedia.org/wiki/YIQ
   ## and truncated to 3 significant figures.  Matlab uses this matrix for their
@@ -85,18 +60,15 @@
   trans = [ 0.299,  0.596,  0.211;
             0.587, -0.274, -0.523;
             0.114, -0.322,  0.312 ];
-
-  ## Convert data.
   yiq = rgb * trans;
+  ## Note that if the input is of class single, we also return an image
+  ## of class single.  This is Matlab incompatible by design, since
+  ## Matlab always returning class double, is a Matlab bug (see patch #8709)
 
-  ## If input was an image, convert it back into one.
-  if (is_image)
-    yiq = reshape (yiq, sz);
-  endif
+  yiq = colorspace_conversion_revert (yiq, sz, is_im, is_nd);
 
 endfunction
 
-
 ## Test pure RED, GREEN, BLUE colors
 %!assert (rgb2ntsc ([1 0 0]), [.299  .596  .211])
 %!assert (rgb2ntsc ([0 1 0]), [.587 -.274 -.523])
@@ -110,9 +82,72 @@
 %! rgb_img = rand (64, 64, 3);
 %! assert (ntsc2rgb (rgb2ntsc (rgb_img)), rgb_img, 1e-3);
 
+## test tolerance input checking on floats
+%! assert (rgb2ntsc ([1.5 1 1]), [1.149   0.298   0.105], 1e-3);
+
 ## Test input validation
 %!error rgb2ntsc ()
 %!error rgb2ntsc (1,2)
 %!error <invalid data type 'cell'> rgb2ntsc ({1})
-%!error <must be a matrix of size Nx3 or NxMx3> rgb2ntsc (ones (2,2))
+%!error <RGB must be a colormap or RGB image> rgb2ntsc (ones (2,2))
+
+## Test ND input
+%!test
+%! rgb = rand (16, 16, 3, 5);
+%! yiq = zeros (size (rgb));
+%! for i = 1:5
+%!   yiq(:,:,:,i) = rgb2ntsc (rgb(:,:,:,i));
+%! endfor
+%! assert (rgb2ntsc (rgb), yiq)
+
+## Test output class and size for input images.
+## Most of the tests only test for colormap input.
+
+%!test
+%! ntsc = rgb2ntsc (rand (10, 10, 3));
+%! assert (class (ntsc), "double")
+%! assert (size (ntsc), [10 10 3])
+
+%!test
+%! ntsc = rgb2ntsc (rand (10, 10, 3, "single"));
+%! assert (class (ntsc), "single")
+%! assert (size (ntsc), [10 10 3])
+
+%!test
+%! rgb = (rand (10, 10, 3) * 3 ) - 0.5; # values outside range [0 1]
+%! ntsc = rgb2ntsc (rgb);
+%! assert (class (ntsc), "double")
+%! assert (size (ntsc), [10 10 3])
 
+%!test
+%! rgb = (rand (10, 10, 3, "single") * 3 ) - 0.5; # values outside range [0 1]
+%! ntsc = rgb2ntsc (rgb);
+%! assert (class (ntsc), "single")
+%! assert (size (ntsc), [10 10 3])
+
+%!test
+%! ntsc = rgb2ntsc (randi ([0 255], 10, 10, 3, "uint8"));
+%! assert (class (ntsc), "double")
+%! assert (size (ntsc), [10 10 3])
+
+%!test
+%! ntsc = rgb2ntsc (randi ([0 65535], 10, 10, 3, "uint16"));
+%! assert (class (ntsc), "double")
+%! assert (size (ntsc), [10 10 3])
+
+%!test
+%! ntsc = rgb2ntsc (randi ([-128 127], 10, 10, 3, "uint16"));
+%! assert (class (ntsc), "double")
+%! assert (size (ntsc), [10 10 3])
+
+%!test
+%! rgb_double = reshape ([1 0 0 0 0 1 0 0 0 0 1 0], [2 2 3]);
+%! rgb_uint8  = reshape (uint8 ([255 0 0 0 0 255 0 0 0 0 255 0]),
+%!                       [2 2 3]);
+%! rgb_int16 = int16 (double (rgb_double * uint16 (65535)) -32768);
+%! expected = reshape ([.299 .587 .114 0 .596 -.274 -.322 0 .211 -.523 .312 0],
+%!                     [2 2 3]);
+%!
+%! assert (rgb2ntsc (rgb_double), expected)
+%! assert (rgb2ntsc (rgb_uint8), expected)
+%! assert (rgb2ntsc (single (rgb_double)), single (expected))
--- a/scripts/image/rgbplot.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/rgbplot.m	Thu Dec 10 12:50:06 2015 -0800
@@ -59,7 +59,8 @@
   switch (tolower (style))
     case "profile"
       htmp = plot (cmap(:,1),"r", cmap(:,2),"g", cmap(:,3),"b");
-      set (gca, 'ytick', 0:0.1:1);
+      set (gca (), 'ytick', 0:0.1:1);
+      set (gca (), 'xlim', [0 rows(cmap)]);
     case "composite"
       htmp = image (1:rows(cmap));
       set (gca, 'ytick', []);
--- a/scripts/image/spring.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/spring.m	Thu Dec 10 12:50:06 2015 -0800
@@ -55,8 +55,9 @@
 
 
 %!demo
-%! ## Show the 'spring' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (spring (64));
-
+%! ## Show the 'spring' colormap profile and as an image
+%! cmap = spring (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/summer.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/summer.m	Thu Dec 10 12:50:06 2015 -0800
@@ -56,8 +56,9 @@
 
 
 %!demo
-%! ## Show the 'summer' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (summer (64));
-
+%! ## Show the 'summer' colormap profile and as an image
+%! cmap = summer (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/image/viridis.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,319 @@
+## Copyright (C) 2015 Eric Firing
+## Copyright (C) 2015 Nathaniel J. Smith
+## Copyright (C) 2015 Stefan van der Walt
+## Copyright (C) 2015 Carlo de Falco
+##
+## 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} =} viridis ()
+## @deftypefnx {Function File} {@var{map} =} viridis (@var{n})
+## Create color colormap.  The colors begin with dark purplish-blue and
+## blue, range through green and end with yellow.
+##
+## 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: Carlo de Falco
+
+## PKG_ADD: colormap ("register", "viridis");
+## PKG_DEL: colormap ("unregister", "viridis");
+
+## This is a port of the the default matplotlib colormap "viridis"
+## by Eric Firing to Octave, the original file is distributed under CC0:
+## http://creativecommons.org/publicdomain/zero/1.0
+
+function c = viridis (n = rows (colormap ()))
+
+  if (nargin > 1)
+    print_usage ();
+  elseif (! isscalar (n))
+    error ("viridis: N must be a scalar");
+  endif
+
+  viridi = [0.26700401  0.00487433  0.32941519
+            0.26851048  0.00960483  0.33542652
+            0.26994384  0.01462494  0.34137895
+            0.27130489  0.01994186  0.34726862
+            0.27259384  0.02556309  0.35309303
+            0.27380934  0.03149748  0.35885256
+            0.27495242  0.03775181  0.36454323
+            0.27602238  0.04416723  0.37016418
+            0.2770184   0.05034437  0.37571452
+            0.27794143  0.05632444  0.38119074
+            0.27879067  0.06214536  0.38659204
+            0.2795655   0.06783587  0.39191723
+            0.28026658  0.07341724  0.39716349
+            0.28089358  0.07890703  0.40232944
+            0.28144581  0.0843197   0.40741404
+            0.28192358  0.08966622  0.41241521
+            0.28232739  0.09495545  0.41733086
+            0.28265633  0.10019576  0.42216032
+            0.28291049  0.10539345  0.42690202
+            0.28309095  0.11055307  0.43155375
+            0.28319704  0.11567966  0.43611482
+            0.28322882  0.12077701  0.44058404
+            0.28318684  0.12584799  0.44496
+            0.283072    0.13089477  0.44924127
+            0.28288389  0.13592005  0.45342734
+            0.28262297  0.14092556  0.45751726
+            0.28229037  0.14591233  0.46150995
+            0.28188676  0.15088147  0.46540474
+            0.28141228  0.15583425  0.46920128
+            0.28086773  0.16077132  0.47289909
+            0.28025468  0.16569272  0.47649762
+            0.27957399  0.17059884  0.47999675
+            0.27882618  0.1754902   0.48339654
+            0.27801236  0.18036684  0.48669702
+            0.27713437  0.18522836  0.48989831
+            0.27619376  0.19007447  0.49300074
+            0.27519116  0.1949054   0.49600488
+            0.27412802  0.19972086  0.49891131
+            0.27300596  0.20452049  0.50172076
+            0.27182812  0.20930306  0.50443413
+            0.27059473  0.21406899  0.50705243
+            0.26930756  0.21881782  0.50957678
+            0.26796846  0.22354911  0.5120084
+            0.26657984  0.2282621   0.5143487
+            0.2651445   0.23295593  0.5165993
+            0.2636632   0.23763078  0.51876163
+            0.26213801  0.24228619  0.52083736
+            0.26057103  0.2469217   0.52282822
+            0.25896451  0.25153685  0.52473609
+            0.25732244  0.2561304   0.52656332
+            0.25564519  0.26070284  0.52831152
+            0.25393498  0.26525384  0.52998273
+            0.25219404  0.26978306  0.53157905
+            0.25042462  0.27429024  0.53310261
+            0.24862899  0.27877509  0.53455561
+            0.2468114   0.28323662  0.53594093
+            0.24497208  0.28767547  0.53726018
+            0.24311324  0.29209154  0.53851561
+            0.24123708  0.29648471  0.53970946
+            0.23934575  0.30085494  0.54084398
+            0.23744138  0.30520222  0.5419214
+            0.23552606  0.30952657  0.54294396
+            0.23360277  0.31382773  0.54391424
+            0.2316735   0.3181058   0.54483444
+            0.22973926  0.32236127  0.54570633
+            0.22780192  0.32659432  0.546532
+            0.2258633   0.33080515  0.54731353
+            0.22392515  0.334994    0.54805291
+            0.22198915  0.33916114  0.54875211
+            0.22005691  0.34330688  0.54941304
+            0.21812995  0.34743154  0.55003755
+            0.21620971  0.35153548  0.55062743
+            0.21429757  0.35561907  0.5511844
+            0.21239477  0.35968273  0.55171011
+            0.2105031   0.36372671  0.55220646
+            0.20862342  0.36775151  0.55267486
+            0.20675628  0.37175775  0.55311653
+            0.20490257  0.37574589  0.55353282
+            0.20306309  0.37971644  0.55392505
+            0.20123854  0.38366989  0.55429441
+            0.1994295   0.38760678  0.55464205
+            0.1976365   0.39152762  0.55496905
+            0.19585993  0.39543297  0.55527637
+            0.19410009  0.39932336  0.55556494
+            0.19235719  0.40319934  0.55583559
+            0.19063135  0.40706148  0.55608907
+            0.18892259  0.41091033  0.55632606
+            0.18723083  0.41474645  0.55654717
+            0.18555593  0.4185704   0.55675292
+            0.18389763  0.42238275  0.55694377
+            0.18225561  0.42618405  0.5571201
+            0.18062949  0.42997486  0.55728221
+            0.17901879  0.43375572  0.55743035
+            0.17742298  0.4375272   0.55756466
+            0.17584148  0.44128981  0.55768526
+            0.17427363  0.4450441   0.55779216
+            0.17271876  0.4487906   0.55788532
+            0.17117615  0.4525298   0.55796464
+            0.16964573  0.45626209  0.55803034
+            0.16812641  0.45998802  0.55808199
+            0.1666171   0.46370813  0.55811913
+            0.16511703  0.4674229   0.55814141
+            0.16362543  0.47113278  0.55814842
+            0.16214155  0.47483821  0.55813967
+            0.16066467  0.47853961  0.55811466
+            0.15919413  0.4822374   0.5580728
+            0.15772933  0.48593197  0.55801347
+            0.15626973  0.4896237   0.557936
+            0.15481488  0.49331293  0.55783967
+            0.15336445  0.49700003  0.55772371
+            0.1519182   0.50068529  0.55758733
+            0.15047605  0.50436904  0.55742968
+            0.14903918  0.50805136  0.5572505
+            0.14760731  0.51173263  0.55704861
+            0.14618026  0.51541316  0.55682271
+            0.14475863  0.51909319  0.55657181
+            0.14334327  0.52277292  0.55629491
+            0.14193527  0.52645254  0.55599097
+            0.14053599  0.53013219  0.55565893
+            0.13914708  0.53381201  0.55529773
+            0.13777048  0.53749213  0.55490625
+            0.1364085   0.54117264  0.55448339
+            0.13506561  0.54485335  0.55402906
+            0.13374299  0.54853458  0.55354108
+            0.13244401  0.55221637  0.55301828
+            0.13117249  0.55589872  0.55245948
+            0.1299327   0.55958162  0.55186354
+            0.12872938  0.56326503  0.55122927
+            0.12756771  0.56694891  0.55055551
+            0.12645338  0.57063316  0.5498411
+            0.12539383  0.57431754  0.54908564
+            0.12439474  0.57800205  0.5482874
+            0.12346281  0.58168661  0.54744498
+            0.12260562  0.58537105  0.54655722
+            0.12183122  0.58905521  0.54562298
+            0.12114807  0.59273889  0.54464114
+            0.12056501  0.59642187  0.54361058
+            0.12009154  0.60010387  0.54253043
+            0.11973756  0.60378459  0.54139999
+            0.11951163  0.60746388  0.54021751
+            0.11942341  0.61114146  0.53898192
+            0.11948255  0.61481702  0.53769219
+            0.11969858  0.61849025  0.53634733
+            0.12008079  0.62216081  0.53494633
+            0.12063824  0.62582833  0.53348834
+            0.12137972  0.62949242  0.53197275
+            0.12231244  0.63315277  0.53039808
+            0.12344358  0.63680899  0.52876343
+            0.12477953  0.64046069  0.52706792
+            0.12632581  0.64410744  0.52531069
+            0.12808703  0.64774881  0.52349092
+            0.13006688  0.65138436  0.52160791
+            0.13226797  0.65501363  0.51966086
+            0.13469183  0.65863619  0.5176488
+            0.13733921  0.66225157  0.51557101
+            0.14020991  0.66585927  0.5134268
+            0.14330291  0.66945881  0.51121549
+            0.1466164   0.67304968  0.50893644
+            0.15014782  0.67663139  0.5065889
+            0.15389405  0.68020343  0.50417217
+            0.15785146  0.68376525  0.50168574
+            0.16201598  0.68731632  0.49912906
+            0.1663832   0.69085611  0.49650163
+            0.1709484   0.69438405  0.49380294
+            0.17570671  0.6978996   0.49103252
+            0.18065314  0.70140222  0.48818938
+            0.18578266  0.70489133  0.48527326
+            0.19109018  0.70836635  0.48228395
+            0.19657063  0.71182668  0.47922108
+            0.20221902  0.71527175  0.47608431
+            0.20803045  0.71870095  0.4728733
+            0.21400015  0.72211371  0.46958774
+            0.22012381  0.72550945  0.46622638
+            0.2263969   0.72888753  0.46278934
+            0.23281498  0.73224735  0.45927675
+            0.2393739   0.73558828  0.45568838
+            0.24606968  0.73890972  0.45202405
+            0.25289851  0.74221104  0.44828355
+            0.25985676  0.74549162  0.44446673
+            0.26694127  0.74875084  0.44057284
+            0.27414922  0.75198807  0.4366009
+            0.28147681  0.75520266  0.43255207
+            0.28892102  0.75839399  0.42842626
+            0.29647899  0.76156142  0.42422341
+            0.30414796  0.76470433  0.41994346
+            0.31192534  0.76782207  0.41558638
+            0.3198086   0.77091403  0.41115215
+            0.3277958   0.77397953  0.40664011
+            0.33588539  0.7770179   0.40204917
+            0.34407411  0.78002855  0.39738103
+            0.35235985  0.78301086  0.39263579
+            0.36074053  0.78596419  0.38781353
+            0.3692142   0.78888793  0.38291438
+            0.37777892  0.79178146  0.3779385
+            0.38643282  0.79464415  0.37288606
+            0.39517408  0.79747541  0.36775726
+            0.40400101  0.80027461  0.36255223
+            0.4129135   0.80304099  0.35726893
+            0.42190813  0.80577412  0.35191009
+            0.43098317  0.80847343  0.34647607
+            0.44013691  0.81113836  0.3409673
+            0.44936763  0.81376835  0.33538426
+            0.45867362  0.81636288  0.32972749
+            0.46805314  0.81892143  0.32399761
+            0.47750446  0.82144351  0.31819529
+            0.4870258   0.82392862  0.31232133
+            0.49661536  0.82637633  0.30637661
+            0.5062713   0.82878621  0.30036211
+            0.51599182  0.83115784  0.29427888
+            0.52577622  0.83349064  0.2881265
+            0.5356211   0.83578452  0.28190832
+            0.5455244   0.83803918  0.27562602
+            0.55548397  0.84025437  0.26928147
+            0.5654976   0.8424299   0.26287683
+            0.57556297  0.84456561  0.25641457
+            0.58567772  0.84666139  0.24989748
+            0.59583934  0.84871722  0.24332878
+            0.60604528  0.8507331   0.23671214
+            0.61629283  0.85270912  0.23005179
+            0.62657923  0.85464543  0.22335258
+            0.63690157  0.85654226  0.21662012
+            0.64725685  0.85839991  0.20986086
+            0.65764197  0.86021878  0.20308229
+            0.66805369  0.86199932  0.19629307
+            0.67848868  0.86374211  0.18950326
+            0.68894351  0.86544779  0.18272455
+            0.69941463  0.86711711  0.17597055
+            0.70989842  0.86875092  0.16925712
+            0.72039115  0.87035015  0.16260273
+            0.73088902  0.87191584  0.15602894
+            0.74138803  0.87344918  0.14956101
+            0.75188414  0.87495143  0.14322828
+            0.76237342  0.87642392  0.13706449
+            0.77285183  0.87786808  0.13110864
+            0.78331535  0.87928545  0.12540538
+            0.79375994  0.88067763  0.12000532
+            0.80418159  0.88204632  0.11496505
+            0.81457634  0.88339329  0.11034678
+            0.82494028  0.88472036  0.10621724
+            0.83526959  0.88602943  0.1026459
+            0.84556056  0.88732243  0.09970219
+            0.8558096   0.88860134  0.09745186
+            0.86601325  0.88986815  0.09595277
+            0.87616824  0.89112487  0.09525046
+            0.88627146  0.89237353  0.09537439
+            0.89632002  0.89361614  0.09633538
+            0.90631121  0.89485467  0.09812496
+            0.91624212  0.89609127  0.1007168
+            0.92610579  0.89732977  0.10407067
+            0.93590444  0.8985704   0.10813094
+            0.94563626  0.899815    0.11283773
+            0.95529972  0.90106534  0.11812832
+            0.96489353  0.90232311  0.12394051
+            0.97441665  0.90358991  0.13021494
+            0.98386829  0.90486726  0.13689671
+            0.99324789  0.90615657  0.1439362];
+
+  p = rows (viridi);
+  c = interp1 (1:p, viridi, linspace (1, p, n), 'linear');
+
+endfunction
+
+## A better demo of this colormap would be to plot the CIECAM02 values.
+%!demo
+%! ## Show the 'viridis' colormap profile and as an image
+%! cmap = viridis (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/white.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/white.m	Thu Dec 10 12:50:06 2015 -0800
@@ -45,8 +45,9 @@
 
 
 %!demo
-%! ## Show the 'white' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (white (64));
-
+%! ## Show the 'white' colormap profile and as an image
+%! cmap = white (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/image/winter.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/image/winter.m	Thu Dec 10 12:50:06 2015 -0800
@@ -55,8 +55,9 @@
 
 
 %!demo
-%! ## Show the 'winter' colormap as an image
-%! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
-%! axis ([1, 64, 0, 1], "ticy", "xy");
-%! colormap (winter (64));
-
+%! ## Show the 'winter' colormap profile and as an image
+%! cmap = winter (256);
+%! subplot (2, 1, 1);
+%! rgbplot (cmap, "composite");
+%! subplot (2, 1, 2);
+%! rgbplot (cmap);
--- a/scripts/io/beep.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/io/beep.m	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,7 @@
 ## Produce a beep from the speaker (or visual bell).
 ##
 ## This function sends the alarm character @qcode{"@xbackslashchar{}a"} to
-## the terminal. Depending on the user's configuration this may produce an
+## the terminal.  Depending on the user's configuration this may produce an
 ## audible beep, a visual bell, or nothing at all.
 ## @seealso{puts, fputs, printf, fprintf}
 ## @end deftypefn
--- a/scripts/io/dlmwrite.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/io/dlmwrite.m	Thu Dec 10 12:50:06 2015 -0800
@@ -24,7 +24,7 @@
 ## @deftypefnx {Function File} {} dlmwrite (@var{fid}, @dots{})
 ## Write the matrix @var{M} to the named file using delimiters.
 ##
-## @var{file} should be a file name or writable file ID given by @code{fopen}.
+## @var{file} should be a filename or writable file ID given by @code{fopen}.
 ##
 ## The parameter @var{delim} specifies the delimiter to use to separate values
 ## on a row.
@@ -107,7 +107,7 @@
   ## process the input arguments
   i = 0;
   while (i < length (varargin))
-    i++;
+    i += 1;
     if (strcmpi (varargin{i}, "delimiter"))
       delim = varargin{++i};
     elseif (strcmpi (varargin{i}, "newline"))
@@ -131,7 +131,7 @@
     elseif (strcmpi (varargin{i}, "-append"))
       opentype = "at";
     elseif (strcmpi (varargin{i}, "append"))
-      i++;
+      i += 1;
       if (strcmpi (varargin{i}, "on"))
         opentype = "at";
       elseif (strcmpi (varargin{i}, "off"))
--- a/scripts/io/importdata.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/io/importdata.m	Thu Dec 10 12:50:06 2015 -0800
@@ -92,7 +92,7 @@
   endif
 
   ## Check file format
-  ## Get the extension from the file name.
+  ## Get the extension from the filename.
   [~, ~, ext, ~] = fileparts (fname);
   ext = lower (ext);
 
@@ -191,7 +191,7 @@
     endif
     row_data = str2double (row_entries);
     if (all (isnan (row_data)) || header_rows < num_header_rows)
-      header_rows++;
+      header_rows += 1;
       output.textdata{end+1, 1} = row;
     else
       if (! isempty (output.textdata))
--- a/scripts/io/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/io/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,19 +1,23 @@
-FCN_FILE_DIRS += io
+FCN_FILE_DIRS += scripts/io
 
-io_FCN_FILES = \
-  io/beep.m \
-  io/csvread.m \
-  io/csvwrite.m \
-  io/dlmwrite.m \
-  io/fileread.m \
-  io/importdata.m \
-  io/is_valid_file_id.m \
-  io/strread.m \
-  io/textscan.m \
-  io/textread.m
+scripts_io_FCN_FILES = \
+  scripts/io/beep.m \
+  scripts/io/csvread.m \
+  scripts/io/csvwrite.m \
+  scripts/io/dlmwrite.m \
+  scripts/io/fileread.m \
+  scripts/io/importdata.m \
+  scripts/io/is_valid_file_id.m \
+  scripts/io/strread.m \
+  scripts/io/textscan.m \
+  scripts/io/textread.m
 
-FCN_FILES += $(io_FCN_FILES)
+scripts_iodir = $(fcnfiledir)/io
+
+scripts_io_DATA = $(scripts_io_FCN_FILES)
 
-PKG_ADD_FILES += io/PKG_ADD
+FCN_FILES += $(scripts_io_FCN_FILES)
 
-DIRSTAMP_FILES += io/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/io/PKG_ADD
+
+DIRSTAMP_FILES += scripts/io/$(octave_dirstamp)
--- a/scripts/io/strread.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/io/strread.m	Thu Dec 10 12:50:06 2015 -0800
@@ -362,7 +362,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 = strrep (comment_end, "eol_char", eol_char);
     cstart = strfind (str, comment_start);
     cstop  = strfind (str, comment_end);
     ## Treat end of string as additional comment stop
@@ -389,7 +389,7 @@
     c2len = length (comment_end);
     if (cstop + c2len == len)
       ## Ignore last char of to-the-end-of-line comments
-      c2len++;
+      c2len += 1;
     end
     str = cellslices (str, [1, cstop + c2len], [cstart - 1, len]);
     str = [str{:}];
@@ -637,11 +637,7 @@
               fwptr = [fwptr(1:ii) (++fwptr(ii+1:end))];
 
             else
-              if (! idg(ii) && ! isempty (strfind (fmt_words{ii-1}, "%s")))
-                ## Trailing literal.
-                ## If preceding format == '%s' this is an error.
-                warning ("strread: ambiguous '%s' specifier next to literal in column %d", icol);
-              elseif (idg(ii))
+              if (idg(ii))
                 ## Current field = fixed width. Strip into icol, rest in icol+1
                 sw = regexp (fmt_words{ii}, '\d', "once");
                 ew = regexp (fmt_words{ii}, '[nfuds]') - 1;
@@ -657,6 +653,10 @@
                   fwptr = [fwptr(1:ii) (++fwptr(ii+1:end))];
                 endif
               else
+                if (! isempty (strfind (fmt_words{ii-1}, "%s")))
+                  ## Trailing literal. Could be ambiguous if preceding format == '%s'
+                  warning ("strread.m:\n  Ambiguous '%%s' specifier immediately before literal in column %d", icol);
+                endif
                 ## FIXME: this assumes char(254)/char(255) won't occur in input!
                 clear wrds;
                 wrds(1:2:2*numel (words(icol, jptr))) = ...
@@ -727,7 +727,7 @@
             data(end+1:num_lines) = {""};
           endif
           varargout{k} = data';
-          k++;
+          k += 1;
         case {"%d", "%u", "%f", "%n"}
           n = cellfun ("isempty", data);
           ### FIXME: Erroneously formatted data lead to NaN, not an error
@@ -742,7 +742,7 @@
             data(end+1:num_lines) = numeric_fill_value;
           endif
           varargout{k} = data.';
-          k++;
+          k += 1;
         case {"%0", "%1", "%2", "%3", "%4", "%5", "%6", "%7", "%8", "%9"}
           sw = regexp (fmt_words{m}, '\d', "once");
           ew = regexp (fmt_words{m}, '[nfudsq]') - 1;
@@ -767,13 +767,13 @@
                 data = int32 (data);
               endif
               varargout{k} = data.';
-              k++;
+              k += 1;
             case "s"
               if (pad_out)
                 data(end+1:num_lines) = {""};
               endif
               varargout{k} = strtrunc (data, swidth)';
-              k++;
+              k += 1;
             otherwise
           endswitch
         case {"%*", "%*s"}
@@ -1102,3 +1102,11 @@
 %! str = "14 :1 z:2 z:3 z:5 z:11";
 %! [a, b, c, d] = strread (str, "%f %s %*s %3s %*3s %f", "delimiter", ":");
 %! assert ({a, b, c, d}, {14, {"1 z"}, {"3 z"}, 11});
+
+## Allow cuddling %sliteral but warn it is ambiguous
+%!test
+%! [a, b] = strread ("abcxyz51\nxyz83\n##xyz101", "%s xyz %d");
+%! assert (a([1 3]), {"abc"; "##"});
+%! assert (isempty (a{2}), true);
+%! assert (b, int32([51; 83; 101]));
+
--- a/scripts/io/textread.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/io/textread.m	Thu Dec 10 12:50:06 2015 -0800
@@ -58,21 +58,26 @@
 ## Examples:
 ##
 ## @example
+## @group
 ##   Assume a data file like:
 ##   1 a 2 b
 ##   3 c 4 d
 ##   5 e
+## @end group
 ## @end example
 ##
 ## @example
+## @group
 ##   [a, b] = textread (f, "%f %s")
 ##   returns two columns of data, one with doubles, the other a
 ##   cellstr array:
 ##   a = [1; 2; 3; 4; 5]
 ##   b = @{"a"; "b"; "c"; "d"; "e"@}
+## @end group
 ## @end example
 ##
 ## @example
+## @group
 ##   [a, b] = textread (f, "%f %s", 3)
 ##   (read data into two culumns, try to use the format string
 ##   three times)
@@ -80,9 +85,11 @@
 ##   a = [1; 2; 3]
 ##   b = @{"a"; "b"; "c"@}
 ##
+## @end group
 ## @end example
 ##
 ## @example
+## @group
 ##   With a data file like:
 ##   1
 ##   a
@@ -92,9 +99,10 @@
 ##   [a, b] = textread (f, "%f %s", 2)
 ##   returns a = 1 and b = @{"a"@}; i.e., the format string is used
 ##   only once because the format string refers to 2 lines of the
-##   data file. To obtain 2x1 data output columns, specify N = 4
+##   data file.  To obtain 2x1 data output columns, specify N = 4
 ##   (number of data lines containing all requested data) rather
 ##   than 2.
+## @end group
 ## @end example
 ##
 ## @seealso{strread, load, dlmread, fscanf, textscan}
@@ -136,7 +144,7 @@
     ## Beware of missing or wrong headerline value
     if (headerlines  == numel (varargin)
        || ! isnumeric (varargin{headerlines + 1}))
-      error ("missing or illegal value for 'headerlines'" );
+      error ("textread: missing or invalid value for 'headerlines'" );
     endif
     ## Avoid conveying floats to fskipl
     varargin{headerlines + 1} = round (varargin{headerlines + 1});
@@ -167,10 +175,10 @@
         eol_char = do_string_escapes (eol_char);
       endif
       if (! any (strcmp (eol_char, {"", "\n", "\r", "\r\n"})))
-        error ("textscan: illegal EndOfLine character value specified");
+        error ("textread: invalid EndOfLine character value specified");
       endif
     else
-      error ("character value required for EndOfLine");
+      error ("textread: character value required for EndOfLine");
     endif
   else
     ## Determine EOL from file.
@@ -496,7 +504,7 @@
 %!error textread (1)
 %!error <arguments must be strings> textread (1, "%f")
 %!error <arguments must be strings> textread ("fname", 1)
-%!error <missing or illegal value for> textread (file_in_loadpath ("textread.m"), "", "headerlines")
-%!error <missing or illegal value for> textread (file_in_loadpath ("textread.m"), "", "headerlines", 'hh')
+%!error <missing or invalid value for> textread (file_in_loadpath ("textread.m"), "", "headerlines")
+%!error <missing or invalid value for> textread (file_in_loadpath ("textread.m"), "", "headerlines", 'hh')
 %!error <character value required for> textread (file_in_loadpath ("textread.m"), "%s", "endofline", true)
 
--- a/scripts/java/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/java/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,24 +1,20 @@
-FCN_FILE_DIRS += java
+FCN_FILE_DIRS += scripts/java
 
-java_FCN_FILES = \
-  java/java_get.m \
-  java/java_set.m \
-  java/javaArray.m \
-  java/javaaddpath.m \
-  java/javachk.m \
-  java/javaclasspath.m \
-  java/javamem.m \
-  java/javarmpath.m \
-  java/usejava.m
-
-FCN_FILES += $(java_FCN_FILES)
-
-PKG_ADD_FILES += java/PKG_ADD
-
-DIRSTAMP_FILES += java/$(octave_dirstamp)
+scripts_java_FCN_FILES = \
+  scripts/java/java_get.m \
+  scripts/java/java_set.m \
+  scripts/java/javaArray.m \
+  scripts/java/javaaddpath.m \
+  scripts/java/javachk.m \
+  scripts/java/javaclasspath.m \
+  scripts/java/javamem.m \
+  scripts/java/javarmpath.m \
+  scripts/java/usejava.m
 
 if AMCOND_HAVE_JAVA
-JAR_FILES += java/octave.jar
+scripts_java_JAR_FILES = scripts/java/octave.jar
+
+JAR_FILES += $(scripts_java_JAR_FILES)
 endif
 
 org_octave_dir = org/octave
@@ -45,36 +41,54 @@
   $(org_octave_dir)/images/information.png \
   $(org_octave_dir)/images/octave.png
 
-java_JAVA_SRC = $(addprefix java/, $(JAVA_SRC))
+scripts_java_JAVA_SRC = $(addprefix scripts/java/, $(JAVA_SRC))
 
-java_JAVA_CLASSES = $(addprefix java/, $(JAVA_CLASSES))
+scripts_java_JAVA_CLASSES = $(addprefix scripts/java/, $(JAVA_CLASSES))
 
-java_JAVA_IMAGES = $(addprefix java/, $(JAVA_IMAGES))
+scripts_java_JAVA_IMAGES = $(addprefix scripts/java/, $(JAVA_IMAGES))
 
-srcdir_java_JAVA_IMAGES = $(addprefix $(srcdir)/java/, $(JAVA_IMAGES))
+scripts_DISTCLEANFILES += $(addprefix $(abs_top_builddir), $(java_JAVA_IMAGES))
 
-%.class : %.java
-	$(AM_V_GEN)$(MKDIR_P) java/$(org_octave_dir) && \
-	( cd $(srcdir)/java; "$(JAVAC)" -source 1.3 -target 1.3 -d $(abs_builddir)/java $(org_octave_dir)/$(<F) )
+srcdir_scripts_java_JAVA_IMAGES = $(addprefix $(srcdir)/scripts/java/, $(JAVA_IMAGES))
 
-java/images.stamp: $(srcdir_java_JAVA_IMAGES)
+$(scripts_java_JAVA_CLASSES) : %.class : %.java | scripts/java/$(octave_dirstamp)
+	$(AM_V_GEN)$(MKDIR_P) scripts/java/$(org_octave_dir) && \
+	( cd $(srcdir)/scripts/java; "$(JAVAC)" -source 1.3 -target 1.3 -d $(abs_top_builddir)/scripts/java $(org_octave_dir)/$(<F) )
+
+scripts/java/images.stamp: $(srcdir_scripts_java_JAVA_IMAGES)
 	$(AM_V_GEN)if [ "x$(srcdir)" != "x." ]; then \
-	  $(MKDIR_P) java/$(org_octave_dir)/images; \
-	  cp $(srcdir_java_JAVA_IMAGES) java/$(org_octave_dir)/images; \
+	  $(MKDIR_P) scripts/java/$(org_octave_dir)/images; \
+	  cp $(srcdir_scripts_java_JAVA_IMAGES) scripts/java/$(org_octave_dir)/images; \
 	fi && \
 	touch $@
 
 if AMCOND_HAVE_JAVA
-java/octave.jar: java/images.stamp $(java_JAVA_CLASSES)
+scripts/java/octave.jar: scripts/java/images.stamp $(scripts_java_JAVA_CLASSES)
 	$(AM_V_GEN)rm -f $@-t $@ && \
-	( cd java; \
+	( cd scripts/java; \
 	  "$(JAR)" cf octave.jar-t $(JAVA_CLASSES) $(JAVA_IMAGES) ) && \
 	mv $@-t $@
 endif
 
-EXTRA_DIST += $(JAR_FILES) $(java_JAVA_SRC) $(java_JAVA_IMAGES)
+scripts_javadir = $(fcnfiledir)/java
+
+scripts_java_DATA = \
+  $(scripts_java_FCN_FILES) \
+  $(scripts_java_JAR_FILES)
+
+FCN_FILES += $(scripts_java_FCN_FILES)
+
+PKG_ADD_FILES += scripts/java/PKG_ADD
 
-CLEANFILES += $(JAR_FILES) $(java_JAVA_CLASSES)
+DIRSTAMP_FILES += scripts/java/$(octave_dirstamp)
 
-DISTCLEANFILES += java/images.stamp
+scripts_EXTRA_DIST += \
+  $(scripts_java_JAR_FILES) \
+  $(scripts_java_JAVA_SRC) \
+  $(scripts_java_JAVA_IMAGES)
 
+scripts_CLEANFILES += \
+  $(scripts_java_JAR_FILES) \
+  $(scripts_java_JAVA_CLASSES)
+
+scripts_DISTCLEANFILES += scripts/java/images.stamp
--- a/scripts/java/org/octave/TeXtranslator.java	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/java/org/octave/TeXtranslator.java	Thu Dec 10 12:50:06 2015 -0800
@@ -250,7 +250,7 @@
                 // 26 08 2010 MH
                 // advance i to avoid deadlock in case of incorrect escape
                 // sequences like \\\\alpha (double backslash) or
-                // \\bogus (unknown escape sequence)
+                // \\invalid (unknown escape sequence)
                 i++;
               }
           }
--- a/scripts/linear-algebra/duplication_matrix.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/linear-algebra/duplication_matrix.m	Thu Dec 10 12:50:06 2015 -0800
@@ -82,7 +82,7 @@
       d((j - 1) * n + i, count + i) = 1;
       d((i - 1) * n + j, count + i) = 1;
     endfor
-    count = count + n - j;
+    count += n - j;
   endfor
 
 endfunction
--- a/scripts/linear-algebra/housh.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/linear-algebra/housh.m	Thu Dec 10 12:50:06 2015 -0800
@@ -72,7 +72,7 @@
     housv = x;
     m = max (abs (housv));
     if (m != 0.0)
-      housv = housv / m;
+      housv /= m;
       alpha = norm (housv);
       if (alpha > z)
         beta = 1.0 / (alpha * (alpha + abs (housv(j))));
--- a/scripts/linear-algebra/isdiag.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/linear-algebra/isdiag.m	Thu Dec 10 12:50:06 2015 -0800
@@ -30,25 +30,28 @@
     print_usage ();
   endif
 
-  retval = (isnumeric (A) || islogical (A)) && ndims (A) == 2;
-  if (retval)
+  if (strcmp (typeinfo (A), "diagonal matrix"))
+    retval = true;
+  elseif ((isnumeric (A) || islogical (A)) && ndims (A) == 2)
     [i, j] = find (A);
     retval = all (i == j);
+  else
+    retval = false;
   endif
 
 endfunction
 
 
-%!assert (! isdiag ("string"))
+%!assert (isdiag ("string"), false)
+%!assert (isdiag (zeros (2,2,2)), false)
 %!assert (isdiag ([]))
-
 %!assert (isdiag (1))
-%!assert (! isdiag ([1, 1]))
-%!assert (! isdiag ([1; 1]))
+%!assert (isdiag ([1, 1]), false)
+%!assert (isdiag ([1; 1]), false)
 %!assert (isdiag (eye (10)))
-%!assert (issymmetric ([i, 0; 0, 1 + i]))
-%!assert (isdiag (speye (1000000)))
 %!assert (isdiag (logical (eye (10))))
+%!assert (isdiag (speye (1e6)))
+%!assert (isdiag (diag (1:10)))
 
 ## Test input validation
 %!error isdiag ()
--- a/scripts/linear-algebra/krylov.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/linear-algebra/krylov.m	Thu Dec 10 12:50:06 2015 -0800
@@ -115,7 +115,7 @@
   alpha = [];
   nh = 0;
   while (length (alpha) < na) && (columns (V) > 0) && (iter < k)
-    iter++;
+    iter += 1;
 
     ## Get orthogonal basis of V.
     jj = 1;
@@ -137,7 +137,7 @@
         endif
         V = V(:,1:(nv-1));
         ## One less reflection.
-        nu--;
+        nu -= 1;
       else
         ## New householder reflection.
         if (pflg)
@@ -171,7 +171,7 @@
         endif
 
         ## Advance to next column of V.
-        jj++;
+        jj += 1;
       endif
     endwhile
 
@@ -209,7 +209,7 @@
     for i = 1:nu
       hv = U(:,i);
       av = alpha(i);
-      V = V - av*hv*(hv'*V);
+      V -= av*hv*(hv'*V);
       H(i,nu-columns(V)+(1:columns(V))) = V(pivot_vec(i),:);
     endfor
 
--- a/scripts/linear-algebra/logm.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/linear-algebra/logm.m	Thu Dec 10 12:50:06 2015 -0800
@@ -86,7 +86,7 @@
   while (k < opt_iters)
     tau = norm (s - eye (size (s)),1);
     if (tau <= theta (7))
-      p = p + 1;
+      p += 1;
       j(1) = find (tau <= theta, 1);
       j(2) = find (tau / 2 <= theta, 1);
       if (j(1) - j(2) <= 1 || p == 2)
@@ -94,7 +94,7 @@
         break
       endif
     endif
-    k = k + 1;
+    k += 1;
     s = sqrtm (s);
   endwhile
 
@@ -102,7 +102,7 @@
     warning ("logm: maximum number of square roots exceeded; results may still be accurate");
   endif
 
-  s = s - eye (size (s));
+  s -= eye (size (s));
 
   if (m > 1)
     s = logm_pade_pf (s, m);
@@ -136,7 +136,7 @@
   [nodes, wts] = gauss_legendre (m);
   ## Convert from [-1,1] to [0,1].
   nodes = (nodes+1)/2;
-  wts = wts/2;
+  wts /= 2;
 
   n = length (A);
   s = zeros (n);
--- a/scripts/linear-algebra/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/linear-algebra/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,38 +1,42 @@
-FCN_FILE_DIRS += linear-algebra
+FCN_FILE_DIRS += scripts/linear-algebra
 
-linear_algebra_FCN_FILES = \
-  linear-algebra/bandwidth.m \
-  linear-algebra/commutation_matrix.m \
-  linear-algebra/cond.m \
-  linear-algebra/condest.m \
-  linear-algebra/cross.m \
-  linear-algebra/duplication_matrix.m \
-  linear-algebra/expm.m \
-  linear-algebra/housh.m \
-  linear-algebra/isbanded.m \
-  linear-algebra/isdefinite.m \
-  linear-algebra/isdiag.m \
-  linear-algebra/ishermitian.m \
-  linear-algebra/issymmetric.m \
-  linear-algebra/istril.m \
-  linear-algebra/istriu.m \
-  linear-algebra/krylov.m \
-  linear-algebra/linsolve.m \
-  linear-algebra/logm.m \
-  linear-algebra/normest.m \
-  linear-algebra/null.m \
-  linear-algebra/onenormest.m \
-  linear-algebra/orth.m \
-  linear-algebra/planerot.m \
-  linear-algebra/qzhess.m \
-  linear-algebra/rank.m \
-  linear-algebra/rref.m \
-  linear-algebra/subspace.m \
-  linear-algebra/trace.m \
-  linear-algebra/vech.m
+scripts_linear_algebra_FCN_FILES = \
+  scripts/linear-algebra/bandwidth.m \
+  scripts/linear-algebra/commutation_matrix.m \
+  scripts/linear-algebra/cond.m \
+  scripts/linear-algebra/condest.m \
+  scripts/linear-algebra/cross.m \
+  scripts/linear-algebra/duplication_matrix.m \
+  scripts/linear-algebra/expm.m \
+  scripts/linear-algebra/housh.m \
+  scripts/linear-algebra/isbanded.m \
+  scripts/linear-algebra/isdefinite.m \
+  scripts/linear-algebra/isdiag.m \
+  scripts/linear-algebra/ishermitian.m \
+  scripts/linear-algebra/issymmetric.m \
+  scripts/linear-algebra/istril.m \
+  scripts/linear-algebra/istriu.m \
+  scripts/linear-algebra/krylov.m \
+  scripts/linear-algebra/linsolve.m \
+  scripts/linear-algebra/logm.m \
+  scripts/linear-algebra/normest.m \
+  scripts/linear-algebra/null.m \
+  scripts/linear-algebra/onenormest.m \
+  scripts/linear-algebra/orth.m \
+  scripts/linear-algebra/planerot.m \
+  scripts/linear-algebra/qzhess.m \
+  scripts/linear-algebra/rank.m \
+  scripts/linear-algebra/rref.m \
+  scripts/linear-algebra/subspace.m \
+  scripts/linear-algebra/trace.m \
+  scripts/linear-algebra/vech.m
 
-FCN_FILES += $(linear_algebra_FCN_FILES)
+scripts_linear_algebradir = $(fcnfiledir)/linear-algebra
+
+scripts_linear_algebra_DATA = $(scripts_linear_algebra_FCN_FILES)
 
-PKG_ADD_FILES += linear-algebra/PKG_ADD
+FCN_FILES += $(scripts_linear_algebra_FCN_FILES)
 
-DIRSTAMP_FILES += linear-algebra/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/linear-algebra/PKG_ADD
+
+DIRSTAMP_FILES += scripts/linear-algebra/$(octave_dirstamp)
--- a/scripts/linear-algebra/normest.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/linear-algebra/normest.m	Thu Dec 10 12:50:06 2015 -0800
@@ -68,7 +68,7 @@
     if (normx == 0)
       x = rand (ncols, 1);
     else
-      x = x / normx;
+      x /= normx;
     endif
     y = A' * x;
     n = norm (y);
--- a/scripts/linear-algebra/onenormest.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/linear-algebra/onenormest.m	Thu Dec 10 12:50:06 2015 -0800
@@ -133,7 +133,7 @@
 
   ## Initial test vectors X.
   X = rand (n, t);
-  X = X ./ (ones (n,1) * sum (abs (X), 1));
+  X ./= ones (n,1) * sum (abs (X), 1);
 
   ## Track if a vertex has been visited.
   been_there = zeros (n, 1);
--- a/scripts/linear-algebra/rref.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/linear-algebra/rref.m	Thu Dec 10 12:50:06 2015 -0800
@@ -41,7 +41,7 @@
   endif
 
   if (ndims (A) > 2)
-    error ("rref: expecting matrix argument");
+    error ("rref: A must be a 2-dimensional matrix");
   endif
 
   [rows, cols] = size (A);
--- a/scripts/linear-algebra/subspace.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/linear-algebra/subspace.m	Thu Dec 10 12:50:06 2015 -0800
@@ -37,7 +37,7 @@
   if (nargin != 2)
     print_usage ();
   elseif (ndims (A) != 2 || ndims (B) != 2)
-    error ("subspace: expecting A and B to be 2-dimensional arrays");
+    error ("subspace: A and B must be 2-dimensional arrays");
   elseif (rows (A) != rows (B))
     error ("subspace: column dimensions of A and B must match");
   endif
--- a/scripts/miscellaneous/copyfile.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/copyfile.m	Thu Dec 10 12:50:06 2015 -0800
@@ -22,7 +22,7 @@
 ## Copy the source files or directories @var{f1} to the destination @var{f2}.
 ##
 ## The name @var{f1} may contain globbing patterns.  If @var{f1} expands to
-## multiple file names, @var{f2} must be a directory.
+## multiple filenames, @var{f2} must be a directory.
 ##
 ## When the force flag @qcode{'f'} is given any existing files will be
 ## overwritten without prompting.
@@ -79,7 +79,7 @@
     error ("copyfile: when copying multiple files, F2 must be a directory");
   endif
 
-  ## Protect the file name(s).
+  ## Protect the filename(s).
   f1 = glob (f1);
   if (isempty (f1))
     error ("copyfile: no files to move");
--- a/scripts/miscellaneous/dos.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/dos.m	Thu Dec 10 12:50:06 2015 -0800
@@ -51,13 +51,8 @@
 
 %!test
 %! cmd = ls_command ();
-%! old_wstate = warning ("query");
-%! warning ("off", "Octave:undefined-return-values");
-%! unwind_protect
-%!   [status, output] = dos (cmd);
-%! unwind_protect_cleanup
-%!   warning (old_wstate);
-%! end_unwind_protect
+%! warning ("off", "Octave:undefined-return-values", "local");
+%! [status, output] = dos (cmd);
 %!
 %! if (ispc () && ! isunix ())
 %!   [status, output] = dos (cmd);
--- a/scripts/miscellaneous/edit.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/edit.m	Thu Dec 10 12:50:06 2015 -0800
@@ -139,7 +139,7 @@
   FUNCTION.EDITOR = [EDITOR() " %s"];
 
   if (nargin == 1)
-    ## User has supplied one arg, this can be a single file name
+    ## User has supplied one arg, this can be a single filename
     ## or a cell array of strings containing multiple files to be opened
     if (iscellstr (varargin{1}))
       ## If first arg is a cell array of strings,
@@ -150,10 +150,10 @@
       ## of length 1 (by copying the input cell array)
       editfilelist = varargin(1);
     else
-      error ("edit: expected file to be a string or cell array of strings");
+      error ("edit: file NAME must be a string or cell array of strings");
     endif
   elseif (nargin == 2)
-    ## User has supplied two arguments, these could be two file names,
+    ## User has supplied two arguments, these could be two filenames,
     ## or a combination of editor state name and new value for that state,
     ## so first check for the various states
     statevar = varargin{1};
@@ -182,7 +182,7 @@
         if (strcmp (stateval, "sync") || strcmp (stateval, "async"))
           FUNCTION.MODE = stateval;
         else
-          error ('edit: expected "edit MODE sync|async"');
+          error ("edit: MODE must be sync or async");
         endif
         return;
       case "EDITINPLACE"
@@ -206,7 +206,7 @@
         return;
       otherwise
         ## If none of the states match, assume both inputs are actually
-        ## file names to be opened.
+        ## filenames to be opened.
         editfilelist = varargin;
     endswitch
   elseif (nargin > 2)
@@ -242,7 +242,7 @@
 
   else
 
-    ## Only one file name was supplied, get it from the cell array
+    ## Only one filename was supplied, get it from the cell array
     file = tilde_expand (editfilelist{1});
 
     ## Check whether the user is trying to edit a builtin or compiled function.
@@ -269,7 +269,7 @@
     ## The code below includes a portion that serves as a place-holder for
     ## the changes suggested above.
 
-    ## Create list of explicit and implicit file names.
+    ## Create list of explicit and implicit filenames.
     filelist = {file};
     ## If file has no extension, add file.m and file.cc to the list.
     idx = rindex (file, ".");
@@ -471,11 +471,15 @@
         else
           code = " ";
         endif
-        body = ["#include <octave/oct.h>\n\n",               ...
-                "DEFUN_DLD(" name ", args, nargout, \"\\\n", ...
-                name, "\\n\\\n\")\n{\n",                     ...
-                "  octave_value_list retval;\n",             ...
-                "  int nargin = args.length ();\n\n",        ...
+        body = ["#include <octave/oct.h>\n\n"             ...
+                "DEFUN_DLD(" name ", args, nargout,\n"    ...
+                "          \"-*- texinfo -*-\\n\\\n"      ...
+                "@deftypefn {Loadable Function} "         ...
+                "{@var{retval} =} " name                  ...
+                " (@var{input1}, @var{input2})\\n\\\n"    ...
+                "@seealso{}\\n\\\n@end deftypefn\")\n{\n" ...
+                "  octave_value_list retval;\n"           ...
+                "  int nargin = args.length ();\n\n"      ...
                 code, "\n  return retval;\n}\n"];
 
         text = [comment, body];
--- a/scripts/miscellaneous/fact.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/fact.m	Thu Dec 10 12:50:06 2015 -0800
@@ -278,10 +278,10 @@
     while (i < numwords
            && length (newline = [line " " wc{i+1}]) < ncol)
       line = newline;
-      i++;
+      i += 1;
     endwhile
     out = [out, line, "\n"];
-    i++;
+    i += 1;
   endwhile
   out = [out, "\n"];
 endfunction
--- a/scripts/miscellaneous/fileattrib.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/fileattrib.m	Thu Dec 10 12:50:06 2015 -0800
@@ -17,7 +17,9 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {[@var{status}, @var{result}, @var{msgid}] =} fileattrib (@var{file})
+## @deftypefn  {Function File} {} fileattrib ()
+## @deftypefnx {Function File} {} fileattrib (@var{file})
+## @deftypefnx {Function File} {[@var{status}, @var{msg}, @var{msgid}] =} fileattrib (@var{file})
 ## Return information about @var{file}.
 ##
 ## If successful, @var{status} is 1, with @var{result} containing a structure
@@ -65,78 +67,108 @@
 ## @seealso{glob}
 ## @end deftypefn
 
-function [status, msg, msgid] = fileattrib (file)
+function [status, msg, msgid] = fileattrib (file = ".")
+
+  if (nargin > 1)
+    print_usage ();
+  endif
+
+  if (! ischar (file))
+    error ("fileattrib: FILE must be a string");
+  endif
 
   status = true;
   msg = "";
   msgid = "";
 
-  if (nargin == 0)
-    file = ".";
+  files = glob (file);
+  if (isempty (files))
+    files = {file};
   endif
+  nfiles = numel (files);
+
+  for i = [nfiles, 1:nfiles-1]  # first time in loop extends the struct array
+    [info, err, msg] = stat (files{i});
+    if (! err)
+      r(i).Name = canonicalize_file_name (files{i});
 
-  if (ischar (file))
-    files = glob (file);
-    if (isempty (files))
-      files = {file};
-      nfiles = 1;
-    else
-      nfiles = length (files);
-    endif
-  else
-    error ("fileattrib: expecting first argument to be a character string");
-  endif
+      if (isunix ())
+        r(i).archive = NaN;
+        r(i).system = NaN;
+        r(i).hidden = NaN;
+      else
+        [~, attrib] = dos (sprintf ('attrib "%s"', r(i).Name));        
+        ## dos() never returns error status so have to check it indirectly
+        if (length (attrib) < 12
+            || ! strcmp (deblank (attrib(12:end)), r(i).Name))
+          status = false;
+          msgid = "fileattrib";
+          break;
+        endif
+        attrib = attrib(1:11);
+        r(i).archive = any (attrib == "A");
+        r(i).system = any (attrib == "S");
+        r(i).hidden = any (attrib == "H");
+      endif
 
-  if (nargin == 0 || nargin == 1)
-
-    r_n = r_a = r_s = r_h = r_d ...
-        = r_u_r = r_u_w = r_u_x ...
-        = r_g_r = r_g_w = r_g_x ...
-        = r_o_r = r_o_w = r_o_x = cell (nfiles, 1);
-
-    curr_dir = pwd ();
+      r(i).directory = S_ISDIR (info.mode);
 
-    for i = 1:nfiles
-      [info, err, msg] = stat (files{i});
-      if (! err)
-        r_n{i} = canonicalize_file_name (files{i});
-        r_a{i} = NaN;
-        r_s{i} = NaN;
-        r_h{i} = NaN;
-        r_d{i} = S_ISDIR (info.mode);
-        ## FIXME: Maybe we should have S_IRUSR etc. masks?
-        modestr = info.modestr;
-        r_u_r{i} = modestr(2) == "r";
-        r_u_w{i} = modestr(3) == "w";
-        r_u_x{i} = modestr(4) == "x";
-        r_g_r{i} = modestr(5) == "r";
-        r_g_w{i} = modestr(6) == "w";
-        r_g_x{i} = modestr(7) == "x";
-        r_o_r{i} = modestr(8) == "r";
-        r_o_w{i} = modestr(9) == "w";
-        r_o_x{i} = modestr(10) == "x";
+      modestr = info.modestr;
+      r(i).UserRead = (modestr(2) == "r");
+      r(i).UserWrite = (modestr(3) == "w");
+      r(i).UserExecute = (modestr(4) == "x");
+      if (isunix ())
+        r(i).GroupRead = (modestr(5) == "r");
+        r(i).GroupWrite = (modestr(6) == "w");
+        r(i).GroupExecute = (modestr(7) == "x");
+        r(i).OtherRead  = (modestr(8) == "r");
+        r(i).OtherWrite = (modestr(9) == "w");
+        r(i).OtherExecute = (modestr(10) == "x");
       else
-        status = false;
-        msgid = "fileattrib";
-        break;
+        r(i).GroupRead = NaN;
+        r(i).GroupWrite = NaN;
+        r(i).GroupExecute = NaN;
+        r(i).OtherRead = NaN;
+        r(i).OtherWrite = NaN;
+        r(i).OtherExecute = NaN;
       endif
-    endfor
-    if (status)
-      r = struct ("Name", r_n, "archive", r_a, "system", r_s,
-                  "hidden", r_s, "directory", r_d, "UserRead", r_u_r,
-                  "UserWrite", r_u_w, "UserExecute", r_u_x,
-                  "GroupRead", r_g_r, "GroupWrite", r_g_w,
-                  "GroupExecute", r_g_x, "OtherRead", r_o_r,
-                  "OtherWrite", r_o_w, "OtherExecute", r_o_x);
-      if (nargout == 0)
-        status = r;
-      else
-        msg = r;
-      endif
+    else
+      status = false;
+      msgid = "fileattrib";
+      break;
     endif
-  else
-    print_usage ();
+  endfor
+
+  if (status)
+    if (nargout == 0)
+      status = r;
+    else
+      msg = r;
+    endif
   endif
 
 endfunction
 
+
+%!test
+%! [status, attr] = fileattrib (P_tmpdir ()); 
+%! assert (status);
+%! assert (isstruct (attr));
+%! assert (numel (fieldnames (attr)), 14);
+%! assert (attr.Name, P_tmpdir ());
+%! assert (attr.directory);
+%! if (ispc ())
+%!   assert (! isnan (attr.archive));
+%! else
+%!   assert (isnan (attr.archive));
+%! endif
+%! assert (attr.UserRead);
+%! if (ispc ())
+%!   assert (isnan (attr.GroupRead));
+%! else
+%!   assert (! isnan (attr.GroupRead));
+%! endif
+
+%!error fileattrib (1, 2)
+%!error <FILE must be a string> fileattrib (1)
+
--- a/scripts/miscellaneous/fullfile.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/fullfile.m	Thu Dec 10 12:50:06 2015 -0800
@@ -42,6 +42,8 @@
 ## replaced by backslashes; in addition drive letters are stripped of leading
 ## file separators to obtain a valid file path.
 ##
+## Note: @code{fullfile} does not perform any validation of the resulting full
+## filename.
 ## @seealso{fileparts, filesep}
 ## @end deftypefn
 
@@ -54,12 +56,14 @@
                                        "UniformOutput", false);
   else
     non_empty = cellfun ("isempty", varargin);
+    unc = 0;
     if (ispc && ! isempty (varargin))
-      varargin = strrep (varargin, "/", filesep);
+      varargin = strrep (varargin, '/', filesep);
+      unc = strncmp (varargin{1}, '\\', 2);
       varargin(1) = regexprep (varargin{1}, '[\\/]*([a-zA-Z]:[\\/]*)', "$1");
     endif
     filename = strjoin (varargin(! non_empty), filesep);
-    filename(strfind (filename, [filesep filesep])) = "";
+    filename(unc + strfind (filename(1+unc : end), [filesep filesep])) = "";
   endif
 
 endfunction
@@ -87,7 +91,6 @@
 %!assert (fullfile ("x", "", "y", ""), xfsy)
 %!assert (fullfile ("", "x", "", "y", ""), xfsy)
 %!assert (fullfile (fs), fs)
-%!assert (fullfile (fs, fs), fs)
 %!assert (fullfile (fs, "x"), fsx)
 %!assert (fullfile (fs, xfs), fsxfs)
 %!assert (fullfile (fsx, fs), fsxfs)
@@ -109,6 +112,12 @@
 %!           ['A:\' xfsyfs]);
 %! endif
 
+## *nix specific - double backslash
+%!test
+%! if (isunix || ismac)
+%!   assert (fullfile (fs, fs), fs)
+%! endif
+
 ## Windows specific - drive letters and file sep type, cell array
 %!test
 %! if (ispc)
--- a/scripts/miscellaneous/genvarname.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/genvarname.m	Thu Dec 10 12:50:06 2015 -0800
@@ -160,7 +160,7 @@
     varname(i) = str(i);
     idx = 0;
     while (excluded)
-      idx++;
+      idx += 1;
       varname{i} = sprintf ("%s%d", str{i}, idx);
       excluded = any (strcmp (varname{i}, exclusions));
     endwhile
--- a/scripts/miscellaneous/inputname.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/inputname.m	Thu Dec 10 12:50:06 2015 -0800
@@ -35,7 +35,13 @@
     print_usage ();
   endif
 
-  s = evalin ("caller", sprintf ("__varval__ (\".argn.\"){%d};", fix (n)));
+  s = "";
+  try
+    s = evalin ("caller", sprintf ("__varval__ ('.argn.'){%d}", fix (n)));
+  catch
+    return;
+  end_try_catch
+
   ## For compatibility with Matlab,
   ## return empty string if argument name is not a valid identifier.
   if (! isvarname (s))
@@ -46,26 +52,33 @@
 
 
 ## 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
-## them.  It does this using the following template:
+## The test function builds a private context for each test, with only the
+## specified values shared between them.  It does this using the following
+## template:
 ##
-##     function [<shared>] = testfn(<shared>)
+##     function [<shared>] = testfn (<shared>)
 ##        <test>
+##     endfunction
 ##
-## 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.
+## 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")
+%!assert (inputname (3), "")
 
-%!function r = foo (x, y)
+## Clear parameter list so that testfn is created with zero inputs/outputs
+%!shared
+%!assert (inputname (-1), "")
+%!assert (inputname (1), "")
+
+%!function r = __foo__ (x, y)
 %!  r = inputname (2);
 %!endfunction
-%!assert (foo (pi, e), "e");
-%!assert (feval (@foo, pi, e), "e");
+%!assert (__foo__ (pi, e), "e");
+%!assert (feval (@__foo__, pi, e), "e");
 
 %!error inputname ()
 %!error inputname (1,2)
--- a/scripts/miscellaneous/ls.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/ls.m	Thu Dec 10 12:50:06 2015 -0800
@@ -86,6 +86,10 @@
     args = "";
   endif
 
+  if (nargout > 0 && (isunix () || ismac ()))
+    args = ["-1 ", args];
+  endif
+
   cmd = [__ls_command__ " " args];
 
   if (page_screen_output () || nargout > 0)
--- a/scripts/miscellaneous/menu.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/menu.m	Thu Dec 10 12:50:06 2015 -0800
@@ -30,7 +30,8 @@
 ## or as a cell array of strings.
 ##
 ## The return value @var{choice} is the number of the option selected by the
-## user counting from 1.
+## user counting from 1 or 0 if the user aborts the dialog or makes an invalid
+## selection.
 ##
 ## This function is useful for interactive programs.  There is no limit to the
 ## number of options that may be passed in, but it may be confusing to present
@@ -58,7 +59,7 @@
     [choice, ok] = listdlg ("Name", "menu", "PromptString", title,
                             "ListString", varargin, "SelectionMode", "Single");
     if (! ok)
-      choice = 1;
+      choice = 0;
     endif
   else  # console menu
     ## Force pending output to appear before the menu.
@@ -82,6 +83,7 @@
       choice = sscanf (s, "%d");
       if (! isscalar (choice) || choice < 1 || choice > nopt)
         printf ("\nerror: input invalid or out of range\n\n");
+        choice = 0;
       else
         break;
       endif
--- a/scripts/miscellaneous/mkoctfile.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/mkoctfile.m	Thu Dec 10 12:50:06 2015 -0800
@@ -31,7 +31,7 @@
 ## the exit status in the @var{status} variable.
 ##
 ## @code{mkoctfile} accepts the following options, all of which are optional
-## except for the file name of the code you wish to compile:
+## except for the filename of the code you wish to compile:
 ##
 ## @table @samp
 ## @item -I DIR
@@ -69,7 +69,7 @@
 ##
 ## @item  -o FILE
 ## @itemx --output FILE
-## Output file name.  Default extension is .oct (or .mex if @samp{--mex} is
+## Output filename.  Default extension is .oct (or .mex if @samp{--mex} is
 ## specified) unless linking a stand-alone executable.
 ##
 ## @item  -p VAR
@@ -168,7 +168,7 @@
   endif
 
   if (sys != 0)
-    warning ("mkoctfile exited with failure status");
+    warning ("mkoctfile: building exited with failure status");
   endif
 
 endfunction
--- a/scripts/miscellaneous/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,88 +1,99 @@
-FCN_FILE_DIRS += miscellaneous
+FCN_FILE_DIRS += \
+  scripts/miscellaneous \
+  scripts/miscellaneous/private
 
-miscellaneous_PRIVATE_FCN_FILES = \
-  miscellaneous/private/display_info_file.m \
-  miscellaneous/private/__w2mpth__.m \
-  miscellaneous/private/__xzip__.m
+scripts_miscellaneous_PRIVATE_FCN_FILES = \
+  scripts/miscellaneous/private/display_info_file.m \
+  scripts/miscellaneous/private/__w2mpth__.m \
+  scripts/miscellaneous/private/__xzip__.m
 
-miscellaneous_FCN_FILES = \
-  miscellaneous/ans.m \
-  miscellaneous/bug_report.m \
-  miscellaneous/bunzip2.m \
-  miscellaneous/bzip2.m \
-  miscellaneous/cast.m \
-  miscellaneous/citation.m \
-  miscellaneous/comma.m \
-  miscellaneous/compare_versions.m \
-  miscellaneous/computer.m \
-  miscellaneous/copyfile.m \
-  miscellaneous/debug.m \
-  miscellaneous/delete.m \
-  miscellaneous/desktop.m \
-  miscellaneous/dir.m \
-  miscellaneous/dos.m \
-  miscellaneous/edit.m \
-  miscellaneous/error_ids.m \
-  miscellaneous/fact.m \
-  miscellaneous/fileattrib.m \
-  miscellaneous/fileparts.m \
-  miscellaneous/fullfile.m \
-  miscellaneous/genvarname.m \
-  miscellaneous/getappdata.m \
-  miscellaneous/getfield.m \
-  miscellaneous/gunzip.m \
-  miscellaneous/gzip.m \
-  miscellaneous/info.m \
-  miscellaneous/inputname.m \
-  miscellaneous/isappdata.m \
-  miscellaneous/isdeployed.m \
-  miscellaneous/ismac.m \
-  miscellaneous/ispc.m \
-  miscellaneous/isunix.m \
-  miscellaneous/license.m \
-  miscellaneous/list_primes.m \
-  miscellaneous/ls.m \
-  miscellaneous/ls_command.m \
-  miscellaneous/menu.m \
-  miscellaneous/mex.m \
-  miscellaneous/mexext.m \
-  miscellaneous/mkoctfile.m \
-  miscellaneous/movefile.m \
-  miscellaneous/namelengthmax.m \
-  miscellaneous/news.m \
-  miscellaneous/open.m \
-  miscellaneous/orderfields.m \
-  miscellaneous/pack.m \
-  miscellaneous/paren.m \
-  miscellaneous/parseparams.m \
-  miscellaneous/perl.m \
-  miscellaneous/python.m \
-  miscellaneous/recycle.m \
-  miscellaneous/rmappdata.m \
-  miscellaneous/run.m \
-  miscellaneous/semicolon.m \
-  miscellaneous/setappdata.m \
-  miscellaneous/setfield.m \
-  miscellaneous/substruct.m \
-  miscellaneous/swapbytes.m \
-  miscellaneous/symvar.m \
-  miscellaneous/tar.m \
-  miscellaneous/tempdir.m \
-  miscellaneous/tmpnam.m \
-  miscellaneous/unix.m \
-  miscellaneous/unpack.m \
-  miscellaneous/untar.m \
-  miscellaneous/unzip.m \
-  miscellaneous/ver.m \
-  miscellaneous/version.m \
-  miscellaneous/warning_ids.m \
-  miscellaneous/what.m \
-  miscellaneous/xor.m \
-  miscellaneous/zip.m \
-  $(miscellaneous_PRIVATE_FCN_FILES)
+scripts_miscellaneous_FCN_FILES = \
+  scripts/miscellaneous/ans.m \
+  scripts/miscellaneous/bug_report.m \
+  scripts/miscellaneous/bunzip2.m \
+  scripts/miscellaneous/bzip2.m \
+  scripts/miscellaneous/cast.m \
+  scripts/miscellaneous/citation.m \
+  scripts/miscellaneous/comma.m \
+  scripts/miscellaneous/compare_versions.m \
+  scripts/miscellaneous/computer.m \
+  scripts/miscellaneous/copyfile.m \
+  scripts/miscellaneous/debug.m \
+  scripts/miscellaneous/delete.m \
+  scripts/miscellaneous/desktop.m \
+  scripts/miscellaneous/dir.m \
+  scripts/miscellaneous/dos.m \
+  scripts/miscellaneous/edit.m \
+  scripts/miscellaneous/error_ids.m \
+  scripts/miscellaneous/fact.m \
+  scripts/miscellaneous/fileattrib.m \
+  scripts/miscellaneous/fileparts.m \
+  scripts/miscellaneous/fullfile.m \
+  scripts/miscellaneous/genvarname.m \
+  scripts/miscellaneous/getappdata.m \
+  scripts/miscellaneous/getfield.m \
+  scripts/miscellaneous/gunzip.m \
+  scripts/miscellaneous/gzip.m \
+  scripts/miscellaneous/info.m \
+  scripts/miscellaneous/inputname.m \
+  scripts/miscellaneous/isappdata.m \
+  scripts/miscellaneous/isdeployed.m \
+  scripts/miscellaneous/ismac.m \
+  scripts/miscellaneous/ispc.m \
+  scripts/miscellaneous/isunix.m \
+  scripts/miscellaneous/license.m \
+  scripts/miscellaneous/list_primes.m \
+  scripts/miscellaneous/ls.m \
+  scripts/miscellaneous/ls_command.m \
+  scripts/miscellaneous/menu.m \
+  scripts/miscellaneous/mex.m \
+  scripts/miscellaneous/mexext.m \
+  scripts/miscellaneous/mkoctfile.m \
+  scripts/miscellaneous/movefile.m \
+  scripts/miscellaneous/namelengthmax.m \
+  scripts/miscellaneous/news.m \
+  scripts/miscellaneous/open.m \
+  scripts/miscellaneous/orderfields.m \
+  scripts/miscellaneous/pack.m \
+  scripts/miscellaneous/paren.m \
+  scripts/miscellaneous/parseparams.m \
+  scripts/miscellaneous/perl.m \
+  scripts/miscellaneous/python.m \
+  scripts/miscellaneous/recycle.m \
+  scripts/miscellaneous/rmappdata.m \
+  scripts/miscellaneous/run.m \
+  scripts/miscellaneous/semicolon.m \
+  scripts/miscellaneous/setappdata.m \
+  scripts/miscellaneous/setfield.m \
+  scripts/miscellaneous/substruct.m \
+  scripts/miscellaneous/swapbytes.m \
+  scripts/miscellaneous/symvar.m \
+  scripts/miscellaneous/tar.m \
+  scripts/miscellaneous/tempdir.m \
+  scripts/miscellaneous/tmpnam.m \
+  scripts/miscellaneous/unix.m \
+  scripts/miscellaneous/unpack.m \
+  scripts/miscellaneous/untar.m \
+  scripts/miscellaneous/unzip.m \
+  scripts/miscellaneous/ver.m \
+  scripts/miscellaneous/version.m \
+  scripts/miscellaneous/warning_ids.m \
+  scripts/miscellaneous/what.m \
+  scripts/miscellaneous/xor.m \
+  scripts/miscellaneous/zip.m
 
-FCN_FILES += $(miscellaneous_FCN_FILES)
+scripts_miscellaneousdir = $(fcnfiledir)/miscellaneous
+
+scripts_miscellaneous_DATA = $(scripts_miscellaneous_FCN_FILES)
+
+scripts_miscellaneous_privatedir = $(fcnfiledir)/miscellaneous/private
+
+scripts_miscellaneous_private_DATA = $(scripts_miscellaneous_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += miscellaneous/PKG_ADD
+FCN_FILES += \
+  $(scripts_miscellaneous_FCN_FILES) \
+  $(scripts_miscellaneous_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += miscellaneous/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/miscellaneous/PKG_ADD
+
+DIRSTAMP_FILES += scripts/miscellaneous/$(octave_dirstamp)
--- a/scripts/miscellaneous/movefile.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/movefile.m	Thu Dec 10 12:50:06 2015 -0800
@@ -24,9 +24,9 @@
 ## Move the source files or directories @var{f1} to the destination @var{f2}.
 ##
 ## The name @var{f1} may contain globbing patterns.  If @var{f1} expands to
-## multiple file names, @var{f2} must be a directory.  If no destination
+## multiple filenames, @var{f2} must be a directory.  If no destination
 ## @var{f2} is specified then the destination is the present working directory.
-## If @var{f2} is a file name then @var{f1} is renamed to @var{f2}.
+## If @var{f2} is a filename then @var{f1} is renamed to @var{f2}.
 ##
 ## When the force flag @qcode{'f'} is given any existing files will be
 ## overwritten without prompting.
@@ -86,7 +86,7 @@
     error ("movefile: when moving multiple files, F2 must be a directory");
   endif
 
-  ## Protect the file name(s).
+  ## Protect the filename(s).
   f1 = glob (f1);
   if (isempty (f1))
     error ("movefile: no files to move");
--- a/scripts/miscellaneous/open.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/open.m	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 ## @deftypefn  {Function File} {@var{output} =} open @var{file}
 ## @deftypefnx {Function File} {@var{output} =} open (@var{file})
 ## Open the file @var{file} in Octave or in an external application based on
-## the file type as determined by the file name extension.
+## the file type as determined by the filename extension.
 ##
 ## Recognized file types are
 ##
@@ -45,7 +45,7 @@
   endif
 
   if (! ischar (file))
-    error ("expecting argument to be a file name");
+    error ("open: FILE must be a string");
   endif
 
   [~, ~, ext] = fileparts (file);
@@ -59,12 +59,12 @@
       evalin ("base", sprintf ("load ('%s');", file));
     endif
   elseif (any (strcmpi (ext, {".fig", ".mdl", ".slx", ".prj"})))
-    error ("opening file type '%s' is not supported", ext);
+    error ("open: opening file type '%s' is not supported", ext);
   elseif (strcmpi (ext, ".exe"))
     if (ispc ())
       dos (file);
     else
-      error ("executing .exe files is only supported on Windows systems");
+      error ("open: executing .exe files is only supported on Windows systems");
     endif
   else
     __open_with_system_app__ (file);
@@ -72,7 +72,9 @@
 
 endfunction
 
+
 ## Test input validation
-%!error open
-%!error open (1)
-%!error output = open (1)
+%!error open ()
+%!error open ("abc", "def")
+%!error <FILE must be a string> open (1)
+
--- a/scripts/miscellaneous/perl.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/perl.m	Thu Dec 10 12:50:06 2015 -0800
@@ -24,7 +24,7 @@
 ## arguments.
 ##
 ## Return output in @var{output} and optional status in @var{status}.  If
-## @var{scriptfile} is not an absolute file name it is searched for in the
+## @var{scriptfile} is not an absolute filename it is searched for in the
 ## current directory and then in the Octave loadpath.
 ## @seealso{system, python}
 ## @end deftypefn
--- a/scripts/miscellaneous/private/__w2mpth__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/private/__w2mpth__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -47,7 +47,7 @@
 
   ## Check for platform
   if (! ispc)
-    error ("__w2mpth__ should only be called on Windows platforms\n");
+    error ("__w2mpth__: function must only be called on Windows platforms\n");
   endif
 
   ## Replace backslash file separators by forward slashes
--- a/scripts/miscellaneous/python.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/python.m	Thu Dec 10 12:50:06 2015 -0800
@@ -25,7 +25,7 @@
 ## arguments.
 ##
 ## Return output in @var{output} and optional status in @var{status}.  If
-## @var{scriptfile} is not an absolute file name it is searched for in the
+## @var{scriptfile} is not an absolute filename it is searched for in the
 ## current directory and then in the Octave loadpath.
 ## @seealso{system, perl}
 ## @end deftypefn
--- a/scripts/miscellaneous/run.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/run.m	Thu Dec 10 12:50:06 2015 -0800
@@ -25,7 +25,7 @@
 ## which end with the extension @file{".m"}, can be run simply by typing
 ## their name.  For scripts not located on the load path, use @code{run}.
 ##
-## The file name @var{script} can be a bare, fully qualified, or relative
+## The filename @var{script} can be a bare, fully qualified, or relative
 ## filename and with or without a file extension.  If no extension is specified,
 ## Octave will first search for a script with the @file{".m"} extension before
 ## falling back to the script name without an extension.
--- a/scripts/miscellaneous/substruct.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/substruct.m	Thu Dec 10 12:50:06 2015 -0800
@@ -67,7 +67,7 @@
       error ("substruct: for TYPE == ., SUBS must be a character string");
     endif
   else
-    error ('substruct: expecting TYPE to be one of "()", "{}", or "."');
+    error ('substruct: TYPE must be one of "()", "{}", or "."');
   endif
 
   retval = struct ("type", typ, "subs", sub);
--- a/scripts/miscellaneous/tmpnam.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/tmpnam.m	Thu Dec 10 12:50:06 2015 -0800
@@ -20,7 +20,7 @@
 ## @deftypefn  {Function File} {@var{fname} =} tmpnam ()
 ## @deftypefnx {Function File} {@var{fname} =} tmpnam (@var{dir})
 ## @deftypefnx {Function File} {@var{fname} =} tmpnam (@var{dir}, @var{prefix})
-## Return a unique temporary file name as a string.
+## Return a unique temporary filename as a string.
 ##
 ## If @var{prefix} is omitted, a value of @qcode{"oct-"} is used.
 ##
--- a/scripts/miscellaneous/unix.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/unix.m	Thu Dec 10 12:50:06 2015 -0800
@@ -51,13 +51,8 @@
 
 %!test
 %! cmd = ls_command ();
-%! old_wstate = warning ("query");
-%! warning ("off", "Octave:undefined-return-values");
-%! unwind_protect
-%!   [status, output] = unix (cmd);
-%! unwind_protect_cleanup
-%!   warning (old_wstate);
-%! end_unwind_protect
+%! warning ("off", "Octave:undefined-return-values", "local");
+%! [status, output] = unix (cmd);
 %!
 %! if (isunix ())
 %!   assert (status, 0);
--- a/scripts/miscellaneous/unpack.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/miscellaneous/unpack.m	Thu Dec 10 12:50:06 2015 -0800
@@ -86,11 +86,14 @@
     file = cellstr (file);
   endif
   if (numel (file) == 1)
-    gfile = glob (file);
-    if (isempty (gfile))
-      error ('unpack: file "%s" not found', file{1});
-    else
-      file = gfile;
+    if (isempty (strfind (file{1}, "://")))
+      ## FIXME: The above code is not a perfect test for a URL
+      gfile = glob (file);
+      if (isempty (gfile))
+        error ('unpack: file "%s" not found', file{1});
+      else
+        file = gfile;
+      endif
     endif
   endif
 
@@ -135,7 +138,7 @@
     if (! isempty (strfind (file, "://")))
       ## FIXME: The above code is not a perfect test for a URL
       urlfile = file;
-      tmpfile = [tempname ext];
+      tmpfile = fullfile (tempdir (), [name ext]);
       [file, success, msg] = urlwrite (urlfile, tmpfile);
       if (! success)
         error ('unpack: could not fetch "%s": %s', urlfile, msg);
@@ -296,7 +299,7 @@
   ## Parse the output from bzip2 and bunzip2 returning the files
   ## commpressed (or decompressed).
 
-  ## Strip leading blanks and .bz2 extension from file name
+  ## Strip leading blanks and .bz2 extension from filename
   files = regexprep (output, '^\s+(.*)\.bz2: .*', '$1');
 endfunction
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,218 @@
+scripts_EXTRA_DIST =
+
+scripts_CLEANFILES =
+scripts_DISTCLEANFILES =
+scripts_MAINTAINERCLEANFILES =
+
+## FIXME -- including scripts/@ftp/module.mk fails.  Is that an automake bug?
+
+FCN_FILE_DIRS += scripts/@ftp
+
+scripts_@ftp_FCN_FILES = \
+  scripts/@ftp/ascii.m \
+  scripts/@ftp/binary.m  \
+  scripts/@ftp/cd.m  \
+  scripts/@ftp/close.m  \
+  scripts/@ftp/delete.m  \
+  scripts/@ftp/dir.m  \
+  scripts/@ftp/display.m  \
+  scripts/@ftp/ftp.m  \
+  scripts/@ftp/loadobj.m  \
+  scripts/@ftp/mget.m  \
+  scripts/@ftp/mkdir.m  \
+  scripts/@ftp/mput.m  \
+  scripts/@ftp/rename.m  \
+  scripts/@ftp/rmdir.m  \
+  scripts/@ftp/saveobj.m
+
+scripts_@ftpdir = $(fcnfiledir)/@ftp
+
+scripts_@ftp_DATA = $(scripts_@ftp_FCN_FILES)
+
+FCN_FILES += $(scripts_@ftp_FCN_FILES)
+
+PKG_ADD_FILES += scripts/@ftp/PKG_ADD
+
+DIRSTAMP_FILES += scripts/@ftp/$(octave_dirstamp)
+
+include scripts/audio/module.mk
+include scripts/deprecated/module.mk
+include scripts/elfun/module.mk
+include scripts/general/module.mk
+include scripts/geometry/module.mk
+include scripts/gui/module.mk
+include scripts/help/module.mk
+include scripts/image/module.mk
+include scripts/io/module.mk
+include scripts/java/module.mk
+include scripts/linear-algebra/module.mk
+include scripts/miscellaneous/module.mk
+include scripts/ode/module.mk
+include scripts/optimization/module.mk
+include scripts/path/module.mk
+include scripts/pkg/module.mk
+include scripts/plot/appearance/module.mk
+include scripts/plot/draw/module.mk
+include scripts/plot/util/module.mk
+include scripts/polynomial/module.mk
+include scripts/prefs/module.mk
+include scripts/set/module.mk
+include scripts/signal/module.mk
+include scripts/sparse/module.mk
+include scripts/specfun/module.mk
+include scripts/special-matrix/module.mk
+include scripts/startup/module.mk
+include scripts/statistics/base/module.mk
+include scripts/statistics/distributions/module.mk
+include scripts/statistics/models/module.mk
+include scripts/statistics/tests/module.mk
+include scripts/strings/module.mk
+include scripts/testfun/module.mk
+include scripts/time/module.mk
+
+image_DATA += $(SCRIPTS_IMAGES)
+
+GEN_FCN_FILES_IN = $(GEN_FCN_FILES:.m=.in)
+
+ALL_LOCAL_TARGETS += \
+  $(GEN_FCN_FILES) \
+  $(PKG_ADD_FILES) \
+  $(JAR_FILES)
+
+if AMCOND_BUILD_DOCS
+ALL_LOCAL_TARGETS += scripts/.DOCSTRINGS
+endif
+
+define PKG_ADD_FILE_TEMPLATE
+$(1)/PKG_ADD: $$($(2)_FCN_FILES) $$($(2)_GEN_FCN_FILES) $(1)/$(octave_dirstamp) scripts/mk-pkg-add
+	$$(AM_V_GEN)rm -f $$@-t $$@ && \
+	$$(srcdir)/scripts/mk-pkg-add $(srcdir) $$($(2)_FCN_FILES) -- $$($(2)_GEN_FCN_FILES) > $$@-t && \
+	mv $$@-t $$@
+endef
+
+$(foreach d, $(FCN_FILE_DIRS), $(eval $(call PKG_ADD_FILE_TEMPLATE, $(d),$(subst /,_,$(subst -,_,$(d))))))
+
+define GEN_FCN_FILES_TEMPLATE
+$(1): $(1:.m=.in) Makefile $(dir $(1))$(octave_dirstamp)
+	$$(AM_V_GEN)$$(do_subst_config_vals)
+endef
+
+$(foreach f, $(GEN_FCN_FILES), $(eval $(call GEN_FCN_FILES_TEMPLATE, $(f))))
+
+if AMCOND_BUILD_DOCS
+
+DOCSTRING_FILES += scripts/DOCSTRINGS
+
+scripts/DOCSTRINGS: | scripts/.DOCSTRINGS
+
+scripts/.DOCSTRINGS: $(FCN_FILES) $(GEN_FCN_FILES) scripts/mkdoc.pl Makefile
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	if [ "x$(srcdir)" != "x." ] && [ -f $(srcdir)/scripts/DOCSTRINGS ] && [ ! -f scripts/DOCSTRINGS ]; then \
+		cp $(srcdir)/scripts/DOCSTRINGS scripts/DOCSTRINGS; \
+		touch -r $(srcdir)/scripts/DOCSTRINGS scripts/DOCSTRINGS; \
+	fi && \
+	$(PERL) $(srcdir)/scripts/mkdoc.pl "$(srcdir)" $(FCN_FILES) -- $(GEN_FCN_FILES) > $@-t && \
+	mv $@-t $@ && \
+	$(top_srcdir)/build-aux/move-if-change $@ scripts/DOCSTRINGS && \
+	touch $@
+
+OCTAVE_INTERPRETER_TARGETS += \
+  scripts/.DOCSTRINGS
+
+endif
+
+check-m-sources:
+	@echo "checking whether files in source tree are listed in module.mk files..."; \
+	for f in $$(find $(srcdir)/scripts -name '*.m'); do \
+	  found=false; \
+	  for m in $(FCN_FILES) $(GEN_FCN_FILES); do \
+	    if [ "$$f" = $(srcdir)/scripts/"$$m" ]; then \
+	      found=true; \
+	      break; \
+	    fi; \
+	  done; \
+	  if $$found; then \
+	    true; \
+	  else \
+	    missing=$$(echo $$f | $(SED) "s|^$(srcdir)/scripts||"); \
+	    echo "$$missing: not listed in SOURCES"; \
+	  fi; \
+	done; \
+	if test -z "$$missing"; then \
+	  echo "yes"; \
+	fi
+.PHONY: check-m-sources
+
+check-missing-semicolon:
+	@echo "checking for missing semicolons in .m files..."
+	( echo "warning on Octave:missing-semicolon;"; \
+	  for m in $(addprefix $(srcdir), $(FCN_FILES)) $(GEN_FCN_FILES); do \
+	    echo "source ('$$m');"; \
+	  done ) | ../run-octave -qf
+.PHONY: check-missing-semicolon
+
+## Add rule to generate ctags.
+## Automake would normally generate such a rule, but only if there is a
+## xxx_SOURCES target
+ctags:
+	ctags $(addprefix $(srcdir)/, $(FCN_FILES)) $(GEN_FCN_FILES)
+
+install-data-local: install-startup-files install-pkg-add
+
+uninstall-local: uninstall-startup-files uninstall-pkg-add
+
+install-pkg-add:
+	for f in $(PKG_ADD_FILES); do \
+	  if [ -n "`cat $$f`" ]; then \
+	    base=`echo $$f | $(SED) 's,^scripts/,,'`; \
+	    $(MKDIR_P) $(DESTDIR)$(fcnfiledir)/`echo $$base | $(SED) 's,/[^/]*$$,,'`; \
+	    $(INSTALL_DATA) $$f $(DESTDIR)$(fcnfiledir)/$$base; \
+	  fi \
+	done
+.PHONY: install-pkg-add
+
+uninstall-pkg-add:
+	for f in $(PKG_ADD_FILES); do \
+	  base=`echo $$f | $(SED) 's,^scripts/,,'`; \
+	  rm -f $(DESTDIR)$(fcnfiledir)/$$base; \
+	done
+.PHONY: uninstall-pkg-add
+
+if AMCOND_HAVE_JAVA
+scripts-dist-hook:
+else
+scripts-dist-hook:
+	@echo "Packaging distribution requires Java." ; exit 1;
+endif
+
+scripts_EXTRA_DIST += \
+  $(SCRIPTS_IMAGES) \
+  $(FCN_FILES) \
+  $(GEN_FCN_FILES_IN) \
+  scripts/DOCSTRINGS \
+  scripts/mkdoc.pl \
+  scripts/mk-pkg-add
+
+EXTRA_DIST += $(scripts_EXTRA_DIST)
+
+scripts_DISTCLEANFILES += \
+  $(PKG_ADD_FILES) \
+  $(DIRSTAMP_FILES) \
+  $(GEN_FCN_FILES)
+
+scripts_MAINTAINERCLEANFILES += \
+  scripts/.DOCSTRINGS \
+  scripts/DOCSTRINGS
+
+CLEANFILES += $(scripts_CLEANFILES)
+DISTCLEANFILES += $(scripts_DISTCLEANFILES)
+MAINTAINERCLEANFILES += $(scripts_MAINTAINERCLEANFILES)
+
+scripts-clean:
+	rm -f $(scripts_CLEANFILES)
+
+scripts-distclean: scripts-clean
+	rm -f $(scripts_DISTCLEANFILES)
+
+scripts-maintainer-clean: scripts-distclean
+	rm -f $(scripts_MAINTAINERCLEANFILES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,36 @@
+FCN_FILE_DIRS += \
+  scripts/ode \
+  scripts/ode/private
+
+scripts_ode_PRIVATE_FCN_FILES = \
+  scripts/ode/private/AbsRel_Norm.m \
+  scripts/ode/private/integrate_adaptive.m \
+  scripts/ode/private/integrate_const.m \
+  scripts/ode/private/integrate_n_steps.m \
+  scripts/ode/private/kahan.m \
+  scripts/ode/private/ode_event_handler.m \
+  scripts/ode/private/ode_struct_value_check.m \
+  scripts/ode/private/runge_kutta_45_dorpri.m \
+  scripts/ode/private/runge_kutta_interpolate.m \
+  scripts/ode/private/starting_stepsize.m
+
+scripts_ode_FCN_FILES = \
+  scripts/ode/ode45.m \
+  scripts/ode/odeset.m \
+  scripts/ode/odeget.m
+
+scripts_odedir = $(fcnfiledir)/ode
+
+scripts_ode_DATA = $(scripts_ode_FCN_FILES)
+
+scripts_ode_privatedir = $(fcnfiledir)/ode/private
+
+scripts_ode_private_DATA = $(scripts_ode_PRIVATE_FCN_FILES)
+
+FCN_FILES += \
+  $(scripts_ode_FCN_FILES) \
+  $(scripts_ode_PRIVATE_FCN_FILES)
+
+PKG_ADD_FILES += scripts/ode/PKG_ADD
+
+DIRSTAMP_FILES += scripts/ode/$(octave_dirstamp)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/ode45.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,616 @@
+## Copyright (C) 2014, Jacopo Corno <jacopo.corno@gmail.com>
+## Copyright (C) 2013, Roberto Porcu' <roberto.porcu@polimi.it>
+## Copyright (C) 2006-2012, Thomas Treichl <treichl@users.sourceforge.net>
+##
+## 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{t}, @var{y}] =} ode45 (@var{fun}, @var{trange}, @var{init})
+## @deftypefnx {Function File} {[@var{t}, @var{y}] =} ode45 (@var{fun}, @var{trange}, @var{init}, @var{ode_opt})
+## @deftypefnx {Function File} {[@var{t}, @var{y}] =} ode45 (@dots{}, @var{par1}, @var{par2}, @dots{})
+## @deftypefnx {Function File} {[@var{t}, @var{y}, @var{te}, @var{ye}, @var{ie}] =} ode45 (@dots{})
+## @deftypefnx {Function File} {@var{solution} =} ode45 (@dots{})
+##
+## Solve a set of non-stiff Ordinary Differential Equations (non-stiff ODEs)
+## with the well known explicit @nospell{Dormand-Prince} method of order 4.
+##
+## @var{fun} is a function handle, inline function, or string containing the
+## name of the function that defines the ODE: @code{y' = f(t,y)}.  The function
+## must accept two inputs where the first is time @var{t} and the second is a
+## column vector of unknowns @var{y}.
+##
+## @var{trange} specifies the time interval over which the ODE will be
+## evaluated.  Typically, it is a two-element vector specifying the initial and
+## final times (@code{[tinit, tfinal]}).  If there are more than two elements
+## then the solution will also be evaluated at these intermediate time
+## instances unless the integrate function specified is
+## @command{integrate_n_steps}.
+##
+## By default, @code{ode45} uses an adaptive timestep with the
+## @code{integrate_adaptive} algorithm.  The tolerance for the timestep
+## computation may be changed by using the option @qcode{"Tau"}, that has a
+## default value of @math{1e-6}.  If the ODE option @qcode{"TimeStepSize"} is
+## not empty, then the stepper called will be @code{integrate_const}.  If, in
+## addition, the option @qcode{"TimeStepNumber"} is also specified then the
+## integrate function @code{integrate_n_steps} will be used.
+##
+## @var{init} contains the initial value for the unknowns.  If it is a row
+## vector then the solution @var{y} will be a matrix in which each column is
+## the solution for the corresponding initial value in @var{init}.
+##
+## The optional fourth argument @var{ode_opt} specifies non-default options to
+## the ODE solver.  It is a structure generated by @code{odeset}.
+##
+## The function typically returns two outputs.  Variable @var{t} is a
+## column vector and contains the times where the solution was found.  The
+## output @var{y} is a matrix in which each column refers to a different
+## unknown of the problem and each row corresponds to a time in @var{t}.
+##
+## The output can also be returned as a structure @var{solution} which
+## has field @var{x} containing the time where the solution was evaluated and
+## field @var{y} containing the solution matrix for the times in @var{x}.
+## Use @code{fieldnames (@var{solution})} to see the other fields and additional
+## information returned.
+##
+## If using the @qcode{"Events"} option then three additional outputs may
+## be returned.  @var{te} holds the time when an Event function returned a
+## zero.  @var{ye} holds the value of the solution at time @var{te}.  @var{ie}
+## contains an index indicating which Event function was triggered in the case
+## of multiple Event functions.
+##
+## Example: Solve the @nospell{Van der Pol} equation
+##
+## @example
+## @group
+## fvdp = @@(@var{t},@var{y}) [@var{y}(2); (1 - @var{y}(1)^2) * @var{y}(2) - @var{y}(1)];
+## [@var{t},@var{y}] = ode45 (fvdp, [0 20], [2 0]);
+## @end group
+## @end example
+## @seealso{odeset, odeget}
+## @end deftypefn
+
+function varargout = ode45 (fun, trange, init, varargin)
+
+  if (nargin < 3)
+    print_usage ();
+  endif
+
+  order = 5;  # runge_kutta_45_dorpri uses local extrapolation
+  solver = "ode45";
+
+  if (nargin >= 4)
+    if (! isstruct (varargin{1}))
+      ## varargin{1:len} are parameters for fun
+      odeopts = odeset ();
+      odeopts.funarguments = varargin;
+    elseif (length (varargin) > 1)
+      ## varargin{1} is an ODE options structure vopt
+      odeopts = ode_struct_value_check ("ode45", varargin{1}, "ode45");
+      odeopts.funarguments = {varargin{2:length(varargin)}};
+    else  # if (isstruct (varargin{1}))
+      odeopts = ode_struct_value_check ("ode45", varargin{1}, "ode45");
+      odeopts.funarguments = {};
+    endif
+  else  # nargin == 3
+    odeopts = odeset ();
+    odeopts.funarguments = {};
+  endif
+
+  if (! isvector (trange) || ! isnumeric (trange))
+    error ("Octave:invalid-input-arg",
+           "ode45: TRANGE must be a numeric vector");
+  endif
+
+  TimeStepNumber = odeget (odeopts, "TimeStepNumber", [], "fast");
+  TimeStepSize = odeget (odeopts, "TimeStepSize", [], "fast");
+  if (length (trange) < 2
+      && (isempty (TimeStepSize) || isempty (TimeStepNumber)))
+    error ("Octave:invalid-input-arg",
+           "ode45: TRANGE must contain at least 2 elements");
+  elseif (trange(1) == trange(2))
+    error ("Octave:invalid-input-arg",
+           "ode45: invalid time span, TRANGE(1) == TRANGE(2)");
+  else
+    odeopts.direction = sign (trange(2) - trange(1));
+  endif
+  trange = trange(:);
+
+  if (! isvector (init) || ! isnumeric (init))
+    error ("Octave:invalid-input-arg",
+           "ode45: INIT must be a numeric vector");
+  endif
+  init = init(:);
+
+  if (ischar (fun))
+    try
+      fun = str2func (fun);
+    catch
+      warning (lasterr);
+    end_try_catch
+  endif
+  if (! isa (fun, "function_handle"))
+    error ("Octave:invalid-input-arg",
+           "ode45: FUN must be a valid function handle");
+  endif
+
+  ## Start preprocessing, have a look which options are set in odeopts,
+  ## check if an invalid or unused option is set
+  if (isempty (TimeStepNumber) && isempty (TimeStepSize))
+    integrate_func = "adaptive";
+    odeopts.stepsizefixed = false;
+  elseif (! isempty (TimeStepNumber) && ! isempty (TimeStepSize))
+    integrate_func = "n_steps";
+    odeopts.stepsizefixed = true;
+    if (sign (TimeStepSize) != odeopts.direction)
+      warning ("Octave:invalid-input-arg",
+               ["ode45: option 'TimeStepSize' has the wrong sign, ", ...
+                "but will be corrected automatically\n"]);
+      TimeStepSize = -TimeStepSize;
+    endif
+  elseif (isempty (TimeStepNumber) && ! isempty (TimeStepSize))
+    integrate_func = "const";
+    odeopts.stepsizefixed = true;
+    if (sign (TimeStepSize) != odeopts.direction)
+      warning ("Octave:invalid-input-arg",
+               ["ode45: option 'TimeStepSize' has the wrong sign, ",
+                "but will be corrected automatically\n"]);
+      TimeStepSize = -TimeStepSize;
+    endif
+  else
+    warning ("Octave:invalid-input-arg",
+             "ode45: assuming an adaptive integrate function\n");
+    integrate_func = "adaptive";
+  endif
+
+  if (isempty (odeopts.RelTol) && ! odeopts.stepsizefixed)
+    odeopts.RelTol = 1e-3;
+    warning ("Octave:invalid-input-arg",
+             "ode45: option 'RelTol' not set, new value %f will be used\n",
+             odeopts.RelTol);
+  elseif (! isempty (odeopts.RelTol) && odeopts.stepsizefixed)
+    warning ("Octave:invalid-input-arg",
+             ["ode45: option 'RelTol' is ignored", ...
+              " when fixed time stamps are given\n"]);
+  endif
+
+  if (isempty (odeopts.AbsTol) && ! odeopts.stepsizefixed)
+    odeopts.AbsTol = 1e-6;
+    warning ("Octave:invalid-input-arg",
+             "ode45: option 'AbsTol' not set, new value %f will be used\n",
+             odeopts.AbsTol);
+  elseif (! isempty (odeopts.AbsTol) && odeopts.stepsizefixed)
+    warning ("Octave:invalid-input-arg",
+             ["ode45: option 'AbsTol' is ignored", ...
+              " when fixed time stamps are given\n"]);
+  else
+    odeopts.AbsTol = odeopts.AbsTol(:);  # Create column vector
+  endif
+
+  odeopts.normcontrol = strcmp (odeopts.NormControl, "on");
+
+  if (! isempty (odeopts.NonNegative))
+    if (isempty (odeopts.Mass))
+      odeopts.havenonnegative = true;
+    else
+      odeopts.havenonnegative = false;
+      warning ("Octave:invalid-input-arg",
+               ["ode45: option 'NonNegative' is ignored", ...
+                " when mass matrix is set\n"]);
+    endif
+  else
+    odeopts.havenonnegative = false;
+  endif
+
+  if (isempty (odeopts.OutputFcn) && nargout == 0)
+    odeopts.OutputFcn = @odeplot;
+    odeopts.haveoutputfunction = true;
+  else
+    odeopts.haveoutputfunction = ! isempty (odeopts.OutputFcn);
+  endif
+
+  odeopts.haveoutputselection = ! isempty (odeopts.OutputSel);
+
+  if (odeopts.Refine > 0)
+    odeopts.haverefine = true;
+  else
+    odeopts.haverefine = false;
+  endif
+
+  if (isempty (odeopts.InitialStep) && strcmp (integrate_func, "adaptive"))
+    odeopts.InitialStep = ...
+      odeopts.direction * starting_stepsize (order, fun, trange(1),
+                                                  init,
+                                                  odeopts.AbsTol,
+                                                  odeopts.RelTol,
+                                                  odeopts.normcontrol);
+    warning ("Octave:invalid-input-arg",
+             ["ode45: option 'InitialStep' not set,", ...
+              " estimated value %f will be used\n"],
+             odeopts.InitialStep);
+  elseif (isempty (odeopts.InitialStep))
+    odeopts.InitialStep = TimeStepSize;
+  endif
+
+  if (isempty (odeopts.MaxStep) && ! odeopts.stepsizefixed)
+    odeopts.MaxStep = abs (trange(end) - trange(1)) / 10;
+    warning ("Octave:invalid-input-arg",
+             "ode45: option 'MaxStep' not set, new value %f will be used\n",
+             odeopts.MaxStep);
+  endif
+
+  odeopts.haveeventfunction = ! isempty (odeopts.Events);
+
+  ## The options "Jacobian", "JPattern" and "Vectorized" will be ignored
+  ## by this solver because this solver uses an explicit Runge-Kutta method
+  ## and therefore no Jacobian calculation is necessary.
+  if (! isempty (odeopts.Jacobian))
+    warning ("Octave:invalid-input-arg",
+             "ode45: option 'Jacobian' is ignored by this solver\n");
+  endif
+
+  if (! isempty (odeopts.JPattern))
+    warning ("Octave:invalid-input-arg",
+             "ode45: option 'JPattern' is ignored by this solver\n");
+  endif
+
+  if (! isempty (odeopts.Vectorized))
+    warning ("Octave:invalid-input-arg",
+             "ode45: option 'Vectorized' is ignored by this solver\n");
+  endif
+
+  if (! isempty (odeopts.Mass) && isnumeric (odeopts.Mass))
+    havemasshandle = false;
+    mass = odeopts.Mass;  # constant mass
+  elseif (isa (odeopts.Mass, "function_handle"))
+    havemasshandle = true;    # mass defined by a function handle
+  else  # no mass matrix - creating a diag-matrix of ones for mass
+    havemasshandle = false;   # mass = diag (ones (length (init), 1), 0);
+  endif
+
+  massdependence = ! strcmp (odeopts.MStateDependence, "none");
+
+  ## Other options that are not used by this solver.
+  if (! isempty (odeopts.MvPattern))
+    warning ("Octave:invalid-input-arg",
+             "ode45: option 'MvPattern' is ignored by this solver\n");
+  endif
+
+  if (! isempty (odeopts.MassSingular))
+    warning ("Octave:invalid-input-arg",
+             "ode45: option 'MassSingular' is ignored by this solver\n");
+  endif
+
+  if (! isempty (odeopts.InitialSlope))
+    warning ("Octave:invalid-input-arg",
+             "ode45: option 'InitialSlope' is ignored by this solver\n");
+  endif
+
+  if (! isempty (odeopts.MaxOrder))
+    warning ("Octave:invalid-input-arg",
+             "ode45: option 'MaxOrder' is ignored by this solver\n");
+  endif
+
+  if (! isempty (odeopts.BDF))
+    warning ("Octave:invalid-input-arg",
+             "ode45: option 'BDF' is ignored by this solver\n");
+  endif
+
+  ## Starting the initialisation of the core solver ode45
+
+  if (havemasshandle)   # Handle only the dynamic mass matrix,
+    if (massdependence) # constant mass matrices have already
+      mass = @(t,x) odeopts.Mass (t, x, odeopts.funarguments{:});
+      fun = @(t,x) mass (t, x, odeopts.funarguments{:}) ...
+             \ fun (t, x, odeopts.funarguments{:});
+    else                 # if (massdependence == false)
+      mass = @(t) odeopts.Mass (t, odeopts.funarguments{:});
+      fun = @(t,x) mass (t, odeopts.funarguments{:}) ...
+             \ fun (t, x, odeopts.funarguments{:});
+    endif
+  endif
+
+  switch (integrate_func)
+    case "adaptive"
+      solution = integrate_adaptive (@runge_kutta_45_dorpri,
+                                     order, fun, trange, init, odeopts);
+    case "n_steps"
+      solution = integrate_n_steps (@runge_kutta_45_dorpri,
+                                    fun, trange(1), init,
+                                    TimeStepSize, TimeStepNumber, odeopts);
+    case "const"
+      solution = integrate_const (@runge_kutta_45_dorpri,
+                                  fun, trange, init,
+                                  TimeStepSize, odeopts);
+  endswitch
+
+  ## Postprocessing, do whatever when terminating integration algorithm
+  if (odeopts.haveoutputfunction)  # Cleanup plotter
+    feval (odeopts.OutputFcn, solution.t(end),
+           solution.x(end,:)', "done", odeopts.funarguments{:});
+  endif
+  if (odeopts.haveeventfunction)   # Cleanup event function handling
+    ode_event_handler (odeopts.Events, solution.t(end),
+                         solution.x(end,:)', "done",
+                         odeopts.funarguments{:});
+  endif
+
+  ## Print additional information if option Stats is set
+  if (strcmp (odeopts.Stats, "on"))
+    havestats = true;
+    nsteps    = solution.cntloop-2;                 # cntloop from 2..end
+    nfailed   = (solution.cntcycles-1)-(nsteps)+1;  # cntcycl from 1..end
+    nfevals   = 6 * (solution.cntcycles-1) + 1;     # number of ode evaluations
+    ndecomps  = 0;  # number of LU decompositions
+    npds      = 0;  # number of partial derivatives
+    nlinsols  = 0;  # no. of linear systems solutions
+    ## Print cost statistics if no output argument is given
+    if (nargout == 0)
+      printf ("Number of successful steps: %d\n", nsteps);
+      printf ("Number of failed attempts:  %d\n", nfailed);
+      printf ("Number of function calls:   %d\n", nfevals);
+    endif
+  else
+    havestats = false;
+  endif
+
+  if (nargout == 2)
+    varargout{1} = solution.t;      # Time stamps are first output argument
+    varargout{2} = solution.x;      # Results are second output argument
+  elseif (nargout == 1)
+    varargout{1}.x = solution.t;    # Time stamps are saved in field x
+    varargout{1}.y = solution.x;    # Results are saved in field y
+    varargout{1}.solver = solver;   # Solver name is saved in field solver
+    if (odeopts.haveeventfunction)
+      varargout{1}.ie = solution.event{2};  # Index info which event occurred
+      varargout{1}.xe = solution.event{3};  # Time info when an event occurred
+      varargout{1}.ye = solution.event{4};  # Results when an event occurred
+    endif
+    if (havestats)
+      varargout{1}.stats = struct ();
+      varargout{1}.stats.nsteps   = nsteps;
+      varargout{1}.stats.nfailed  = nfailed;
+      varargout{1}.stats.nfevals  = nfevals;
+      varargout{1}.stats.npds     = npds;
+      varargout{1}.stats.ndecomps = ndecomps;
+      varargout{1}.stats.nlinsols = nlinsols;
+    endif
+  elseif (nargout == 5)
+    varargout = cell (1,5);
+    varargout{1} = solution.t;
+    varargout{2} = solution.x;
+    if (odeopts.haveeventfunction)
+      varargout{3} = solution.event{3};  # Time info when an event occurred
+      varargout{4} = solution.event{4};  # Results when an event occurred
+      varargout{5} = solution.event{2};  # Index info which event occurred
+    endif
+  endif
+
+endfunction
+
+
+## We are using the "Van der Pol" implementation for all tests that are done
+## for this function.
+## For further tests we also define a reference solution (computed at high
+## accuracy)
+%!function ydot = fpol (t, y)  # The Van der Pol
+%! ydot = [y(2); (1 - y(1)^2) * y(2) - y(1)];
+%!endfunction
+%!function ref = fref ()         # The computed reference solution
+%! ref = [0.32331666704577, -1.83297456798624];
+%!endfunction
+%!function jac = fjac (t, y, varargin) # its Jacobian
+%! jac = [0, 1; -1 - 2 * y(1) * y(2), 1 - y(1)^2];
+%!endfunction
+%!function jac = fjcc (t, y, varargin) # sparse type
+%! jac = sparse ([0, 1; -1 - 2 * y(1) * y(2), 1 - y(1)^2])
+%!endfunction
+%!function [val, trm, dir] = feve (t, y, varargin)
+%! val = fpol (t, y, varargin);  # We use the derivatives
+%! trm = zeros (2,1);              # that's why component 2
+%! dir = ones (2,1);               # seems to not be exact
+%!endfunction
+%!function [val, trm, dir] = fevn (t, y, varargin)
+%! val = fpol (t, y, varargin);    # We use the derivatives
+%! trm = ones (2,1);               # that's why component 2
+%! dir = ones (2,1);               # seems to not be exact
+%!endfunction
+%!function mas = fmas (t, y, varargin)
+%! mas = [1, 0; 0, 1];            # Dummy mass matrix for tests
+%!endfunction
+%!function mas = fmsa (t, y, varargin)
+%! mas = sparse ([1, 0; 0, 1]);   # A sparse dummy matrix
+%!endfunction
+%!function out = fout (t, y, flag, varargin)
+%! if (regexp (char (flag), 'init') == 1)
+%!   if (any (size (t) != [2, 1])) error ('"fout" step "init"'); endif
+%! elseif (isempty (flag))
+%!   if (any (size (t) != [1, 1])) error ('"fout" step "calc"'); endif
+%!   out = false;
+%! elseif (regexp (char (flag), 'done') == 1)
+%!   if (any (size (t) != [1, 1])) error ('"fout" step "done"'); endif
+%! else
+%!   error ('"fout" invalid flag');
+%! endif
+%!endfunction
+%!
+%! ## Turn off output of warning messages for all tests,
+%! ## turn them on again after the last test is called
+%!test
+%! warning ("off", "Octave:invalid-input-arg", "local");
+%!error  # first input arg is not a function
+%! [t, y] = ode45 (1, [0 25], [3 15 1]);
+%!error  # input argument number one as name of non existing function
+%! [t, y] = ode45 ("non-existing-function", [0 25], [3 15 1]);
+%!error  # input argument number two
+%! [t, y] = ode45 (@fpol, 1, [3 15 1]);
+%!test  # two output arguments
+%! [t, y] = ode45 (@fpol, [0 2], [2 0]);
+%! assert ([t(end), y(end,:)], [2, fref], 1e-2);
+%!test  # not too many steps
+%! [t, y] = ode45 (@fpol, [0 2], [2 0]);
+%! assert (size (t) < 20);
+%!test  # anonymous function instead of real function
+%! fvdb = @(t,y) [y(2); (1 - y(1)^2) * y(2) - y(1)];
+%! [t, y] = ode45 (fvdb, [0 2], [2 0]);
+%! assert ([t(end), y(end,:)], [2, fref], 1e-2);
+%!test  # string instead of function
+%! [t, y] = ode45 ("fpol", [0 2], [2 0]);
+%! assert ([t(end), y(end,:)], [2, fref], 1e-2);
+%!test  # extra input arguments passed through
+%! [t, y] = ode45 (@fpol, [0 2], [2 0], 12, 13, "KL");
+%! assert ([t(end), y(end,:)], [2, fref], 1e-2);
+%!test  # empty ODEOPT structure *but* extra input arguments
+%! opt = odeset;
+%! [t, y] = ode45 (@fpol, [0 2], [2 0], opt, 12, 13, "KL");
+%! assert ([t(end), y(end,:)], [2, fref], 1e-2);
+%!error  # strange ODEOPT structure
+%! opt = struct ("foo", 1);
+%! [t, y] = ode45 (@fpol, [0 2], [2 0], opt);
+%!test  # Solve vdp in fixed step sizes
+%! opt = odeset("TimeStepSize", 0.1);
+%! [t, y] = ode45 (@fpol, [0,2], [2 0], opt);
+%! assert (t(:), [0:0.1:2]', 1e-2);
+%!test  # Solve another anonymous function below zero
+%! vref = [0, 14.77810590694212];
+%! [t, y] = ode45 (@(t,y) y, [-2 0], 2);
+%! assert ([t(end), y(end,:)], vref, 1e-1);
+%!test  # InitialStep option
+%! opt = odeset ("InitialStep", 1e-8);
+%! [t, y] = ode45 (@fpol, [0 0.2], [2 0], opt);
+%! assert ([t(2)-t(1)], [1e-8], 1e-9);
+%!test  # MaxStep option
+%! opt = odeset ("MaxStep", 1e-3);
+%! sol = ode45 (@fpol, [0 0.2], [2 0], opt);
+%! assert ([sol.x(5)-sol.x(4)], [1e-3], 1e-3);
+%!test  # Solve with intermidiate step
+%! sol = ode45 (@fpol, [0 1 2], [2 0]);
+%! assert (any((sol.x-1) == 0));
+%! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
+%!test  # Solve in backward direction starting at t=0
+%! vref = [-1.205364552835178, 0.951542399860817];
+%! sol = ode45 (@fpol, [0 -2], [2 0]);
+%! assert ([sol.x(end), sol.y(end,:)], [-2, vref], 1e-2);
+%!test  # Solve in backward direction starting at t=2
+%! vref = [-1.205364552835178, 0.951542399860817];
+%! sol = ode45 (@fpol, [2 -2], fref);
+%! assert ([sol.x(end), sol.y(end,:)], [-2, vref], 1e-2);
+%!test  # Solve in backward direction starting at t=2, with intermidiate step
+%! vref = [-1.205364552835178, 0.951542399860817];
+%! sol = ode45 (@fpol, [2 0 -2], fref);
+%! idx = find(sol.x < 0, 1, "first") - 1;
+%! assert ([sol.x(idx), sol.y(idx,:)], [0 2 0], 1e-2);
+%! assert ([sol.x(end), sol.y(end,:)], [-2, vref], 1e-2);
+%!test  # Solve another anonymous function in backward direction
+%! vref = [-1, 0.367879437558975];
+%! sol = ode45 (@(t,y) y, [0 -1], 1);
+%! assert ([sol.x(end), sol.y(end,:)], vref, 1e-3);
+%!test  # Solve another anonymous function below zero
+%! vref = [0, 14.77810590694212];
+%! sol = ode45 (@(t,y) y, [-2 0], 2);
+%! assert ([sol.x(end), sol.y(end,:)], vref, 1e-3);
+%!test  # Solve in backward direction starting at t=0 with MaxStep option
+%! vref = [-1.205364552835178, 0.951542399860817];
+%! opt = odeset ("MaxStep", 1e-3);
+%! sol = ode45 (@fpol, [0 -2], [2 0], opt);
+%! assert ([abs(sol.x(8)-sol.x(7))], [1e-3], 1e-3);
+%! assert ([sol.x(end), sol.y(end,:)], [-2, vref], 1e-3);
+%!test  # AbsTol option
+%! opt = odeset ("AbsTol", 1e-5);
+%! sol = ode45 (@fpol, [0 2], [2 0], opt);
+%! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
+%!test  # AbsTol and RelTol option
+%! opt = odeset ("AbsTol", 1e-8, "RelTol", 1e-8);
+%! sol = ode45 (@fpol, [0 2], [2 0], opt);
+%! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
+%!test  # RelTol and NormControl option -- higher accuracy
+%! opt = odeset ("RelTol", 1e-8, "NormControl", "on");
+%! sol = ode45 (@fpol, [0 2], [2 0], opt);
+%! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-5);
+%!test  # Keeps initial values while integrating
+%! opt = odeset ("NonNegative", 2);
+%! sol = ode45 (@fpol, [0 2], [2 0], opt);
+%! assert ([sol.x(end), sol.y(end,:)], [2, 2, 0], 0.5);
+%!test  # Details of OutputSel and Refine can't be tested
+%! opt = odeset ("OutputFcn", @fout, "OutputSel", 1, "Refine", 5);
+%! sol = ode45 (@fpol, [0 2], [2 0], opt);
+%!test  # Stats must add further elements in sol
+%! opt = odeset ("Stats", "on");
+%! sol = ode45 (@fpol, [0 2], [2 0], opt);
+%! assert (isfield (sol, "stats"));
+%! assert (isfield (sol.stats, "nsteps"));
+%!test  # Events option add further elements in sol
+%! opt = odeset ("Events", @feve);
+%! sol = ode45 (@fpol, [0 10], [2 0], opt);
+%! assert (isfield (sol, "ie"));
+%! assert (sol.ie(1), 2);
+%! assert (isfield (sol, "xe"));
+%! assert (isfield (sol, "ye"));
+%!test  # Events option, now stop integration
+%! opt = odeset ("Events", @fevn, "NormControl", "on");
+%! sol = ode45 (@fpol, [0 10], [2 0], opt);
+%! assert ([sol.ie, sol.xe, sol.ye],
+%!         [2.0, 2.496110, -0.830550, -2.677589], 6e-1);
+%!test  # Events option, five output arguments
+%! opt = odeset ("Events", @fevn, "NormControl", "on");
+%! [t, y, vxe, ye, vie] = ode45 (@fpol, [0 10], [2 0], opt);
+%! assert ([vie, vxe, ye],
+%!         [2.0, 2.496110, -0.830550, -2.677589], 6e-1);
+%!test  # Jacobian option
+%! opt = odeset ("Jacobian", @fjac);
+%! sol = ode45 (@fpol, [0 2], [2 0], opt);
+%! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
+%!test  # Jacobian option and sparse return value
+%! opt = odeset ("Jacobian", @fjcc);
+%! sol = ode45 (@fpol, [0 2], [2 0], opt);
+%! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
+
+## test for JPattern option is missing
+## test for Vectorized option is missing
+
+%!test  # Mass option as function
+%! opt = odeset ("Mass", @fmas);
+%! sol = ode45 (@fpol, [0 2], [2 0], opt);
+%! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
+%!test  # Mass option as matrix
+%! opt = odeset ("Mass", eye (2,2));
+%! sol = ode45 (@fpol, [0 2], [2 0], opt);
+%! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
+%!test  # Mass option as sparse matrix
+%! opt = odeset ("Mass", sparse (eye (2,2)));
+%! sol = ode45 (@fpol, [0 2], [2 0], opt);
+%! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
+%!test  # Mass option as function and sparse matrix
+%! opt = odeset ("Mass", @fmsa);
+%! sol = ode45 (@fpol, [0 2], [2 0], opt);
+%! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
+%!test  # Mass option as function and MStateDependence
+%! opt = odeset ("Mass", @fmas, "MStateDependence", "strong");
+%! sol = ode45 (@fpol, [0 2], [2 0], opt);
+%! assert ([sol.x(end), sol.y(end,:)], [2, fref], 1e-3);
+%!test  # Set BDF option to something other than default
+%! opt = odeset ("BDF", "on");
+%! [t, y] = ode45 (@fpol, [0 2], [2 0], opt);
+%! assert ([t(end), y(end,:)], [2, fref], 1e-3);
+
+## test for MvPattern option is missing
+## test for InitialSlope option is missing
+## test for MaxOrder option is missing
+
+%!test
+%!
+%! #warning ("on", "Octave:invalid-input-arg");
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/odeget.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,149 @@
+## Copyright (C) 2013, Roberto Porcu' <roberto.porcu@polimi.it>
+## Copyright (C) 2006-2012, Thomas Treichl <treichl@users.sourceforge.net>
+##
+## 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{val} =} odeget (@var{ode_opt}, @var{field})
+## @deftypefnx {Function File} {@var{val} =} odeget (@var{ode_opt}, @var{field}, @var{default})
+##
+## Query the value of the property @var{field} in the ODE options structure
+## @var{ode_opt}.
+##
+## If called with two input arguments and the first input argument @var{ode_opt}
+## is an ODE option structure and the second input argument @var{field} is a
+## string specifying an option name, then return the option value @var{val}
+## corresponding to @var{field} from @var{ode_opt}.
+##
+## If called with an optional third input argument, and @var{field} is
+## not set in the structure @var{ode_opt}, then return the default value
+## @var{default} instead.
+## @seealso{odeset}
+## @end deftypefn
+
+## FIXME: 4th input argument "opt" is undocumented.
+
+function val = odeget (ode_opt, field, default = [], opt = "")
+
+  ## Shortcut for quickly extracting option
+  if (strncmp (opt, "fast", 4))
+    try
+      val = ode_opt.(field);
+      if (strcmp (opt, "fast_not_empty") && isempty (val))
+        val = default;
+      endif
+    catch
+      val = default;
+    end_try_catch
+    return;
+  endif
+
+  if (nargin < 1 || nargin > 4)
+    print_usage ();
+  endif
+
+  ## Shortcut for empty option structures
+  if (isempty (ode_opt))
+    if (nargin < 3)
+      val = [];
+    else
+      val = default;
+    endif
+    return;
+  endif
+
+  if (! isstruct (ode_opt))
+    error ("odeget: ODE_OPT must be a valid ODE_STRUCT");
+  elseif (! ischar (field))
+    error ("odeget: FIELD must be a string");
+  endif
+
+  ## Check if the given struct is a valid ODEOPT struct
+  ode_struct_value_check ("odeget", ode_opt);
+
+  ## Define all the possible ODEOPT fields
+  persistent options = {"AbsTol"; "BDF"; "Events"; "InitialSlope";
+                        "InitialStep"; "Jacobian"; "JConstant"; "JPattern";
+                        "Mass"; "MassConstant"; "MassSingular"; "MaxOrder";
+                        "MaxStep"; "MStateDependence"; "MvPattern";
+                        "NonNegative"; "NormControl"; "OutputFcn"; "OutputSel";
+                        "Refine"; "RelTol"; "Stats"; "Vectorized"};
+
+  exactmatch = true;
+  match = find (strcmpi (field, options));
+  if (isempty (match))
+    match = find (strncmpi (field, options, length (field)));
+    exactmatch = false;
+  endif
+
+  if (isempty (match))
+    ## Possibly a custom user-defined option
+    try
+      val = ode_opt.(field);
+    catch
+      warning ("Octave:invalid-input-arg",
+               "odeget: no field '%s' exists in ODE_OPT\n", field);
+      val = default;
+    end_try_catch
+  elseif (numel (match) == 1)
+    if (! exactmatch)
+      warning ("odeget:NoExactMatching",
+               "odeget: no exact match for '%s'.  Assuming '%s'.\n",
+               field, options{match});
+    endif
+    val = [];
+    try
+      val = ode_opt.(options{match});
+    end_try_catch
+    if (isempty (val))
+      val = default;
+    endif
+  else
+    error ("odeget: no exact match for '%s'.  Possible fields found: %s.",
+           field, strjoin (options(match), ", "));
+  endif
+
+endfunction
+
+
+%!demo
+%! # Return the manually changed value RelTol of the ODE options
+%! # structure A.  If RelTol wouldn't have been changed then an
+%! # empty matrix value would have been returned.
+%!
+%! A = odeset ("RelTol", 1e-1, "AbsTol", 1e-2);
+%! odeget (A, "RelTol", [])
+
+%!assert (odeget (odeset (), "RelTol"), [])
+%!assert (odeget (odeset ("RelTol", 10), "RelTol"), 10)
+%!assert (odeget (odeset (), "RelTol", 10), 10)
+%!assert (odeget (odeset (), "Stats"), [])
+%!assert (odeget (odeset (), "Stats", "on"), "on")
+%!assert (odeget (odeset (), "Mass"), [])
+%!assert (odeget (odeset (), "AbsTol", 1e-6, "fast"), [])
+%!assert (odeget (odeset (), "AbsTol", 1e-6, "fast_not_empty"), 1e-6)
+%!assert (odeget (odeset (), "AbsTol", 1e-9), 1e-9)
+
+%!error odeget ()
+%!error odeget (1)
+%!error odeget (1,2,3,4,5)
+%!error <ODE_OPT must be a valid ODE_STRUCT> odeget (1, "opt1")
+%!error <FIELD must be a string> odeget (struct ("opt1", 1), 1)
+%!warning <no field 'foo' exists> odeget (struct ("opt1", 1), "foo");
+%!warning <no exact match for 'Rel'.  Assuming 'RelTol'> odeget (struct ("RelTol", 1), "Rel");
+%!error <Possible fields found: InitialSlope, InitialStep> odeget (odeset (), "Initial")
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/odeset.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,310 @@
+## Copyright (C) 2013, Roberto Porcu' <roberto.porcu@polimi.it>
+## Copyright (C) 2006-2012, Thomas Treichl <treichl@users.sourceforge.net>
+##
+## 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} {} odeset ()
+## @deftypefnx {Function File} {@var{odestruct} =} odeset (@var{"field1"}, @var{value1}, @var{"field2"}, @var{value2}, @dots{})
+## @deftypefnx {Function File} {@var{odestruct} =} odeset (@var{oldstruct}, @var{"field1"}, @var{value1}, @var{"field2"}, @var{value2}, @dots{})
+## @deftypefnx {Function File} {@var{odestruct} =} odeset (@var{oldstruct}, @var{newstruct})
+##
+## Create or modify an ODE options structure.
+##
+## When called without an input argument, return a new ODE options structure
+## that contains all possible fields initialized to their default values.
+##
+## If called with string input arguments @var{"field1"}, @var{"field2"},
+## @dots{} identifying valid ODE options then return a new ODE options
+## structure with all possible fields initialized @strong{and} set the values
+## of the fields @var{"field1"}, @var{"field2"}, @dots{} to the values
+## @var{value1}, @var{value2}, @dots{}
+##
+## If called with an input structure @var{oldstruct} then overwrite the values
+## of the options @var{"field1"}, @var{"field2"}, @dots{} with new values
+## @var{value1}, @var{value2}, @dots{} and return the modified structure.
+##
+## When called with two input ODE options structures @var{oldstruct} and
+## @var{newstruct} overwrite all values from the structure @var{oldstruct} with
+## new values from the structure @var{newstruct}.  Empty values in
+## @var{newstruct} will not overwrite values in @var{oldstruct}.
+## @seealso{odeget}
+## @end deftypefn
+
+function odestruct = odeset (varargin)
+
+  ## Column vector of all possible ODE options
+  persistent options = {"AbsTol"; "BDF"; "Events"; "InitialSlope";
+                        "InitialStep"; "Jacobian"; "JConstant"; "JPattern";
+                        "Mass"; "MassConstant"; "MassSingular"; "MaxOrder";
+                        "MaxStep"; "MStateDependence"; "MvPattern";
+                        "NonNegative"; "NormControl"; "OutputFcn"; "OutputSel";
+                        "Refine"; "RelTol"; "Stats"; "Vectorized"};
+
+  if (nargin == 0)
+    ## Special calling syntax to display defaults
+    if (nargout == 0)
+      print_options ();
+    else
+      odestruct = cell2struct (cell (numel (options), 1), options);
+    endif
+    return;
+  endif
+
+  ## initialize output
+  odestruct = cell2struct (cell (numel (options), 1), options);
+
+  if (isstruct (varargin{1}))
+    oldstruct = varargin{1};
+
+    ## Copy oldstruct values into output odestruct
+    for [val, name] = oldstruct
+
+      exactmatch = true;
+      match = find (strcmpi (name, options));
+      if (isempty (match))
+        match = find (strncmpi (name, options, length (name)));
+        exactmatch = false;
+      endif
+
+      if (isempty (match))
+        odestruct.(name) = val;
+      elseif (numel (match) == 1)
+        if (! exactmatch)
+          warning ("odeset:NoExactMatching",
+                   "no exact match for '%s'.  Assuming '%s'.",
+                   name, options{match});
+        endif
+        odestruct.(options{match}) = val;
+      else
+        error ("odeset: no exact match for '%s'.  Possible fields found: %s.",
+               name, strjoin (options(match), ", "));
+      endif
+
+      if (nargin == 1)
+        ## Check if all changes have resulted in a valid ODEOPT struct
+        ode_struct_value_check ("odeset", odestruct);
+        return;
+      endif
+
+    endfor
+
+    ## At this point, odestruct has been initialized with default values,
+    ## and if oldstruct was present it has overwritten fields in odestruct.
+
+    if (nargin == 2 && isstruct (varargin{2}))
+      newstruct = varargin{2};
+
+      ## Update the first struct with the values from the second one
+      for [val, name] = newstruct
+
+        exactmatch = true;
+        match = find (strcmpi (name, options));
+        if (isempty (match))
+          match = find (strncmpi (name, options, length (name)));
+          exactmatch = false;
+        endif
+
+        if (isempty (match))
+          odestruct.(name) = val;
+        elseif (numel (match) == 1)
+          if (! exactmatch)
+            warning ("odeset:NoExactMatching",
+                     "no exact match for '%s'.  Assuming '%s'.",
+                     name, options{match});
+          endif
+          odestruct.(options{match}) = val;
+        else
+          error ("odeset: no exact match for '%s'.  Possible fields found: %s.",
+                 name, strjoin (options(match), ", "));
+        endif
+      endfor
+
+      ## Check if all changes have resulted in a valid ODEOPT struct
+      ode_struct_value_check ("odeset", odestruct);
+      return;
+    endif
+
+    ## Second argument is not a struct
+    if (mod (nargin, 2) != 1)
+      error ("odeset: FIELD/VALUE arguments must occur in pairs");
+    endif
+    if (! all (cellfun ("isclass", varargin(2:2:end), "char")))
+      error ("odeset: All FIELD names must be strings");
+    endif
+
+    ## Write new field/value pairs into odestruct
+    for i = 2:2:nargin
+      name = varargin{i};
+
+      exactmatch = true;
+      match = find (strcmpi (name, options));
+      if (isempty (match))
+        match = find (strncmpi (name, options, length (name)));
+        exactmatch = false;
+      endif
+
+      if (isempty (match))
+        odestruct.(name) = varargin{i+1};
+      elseif (numel (match) == 1)
+        if (! exactmatch)
+          warning ("odeset:NoExactMatching",
+                   "no exact match for '%s'.  Assuming '%s'.",
+                   name, options{match});
+        endif
+        odestruct.(options{match}) = varargin{i+1};
+      else
+        error ("odeset: no exact match for '%s'.  Possible fields found: %s.",
+               name, strjoin (options(match), ", "));
+      endif
+    endfor
+
+    ## Check if all changes have resulted in a valid ODEOPT struct
+    ode_struct_value_check ("odeset", odestruct);
+
+  else
+    ## First input argument was not a struct, must be field/value pairs
+    if (mod (nargin, 2) != 0)
+      error ("odeset: FIELD/VALUE arguments must occur in pairs");
+    elseif (! all (cellfun ("isclass", varargin(1:2:end), "char")))
+      error ("odeset: All FIELD names must be strings");
+    endif
+
+    for i = 1:2:nargin
+      name = varargin{i};
+
+      exactmatch = true;
+      match = find (strcmpi (name, options));
+      if (isempty (match))
+        match = find (strncmpi (name, options, length (name)));
+        exactmatch = false;
+      endif
+
+      if (isempty (match))
+        odestruct.(name) = varargin{i+1};
+      elseif (numel (match) == 1)
+        if (! exactmatch)
+          warning ("odeset:NoExactMatching",
+                   "no exact match for '%s'.  Assuming '%s'.",
+                   name, options{match});
+        endif
+        odestruct.(options{match}) = varargin{i+1};
+      else
+        error ("odeset: no exact match for '%s'.  Possible fields found: %s.",
+               name, strjoin (options(match), ", "));
+      endif
+    endfor
+
+    ## Check if all changes have resulted in a valid ODEOPT struct
+    ode_struct_value_check ("odeset", odestruct);
+
+  endif
+
+endfunction
+
+## function to print all possible options
+function print_options ()
+
+  disp ("List of all possible ODE solver options.");
+  disp ("Default values are in square brackets.");
+  disp ("");
+  disp ("             AbsTol:  scalar or vector, >0, [1e-6]");
+  disp ("                BDF:  binary, {'on', ['off']}");
+  disp ("             Events:  function_handle, []");
+  disp ("       InitialSlope:  vector, []");
+  disp ("        InitialStep:  scalar, >0, []");
+  disp ("           Jacobian:  matrix or function_handle, []");
+  disp ("          JConstant:  binary, {'on', ['off']}");
+  disp ("           JPattern:  sparse matrix, []");
+  disp ("               Mass:  matrix or function_handle, []");
+  disp ("       MassConstant:  binary, {'on', ['off']}");
+  disp ("       MassSingular:  switch, {'yes', ['maybe'], 'no'}");
+  disp ("           MaxOrder:  switch, {1, 2, 3, 4, [5]}");
+  disp ("            MaxStep:  scalar, >0, []");
+  disp ("   MStateDependence:  switch, {'none', ['weak'], 'strong'}");
+  disp ("          MvPattern:  sparse matrix, []");
+  disp ("        NonNegative:  vector of integers, []");
+  disp ("        NormControl:  binary, {'on', ['off']}");
+  disp ("          OutputFcn:  function_handle, []");
+  disp ("          OutputSel:  scalar or vector, []");
+  disp ("             Refine:  scalar, integer, >0, []");
+  disp ("             RelTol:  scalar, >0, [1e-3]");
+  disp ("              Stats:  binary, {'on', ['off']}");
+  disp ("         Vectorized:  binary, {'on', ['off']}");
+
+endfunction
+
+
+%!demo
+%! # A new ODE options structure with default values is created.
+%!
+%! odeoptA = odeset ();
+
+%!demo
+%! # A new ODE options structure with manually set options
+%! # for "AbsTol" and "RelTol" is created.
+%!
+%! odeoptB = odeset ("AbsTol", 1e-2, "RelTol", 1e-1);
+
+%!demo
+%! # A new ODE options structure is created from odeoptB with
+%! # a modified value for option "NormControl".
+%!
+%! odeoptB = odeset ("AbsTol", 1e-2, "RelTol", 1e-1);
+%! odeoptC = odeset (odeoptB, "NormControl", "on");
+
+## All tests that are needed to check if a valid option has been set are
+## implemented in ode_struct_value_check.m
+%!test
+%! odeoptA = odeset ();
+%! assert (isstruct (odeoptA));
+%! assert (numel (fieldnames (odeoptA)), 23);
+%! assert (all (structfun ("isempty", odeoptA)));
+
+%!shared odeoptB, odeoptC
+%!test
+%! odeoptB = odeset ("ABSTOL", 1e-2, "reltol", 1e-1);
+%! assert (odeoptB.AbsTol, 1e-2);  # Check canonicalization of name
+%! assert (odeoptB.RelTol, 1e-1);
+
+%!test
+%! odeoptC = odeset (odeoptB, "NormControl", "on");
+%! assert (odeoptC.AbsTol, 1e-2);       # check values from first struct copied
+%! assert (odeoptC.NormControl, "on");  # check new values override old ones
+
+%!test
+%! odeoptD = odeset (odeoptB, odeoptC);
+%! assert (odeoptD, odeoptC);
+
+## Test custom user-defined option
+%!test
+%! wstate = warning ("off", "Octave:invalid-input-arg");
+%! unwind_protect
+%!   odeopt = odeset ("NewtonTol", 3);
+%!   assert (odeopt.NewtonTol, 3);
+%! unwind_protect_cleanup
+%!   warning (wstate);
+%! end_unwind_protect
+
+## Test input validation
+%!error <FIELD/VALUE arguments must occur in pairs> odeset ("opt1")
+%!error <FIELD names must be strings> odeset (1, 1)
+%!error <FIELD/VALUE arguments must occur in pairs> odeset (odeset (), "opt1")
+%!error <FIELD names must be strings> odeset (odeset (), 1, 1)
+%!warning <no exact match for 'Rel'.  Assuming 'RelTol'> odeset ("Rel", 1);
+%!error <Possible fields found: InitialSlope, InitialStep> odeset ("Initial", 1)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/AbsRel_Norm.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,45 @@
+## Copyright (C) 2014-15 Jacopo Corno <jacopo.corno@gmail.com>
+## Copyright (C) 2013 Roberto Porcu' <roberto.porcu@polimi.it>
+##
+## 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 retval = AbsRel_Norm (x, x_old, AbsTol, RelTol, normcontrol, y)
+
+  n = length (x);
+
+  if (nargin == 5)
+    y = zeros (size (x));
+  endif
+
+  if (length (x_old) != n || length (y) != n)
+    error ("Octave:invalid-input-arg", "invalid dimensions of input arguments");
+  endif
+
+  if ((length (AbsTol) != 1 && length (AbsTol) != n)
+      || (length (RelTol) != 1 && length (RelTol) != n))
+    error ("Octave:invalid-input-arg", "invalid dimensions of input arguments");
+  endif
+
+  sc = AbsTol + max (abs (x), abs (x_old)) .* RelTol;
+  if (normcontrol)
+    retval = max (abs (x - y) ./ sc);
+  else
+    retval = sqrt ((1 / n) * sumsq ((x - y) ./ sc));
+  endif
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/integrate_adaptive.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,313 @@
+## Copyright (C) 2015 Carlo de Falco
+## Copyright (C) 2013 Roberto Porcu' <roberto.porcu@polimi.it>
+##
+## 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{solution} =} integrate_adaptive (@var{@@stepper}, @var{order}, @var{@@func}, @var{tspan}, @var{x0}, @var{options})
+##
+## This function file can be called by an ODE solver function in order to
+## integrate the set of ODEs on the interval @var{[t0, t1]} with an
+## adaptive timestep.
+##
+## The function returns a structure @var{solution} with two fieldss: @var{t}
+## and @var{y}.  @var{t} is a column vector and contains the time stamps.
+## @var{y} is a matrix in which each column refers to a different unknown
+## of the problem and the row number is the same as the @var{t} row number.
+## Thus, each row of the matrix @var{y} contains the values of all unknowns at
+## the time value contained in the corresponding row in @var{t}.
+##
+## The first input argument must be a function handle or inline function
+## representing the stepper, i.e., the function responsible for step-by-step
+## integration.  This function discriminates one method from the others.
+##
+## The second input argument is the order of the stepper.  It is needed
+## to compute the adaptive timesteps.
+##
+## The third input argument is a function handle or inline function that
+## defines the ODE:
+##
+## @ifhtml
+## @example
+## @math{y' = f(t,y)}
+## @end example
+## @end ifhtml
+## @ifnothtml
+## @math{y' = f(t,y)}.
+## @end ifnothtml
+##
+## The fourth input argument is the time vector which defines the integration
+## interval, i.e., @var{[tspan(1), tspan(end)]} and all intermediate elements
+## are taken as times at which the solution is required.
+##
+## The fifth argument represents the initial conditions for the ODEs and the
+## last input argument contains some options that may be needed for the stepper.
+##
+## @end deftypefn
+##
+## @seealso{integrate_const, integrate_n_steps}
+
+function solution = integrate_adaptive (stepper, order, func, tspan, x0,
+                                        options)
+
+  fixed_times = numel (tspan) > 2;
+
+  t_new = t_old = t = tspan(1);
+  x_new = x_old = x = x0(:);
+
+  ## Get first initial timestep
+  dt = odeget (options, "InitialStep", [], "fast");
+  if (isempty (dt))
+    dt = starting_stepsize (order, func, t, x, options.AbsTol, options.RelTol,
+                            options.normcontrol);
+  endif
+
+  dir = odeget (options, "direction", [], "fast");
+  dt = dir * min (abs (dt), options.MaxStep);
+
+  options.comp = 0.0;
+
+  ## Factor multiplying the stepsize guess
+  facmin = 0.8;
+  facmax = 1.5;
+  fac = 0.38^(1/(order+1));  # formula taken from Hairer
+
+  ## Initialize the OutputFcn
+  if (options.haveoutputfunction)
+    if (options.haveoutputselection)
+      solution.retout = x(options.OutputSel,end);
+    else
+      solution.retout = x;
+    endif
+    feval (options.OutputFcn, tspan, solution.retout,
+           "init", options.funarguments{:});
+  endif
+
+  ## Initialize the EventFcn
+  if (options.haveeventfunction)
+    ode_event_handler (options.Events, tspan(end), x,
+                         "init", options.funarguments{:});
+  endif
+
+  if (options.havenonnegative)
+    nn = options.NonNegative;
+  endif
+
+  solution.cntloop = 2;
+  solution.cntcycles = 1;
+  solution.cntsave = 2;
+  solution.unhandledtermination = true;
+  ireject = 0;
+
+  k_vals = [];
+  iout = istep = 1;
+  while (dir * t_old < dir * tspan(end))
+
+    ## Compute integration step from t_old to t_new = t_old + dt
+    [t_new, options.comp] = kahan (t_old, options.comp, dt);
+    [t_new, x_new, x_est, new_k_vals] = ...
+      stepper (func, t_old, x_old, dt, options, k_vals, t_new);
+
+    solution.cntcycles += 1;
+
+    if (options.havenonnegative)
+      x_new(nn, end) = abs (x_new(nn, end));
+      x_est(nn, end) = abs (x_est(nn, end));
+    endif
+
+    err = AbsRel_Norm (x_new, x_old, options.AbsTol, options.RelTol,
+                       options.normcontrol, x_est);
+
+    ## Accept solution only if err <= 1.0
+    if (err <= 1)
+
+      solution.cntloop += 1;
+      ireject = 0;              # Clear reject counter
+
+      ## if output time steps are fixed
+      if (fixed_times)
+
+        t_caught = find ((dir * tspan(iout:end) > dir * t_old)
+                         & (dir * tspan(iout:end) <= dir * t_new));
+        t_caught = t_caught + iout - 1;
+
+        if (! isempty (t_caught))
+          t(t_caught) = tspan(t_caught);
+          iout = max (t_caught);
+          x(:, t_caught) = ...
+            runge_kutta_interpolate (order, [t_old t_new], [x_old x_new],
+                                     tspan(t_caught), new_k_vals, dt,
+                                     options.funarguments{:});
+
+          istep += 1;
+
+          ## Call Events function only if a valid result has been found.
+          ## Stop integration if eventbreak is true.
+          if (options.haveeventfunction)
+            break_loop = false;
+            for idenseout = 1:numel (t_caught)
+              id = t_caught(idenseout);
+              td = t(id);
+              solution.event = ...
+                ode_event_handler (options.Events, t(id), x(:, id), [],
+                                     options.funarguments{:});
+              if (! isempty (solution.event{1}) && solution.event{1} == 1)
+                t(id) = solution.event{3}(end);
+                t = t(1:id);
+                x(:, id) = solution.event{4}(end, :).';
+                x = x(:,1:id);
+                solution.unhandledtermination = false;
+                break_loop = true;
+                break;
+              endif
+            endfor
+            if (break_loop)
+              break;
+            endif
+          endif
+
+          ## Call OutputFcn only if a valid result has been found.
+          ## Stop integration if function returns false.
+          if (options.haveoutputfunction)
+            cnt = options.Refine + 1;
+            approxtime = linspace (t_old, t_new, cnt);
+            approxvals = interp1 ([t_old, t(t_caught), t_new],
+                                  [x_old, x(:, t_caught), x_new] .',
+                                  approxtime, 'linear') .';
+            if (options.haveoutputselection)
+              approxvals = approxvals(options.OutputSel, :);
+            endif
+            for ii = 1:numel (approxtime)
+              pltret = feval (options.OutputFcn, approxtime(ii),
+                              approxvals(:, ii), [],
+                              options.funarguments{:});
+            endfor
+            if (pltret)  # Leave main loop
+              solution.unhandledtermination = false;
+              break;
+            endif
+          endif
+
+        endif
+
+      else
+
+        t(++istep)  = t_new;
+        x(:, istep) = x_new;
+        iout = istep;
+
+        ## Call Events function only if a valid result has been found.
+        ## Stop integration if eventbreak is true.
+        if (options.haveeventfunction)
+          solution.event = ...
+            ode_event_handler (options.Events, t(istep), x(:, istep), [],
+                                 options.funarguments{:});
+          if (! isempty (solution.event{1}) && solution.event{1} == 1)
+            t(istep) = solution.event{3}(end);
+            x(:, istep) = solution.event{4}(end, :).';
+            solution.unhandledtermination = false;
+            break;
+          endif
+        endif
+
+        ## Call OutputFcn only if a valid result has been found.
+        ## Stop integration if function returns false.
+        if (options.haveoutputfunction)
+          cnt = options.Refine + 1;
+          approxtime = linspace (t_old, t_new, cnt);
+          approxvals = interp1 ([t_old, t_new],
+                                [x_old, x_new] .',
+                                approxtime, 'linear') .';
+          if (options.haveoutputselection)
+            approxvals = approxvals(options.OutputSel, :);
+          endif
+          for ii = 1:numel (approxtime)
+            pltret = feval (options.OutputFcn, approxtime(ii),
+                            approxvals(:, ii), [], options.funarguments{:});
+          endfor
+          if (pltret)  # Leave main loop
+            solution.unhandledtermination = false;
+            break;
+          endif
+        endif
+
+      endif
+
+      ## move to next time-step
+      t_old = t_new;
+      x_old = x_new;
+      k_vals = new_k_vals;
+
+      solution.cntloop += 1;
+
+    else
+
+      ireject += 1;
+
+      ## Stop solving because, in the last 5,000 steps, no successful valid
+      ## value has been found
+      if (ireject >= 5_000)
+        error (["integrate_adaptive: Solving was not successful. ", ...
+                " The iterative integration loop exited at time", ...
+                " t = %f before the endpoint at tend = %f was reached. ", ...
+                " This happened because the iterative integration loop", ...
+                " did not find a valid solution at this time stamp. ", ...
+                " Try to reduce the value of 'InitialStep' and/or", ...
+                " 'MaxStep' with the command 'odeset'.\n"],
+               t_old, tspan(end));
+      endif
+
+    endif
+
+    ## Compute next timestep, formula taken from Hairer
+    err += eps;  # avoid divisions by zero
+    dt *= min (facmax, max (facmin, fac * (1 / err)^(1 / (order + 1))));
+    dt = dir * min (abs (dt), options.MaxStep);
+
+    ## make sure we don't go past tpan(end)
+    dt = dir * min (abs (dt), abs (tspan(end) - t_old));
+
+  endwhile
+
+  ## Check if integration of the ode has been successful
+  if (dir * t(end) < dir * tspan(end))
+    if (solution.unhandledtermination == true)
+      error ("integrate_adaptive:unexpected_termination",
+             [" Solving was not successful. ", ...
+              " The iterative integration loop exited at time", ...
+              " t = %f before the endpoint at tend = %f was reached. ", ...
+              " This may happen if the stepsize becomes too small. ", ...
+              " Try to reduce the value of 'InitialStep'", ...
+              " and/or 'MaxStep' with the command 'odeset'."],
+             t(end), tspan(end));
+    else
+      warning ("integrate_adaptive:unexpected_termination",
+               ["Solver was stopped by a call of 'break'", ...
+                " in the main iteration loop at time", ...
+                " t = %f before the endpoint at tend = %f was reached. ", ...
+                " This may happen because the @odeplot function", ...
+                " returned 'true' or the @event function returned 'true'."],
+               t(end), tspan(end));
+    endif
+  endif
+
+  ## Set up return structure
+  solution.t = t(:);
+  solution.x = x.';
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/integrate_const.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,282 @@
+## Copyright (C) 2013 Roberto Porcu' <roberto.porcu@polimi.it>
+##
+## 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{solution} =} integrate_const (@var{@@stepper}, @var{@@func}, @var{tspan}, @var{x0}, @var{dt}, @var{options})
+##
+## This function file can be called by an ODE solver function in order to
+## integrate the set of ODEs on the interval @var{[t0,t1]} with a constant
+## timestep @var{dt}.
+##
+## The function returns a structure @var{solution} with two fieldss: @var{t}
+## and @var{y}.  @var{t} is a column vector and contains the time stamps.
+## @var{y} is a matrix in which each column refers to a different unknown
+## of the problem and the row number is the same as the @var{t} row number.
+## Thus, each row of the matrix @var{y} contains the values of all unknowns at
+## the time value contained in the corresponding row in @var{t}.
+##
+## The first input argument must be a function handle or inline function
+## representing the stepper, i.e., the function responsible for step-by-step
+## integration.  This function discriminates one method from the others.
+##
+## The second input argument is the order of the stepper.  It is needed to
+## compute the adaptive timesteps.
+##
+## The third input argument is a function handle or inline function that
+## defines the ODE:
+##
+## @ifhtml
+## @example
+## @math{y' = f(t,y)}
+## @end example
+## @end ifhtml
+## @ifnothtml
+## @math{y' = f(t,y)}.
+## @end ifnothtml
+##
+## The fourth input argument is the time vector which defines the integration
+## interval, i.e., @var{[tspan(1), tspan(end)]} and all intermediate elements
+## are taken as times at which the solution is required.
+##
+## The fourth argument contains the initial conditions for the ODEs.
+##
+## The fifth input argument represents the fixed timestep and the last input
+## argument contains some options that may be needed for the stepper.
+## @end deftypefn
+##
+## @seealso{integrate_adaptive, integrate_n_steps}
+
+function solution = integrate_const (stepper, func, tspan, x0, dt, options)
+
+  solution = struct ();
+
+  ## first values for time and solution
+  t = tspan(1);
+  x = x0(:);
+
+  direction = odeget (options, "direction", [], "fast");
+  if (sign (dt) != direction)
+    error ("Octave:invalid-input-arg",
+           "option 'InitialStep' has a wrong sign");
+  endif
+
+  ## setting parameters
+  k = length (tspan);
+  counter = 2;
+  comp = 0.0;
+  tk = tspan(1);
+  options.comp = comp;
+
+  ## Initialize the OutputFcn
+  if (options.haveoutputfunction)
+    if (options.haveoutputselection)
+      solution.retout = x(options.OutputSel,end);
+    else
+      solution.retout = x;
+    endif
+    feval (options.OutputFcn, tspan, solution.retout, "init",
+           options.funarguments{:});
+  endif
+
+  ## Initialize the EventFcn
+  if (options.haveeventfunction)
+    ode_event_handler (options.Events, t(end), x, "init",
+                         options.funarguments{:});
+  endif
+
+  solution.cntloop = 2;
+  solution.cntcycles = 1;
+  cntiter = 0;
+  solution.unhandledtermination = true;
+  solution.cntsave = 2;
+
+  z = t;
+  u = x;
+  k_vals = feval (func, t , x, options.funarguments{:});
+
+  while (counter <= k)
+    ## computing the integration step from t to t+dt
+    [s, y, ~, k_vals] = stepper (func, z(end), u(:,end), dt, options, k_vals);
+
+    [tk, comp] = kahan (tk,comp, dt);
+    options.comp = comp;
+    s(end) = tk;
+
+    if (options.havenonnegative)
+      x(options.NonNegative,end) = abs (x(options.NonNegative,end));
+      y(options.NonNegative,end) = abs (y(options.NonNegative,end));
+      y_est(options.NonNegative,end) = abs (y_est(options.NonNegative,end));
+    endif
+
+    if (options.haveoutputfunction && options.haverefine)
+      SaveVUForRefine = u(:,end);
+    endif
+
+    ## values on this interval for time and solution
+    z = [t(end);s];
+    u = [x(:,end),y];
+
+    ## if next tspan value is caught, update counter
+    if ((z(end) == tspan(counter))
+        || (abs (z(end) - tspan(counter)) /
+            (max (abs (z(end)), abs (tspan(counter)))) < 8*eps) )
+      counter += 1;
+
+    ## if there is an element in time vector at which the solution is required
+    ## the program must compute this solution before going on with next steps
+    elseif (direction * z(end) > direction * tspan(counter) )
+      ## initializing counter for the following cycle
+      i = 2;
+      while (i <= length (z))
+
+        ## if next tspan value is caught, update counter
+        if ((counter <= k)
+            && (((z(i) == tspan(counter))
+                 || (abs (z(i) - tspan(counter)) /
+                     (max (abs (z(i)), abs (tspan(counter)))) < 8*eps))) )
+          counter += 1;
+        endif
+        ## else, loop until there are requested values inside this subinterval
+        while ((counter <= k)
+               && direction * z(i) > direction * tspan(counter) )
+          ## add the interpolated value of the solution
+          u = [u(:,1:i-1),u(:,i-1) + (tspan(counter)-z(i-1))/(z(i)-z(i-1))* ...
+              (u(:,i)-u(:,i-1)),u(:,i:end)];
+          ## add the time requested
+          z = [z(1:i-1);tspan(counter);z(i:end)];
+
+          ## update counters
+          counter += 1;
+          i += 1;
+        endwhile
+
+        ## if new time requested is not out of this interval
+        if (counter <= k && direction * z(end) > direction * tspan(counter))
+          ## update the counter
+          i += 1;
+        else
+          ## else, stop the cycle and go on with the next iteration
+          i = length (z)+1;
+        endif
+
+      endwhile
+    endif
+
+    x = [x,u(:,2:end)];
+    t = [t;z(2:end)];
+    solution.cntsave += 1;
+    solution.cntloop += 1;
+    cntiter = 0;
+
+    ## Call OutputFcn only if a valid result has been found.
+    ## Stop integration if function returns false.
+    if (options.haveoutputfunction)
+      for cnt = 0:options.Refine  # Approximation between told and t
+        if (options.haverefine)   # Do interpolation
+          approxtime = (cnt + 1) / (options.Refine + 2);
+          approxvals = (1 - approxtime) * SaveVUForRefine ...
+                        + (approxtime) * y(:,end);
+          approxtime = s(end) + approxtime*dt;
+        else
+          approxvals = x(:,end);
+          approxtime = t(end);
+        endif
+        if (options.haveoutputselection)
+          approxvals = approxvals(options.OutputSel);
+        endif
+        pltret = feval (options.OutputFcn, approxtime, approxvals, [],
+                         options.funarguments{:});
+        if (pltret)  # Leave refinement loop
+          break;
+        endif
+      endfor
+      if (pltret)  # Leave main loop
+        solution.unhandledtermination = false;
+        break;
+      endif
+    endif
+
+    ## Call Events function only if a valid result has been found.
+    ## Stop integration if eventbreak is true.
+    if (options.haveeventfunction)
+      solution.event = ode_event_handler (options.Events, t(end), x(:,end),
+                                             [], options.funarguments{:});
+      if (! isempty (solution.event{1}) && solution.event{1} == 1)
+        t(solution.cntloop-1,:) = solution.event{3}(end,:);
+        x(:,solution.cntloop-1) = solution.event{4}(end,:)';
+        solution.unhandledtermination = false;
+        break;
+      endif
+    endif
+
+    ## Update counters that count the number of iteration cycles
+    solution.cntcycles += 1;  # Needed for cost statistics
+    cntiter += 1;             # Needed to find iteration problems
+
+    ## Stop solving because, in the last 5,000 steps, no successful valid
+    ## value has been found
+    if (cntiter >= 5_000)
+      error (["integrate_const: Solving was not successful. ", ...
+              " The iterative integration loop exited at time", ...
+              " t = %f before the endpoint at tend = %f was reached. ", ...
+              " This happened because the iterative integration loop", ...
+              " did not find a valid solution at this time stamp. ", ...
+              " Try to reduce the value of 'InitialStep' and/or", ...
+              " 'MaxStep' with the command 'odeset'."],
+             s(end), tspan(end));
+    endif
+
+    ## if this is the last iteration, save the length of last interval
+    if (counter > k)
+      j = length (z);
+    endif
+
+  endwhile
+
+  ## Check if integration of the ode has been successful
+  if (direction * z(end) < direction * tspan(end))
+    if (solution.unhandledtermination == true)
+      error ("integrate_const:unexpected_termination",
+             [" Solving was not successful. ", ...
+              " The iterative integration loop exited at time", ...
+              " t = %f before the endpoint at tend = %f was reached. ", ...
+              " This may happen if the stepsize becomes too small. ", ...
+              " Try to reduce the value of 'InitialStep'", ...
+              " and/or 'MaxStep' with the command 'odeset'."],
+             z(end), tspan(end));
+    else
+      warning ("integrate_const:unexpected_termination",
+               ["Solver was stopped by a call of 'break'", ...
+                " in the main iteration loop at time", ...
+                " t = %f before the endpoint at tend = %f was reached. ", ...
+                " This may happen because the @odeplot function", ...
+                " returned 'true' or the @event function returned 'true'."],
+               z(end), tspan(end));
+    endif
+  endif
+
+  ## compute how many values are out of time inerval
+  d = direction * t((end-(j-1)):end) > direction * tspan(end) * ones (j, 1);
+  f = sum (d);
+
+  ## remove not-requested values of time and solution
+  solution.t = t(1:end-f);
+  solution.x = x(:,1:end-f)';
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/integrate_n_steps.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,221 @@
+## Copyright (C) 2013, Roberto Porcu' <roberto.porcu@polimi.it>
+##
+## 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{solution} =} integrate_n_steps (@var{@@stepper}, @var{@@func}, @var{t0}, @var{x0}, @var{dt}, @var{n}, @var{options})
+##
+## This function file can be called by an ODE solver function in order to
+## integrate the set of ODEs on the interval @var{[t0,t0 + n*dt]} with a
+## constant timestep dt and on a fixed number of steps.
+##
+## The function returns a structure @var{solution} with two fieldss: @var{t}
+## and @var{y}.  @var{t} is a column vector and contains the time stamps.
+## @var{y} is a matrix in which each column refers to a different unknown
+## of the problem and the row number is the same as the @var{t} row number.
+## Thus, each row of the matrix @var{y} contains the values of all unknowns at
+## the time value contained in the corresponding row in @var{t}.
+##
+## The first input argument must be a function handle or inline function
+## representing the stepper, i.e., the function responsible for step-by-step
+## integration.  This function discriminates one method from the others.
+##
+## The second input argument is the order of the stepper.  It is needed to
+## compute the adaptive timesteps.
+##
+## The third input argument is a function handle or inline function that
+## defines the ODE:
+##
+## @ifhtml
+## @example
+## @math{y' = f(t,y)}
+## @end example
+## @end ifhtml
+## @ifnothtml
+## @math{y' = f(t,y)}.
+## @end ifnothtml
+##
+## The third input argument is the starting point for the integration.
+##
+## The fourth argument contains the initial conditions for the ODEs.
+##
+## The fifth input argument represents the fixed timestep while the sixth
+## contains the number of integration steps.
+##
+## The last argument is a struct with the options that may be needed by the
+## stepper.
+## @end deftypefn
+##
+## @seealso{integrate_adaptive, integrate_const}
+
+function solution = integrate_n_steps (stepper, func, t0, x0, dt, n, options)
+
+  solution = struct ();
+
+  ## first values for time and solution
+  x = x0(:);
+  t = t0;
+
+  direction = odeget (options, "direction", [], "fast");
+  if (sign (dt) != direction)
+    error ("Octave:invalid-input-arg", "option 'InitialStep' has a wrong sign");
+  endif
+
+  comp = 0.0;
+  tk = t0;
+  options.comp = comp;
+
+  ## Initialize the OutputFcn
+  if (options.haveoutputfunction)
+    if (options.haveoutputselection)
+      solution.retout = x(options.OutputSel,end);
+    else
+      solution.retout = x;
+    endif
+    feval (options.OutputFcn, tspan, solution.retout, "init",
+           options.funarguments{:});
+  endif
+
+  ## Initialize the EventFcn
+  if (options.haveeventfunction)
+    ode_event_handler (options.Events, t(end), x, "init",
+                         options.funarguments{:});
+  endif
+
+  solution.cntloop = 2;
+  solution.cntcycles = 1;
+  cntiter = 0;
+  solution.unhandledtermination = true;
+  solution.cntsave = 2;
+
+  z = t;
+  u = x;
+  k_vals = feval (func, t , x, options.funarguments{:});
+
+  for i = 1:n
+    ## Compute the integration step from t to t+dt
+    [s, y, ~, k_vals] = stepper (func, z(end), u(:,end), dt, options, k_vals);
+
+    [tk, comp] = kahan (tk, comp, dt);
+    options.comp = comp;
+    s(end) = tk;
+
+    if (options.havenonnegative)
+      x(options.NonNegative,end) = abs (x(options.NonNegative,end));
+      y(options.NonNegative,end) = abs (y(options.NonNegative,end));
+    endif
+
+    if (options.haveoutputfunction && options.haverefine)
+      SaveVUForRefine = u(:,end);
+    endif
+
+    ## values on this interval for time and solution
+    z = [t(end);s];
+    u = [x(:,end),y];
+
+    x = [x,u(:,2:end)];
+    t = [t;z(2:end)];
+    solution.cntsave += 1;
+    solution.cntloop += 1;
+    cntiter = 0;
+
+    ## Call OutputFcn only if a valid result has been found.
+    ## Stop integration if function returns false.
+    if (options.haveoutputfunction)
+      for cnt = 0:options.Refine  # Approximation between told and t
+        if (options.haverefine)   # Do interpolation
+          approxtime = (cnt + 1) / (options.Refine + 2);
+          approxvals = (1 - approxtime) * SaveVUForRefine ...
+                        + (approxtime) * y(:,end);
+          approxtime = s(end) + approxtime*dt;
+        else
+          approxvals = x(:,end);
+          approxtime = t(end);
+        endif
+        if (options.haveoutputselection)
+          approxvals = approxvals(options.OutputSel);
+        endif
+        pltret = feval (options.OutputFcn, approxtime, approxvals, [],
+                        options.funarguments{:});
+        if (pltret)  # Leave refinement loop
+          break;
+        endif
+      endfor
+      if (pltret)  # Leave main loop
+        solution.unhandledtermination = false;
+        break;
+      endif
+    endif
+
+    ## Call Events function only if a valid result has been found.
+    ## Stop integration if eventbreak is true.
+    if (options.haveeventfunction)
+      solution.event = ode_event_handler (options.Events, t(end), x(:,end),
+                                             [], options.funarguments{:});
+      if (! isempty (solution.event{1}) && solution.event{1} == 1)
+        t(solution.cntloop-1,:) = solution.event{3}(end,:);
+        x(:,solution.cntloop-1) = solution.event{4}(end,:)';
+        solution.unhandledtermination = false;
+        break;
+      endif
+    endif
+
+    ## Update counters that count the number of iteration cycles
+    solution.cntcycles += 1;  # Needed for cost statistics
+    cntiter += 1;             # Needed to find iteration problems
+
+    ## Stop solving because, in the last 5,000 steps, no successful valid
+    ## value has been found
+    if (cntiter >= 5_000)
+      error (["integrate_n_steps: Solving was not successful. ", ...
+              " The iterative integration loop exited at time", ...
+              " t = %f before the endpoint at tend = %f was reached. ", ...
+              " This happened because the iterative integration loop", ...
+              " did not find a valid solution at this time stamp. ", ...
+              " Try to reduce the value of 'InitialStep' and/or", ...
+              " 'MaxStep' with the command 'odeset'.],
+             s(end), tspan(end));
+    endif
+  endfor
+
+  ## Check if integration of the ode has been successful
+  #if (direction * z(end) < direction * tspan(end))
+  #  if (solution.unhandledtermination == true)
+  #   error ("integrate_n_steps:unexpected_termination",
+  #          [" Solving was not successful. ", ...
+  #           " The iterative integration loop exited at time", ...
+  #           " t = %f before the endpoint at tend = %f was reached. ", ...
+  #           " This may happen if the stepsize becomes too small. ", ...
+  #           " Try to reduce the value of 'InitialStep'", ...
+  #           " and/or 'MaxStep' with the command 'odeset'."],
+  #           z(end), tspan(end));
+  #  else
+  #   warning ("integrate_n_steps:unexpected_termination",
+  #            ["Solver was stopped by a call of 'break'", ...
+  #             " in the main iteration loop at time", ...
+  #             " t = %f before the endpoint at tend = %f was reached. ", ...
+  #             " This may happen because the @odeplot function", ...
+  #             " returned 'true' or the @event function returned 'true'."],
+  #             z(end), tspan(end));
+  #  endif
+  #endif
+
+  solution.t = t;
+  solution.x = x';
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/kahan.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,52 @@
+## Copyright (C) 2013 Roberto Porcu' <roberto.porcu@polimi.it>
+##
+## 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{sum} =} kahan (@var{sum}, @var{comp}, @var{term})
+## @deftypefnx {Function File} {[@var{sum}, @var{comp}] =} kahan (@var{sum}, @var{comp}, @var{term})
+##
+## This function implements the Kahan summation algorithm, also known as
+## compensated summation.
+##
+## The algorithm significantly reduces the numerical error in the total
+## obtained by adding a sequence of finite precision floating point numbers,
+## compared to the straightforward approach.  For more details
+## see @url{http://en.wikipedia.org/wiki/Kahan_summation_algorithm}.
+## This function is called by @code{integrate_adaptive} and
+## @code{integrate_const} to better catch equality comparisons.
+##
+## The first input argument is the variable that will contain the summation,
+## so that is also returned as first output argument in order to reuse it in
+## next calls to @code{kahan} function.
+##
+## The second input argument contains the compensation term and it is returned
+## as the second output argument so that it can be reused in future calls of
+## the same summation.
+##
+## The third input argument @var{term} is the variable to be added to @var{sum}.
+## @end deftypefn
+
+function [sum, comp] = kahan (sum, comp, term)
+
+  y = term - comp;
+  t = sum + y;
+  comp = (t - sum) - y;
+  sum = t;
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/ode_event_handler.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,159 @@
+## Copyright (C) 2006-2012 Thomas Treichl <treichl@users.sourceforge.net>
+##
+## 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{sol} =} ode_event_handler (@var{@@evtfun}, @var{t}, @var{y}, @var{flag}, @var{par1}, @var{par2}, @dots{})
+##
+## Return the solution of the event function that is specified as the first
+## input argument @var{@@evtfun} in the form of a function handle.
+##
+## The second input argument @var{t} is of type double scalar and
+## specifies the time of the event evaluation, the third input argument
+## @var{y} either is of type double column vector (for ODEs and DAEs) and
+## specifies the solutions or is of type cell array (for IDEs and DDEs) and
+## specifies the derivatives or the history values, the third input argument
+## @var{flag} is of type string and can be of the form
+##
+## @table @option
+## @item  @qcode{"init"}
+## then initialize internal persistent variables of the function
+## @code{ode_event_handler} and return an empty cell array of size 4,
+##
+## @item  @qcode{"calc"}
+## then do the evaluation of the event function and return the solution
+## @var{sol} as type cell array of size 4,
+##
+## @item  @qcode{"done"}
+## then cleanup internal variables of the function
+## @code{ode_event_handler} and return an empty cell array of size 4.
+## @end table
+##
+## Optionally if further input arguments @var{par1}, @var{par2}, @dots{} of
+## any type are given then pass these parameters through
+## @code{ode_event_handler} to the event function.
+##
+## This function is an ODE internal helper function therefore it should
+## never be necessary that this function is called directly by a user.  There
+## is only little error detection implemented in this function file to
+## achieve the highest performance.
+## @end deftypefn
+##
+## @seealso{odepkg}
+
+function retval = ode_event_handler (evtfun, t, y, flag = "", varargin)
+
+  ## No error handling has been implemented in this function to achieve
+  ## the highest performance available.
+
+  ## retval{1} is true (to terminate) or false (to continue)
+  ## retval{2} is the index information for which an event occurred
+  ## retval{3} is the time information column vector
+  ## retval{4} is the line by line result information matrix
+
+  ## These persistent variables store the results and time value from the
+  ## processing in the previous time stamp.
+  ## evtold  the results from the event function
+  ## told    the time stamp
+  ## yold    the ODE result
+  ## retcell the return values cell array
+  ## evtcnt  the counter for how often this function has been called
+  ## has been called
+  persistent evtold told yold retcell evtcnt;
+
+  ## Call the event function if an event function has been defined to
+  ## initialize the internal variables of the event function and to get
+  ## a value for evtold.
+  if (strcmp (flag, "init"))
+
+    if (! iscell (y))
+      inpargs = {evtfun, t, y};
+    else
+      inpargs = {evtfun, t, y{1}, y{2}};
+      y = y{1};  # Delete cell element 2
+    endif
+    if (nargin > 4)
+      inpargs = {inpargs{:}, varargin{:}};
+    endif
+    [evtold, term, dir] = feval (inpargs{:});
+
+    ## FIXME: This actually seems to assume that everything must be row vectors
+    ## We assume that all return values must be column vectors
+    evtold = evtold(:)'; term = term(:)'; dir = dir(:)';
+    told = t; yold = y; evtcnt = 1; retcell = cell (1,4);
+
+  ## Process the event, i.e.,
+  ## find the zero crossings for either a rising or falling edge
+  elseif (isempty (flag))
+
+    if (! iscell (y))
+      inpargs = {evtfun, t, y};
+    else
+      inpargs = {evtfun, t, y{1}, y{2}};
+      y = y{1};  # Delete cell element 2
+    endif
+    if (nargin > 4)
+      inpargs = {inpargs{:}, varargin{:}};
+    endif
+    [evt, term, dir] = feval (inpargs{:});
+
+    ## FIXME: This actually seems to assume that everything must be row vectors
+    ## We assume that all return values must be column vectors
+    evt = evt(:)'; term = term(:)'; dir = dir(:)';
+
+    ## Check if one or more signs of the event has changed
+    signum = (sign (evtold) != sign (evt));
+    if (any (signum))         # One or more values have changed
+      idx = find (signum);    # Get the index of the changed values
+
+      if (any (dir(idx) == 0))
+        ## Rising or falling (both are possible)
+        ## Don't change anything, keep the index
+      elseif (any (dir(idx) == sign (evt(idx))))
+        ## Detected rising or falling, need a new index
+        idx = find (dir == sign (evt));
+      else
+        ## Found a zero crossing but must not be notified
+        idx = [];
+      endif
+
+      ## Create new output values if a valid index has been found
+      if (! isempty (idx))
+        ## Change the persistent result cell array
+        retcell{1} = any (term(idx));     # Stop integration or not
+        retcell{2}(evtcnt,1) = idx(1,1);  # Take first event found
+        ## Calculate the time stamp when the event function returned 0 and
+        ## calculate new values for the integration results, we do both by
+        ## a linear interpolation
+        tnew = t - evt(1,idx) * (t - told) / (evt(1,idx) - evtold(1,idx));
+        ynew = (y - (t - tnew) * (y - yold) / (t - told))';
+        retcell{3}(evtcnt,1) = tnew;
+        retcell{4}(evtcnt,:) = ynew;
+        evtcnt += 1;
+      endif
+
+    endif  # Check for one or more signs ...
+    evtold = evt; told = t; retval = retcell; yold = y;
+
+  elseif (strcmp (flag, "done"))  # Clear this event handling function
+    clear ("evtold", "told", "retcell", "yold", "evtcnt");
+    retcell = cell (1,4);
+
+  endif
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/ode_struct_value_check.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,277 @@
+## Copyright (C) 2013 Roberto Porcu' <roberto.porcu@polimi.it>
+## Copyright (C) 2006-2012 Thomas Treichl <treichl@users.sourceforge.net>
+##
+## 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} {} ode_struct_value_check (@var{"caller"}, @var{ode_struct})
+## @deftypefnx {Function File} {} ode_struct_value_check (@var{"caller"), @var{ode_struct}, @var{"solver"})
+## @deftypefnx {Function File} {@var{ode_struct} =} ode_struct_value_check (@dots{})
+##
+## Validate the fields and values in the ODE options structure @var{ode_struct}.
+##
+## The first argument @var{caller} is a string with the name of the calling
+## function so that warning and error messages properly display the source
+## of any problems.
+##
+## The second argument @var{ode_struct} is a structure with fields and values
+## that configure the ODE solvers (@pxref{XREFodeset,,odeset).
+##
+## The optional third argument @var{"solver"} is a string with the name of a
+## specific ODE solver.  This extra information can enable more extensive value
+## validation for certain options.
+##
+## The function does not modify any of the field names or field values, but
+## terminates with an error if an invalid value is found.
+##
+## Normally the function is called with no output.  However, the input struct
+## is passed unmodified to the output for certain solvers which expect to
+## receive the validated ODE structure returned.
+## @end deftypefn
+##
+## @seealso{odeset, odeget}
+
+function ode_struct = ode_struct_value_check (caller, ode_struct, solver = "")
+
+  for [val, opt] = ode_struct  # Cycle over all fields
+
+    switch (opt)
+
+      case "AbsTol"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isreal (val)
+              || ! isvector (val) || any (val <= 0))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "BDF"
+        if (! isempty (val))
+          if (! strcmp (val, "on") && ! strcmp (val, "off"))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "Events"
+        if (! isempty (val))
+          if (! isa (val, "function_handle"))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "InitialSlope"
+        if (! isempty (val))
+          if (! ischar (val)
+              && (! isnumeric (val) || (! isvector (val) && ! isreal (val))))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "InitialStep"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isreal (val) || ! isscalar (val)
+              || val <= 0)
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "Jacobian"
+        if (! isempty (val))
+          if (! isnumeric (val))
+            if (! isa (val, "function_handle") && ! iscell (val))
+              error ("Octave:invalid-input-arg",
+                     [caller ": invalid value assigned to field '%s'"], opt);
+            endif
+          endif
+        endif
+
+      case "JConstant"
+        if (! isempty (val))
+          if (! strcmp (val, "on") && ! strcmp (val, "off"))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "JPattern"
+        if (! isempty (val))
+          if (! isnumeric (val) && ! isvector (val))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "Mass"
+        if (! isempty (val))
+          if ((! isnumeric (val) || ! ismatrix (val))
+              && ! isa (val, "function_handle"))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "MassConstant"
+        if (! isempty (val))
+          if (! strcmp (val, "on") && ! strcmp (val, "off"))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "MassSingular"
+        if (! isempty (val))
+          if (! any (strcmp (val, {"yes", "no", "maybe"})))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "MaxOrder"
+        if (! isempty (val))
+          if (! isnumeric (val)
+              || val != fix (val) || val <= 0 || val >= 8)
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "MaxStep"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isscalar (val) || val <= 0)
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "MStateDependence"
+        if (! isempty (val))
+          if (! any (strcmp (val, {"none", "weak", "strong"})))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "MvPattern"
+        if (! isempty (val))
+          if (! isnumeric (val) && ! isvector (val))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "NonNegative"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isvector (val)
+              || any (val <= 0) || any (val != fix (val)))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "NormControl"
+        if (! isempty (val))
+          if (! strcmp (val, "on") && ! strcmp (val, "off"))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "OutputFcn"
+        if (! isempty (val))
+          if (! isa (val, "function_handle"))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "OutputSel"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isvector (val))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "Refine"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isscalar (val)
+              || val != fix (val)  || val < 0 || val > 5)
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "RelTol"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isreal (val) || any (val <= 0))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+          if (any (strcmp (solver, {"ode23", "ode23d", "ode45", "ode45d",
+                                    "ode54", "ode54d", "ode78", "ode78d"})))
+            if (! isscalar (val))
+              error ("Octave:invalid-input-arg",
+                     [caller ": invalid value assigned to field '%s'"], opt);
+            endif
+          endif
+        endif
+
+      case "Stats"
+        if (! isempty (val))
+          if (! strcmp (val, "on") && ! strcmp (val, "off"))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      case "Vectorized"
+        if (! isempty (val))
+          if (! strcmp (val, "on") && ! strcmp (val, "off"))
+            error ("Octave:invalid-input-arg",
+                   [caller ": invalid value assigned to field '%s'"], opt);
+          endif
+        endif
+
+      otherwise
+        warning ("Octave:invalid-input-arg",
+                 [caller ": unknown field '%s' in ODE options\n"], opt);
+    endswitch
+  endfor
+
+endfunction
+
+
+%!demo
+%! # Return the checked ODE options structure that is created by
+%! # the command odeset.
+%!
+%! ode_struct_value_check (odeset);
+
+%!demo
+%! # Create the ODE options structure A with odeset and check it
+%! # with ode_struct_value_check.  This actually is unnecessary
+%! # because odeset automatically calls ode_struct_value_check before
+%! # returning.
+%!
+%! A = odeset ();
+%! ode_struct_value_check (A);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/runge_kutta_45_dorpri.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,116 @@
+## Copyright (C) 2015 Carlo de Falco
+## Copyright (C) 2013 Roberto Porcu' <roberto.porcu@polimi.it>
+##
+## 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{t_next}, @var{x_next}] =} runge_kutta_45_dorpri (@var{@@fun}, @var{t}, @var{x}, @var{dt}, @var{options}, @var{k_vals_in})
+## @deftypefnx {Function File} {[@var{t_next}, @var{x_next}, @var{x_est}] =} runge_kutta_45_dorpri (@var{@@fun}, @var{t}, @var{x}, @var{dt}, @var{options}, @var{k_vals_in})
+## @deftypefnx {Function File} {[@var{t_next}, @var{x_next}, @var{x_est}, @var{k_vals_out}] =} runge_kutta_45_dorpri (@var{@@fun}, @var{t}, @var{x}, @var{dt}, @var{options}, @var{k_vals_in})
+##
+## This function can be used to integrate a system of ODEs with a given initial
+## condition @var{x} from @var{t} to @var{t+dt} with the Dormand-Prince method.
+## For the definition of this method see
+## @url{http://en.wikipedia.org/wiki/Dormand%E2%80%93Prince_method}.
+##
+## First output argument is the final integration time value.
+##
+## Second output parameter is the higher order computed solution at time
+## @var{t_next} (local extrapolation).
+##
+## Third output parameter is a lower order solution for the estimation of the
+## error.
+##
+## Fourth output parameter is matrix containing the Runge-Kutta evaluations
+## to use in an FSAL scheme or for dense output.
+##
+## First input argument is the function describing the system of ODEs to be
+## integrated.
+##
+## Second input parameter is the first extreme of integration interval.
+##
+## Third input argument is the initial condition of the system.
+##
+## Fourth input argument is the timestep, that is the length of the
+## integration interval.
+##
+## Fifth input parameter is optional and describes a set of options useful to
+## adapt the computation to what is needed.
+##
+## Sixth input parameter is optional and describes the Runge-Kutta evaluations
+## of the previous step to use in an FSAL scheme.
+## @end deftypefn
+##
+## @seealso{odepkg}
+
+function [t_next, x_next, x_est, k] = runge_kutta_45_dorpri (f, t, x, dt,
+                                                             options = [],
+                                                             k_vals = [],
+                                                             t_next = t + dt)
+
+  persistent a = [0           0          0           0        0          0;
+                  1/5         0          0           0        0          0;
+                  3/40        9/40       0           0        0          0;
+                  44/45      -56/15      32/9        0        0          0;
+                  19372/6561 -25360/2187 64448/6561 -212/729  0          0;
+                  9017/3168  -355/33     46732/5247  49/176  -5103/18656 0;
+                  35/384      0          500/1113    125/192 -2187/6784  11/84];
+  persistent b = [0 1/5 3/10 4/5 8/9 1 1];
+  persistent c = [(35/384) 0 (500/1113) (125/192) (-2187/6784) (11/84)];
+  persistent c_prime = [(5179/57600) 0 (7571/16695) (393/640), ...
+                        (-92097/339200) (187/2100)  (1/40)];
+  ## According to Shampine 1986:
+  ## persistent c_prime = [(1951/21600) 0 (22642/50085) (451/720), ...
+  ##                       (-12231/42400) (649/6300) (1/60)];
+
+  s = t + dt * b;
+  cc = dt * c;
+  aa = dt * a;
+  k = zeros (rows (x), 7);
+
+  if (! isempty (options))  # extra arguments for function evaluator
+    args = options.funarguments;
+  else
+    args = {};
+  endif
+
+  if (! isempty (k_vals))    # k values from previous step are passed
+    k(:,1) = k_vals(:,end);  # FSAL property
+  else
+    k(:,1) = feval (f, t, x, args{:});
+  endif
+
+  k(:,2) = feval (f, s(2), x + k(:,1)   * aa(2, 1).'  , args{:});
+  k(:,3) = feval (f, s(3), x + k(:,1:2) * aa(3, 1:2).', args{:});
+  k(:,4) = feval (f, s(4), x + k(:,1:3) * aa(4, 1:3).', args{:});
+  k(:,5) = feval (f, s(5), x + k(:,1:4) * aa(5, 1:4).', args{:});
+  k(:,6) = feval (f, s(6), x + k(:,1:5) * aa(6, 1:5).', args{:});
+
+  ## compute new time and new values for the unknowns
+  ## t_next = t + dt;
+  x_next = x + k(:,1:6) * cc(:);  # 5th order approximation
+
+  ## if the estimation of the error is required
+  if (nargout >= 3)
+    ## new solution to be compared with the previous one
+    k(:,7) = feval (f, t_next, x_next, args{:});
+    cc_prime = dt * c_prime;
+    x_est = x + k * cc_prime(:);
+  endif
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/runge_kutta_interpolate.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,105 @@
+## Copyright (C) 2015 Carlo de Falco
+## Copyright (C) 2015 Jacopo Corno <jacopo.corno@gmail.com>
+##
+## 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 u_interp = runge_kutta_interpolate (order, z, u, t, k_vals, dt, args)
+
+  switch (order)
+
+    ## FIXME: Can interpolations for orders 1-4 simply be deleted? 2015-10-14.
+    #{
+    case 1
+      u_interp = linear_interpolation (z, u, t);
+    case 2
+      if (! isempty (k_vals))
+        der = k_vals(:,1);
+      else
+        der = feval (func, z(1) , u(:,1), args);
+      endif
+      u_interp = quadratic_interpolation (z, u, der, t);
+    case 3
+      u_interp = ...
+      hermite_cubic_interpolation (z, u, k_vals, t);
+    case 4
+      ## if ode45 is used without local extrapolation this function
+      ## doesn't require a new function evaluation.
+      u_interp = dorpri_interpolation ([z(i-1) z(i)],
+                                       [u(:,i-1) u(:,i)],
+                                       k_vals, tspan(counter));
+    #}
+
+    case 5
+      ## ode45 with Dormand-Prince scheme:
+      u_interp = hermite_quartic_interpolation (z, u, k_vals, t);
+
+      ## it is also possible to do a new function evaluation and use
+      ## the quintic hermite interpolator
+      ## f_half = feval (func, t+1/2*dt, u_half,
+      ##                 options.funarguments{:});
+      ## u_interp =
+      ##   hermite_quintic_interpolation ([z(i-1) z(i)],
+      ##                                  [u(:,i-1) u_half u(:,i)],
+      ##                                  [k_vals(:,1) f_half ...
+      ##                                   k_vals(:,end)],
+      ##                                  tspan(counter));
+
+    otherwise
+      warning (["High order interpolation not yet implemented: ", ...
+                "using cubic interpolation instead"]);
+      der(:,1) = feval (func, z(1), u(:,1), args);
+      der(:,2) = feval (func, z(2), u(:,2), args);
+      u_interp = hermite_cubic_interpolation (z, u, der, t);
+
+  endswitch
+
+endfunction
+
+
+## The function below can be used in an ODE solver to interpolate the solution
+## at the time t_out using 4th order hermite interpolation.
+function x_out = hermite_quartic_interpolation (t, x, der, t_out)
+
+  persistent coefs_u_half = ...
+  [(6025192743/30085553152), 0, (51252292925/65400821598), ...
+   (-2691868925/45128329728), (187940372067/1594534317056), ...
+   (-1776094331/19743644256), (11237099/235043384)].';
+
+  ## 4th order approximation of y in t+dt/2 as proposed by Shampine in
+  ## Lawrence, Shampine, "Some Practical Runge-Kutta Formulas", 1986.
+  dt = t(2) - t(1);
+  u_half = x(:,1) + (1/2) * dt * (der(:,1:7) * coefs_u_half);
+
+  ## Rescale time on [0,1]
+  s = (t_out - t(1)) / dt;
+
+  ## Hermite basis functions
+  ## H0 = 1   - 11*s.^2 + 18*s.^3 -  8*s.^4;
+  ## H1 =   s -  4*s.^2 +  5*s.^3 -  2*s.^4;
+  ## H2 =       16*s.^2 - 32*s.^3 + 16*s.^4;
+  ## H3 =     -  5*s.^2 + 14*s.^3 -  8*s.^4;
+  ## H4 =          s.^2 -  3*s.^3 +  2*s.^4;
+
+  x_out = zeros (rows (x), length (t_out));
+  x_out = (1   - 11*s.^2 + 18*s.^3 -  8*s.^4) .* x(:,1) + ...
+          (  s -  4*s.^2 +  5*s.^3 -  2*s.^4) .* (dt * der(:,1)) + ...
+          (      16*s.^2 - 32*s.^3 + 16*s.^4) .* u_half + ...
+          (    -  5*s.^2 + 14*s.^3 -  8*s.^4) .* x(:,2) + ...
+          (         s.^2 -  3*s.^3 +  2*s.^4) .* (dt * der(:,end));
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/starting_stepsize.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,71 @@
+## Copyright (C) 2013 Roberto Porcu' <roberto.porcu@polimi.it>
+##
+## 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} =} starting_stepsize (@var{order}, @var{@@func}, @var{t0}, @var{x0}, @var{AbsTol}, @var{RelTol}, @var{normcontrol})
+##
+## Determine a good initial timestep for an ODE solver of order @var{order}
+## using the algorithm described in reference [1].
+##
+## The input argument @var{@@func}, is the function describing the differential
+## equations, @var{t0} is the initial time, and @var{x0} is the initial
+## condition.  @var{AbsTol} and @var{RelTol} are the absolute and relative
+## tolerance on the ODE integration taken from an ode options structure.
+##
+## References:
+## [1] E. Hairer, S.P. Norsett and G. Wanner,
+## @cite{Solving Ordinary Differential Equations I: Nonstiff Problems},
+## Springer.
+## @end deftypefn
+##
+## @seealso{odepkg}
+
+function h = starting_stepsize (order, func, t0, x0,
+                                AbsTol, RelTol, normcontrol)
+
+  ## compute norm of initial conditions
+  d0 = AbsRel_Norm (x0, x0, AbsTol, RelTol, normcontrol);
+
+  ## compute norm of the function evaluated at initial conditions
+  y = func (t0, x0);
+  d1 = AbsRel_Norm (y, y, AbsTol, RelTol, normcontrol);
+
+  if (d0 < 1e-5 || d1 < 1e-5)
+    h0 = 1e-6;
+  else
+    h0 = .01 * (d0 / d1);
+  endif
+
+  ## compute one step of Explicit-Euler
+  x1 = x0 + h0 * y;
+
+  ## approximate the derivative norm
+  d2 = (1 / h0) * ...
+       AbsRel_Norm (func (t0+h0, x1) - y,
+                    func (t0+h0, x1) - y, AbsTol, RelTol, normcontrol);
+
+  if (max (d1, d2) <= 1e-15)
+    h1 = max (1e-6, h0*1e-3);
+  else
+    h1 = (1e-2 / max (d1, d2)) ^(1 / (order+1));
+  endif
+
+  h = min (100*h0, h1);
+
+endfunction
+
--- a/scripts/optimization/fminbnd.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/optimization/fminbnd.m	Thu Dec 10 12:50:06 2015 -0800
@@ -106,7 +106,7 @@
   w = x = v;
   e = 0;
   fv = fw = fval = fun (x);
-  nfev++;
+  nfev += 1;
 
   ## Only for display purposes.
   iter(1).funccount = nfev;
@@ -169,7 +169,7 @@
     u = x + max (abs (d), tol) * (sign (d) + (d == 0));
     fu = fun (u);
 
-    niter++;
+    niter += 1;
 
     iter(niter).funccount = nfev++;
     iter(niter).x = u;
@@ -231,7 +231,7 @@
     case "off"
       "skip";
     otherwise
-      warning ("unknown option for Display: '%s'", displ);
+      warning ("fminbnd: unknown option for Display: '%s'", displ);
   endswitch
 
   output.iterations = niter;
@@ -278,7 +278,7 @@
     case -1
       "FIXME"; # FIXME: what's the message MATLAB prints for this case?
     otherwise
-      error ("internal error - fminbnd() is bug, sorry!");
+      error ("fminbnd: internal error, info return code was %d", info);
   endswitch
   printf ("\n");
 endfunction
--- a/scripts/optimization/fminsearch.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/optimization/fminsearch.m	Thu Dec 10 12:50:06 2015 -0800
@@ -150,7 +150,7 @@
   ## Use function to minimize, not maximize
   stopit(6) = dirn = -1;
 
-  ## File name for snapshots.
+  ## Filename for snapshots.
   savit = [];  # FIXME: expose this parameter to the outside
 
 endfunction
@@ -211,7 +211,7 @@
   alpha = 1;  beta = 1/2;  gamma = 2;
 
   while (1)   # Outer (and only) loop.
-    k++;
+    k += 1;
 
     if (k > maxiter)
       msg = "Exceeded maximum iterations...quitting\n";
@@ -265,14 +265,14 @@
     vr = (1 + alpha)*vbar - alpha*V(:,n+1);
     x(:) = vr;
     fr = dirn * feval (fun,x,varargin{:});
-    nf = nf + 1;
+    nf += 1;
     vk = vr;  fk = fr; how = "reflect, ";
     if (fr > f(n))
       if (fr > f(1))
         ve = gamma*vr + (1-gamma)*vbar;
         x(:) = ve;
         fe = dirn * feval (fun,x,varargin{:});
-        nf = nf + 1;
+        nf += 1;
         if (fe > f(1))
           vk = ve;
           fk = fe;
@@ -289,7 +289,7 @@
       vc = beta*vt + (1-beta)*vbar;
       x(:) = vc;
       fc = dirn * feval (fun,x,varargin{:});
-      nf = nf + 1;
+      nf += 1;
       if (fc > f(n))
         vk = vc; fk = fc;
         how = "contract,";
@@ -299,11 +299,11 @@
           x(:) = V(:,j);
           f(j) = dirn * feval (fun,x,varargin{:});
         endfor
-        nf = nf + n-1;
+        nf += n-1;
         vk = (V(:,1) + V(:,n+1))/2;
         x(:) = vk;
         fk = dirn * feval (fun,x,varargin{:});
-        nf = nf + 1;
+        nf += 1;
         how = "shrink,  ";
       endif
     endif
--- a/scripts/optimization/fminunc.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/optimization/fminunc.m	Thu Dec 10 12:50:06 2015 -0800
@@ -41,7 +41,7 @@
 ## @qcode{"AutoScaling"}.
 ##
 ## If @qcode{"GradObj"} is @qcode{"on"}, it specifies that @var{fcn}, when
-## called with 2 output arguments, also returns the Jacobian matrix of partial
+## called with two output arguments, also returns the Jacobian matrix of partial
 ## first derivatives at the requested point.  @code{TolX} specifies the
 ## termination tolerance for the unknown variables @var{x}, while @code{TolFun}
 ## is a tolerance for the objective function value @var{fval}.  The default is
@@ -80,8 +80,8 @@
 ## (@var{output}), the output gradient (@var{grad}) at the solution @var{x},
 ## and approximate Hessian (@var{hess}) at the solution @var{x}.
 ##
-## Application Notes: If have only a single nonlinear equation of one variable
-## then using @code{fminbnd} is usually a better choice.
+## Application Notes: If the objective function is a single nonlinear equation
+## of one variable then using @code{fminbnd} is usually a better choice.
 ##
 ## The algorithm used by @code{fminsearch} is a gradient search which depends
 ## on the objective function being differentiable.  If the function has
@@ -96,7 +96,7 @@
 function [x, fval, info, output, grad, hess] = fminunc (fcn, x0, options = struct ())
 
   ## Get default options if requested.
-  if (nargin == 1 && ischar (fcn) && strcmp (fcn, 'defaults'))
+  if (nargin == 1 && strcmp (fcn, "defaults"))
     x = optimset ("MaxIter", 400, "MaxFunEvals", Inf,
                   "GradObj", "off", "TolX", 1e-7, "TolFun", 1e-7,
                   "OutputFcn", [], "FunValCheck", "off",
@@ -113,7 +113,7 @@
     fcn = str2func (fcn, "global");
   endif
 
-  xsiz = size (x0);
+  xsz = size (x0);
   n = numel (x0);
 
   has_grad = strcmpi (optimget (options, "GradObj", "off"), "on");
@@ -122,8 +122,8 @@
   maxfev = optimget (options, "MaxFunEvals", Inf);
   outfcn = optimget (options, "OutputFcn");
 
-  ## Get scaling matrix using the TypicalX option. If set to "auto", the
-  ## scaling matrix is estimated using the jacobian.
+  ## Get scaling matrix using the TypicalX option.  If set to "auto", the
+  ## scaling matrix is estimated using the Jacobian.
   typicalx = optimget (options, "TypicalX");
   if (isempty (typicalx))
     typicalx = ones (n, 1);
@@ -140,7 +140,7 @@
     fcn = @(x) guarded_eval (fcn, x);
   endif
 
-  ## These defaults are rather stringent. I think that normally, user
+  ## These defaults are rather stringent.  I think that normally, user
   ## prefers accuracy to performance.
 
   macheps = eps (class (x0));
@@ -159,7 +159,7 @@
   info = 0;
 
   ## Initial evaluation.
-  fval = fcn (reshape (x, xsiz));
+  fval = fcn (reshape (x, xsz));
   n = length (x);
 
   if (! isempty (outfcn))
@@ -167,7 +167,7 @@
     optimvalues.funccount = nfev;
     optimvalues.fval = fval;
     optimvalues.searchdirection = zeros (n, 1);
-    state = 'init';
+    state = "init";
     stop = outfcn (x, optimvalues, state);
     if (stop)
       info = -1;
@@ -187,11 +187,11 @@
 
     ## Calculate function value and gradient (possibly via FD).
     if (has_grad)
-      [fval, grad] = fcn (reshape (x, xsiz));
+      [fval, grad] = fcn (reshape (x, xsz));
       grad = grad(:);
-      nfev ++;
+      nfev += 1;
     else
-      grad = __fdjac__ (fcn, reshape (x, xsiz), fval, typicalx, cdif)(:);
+      grad = __fdjac__ (fcn, reshape (x, xsz), fval, typicalx, cdif)(:);
       nfev += (1 + cdif) * length (x);
     endif
 
@@ -202,11 +202,11 @@
       ## Use the damped BFGS formula.
       y = grad - grad0;
       sBs = sumsq (w);
-      Bs = hesr'*w;
-      sy = y'*s;
+      Bs = hesr' * w;
+      sy = y' * s;
       theta = 0.8 / max (1 - sy / sBs, 0.8);
       r = theta * y + (1-theta) * Bs;
-      hesr = cholupdate (hesr, r / sqrt (s'*r), "+");
+      hesr = cholupdate (hesr, r / sqrt (s' * r), "+");
       [hesr, info] = cholupdate (hesr, Bs / sqrt (sBs), "-");
       if (info)
         hesr = eye (n);
@@ -214,8 +214,8 @@
     endif
 
     if (autoscale)
-      ## Second derivatives approximate the hessian.
-      d2f = norm (hesr, 'columns').';
+      ## Second derivatives approximate the Hessian.
+      d2f = norm (hesr, "columns").';
       if (niter == 1)
         dg = d2f;
       else
@@ -251,8 +251,8 @@
         delta = min (delta, sn);
       endif
 
-      fval1 = fcn (reshape (x + s, xsiz)) (:);
-      nfev ++;
+      fval1 = fcn (reshape (x + s, xsz))(:);
+      nfev += 1;
 
       if (fval1 < fval)
         ## Scaled actual reduction.
@@ -261,7 +261,7 @@
         actred = -1;
       endif
 
-      w = hesr*s;
+      w = hesr * s;
       ## Scaled predicted reduction, and ratio.
       t = 1/2 * sumsq (w) + grad'*s;
       if (t < 0)
@@ -276,7 +276,7 @@
       if (ratio < min (max (0.1, 0.8*lastratio), 0.9))
         delta *= decfac;
         decfac ^= 1.4142;
-        if (delta <= 1e1*macheps*xn)
+        if (delta <= 10*macheps*xn)
           ## Trust region became uselessly small.
           info = -3;
           break;
@@ -296,11 +296,11 @@
         x += s;
         xn = norm (dg .* x);
         fval = fval1;
-        nsuciter++;
+        nsuciter += 1;
         suc = true;
       endif
 
-      niter ++;
+      niter += 1;
 
       ## FIXME: should outputfcn be called only after a successful iteration?
       if (! isempty (outfcn))
@@ -308,7 +308,7 @@
         optimvalues.funccount = nfev;
         optimvalues.fval = fval;
         optimvalues.searchdirection = s;
-        state = 'iter';
+        state = "iter";
         stop = outfcn (x, optimvalues, state);
         if (stop)
           info = -1;
@@ -316,18 +316,18 @@
         endif
       endif
 
-      ## Tests for termination conditions. A mysterious place, anything
+      ## Tests for termination conditions.  A mysterious place, anything
       ## can happen if you change something here...
 
       ## The rule of thumb (which I'm not sure M*b is quite following)
       ## is that for a tolerance that depends on scaling, only 0 makes
-      ## sense as a default value. But 0 usually means uselessly long
+      ## sense as a default value.  But 0 usually means uselessly long
       ## iterations, so we need scaling-independent tolerances wherever
       ## possible.
 
       ## The following tests done only after successful step.
       if (ratio >= 1e-4)
-        ## This one is classic. Note that we use scaled variables again,
+        ## This one is classic.  Note that we use scaled variables again,
         ## but compare to scaled step, so nothing bad.
         if (sn <= tolx*xn)
           info = 2;
@@ -340,12 +340,39 @@
     endwhile
   endwhile
 
-  ## Restore original shapes.
-  x = reshape (x, xsiz);
+  ## When info != 1, recalculate the gradient and Hessian using the final x.
+  if (nargout > 4 && (info == -1 || info == 2 || info == 3))
+    grad0 = grad;
+    if (has_grad)
+      [fval, grad] = fcn (reshape (x, xsz));
+      grad = grad(:);
+    else
+      grad = __fdjac__ (fcn, reshape (x, xsz), fval, typicalx, cdif)(:);
+    endif
 
-  output.iterations = niter;
-  output.successful = nsuciter;
-  output.funcCount = nfev;
+    if (nargout > 5)
+      ## Use the damped BFGS formula.
+      y = grad - grad0;
+      sBs = sumsq (w);
+      Bs = hesr' * w;
+      sy = y' * s;
+      theta = 0.8 / max (1 - sy / sBs, 0.8);
+      r = theta * y + (1-theta) * Bs;
+      hesr = cholupdate (hesr, r / sqrt (s' * r), "+");
+      hesr = cholupdate (hesr, Bs / sqrt (sBs), "-");
+    endif
+    ## Return the gradient in the same shape as x
+    grad = reshape (grad, xsz);
+  endif
+
+  ## Restore original shapes.
+  x = reshape (x, xsz);
+
+  if (nargout > 3)
+    output.iterations = niter;
+    output.successful = nsuciter;
+    output.funcCount = nfev;
+  endif
 
   if (nargout > 5)
     hess = hesr'*hesr;
@@ -372,19 +399,19 @@
 endfunction
 
 
-%!function f = __rosenb (x)
+%!function f = __rosenb__ (x)
 %!  n = length (x);
 %!  f = sumsq (1 - x(1:n-1)) + 100 * sumsq (x(2:n) - x(1:n-1).^2);
 %!endfunction
 %!
 %!test
-%! [x, fval, info, out] = fminunc (@__rosenb, [5, -5]);
+%! [x, fval, info, out] = fminunc (@__rosenb__, [5, -5]);
 %! tol = 2e-5;
 %! assert (info > 0);
 %! assert (x, ones (1, 2), tol);
 %! assert (fval, 0, tol);
 %!test
-%! [x, fval, info, out] = fminunc (@__rosenb, zeros (1, 4));
+%! [x, fval, info, out] = fminunc (@__rosenb__, zeros (1, 4));
 %! tol = 2e-5;
 %! assert (info > 0);
 %! assert (x, ones (1, 4), tol);
--- a/scripts/optimization/fsolve.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/optimization/fsolve.m	Thu Dec 10 12:50:06 2015 -0800
@@ -236,7 +236,7 @@
         updating = false;
       endif
       fvec = fvec(:);
-      nfev ++;
+      nfev += 1;
     else
       fjac = __fdjac__ (fcn, reshape (x, xsiz), fvec, typicalx, cdif);
       nfev += (1 + cdif) * length (x);
@@ -311,7 +311,7 @@
 
       fvec1 = fcn (reshape (x + s, xsiz)) (:);
       fn1 = norm (fvec1);
-      nfev ++;
+      nfev += 1;
 
       if (fn1 < fn)
         ## Scaled actual reduction.
@@ -333,7 +333,7 @@
       ## Update delta.
       if (ratio < min (max (0.1, 0.8*lastratio), 0.9))
         nsuc = 0;
-        nfail ++;
+        nfail += 1;
         delta *= decfac;
         decfac ^= 1.4142;
         if (delta <= 1e1*macheps*xn)
@@ -345,7 +345,7 @@
         lastratio = ratio;
         decfac = 0.5;
         nfail = 0;
-        nsuc ++;
+        nsuc += 1;
         if (abs (1-ratio) <= 0.1)
           delta = 1.4142*sn;
         elseif (ratio >= 0.5 || nsuc > 1)
@@ -359,10 +359,10 @@
         xn = norm (dg .* x);
         fvec = fvec1;
         fn = fn1;
-        nsuciter ++;
+        nsuciter += 1;
       endif
 
-      niter ++;
+      niter += 1;
 
       ## FIXME: should outputfcn be only called after a successful iteration?
       if (! isempty (outfcn))
--- a/scripts/optimization/fzero.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/optimization/fzero.m	Thu Dec 10 12:50:06 2015 -0800
@@ -276,7 +276,7 @@
     ## Calculate new point.
     x = c;
     fval = fc = fun (c);
-    niter ++; nfev ++;
+    niter += 1; nfev += 1;
 
     ## Modification 2: skip inverse cubic interpolation if
     ## nonmonotonicity is detected.
--- a/scripts/optimization/lsqnonneg.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/optimization/lsqnonneg.m	Thu Dec 10 12:50:06 2015 -0800
@@ -117,7 +117,7 @@
   ## LH3: test for completion.
   while (iter < max_iter)
     while (iter < max_iter)
-      iter++;
+      iter += 1;
 
       ## LH6: compute the positive matrix and find the min norm solution
       ## of the positive problem.
@@ -144,7 +144,7 @@
         x += alpha*(xx - x);
         ## LH11: move from P to Z all X == 0.
         ## This corresponds to those indices where minimum of sf is attained.
-        idx = idx (sf == alpha);
+        idx = idx(sf == alpha);
         p(idx) = [];
         if (useqr)
           ## update the QR factorization.
--- a/scripts/optimization/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/optimization/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,26 +1,37 @@
-FCN_FILE_DIRS += optimization
+FCN_FILE_DIRS += \
+  scripts/optimization \
+  scripts/optimization/private
 
-optimization_PRIVATE_FCN_FILES = \
-  optimization/private/__fdjac__.m
+scripts_optimization_PRIVATE_FCN_FILES = \
+  scripts/optimization/private/__fdjac__.m
 
-optimization_FCN_FILES = \
-  optimization/__all_opts__.m \
-  optimization/fminbnd.m \
-  optimization/fminsearch.m \
-  optimization/fminunc.m \
-  optimization/fsolve.m \
-  optimization/fzero.m \
-  optimization/glpk.m \
-  optimization/lsqnonneg.m \
-  optimization/optimget.m \
-  optimization/optimset.m \
-  optimization/pqpnonneg.m \
-  optimization/qp.m \
-  optimization/sqp.m \
-  $(optimization_PRIVATE_FCN_FILES)
+scripts_optimization_FCN_FILES = \
+  scripts/optimization/__all_opts__.m \
+  scripts/optimization/fminbnd.m \
+  scripts/optimization/fminsearch.m \
+  scripts/optimization/fminunc.m \
+  scripts/optimization/fsolve.m \
+  scripts/optimization/fzero.m \
+  scripts/optimization/glpk.m \
+  scripts/optimization/lsqnonneg.m \
+  scripts/optimization/optimget.m \
+  scripts/optimization/optimset.m \
+  scripts/optimization/pqpnonneg.m \
+  scripts/optimization/qp.m \
+  scripts/optimization/sqp.m
 
-FCN_FILES += $(optimization_FCN_FILES)
+scripts_optimizationdir = $(fcnfiledir)/optimization
+
+scripts_optimization_DATA = $(scripts_optimization_FCN_FILES)
+
+scripts_optimization_privatedir = $(fcnfiledir)/optimization/private
+
+scripts_optimization_private_DATA = $(scripts_optimization_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += optimization/PKG_ADD
+FCN_FILES += \
+  $(scripts_optimization_FCN_FILES) \
+  $(scripts_optimization_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += optimization/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/optimization/PKG_ADD
+
+DIRSTAMP_FILES += scripts/optimization/$(octave_dirstamp)
--- a/scripts/optimization/pqpnonneg.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/optimization/pqpnonneg.m	Thu Dec 10 12:50:06 2015 -0800
@@ -111,7 +111,7 @@
   ## LH3: test for completion.
   while (iter < max_iter)
     while (iter < max_iter)
-      iter++;
+      iter += 1;
 
       ## LH6: compute the positive matrix and find the min norm solution
       ## of the positive problem.
--- a/scripts/optimization/qp.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/optimization/qp.m	Thu Dec 10 12:50:06 2015 -0800
@@ -116,20 +116,23 @@
 
 function [x, obj, INFO, lambda] = qp (x0, H, varargin)
 
-  nargs = nargin;
-
-  if (nargin == 1 && ischar (x0) && strcmp (x0, 'defaults'))
+  if (nargin == 1 && ischar (x0) && strcmp (x0, "defaults"))
     x = optimset ("MaxIter", 200);
     return;
   endif
 
+  nargs = nargin;
   if (nargs > 2 && isstruct (varargin{end}))
     options = varargin{end};
-    nargs--;
+    nargs -= 1;
   else
     options = struct ();
   endif
 
+  if (nargs != 2 && nargs != 3 && nargs != 5 && nargs != 7 && nargs != 10)
+    print_usage ();
+  endif
+
   if (nargs >= 3)
     q = varargin{1};
   else
@@ -162,250 +165,256 @@
     A_ub = [];
   endif
 
-  if (nargs == 2 || nargs == 3 || nargs == 5 || nargs == 7 || nargs == 10)
-
-    maxit = optimget (options, "MaxIter", 200);
+  maxit = optimget (options, "MaxIter", 200);
 
-    ## Checking the quadratic penalty
-    if (! issquare (H))
-      error ("qp: quadratic penalty matrix not square");
-    elseif (! ishermitian (H))
-      ## warning ("qp: quadratic penalty matrix not hermitian");
-      H = (H + H')/2;
-    endif
-    n = rows (H);
+  ## Validate the quadratic penalty.
+  if (! issquare (H))
+    error ("qp: quadratic penalty matrix must be square");
+  elseif (! ishermitian (H))
+    ## warning ("qp: quadratic penalty matrix not hermitian");
+    H = (H + H')/2;
+  endif
+  n = rows (H);
 
-    ## Checking the initial guess (if empty it is resized to the
-    ## right dimension and filled with 0)
-    if (isempty (x0))
-      x0 = zeros (n, 1);
+  ## Validate the initial guess.
+  ## If empty it is resized to the right dimension and filled with 0.
+  if (isempty (x0))
+    x0 = zeros (n, 1);
+  else
+    if (! isvector (x0))
+      error ("qp: the initial guess X0 must be a vector");
     elseif (numel (x0) != n)
-      error ("qp: the initial guess has incorrect length");
+      error ("qp: the initial guess X0 has incorrect length");
     endif
+    x0 = x0(:);  # always use column vector.
+  endif
 
-    ## Linear penalty.
-    if (isempty (q))
-      q = zeros (n, 1);
+  ## Validate linear penalty.
+  if (isempty (q))
+    q = zeros (n, 1);
+  else
+    if (! isvector (q))
+      error ("qp: Q must be a vector");
     elseif (numel (q) != n)
-      error ("qp: the linear term has incorrect length");
+      error ("qp: Q has incorrect length");
     endif
+    q = q(:);   # always use column vector.
+  endif
 
-    ## Equality constraint matrices
-    if (isempty (A) || isempty (b))
-      A = zeros (0, n);
-      b = zeros (0, 1);
-      n_eq = 0;
-    else
-      [n_eq, n1] = size (A);
-      if (n1 != n)
-        error ("qp: equality constraint matrix has incorrect column dimension");
-      endif
-      if (numel (b) != n_eq)
-        error ("qp: equality constraint matrix and vector have inconsistent dimension");
+  ## Validate equality constraint matrices.
+  if (isempty (A) || isempty (b))
+    A = zeros (0, n);
+    b = zeros (0, 1);
+    n_eq = 0;
+  else
+    [n_eq, n1] = size (A);
+    if (n1 != n)
+      error ("qp: equality constraint matrix has incorrect column dimension");
+    endif
+    if (numel (b) != n_eq)
+      error ("qp: equality constraint matrix and vector have inconsistent dimensions");
+    endif
+  endif
+
+  ## Validate bound constraints.
+  Ain = zeros (0, n);
+  bin = zeros (0, 1);
+  n_in = 0;
+  if (nargs > 5)
+    if (! isempty (lb))
+      if (numel (lb) != n)
+        error ("qp: lower bound LB has incorrect length");
+      elseif (isempty (ub))
+        Ain = [Ain; eye(n)];
+        bin = [bin; lb];
       endif
     endif
 
-    ## Bound constraints
-    Ain = zeros (0, n);
-    bin = zeros (0, 1);
-    n_in = 0;
-    if (nargs > 5)
-      if (! isempty (lb))
-        if (numel (lb) != n)
-          error ("qp: lower bound has incorrect length");
-        elseif (isempty (ub))
-          Ain = [Ain; eye(n)];
-          bin = [bin; lb];
+    if (! isempty (ub))
+      if (numel (ub) != n)
+        error ("qp: upper bound UB has incorrect length");
+      elseif (isempty (lb))
+        Ain = [Ain; -eye(n)];
+        bin = [bin; -ub];
+      endif
+    endif
+
+    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)))))
+          ## These are actually an equality constraint
+          tmprow = zeros (1,n);
+          tmprow(i) = 1;
+          A = [A;tmprow];
+          b = [b; 0.5*(lb(i) + ub(i))];
+          n_eq += 1;
+        else
+          tmprow = zeros (1,n);
+          tmprow(i) = 1;
+          Ain = [Ain; tmprow; -tmprow];
+          bin = [bin; lb(i); -ub(i)];
+          n_in += 2;
+        endif
+      endfor
+    endif
+  endif
+
+  ## Validate inequality constraints.
+  if (nargs > 7)
+    [dimA_in, n1] = size (A_in);
+    if (n1 != n)
+      error ("qp: inequality constraint matrix has incorrect column dimension");
+    else
+      if (! isempty (A_lb))
+        if (numel (A_lb) != dimA_in)
+          error ("qp: inequality constraint matrix and lower bound vector are inconsistent");
+        elseif (isempty (A_ub))
+          Ain = [Ain; A_in];
+          bin = [bin; A_lb];
+        endif
+      endif
+      if (! isempty (A_ub))
+        if (numel (A_ub) != dimA_in)
+          error ("qp: inequality constraint matrix and upper bound vector are inconsistent");
+        elseif (isempty (A_lb))
+          Ain = [Ain; -A_in];
+          bin = [bin; -A_ub];
         endif
       endif
 
-      if (! isempty (ub))
-        if (numel (ub) != n)
-          error ("qp: upper bound has incorrect length");
-        elseif (isempty (lb))
-          Ain = [Ain; -eye(n)];
-          bin = [bin; -ub];
-        endif
-      endif
-
-      if (! isempty (lb) && ! isempty (ub))
+      if (! isempty (A_lb) && ! isempty (A_ub))
         rtol = sqrt (eps);
-        for i = 1:n
-          if (abs (lb (i) - ub(i)) < rtol*(1 + max (abs (lb(i) + ub(i)))))
+        for i = 1:dimA_in
+          if (abs (A_lb(i) - A_ub(i))
+              < rtol*(1 + max (abs (A_lb(i) + A_ub(i)))))
             ## These are actually an equality constraint
-            tmprow = zeros (1,n);
-            tmprow(i) = 1;
+            tmprow = A_in(i,:);
             A = [A;tmprow];
-            b = [b; 0.5*(lb(i) + ub(i))];
-            n_eq = n_eq + 1;
+            b = [b; 0.5*(A_lb(i) + A_ub(i))];
+            n_eq += 1;
           else
-            tmprow = zeros (1,n);
-            tmprow(i) = 1;
+            tmprow = A_in(i,:);
             Ain = [Ain; tmprow; -tmprow];
-            bin = [bin; lb(i); -ub(i)];
-            n_in = n_in + 2;
+            bin = [bin; A_lb(i); -A_ub(i)];
+            n_in += 2;
           endif
         endfor
       endif
     endif
+  endif
 
-    ## Inequality constraints
-    if (nargs > 7)
-      [dimA_in, n1] = size (A_in);
-      if (n1 != n)
-        error ("qp: inequality constraint matrix has incorrect column dimension");
-      else
-        if (! isempty (A_lb))
-          if (numel (A_lb) != dimA_in)
-            error ("qp: inequality constraint matrix and lower bound vector inconsistent");
-          elseif (isempty (A_ub))
-            Ain = [Ain; A_in];
-            bin = [bin; A_lb];
-          endif
-        endif
-        if (! isempty (A_ub))
-          if (numel (A_ub) != dimA_in)
-            error ("qp: inequality constraint matrix and upper bound vector inconsistent");
-          elseif (isempty (A_lb))
-            Ain = [Ain; -A_in];
-            bin = [bin; -A_ub];
+  ## Now we should have the following QP:
+  ##
+  ##   min_x  0.5*x'*H*x + x'*q
+  ##   s.t.   A*x = b
+  ##          Ain*x >= bin
+
+  ## Discard inequality constraints that have -Inf bounds since those
+  ## will never be active.
+  idx = (bin == -Inf);
+
+  bin(idx) = [];
+  Ain(idx,:) = [];
+
+  n_in = numel (bin);
+
+  ## Check if the initial guess is feasible.
+  if (isa (x0, "single") || isa (H, "single") || isa (q, "single")
+      || isa (A, "single") || isa (b, "single"))
+    rtol = sqrt (eps ("single"));
+  else
+    rtol = sqrt (eps);
+  endif
+
+  eq_infeasible = (n_eq > 0 && norm (A*x0-b) > rtol*(1+abs (b)));
+  in_infeasible = (n_in > 0 && any (Ain*x0-bin < -rtol*(1+abs (bin))));
+
+  info = 0;
+  if (eq_infeasible || in_infeasible)
+    ## The initial guess is not feasible.
+    ## First, define an xbar that is feasible with respect to the
+    ## equality constraints.
+    if (eq_infeasible)
+      if (rank (A) < n_eq)
+        error ("qp: equality constraint matrix must be full row rank");
+      endif
+      xbar = pinv (A) * b;
+    else
+      xbar = x0;
+    endif
+
+    ## Second, check that xbar is also feasible with respect to the
+    ## inequality constraints.
+    if (n_in > 0)
+      res = Ain * xbar - bin;
+      if (any (res < -rtol * (1 + abs (bin))))
+        ## xbar is not feasible with respect to the inequality constraints.
+        ## Compute a step in the null space of the equality constraints,
+        ## by solving a QP.  If the slack is small, we have a feasible initial
+        ## guess.  Otherwise, the problem is infeasible.
+        if (n_eq > 0)
+          Z = null (A);
+          if (isempty (Z))
+            ## The problem is infeasible because A is square and full rank,
+            ## but xbar is not feasible.
+            info = 6;
           endif
         endif
 
-        if (! isempty (A_lb) && ! isempty (A_ub))
-          rtol = sqrt (eps);
-          for i = 1:dimA_in
-            if (abs (A_lb(i) - A_ub(i))
-                < rtol*(1 + max (abs (A_lb(i) + A_ub(i)))))
-              ## These are actually an equality constraint
-              tmprow = A_in(i,:);
-              A = [A;tmprow];
-              b = [b; 0.5*(A_lb(i) + A_ub(i))];
-              n_eq = n_eq + 1;
+        if (info != 6)
+          ## Solve an LP with additional slack variables
+          ## to find a feasible starting point.
+          gamma = eye (n_in);
+          if (n_eq > 0)
+            Atmp = [Ain*Z, gamma];
+            btmp = -res;
+          else
+            Atmp = [Ain, gamma];
+            btmp = bin;
+          endif
+          ctmp = [zeros(n-n_eq, 1); ones(n_in, 1)];
+          lb = [-Inf(n-n_eq,1); zeros(n_in,1)];
+          ub = [];
+          ctype = repmat ("L", n_in, 1);
+          [P, dummy, status] = glpk (ctmp, Atmp, btmp, lb, ub, ctype);
+          if ((status == 0)
+              && all (abs (P(n-n_eq+1:end)) < rtol * (1 + norm (btmp))))
+            ## We found a feasible starting point
+            if (n_eq > 0)
+              x0 = xbar + Z*P(1:n-n_eq);
             else
-              tmprow = A_in(i,:);
-              Ain = [Ain; tmprow; -tmprow];
-              bin = [bin; A_lb(i); -A_ub(i)];
-              n_in = n_in + 2;
+              x0 = P(1:n);
             endif
-          endfor
-        endif
-      endif
-    endif
-
-    ## Now we should have the following QP:
-    ##
-    ##   min_x  0.5*x'*H*x + x'*q
-    ##   s.t.   A*x = b
-    ##          Ain*x >= bin
-
-    ## Discard inequality constraints that have -Inf bounds since those
-    ## will never be active.
-    idx = isinf (bin) & bin < 0;
-
-    bin(idx) = [];
-    Ain(idx,:) = [];
-
-    n_in = numel (bin);
-
-    ## Check if the initial guess is feasible.
-    if (isa (x0, "single") || isa (H, "single") || isa (q, "single")
-        || isa (A, "single") || isa (b, "single"))
-      rtol = sqrt (eps ("single"));
-    else
-      rtol = sqrt (eps);
-    endif
-
-    eq_infeasible = (n_eq > 0 && norm (A*x0-b) > rtol*(1+abs (b)));
-    in_infeasible = (n_in > 0 && any (Ain*x0-bin < -rtol*(1+abs (bin))));
-
-    info = 0;
-    if (eq_infeasible || in_infeasible)
-      ## The initial guess is not feasible.
-      ## First define xbar that is feasible with respect to the equality
-      ## constraints.
-      if (eq_infeasible)
-        if (rank (A) < n_eq)
-          error ("qp: equality constraint matrix must be full row rank");
-        endif
-        xbar = pinv (A) * b;
-      else
-        xbar = x0;
-      endif
-
-      ## Check if xbar is feasible with respect to the inequality
-      ## constraints also.
-      if (n_in > 0)
-        res = Ain * xbar - bin;
-        if (any (res < -rtol * (1 + abs (bin))))
-          ## xbar is not feasible with respect to the inequality
-          ## constraints.  Compute a step in the null space of the
-          ## equality constraints, by solving a QP.  If the slack is
-          ## small, we have a feasible initial guess.  Otherwise, the
-          ## problem is infeasible.
-          if (n_eq > 0)
-            Z = null (A);
-            if (isempty (Z))
-              ## The problem is infeasible because A is square and full
-              ## rank, but xbar is not feasible.
-              info = 6;
-            endif
+          else
+            ## The problem is infeasible
+            info = 6;
           endif
-
-          if (info != 6)
-            ## Solve an LP with additional slack variables to find
-            ## a feasible starting point.
-            gamma = eye (n_in);
-            if (n_eq > 0)
-              Atmp = [Ain*Z, gamma];
-              btmp = -res;
-            else
-              Atmp = [Ain, gamma];
-              btmp = bin;
-            endif
-            ctmp = [zeros(n-n_eq, 1); ones(n_in, 1)];
-            lb = [-Inf(n-n_eq,1); zeros(n_in,1)];
-            ub = [];
-            ctype = repmat ("L", n_in, 1);
-            [P, dummy, status] = glpk (ctmp, Atmp, btmp, lb, ub, ctype);
-            if ((status == 0)
-                && all (abs (P(n-n_eq+1:end)) < rtol * (1 + norm (btmp))))
-              ## We found a feasible starting point
-              if (n_eq > 0)
-                x0 = xbar + Z*P(1:n-n_eq);
-              else
-                x0 = P(1:n);
-              endif
-            else
-              ## The problem is infeasible
-              info = 6;
-            endif
-          endif
-        else
-          ## xbar is feasible.  We use it a starting point.
-          x0 = xbar;
         endif
       else
         ## xbar is feasible.  We use it a starting point.
         x0 = xbar;
       endif
+    else
+      ## xbar is feasible.  We use it a starting point.
+      x0 = xbar;
     endif
+  endif
 
-    if (info == 0)
-      ## The initial (or computed) guess is feasible.
-      ## We call the solver.
-      [x, lambda, info, iter] = __qp__ (x0, H, q, A, b, Ain, bin, maxit);
-    else
-      iter = 0;
-      x = x0;
-      lambda = [];
-    endif
+  if (info == 0)
+    ## The initial (or computed) guess is feasible.  Call the solver.
+    [x, lambda, info, iter] = __qp__ (x0, H, q, A, b, Ain, bin, maxit);
+  else
+    iter = 0;
+    x = x0;
+    lambda = [];
+  endif
+  if (isargout (2))
     obj = 0.5 * x' * H * x + q' * x;
+  endif
+  if (isargout (3))
     INFO.solveiter = iter;
     INFO.info = info;
-
-  else
-    print_usage ();
   endif
 
 endfunction
--- a/scripts/optimization/sqp.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/optimization/sqp.m	Thu Dec 10 12:50:06 2015 -0800
@@ -540,7 +540,7 @@
 
   if (isempty (obj))
     obj = feval (obj_fun, x);
-    globals.nfun++;
+    globals.nfun += 1;
   endif
 
   merit = obj;
--- a/scripts/path/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/path/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,16 +1,27 @@
-FCN_FILE_DIRS += path
+FCN_FILE_DIRS += \
+  scripts/path \
+  scripts/path/private
+
+scripts_path_PRIVATE_FCN_FILES = \
+  scripts/path/private/getsavepath.m
 
-path_PRIVATE_FCN_FILES = \
-  path/private/getsavepath.m
+scripts_path_FCN_FILES = \
+  scripts/path/matlabroot.m \
+  scripts/path/pathdef.m \
+  scripts/path/savepath.m
+
+scripts_pathdir = $(fcnfiledir)/path
 
-path_FCN_FILES = \
-  path/matlabroot.m \
-  path/pathdef.m \
-  path/savepath.m \
-  $(path_PRIVATE_FCN_FILES)
+scripts_path_DATA = $(scripts_path_FCN_FILES)
+
+scripts_path_privatedir = $(fcnfiledir)/path/private
+
+scripts_path_private_DATA = $(scripts_path_PRIVATE_FCN_FILES)
 
-FCN_FILES += $(path_FCN_FILES)
+FCN_FILES += \
+  $(scripts_path_FCN_FILES) \
+  $(scripts_path_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += path/PKG_ADD
+PKG_ADD_FILES += scripts/path/PKG_ADD
 
-DIRSTAMP_FILES += path/$(octave_dirstamp)
+DIRSTAMP_FILES += scripts/path/$(octave_dirstamp)
--- a/scripts/path/savepath.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/path/savepath.m	Thu Dec 10 12:50:06 2015 -0800
@@ -202,7 +202,7 @@
 %!   assert (fid >= 0);
 %!   fclose (fid);
 %!   ## Save path into local .octaverc file
-%!   warning ("off", "Octave:savepath-local");
+%!   warning ("off", "Octave:savepath-local", "local");
 %!   status = savepath ();
 %!   assert (status == 0);
 %!   ## Compare old and new versions
--- a/scripts/pkg/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/pkg/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,52 +1,61 @@
-FCN_FILE_DIRS += pkg
+FCN_FILE_DIRS += \
+  scripts/pkg \
+  scripts/pkg/private
 
-pkg_PRIVATE_FCN_FILES = \
-  pkg/private/build.m \
-  pkg/private/configure_make.m \
-  pkg/private/copy_files.m \
-  pkg/private/create_pkgadddel.m \
-  pkg/private/default_prefix.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
+scripts_pkg_PRIVATE_FCN_FILES = \
+  scripts/pkg/private/build.m \
+  scripts/pkg/private/configure_make.m \
+  scripts/pkg/private/copy_files.m \
+  scripts/pkg/private/create_pkgadddel.m \
+  scripts/pkg/private/default_prefix.m \
+  scripts/pkg/private/describe.m \
+  scripts/pkg/private/dirempty.m \
+  scripts/pkg/private/extract_pkg.m \
+  scripts/pkg/private/finish_installation.m \
+  scripts/pkg/private/fix_depends.m \
+  scripts/pkg/private/fix_version.m \
+  scripts/pkg/private/generate_lookfor_cache.m \
+  scripts/pkg/private/get_description.m \
+  scripts/pkg/private/get_forge_download.m \
+  scripts/pkg/private/get_forge_pkg.m \
+  scripts/pkg/private/getarch.m \
+  scripts/pkg/private/getarchdir.m \
+  scripts/pkg/private/getarchprefix.m \
+  scripts/pkg/private/get_unsatisfied_deps.m \
+  scripts/pkg/private/install.m \
+  scripts/pkg/private/installed_packages.m \
+  scripts/pkg/private/is_architecture_dependent.m \
+  scripts/pkg/private/list_forge_packages.m \
+  scripts/pkg/private/load_package_dirs.m \
+  scripts/pkg/private/load_packages.m \
+  scripts/pkg/private/load_packages_and_dependencies.m \
+  scripts/pkg/private/packinfo_copy_file.m \
+  scripts/pkg/private/parse_pkg_idx.m \
+  scripts/pkg/private/prepare_installation.m \
+  scripts/pkg/private/print_package_description.m \
+  scripts/pkg/private/rebuild.m \
+  scripts/pkg/private/repackage.m \
+  scripts/pkg/private/save_order.m \
+  scripts/pkg/private/shell.m \
+  scripts/pkg/private/uninstall.m \
+  scripts/pkg/private/unload_packages.m \
+  scripts/pkg/private/verify_directory.m \
+  scripts/pkg/private/write_index.m
 
+scripts_pkg_FCN_FILES = scripts/pkg/pkg.m
 
-pkg_FCN_FILES = \
-  pkg/pkg.m \
-  $(pkg_PRIVATE_FCN_FILES)
+scripts_pkgdir = $(fcnfiledir)/pkg
+
+scripts_pkg_DATA = $(scripts_pkg_FCN_FILES)
+
+scripts_pkg_privatedir = $(fcnfiledir)/pkg/private
 
-FCN_FILES += $(pkg_FCN_FILES)
+scripts_pkg_private_DATA = $(scripts_pkg_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += pkg/PKG_ADD
+FCN_FILES += \
+  $(scripts_pkg_FCN_FILES) \
+  $(scripts_pkg_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += pkg/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/pkg/PKG_ADD
+
+DIRSTAMP_FILES += scripts/pkg/$(octave_dirstamp)
--- a/scripts/pkg/pkg.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/pkg/pkg.m	Thu Dec 10 12:50:06 2015 -0800
@@ -68,6 +68,12 @@
 ## Install a package directly from the Octave-Forge repository.  This
 ## requires an internet connection and the cURL library.
 ##
+## @emph{Security risk}: no verification of the package is performed
+## before the installation.  There are no signature for packages, or
+## checksums to confirm the correct file was downloaded.  It has the
+## same security issues as manually downloading the package from the
+## Octave Forge repository and installing it.
+##
 ## @item -verbose
 ## The package manager will print the output of all commands as
 ## they are performed.
@@ -346,7 +352,7 @@
         endif
       case available_actions
         if (! strcmp (action, "none"))
-          error ("more than one action specified");
+          error ("pkg: more than one action specified");
         endif
         action = varargin{i};
       otherwise
@@ -355,35 +361,33 @@
   endfor
 
   if (octave_forge && ! any (strcmp (action, {"install", "list"})))
-    error ("-forge can only be used with install or list");
+    error ("pkg: '-forge' can only be used with install or list");
   endif
 
   ## Take action
   switch (action)
     case "list"
       if (octave_forge)
-        if (nargout > 0)
+        if (nargout)
           local_packages = list_forge_packages ();
         else
           list_forge_packages ();
         endif
       else
-        if (nargout == 0)
-          installed_packages (local_list, global_list, files);
-        elseif (nargout == 1)
+        if (nargout == 1)
           local_packages = installed_packages (local_list, global_list, files);
-        elseif (nargout == 2)
+        elseif (nargout > 1)
           [local_packages, global_packages] = installed_packages (local_list,
                                                                   global_list,
                                                                   files);
         else
-          error ("too many output arguments requested");
+          installed_packages (local_list, global_list, files);
         endif
       endif
 
     case "install"
       if (isempty (files))
-        error ("you must specify at least one filename when calling 'pkg install'");
+        error ("pkg: install action requires at least one filename");
       endif
 
       local_files = {};
@@ -397,7 +401,7 @@
           succ = [succ{:}];
           if (! all (succ))
             i = find (! succ, 1);
-            error ("could not download file %s from url %s",
+            error ("pkg: could not download file %s from url %s",
                    local_files{i}, urls{i});
           endif
         endif
@@ -411,37 +415,37 @@
 
     case "uninstall"
       if (isempty (files))
-        error ("you must specify at least one package when calling 'pkg uninstall'");
+        error ("pkg: uninstall action requires at least one package name");
       endif
       uninstall (files, deps, verbose, local_list, global_list, global_install);
 
     case "load"
       if (isempty (files))
-        error ("you must specify at least one package, 'all', or 'auto' when calling 'pkg load'");
+        error ("pkg: load action requires at least one package, 'all', or 'auto'");
       endif
       load_packages (files, deps, local_list, global_list);
 
     case "unload"
       if (isempty (files))
-        error ("you must specify at least one package or 'all' when calling 'pkg unload'");
+        error ("pkg: unload action requires at least one package or 'all'");
       endif
       unload_packages (files, deps, local_list, global_list);
 
     case "prefix"
-      if (isempty (files) && nargout == 0)
+      if (isempty (files) && ! nargout)
         printf ("Installation prefix:             %s\n", prefix);
         printf ("Architecture dependent prefix:   %s\n", archprefix);
-      elseif (isempty (files) && nargout >= 1)
+      elseif (isempty (files) && nargout)
         local_packages = prefix;
         global_packages = archprefix;
-      elseif (numel (files) >= 1 && nargout <= 2 && ischar (files{1}))
+      elseif (numel (files) >= 1 && ischar (files{1}))
         prefix = tilde_expand (files{1});
         if (! exist (prefix, "dir"))
           [status, msg] = mkdir (prefix);
           if (status == 0)
-            error ("cannot create prefix %s: %s", prefix, msg);
+            error ("pkg: cannot create prefix %s: %s", prefix, msg);
           endif
-          warning ("creating the directory %s\n", prefix);
+          warning ("pkg: creating the directory %s\n", prefix);
         endif
         local_packages = prefix = canonicalize_file_name (prefix);
         user_prefix = true;
@@ -450,54 +454,54 @@
           if (! exist (archprefix, "dir"))
             [status, msg] = mkdir (archprefix);
             if (status == 0)
-              error ("cannot create archprefix %s: %s", archprefix, msg);
+              error ("pkg: cannot create archprefix %s: %s", archprefix, msg);
             endif
-            warning ("creating the directory %s\n", archprefix);
+            warning ("pkg: creating the directory %s\n", archprefix);
             global_packages = archprefix = canonicalize_file_name (archprefix);
           endif
         endif
       else
-        error ("you must specify a prefix directory, or request an output argument");
+        error ("pkg: prefix action requires a directory input, or an output argument");
       endif
 
     case "local_list"
-      if (isempty (files) && nargout == 0)
+      if (isempty (files) && ! nargout)
         disp (local_list);
-      elseif (isempty (files) && nargout == 1)
+      elseif (isempty (files) && nargout)
         local_packages = local_list;
-      elseif (numel (files) == 1 && nargout == 0 && ischar (files{1}))
+      elseif (numel (files) == 1 && ! nargout && ischar (files{1}))
         local_list = files{1};
         if (! exist (local_list, "file"))
           try
             ## Force file to be created
             fclose (fopen (local_list, "wt"));
           catch
-            error ("cannot create file %s", local_list);
+            error ("pkg: cannot create file %s", local_list);
           end_try_catch
         endif
         local_list = canonicalize_file_name (local_list);
       else
-        error ("you must specify a local_list file, or request an output argument");
+        error ("pkg: specify a local_list file, or request an output argument");
       endif
 
     case "global_list"
-      if (isempty (files) && nargout == 0)
+      if (isempty (files) && ! nargout)
         disp (global_list);
-      elseif (isempty (files) && nargout == 1)
+      elseif (isempty (files) && nargout)
         local_packages = global_list;
-      elseif (numel (files) == 1 && nargout == 0 && ischar (files{1}))
+      elseif (numel (files) == 1 && ! nargout && ischar (files{1}))
         global_list = files{1};
         if (! exist (global_list, "file"))
           try
             ## Force file to be created
             fclose (fopen (files{1}, "wt"));
           catch
-            error ("cannot create file %s", global_list);
+            error ("pkg: cannot create file %s", global_list);
           end_try_catch
         endif
         global_list = canonicalize_file_name (global_list);
       else
-        error ("you must specify a global_list file, or request an output argument");
+        error ("pkg: specify a global_list file, or request an output argument");
       endif
 
     case "rebuild"
@@ -506,7 +510,7 @@
                                    auto, verbose);
         global_packages = save_order (global_packages);
         save (global_list, "global_packages");
-        if (nargout > 0)
+        if (nargout)
           local_packages = global_packages;
         endif
       else
@@ -514,67 +518,55 @@
                                   auto, verbose);
         local_packages = save_order (local_packages);
         save (local_list, "local_packages");
-        if (nargout == 0)
+        if (! nargout)
           clear ("local_packages");
         endif
       endif
 
     case "build"
       if (numel (files) < 2)
-        error ("you must specify at least the build directory and one filename\nwhen calling 'pkg build'");
+        error ("pkg: build action requires build directory and at least one filename");
       endif
       build (files, deps, auto, verbose);
 
     case "describe"
       if (isempty (files))
-        error ("you must specify at least one package or 'all' when calling 'pkg describe'");
+        error ("pkg: describe action requires at least one package or 'all'");
       endif
       ## FIXME: name of the output variables is inconsistent with their content
-      switch (nargout)
-        case 0
-          describe (files, verbose, local_list, global_list);
-        case 1
-          pkg_desc_list = describe (files, verbose, local_list, global_list);
-          local_packages = pkg_desc_list;
-        case 2
-          [pkg_desc_list, flag] = describe (files, verbose, local_list, ...
-                                            global_list);
-          local_packages  = pkg_desc_list;
-          global_packages = flag;
-        otherwise
-          error ("you can request at most two outputs when calling 'pkg describe'");
-      endswitch
+      if (nargout)
+        [local_packages, global_packages] = describe (files, verbose,
+                                                      local_list, global_list);
+      else
+        describe (files, verbose, local_list, global_list);
+      endif
 
     case "update"
-      if (nargout == 0)
-        installed_pkgs_lst = installed_packages (local_list, global_list);
-        if (numel (files) > 0)
-           update_lst = {};
-           installed_names = {installed_pkgs_list.name}';
-           for i = 1:numel (files)
-             idx = find (strcmp (files{i}, installed_names), 1);
-             if (isempty (idx))
-               warning ("Package %s is not installed - not updating this package", files{i});
-             else
-               update_lst = { update_lst, installed_pkgs_lst{idx} };
-             endif
-           endfor
-           installed_pkgs_lst = update_lst;
+      installed_pkgs_lst = installed_packages (local_list, global_list);
+      if (numel (files) > 0)
+         update_lst = {};
+         installed_names = {installed_pkgs_list.name}';
+         for i = 1:numel (files)
+           idx = find (strcmp (files{i}, installed_names), 1);
+           if (isempty (idx))
+             warning ("pkg: package %s is not installed - skipping update", files{i});
+           else
+             update_lst = { update_lst, installed_pkgs_lst{idx} };
+           endif
+         endfor
+         installed_pkgs_lst = update_lst;
+      endif
+      for i = 1:numel (installed_pkgs_lst)
+        installed_pkg_name = installed_pkgs_lst{i}.name;
+        installed_pkg_version = installed_pkgs_lst{i}.version;
+        forge_pkg_version = get_forge_pkg (installed_pkg_name);
+        if (compare_versions (forge_pkg_version, installed_pkg_version, ">"))
+          feval (@pkg, "install", "-forge", installed_pkg_name);
         endif
-        for i = 1:numel (installed_pkgs_lst)
-          installed_pkg_name = installed_pkgs_lst{i}.name;
-          installed_pkg_version = installed_pkgs_lst{i}.version;
-          forge_pkg_version = get_forge_pkg (installed_pkg_name);
-          if (compare_versions (forge_pkg_version, installed_pkg_version, ">"))
-            feval (@pkg, "install", "-forge", installed_pkg_name);
-          endif
-        endfor
-      else
-        error ("no output arguments available");
-      endif
+      endfor
 
     otherwise
-      error ("you must specify a valid action for 'pkg'.  See 'help pkg' for details");
+      error ("pkg: invalid action.  See 'help pkg' for available actions");
   endswitch
 
 endfunction
--- a/scripts/pkg/private/configure_make.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/pkg/private/configure_make.m	Thu Dec 10 12:50:06 2015 -0800
@@ -103,7 +103,7 @@
     instdir = fullfile (packdir, "inst");
     archdir = fullfile (packdir, "inst", getarch ());
 
-    ## Get file names.
+    ## Get filenames.
     if (exist (files, "file"))
       [fid, msg] = fopen (files, "r");
       if (fid < 0)
--- a/scripts/pkg/private/fix_version.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/pkg/private/fix_version.m	Thu Dec 10 12:50:06 2015 -0800
@@ -29,7 +29,7 @@
   if (regexp (v, '^\d+(\.\d+){1,2}$') == 1)
     parts = ostrsplit (v, '.', true);
     if (numel (parts) == 2)
-      out = strcat (v, ".0");
+      out = [v ".0"];
     else
       out = v;
     endif
--- a/scripts/pkg/private/installed_packages.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/pkg/private/installed_packages.m	Thu Dec 10 12:50:06 2015 -0800
@@ -83,73 +83,69 @@
   endfor
 
   ## Should we return something?
-  if (nargout == 2)
+  if (nargout == 1)
+    out1 = installed_pkgs_lst;
+  elseif (nargout > 1)
     out1 = local_packages;
     out2 = global_packages;
-    return;
-  elseif (nargout == 1)
-    out1 = installed_pkgs_lst;
-    return;
-  endif
-
-  ## Don't return anything, instead we'll print something.
-  num_packages = numel (installed_pkgs_lst);
-  if (num_packages == 0)
-    if (isempty (pkgname))
-      printf ("no packages installed.\n");
-    else
-      printf ("package %s is not installed.\n", pkgname{1});
+  else
+    ## Don't return anything, instead we'll print something.
+    num_packages = numel (installed_pkgs_lst);
+    if (num_packages == 0)
+      if (isempty (pkgname))
+        printf ("no packages installed.\n");
+      else
+        printf ("package %s is not installed.\n", pkgname{1});
+      endif
+      return;
     endif
-    return;
-  endif
 
-  ## Compute the maximal lengths of name, version, and dir.
-  h1 = "Package Name";
-  h2 = "Version";
-  h3 = "Installation directory";
-  max_name_length = max ([length(h1), cellfun(@length, installed_names)]);
-  version_lengths = cellfun (@(x) length (x.version), installed_pkgs_lst);
-  max_version_length = max ([length(h2), version_lengths]);
-  ncols = terminal_size ()(2);
-  max_dir_length = ncols - max_name_length - max_version_length - 7;
-  if (max_dir_length < 20)
-    max_dir_length = Inf;
-  endif
+    ## Compute the maximal lengths of name, version, and dir.
+    h1 = "Package Name";
+    h2 = "Version";
+    h3 = "Installation directory";
+    max_name_length = max ([length(h1), cellfun(@length, installed_names)]);
+    version_lengths = cellfun (@(x) length (x.version), installed_pkgs_lst);
+    max_version_length = max ([length(h2), version_lengths]);
+    ncols = terminal_size ()(2);
+    max_dir_length = ncols - 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, " ");;
+    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 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);
-  for i = 1:num_packages
-    cur_name = installed_pkgs_lst{i}.name;
-    cur_version = installed_pkgs_lst{i}.version;
-    cur_dir = installed_pkgs_lst{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 = ["..." cur_dir((first_char + first_filesep(1) - 1):end)];
+    ## Print the packages.
+    format = sprintf ("%%%ds %%1s| %%%ds | %%s\n",
+                      max_name_length, max_version_length);
+    for i = 1:num_packages
+      cur_name = installed_pkgs_lst{i}.name;
+      cur_version = installed_pkgs_lst{i}.version;
+      cur_dir = installed_pkgs_lst{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 = ["..." cur_dir((first_char + first_filesep(1) - 1):end)];
+        else
+          cur_dir = ["..." cur_dir(first_char:end)];
+        endif
+      endif
+      if (installed_pkgs_lst{i}.loaded)
+        cur_loaded = "*";
       else
-        cur_dir = ["..." cur_dir(first_char:end)];
+        cur_loaded = " ";
       endif
-    endif
-    if (installed_pkgs_lst{i}.loaded)
-      cur_loaded = "*";
-    else
-      cur_loaded = " ";
-    endif
-    printf (format, cur_name, cur_loaded, cur_version, cur_dir);
-  endfor
-
+      printf (format, cur_name, cur_loaded, cur_version, cur_dir);
+    endfor
+  endif
 endfunction
-
--- a/scripts/plot/appearance/annotation.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/appearance/annotation.m	Thu Dec 10 12:50:06 2015 -0800
@@ -100,7 +100,7 @@
 ## @item @qcode{"textarrow"}
 ## Construct an arrow with a text label at the opposite end from the arrowhead.
 ##
-## Use the "string" property to change the text string.
+## Use the @qcode{"string"} property to change the text string.
 ## The line and the arrowhead can be customized as for arrow annotations, and
 ## the text can be customized using the same properties as @code{text} graphics
 ## objects.  Note, however, that some text property names are prefixed with
@@ -113,7 +113,7 @@
 ## Construct a box with text inside.  @var{pos} specifies the
 ## @qcode{"position"} property of the annotation.
 ##
-## Use the "string" property to change the text string.
+## Use the @qcode{"string"} property to change the text string.
 ## You may use @qcode{"backgroundcolor"}, @qcode{"edgecolor"},
 ## @qcode{"linestyle"}, and @qcode{"linewidth"} properties to customize
 ## the box background color and edge appearance.  A limited set of @code{text}
@@ -161,7 +161,7 @@
   if (isfigure (varargin{1}))
     hf = varargin{1};
     varargin = varargin(2:end);
-    nargin --;
+    nargin -= 1;
   endif
 
   ## Annotation type
@@ -170,7 +170,7 @@
   if (ischar (varargin{1}))
     objtype = varargin{1};
     varargin(1) = [];
-    nargin --;
+    nargin -= 1;
   else
     print_usage ();
   endif
@@ -189,7 +189,7 @@
             && length (x) == 2 && length (y) == 2)
           lims = [x(1) y(1) diff(x) diff(y)];
         else
-          error ("annotation: expect 2 elements vectors for X and Y");
+          error ("annotation: X and Y must be 2-element vectors");
         endif
       else
         print_usage ();
@@ -202,11 +202,11 @@
         varargin(1) = [];
 
         if (! isvector (lims) || length (lims) != 4)
-          error ("annotation: expect 4 elements vector for POS")
+          error ("annotation: POS must be a 4-element vector");
         endif
       endif
     otherwise
-      error ("annotation: unknown annotation type %s", objtype)
+      error ("annotation: unknown annotation type %s", objtype);
   endswitch
 
   ## options
@@ -938,7 +938,7 @@
     headstyle = get (h, "head2style");
     pos = pos(1:2) .+ pos(3:4);
   else
-    error ("annotation: %d, no such arrow number")
+    error ("annotation: %d, no such arrow number");
   endif
 
   switch (headstyle)
@@ -968,7 +968,7 @@
       x = [0 0 0];
       y = [0 0 0];
     otherwise
-      error ("annotation: \"%s\" headstyle not implemented", headstyle)
+      error ("annotation: \"%s\" headstyle not implemented", headstyle);
   endswitch
 
   R = [cos(ang) -sin(ang);
@@ -1098,7 +1098,7 @@
   ## the vertical alignment of the arrow.
 
   ang = angle (complex (pos(3), pos(4)));
-  rot = rot / 180 * pi;
+  rot *= pi / 180;
 
   [~, pt] = min (abs ((-pi:pi/4:pi) - ang));
   pt -= floor (rot / (pi/4));
@@ -1489,5 +1489,6 @@
 %!error annotation ([], "foo")
 %!error annotation ({})
 %!error annotation ("line", [.5 .6])
-%!error <expect 2 elements vectors for X and Y> annotation ("line", 1:3, 1:3)
-%!error <expect 4 elements vector for POS> annotation ("textbox", 1:3)
+%!error <X and Y must be 2-element vectors> annotation ("line", 1:3, 1:3)
+%!error <POS must be a 4-element vector> annotation ("textbox", 1:3)
+
--- a/scripts/plot/appearance/axis.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/appearance/axis.m	Thu Dec 10 12:50:06 2015 -0800
@@ -279,7 +279,7 @@
       endif
 
     else
-      warning ("unknown axis option '%s'", ax);
+      warning ("axis: unknown option '%s'", ax);
     endif
 
   elseif (isvector (ax))
@@ -287,12 +287,12 @@
     len = length (ax);
 
     if (len != 2 && len != 4 && len != 6)
-      error ("axis: expecting vector with 2, 4, or 6 elements");
+      error ("axis: LIMITS vector must have 2, 4, or 6 elements");
     endif
 
     for i = 1:2:len
       if (ax(i) >= ax(i+1))
-        error ("axis: limits(%d) must be less than limits(%d)", i, i+1);
+        error ("axis: LIMITS(%d) must be less than LIMITS(%d)", i, i+1);
       endif
     endfor
 
@@ -322,19 +322,19 @@
 
   ## Get the limits for axis ("tight").
   ## AX should be one of "x", "y", or "z".
-  kids = findobj (ca, "-property", strcat (ax, "data"));
+  kids = findobj (ca, "-property", [ax "data"]);
   ## The data properties for hggroups mirror their children.
   ## Exclude the redundant hgroup values.
   hg_kids = findobj (kids, "type", "hggroup");
   kids = setdiff (kids, hg_kids);
   if (isempty (kids))
     ## Return the current limits.
-    lims = get (ca, strcat (ax, "lim"));
+    lims = get (ca, [ax "lim"]);
   else
-    data = get (kids, strcat (ax, "data"));
+    data = get (kids, [ax "data"]);
     types = get (kids, "type");
 
-    scale = get (ca, strcat (ax, "scale"));
+    scale = get (ca, [ax "scale"]);
     if (! iscell (data))
       data = {data};
     endif
@@ -375,13 +375,13 @@
   if (all (xlim == 0))
     xlim = eps () * [-1 1];
   elseif (diff (xlim == 0))
-    xlim = xlim .* (1 + eps () * [-1, 1]);
+    xlim .*= (1 + eps () * [-1, 1]);
   endif
   ylim = __get_tight_lims__ (ca, "y");
   if (all (ylim == 0))
     ylim = eps () * [-1 1];
   elseif (diff (ylim == 0))
-    ylim = ylim .* (1 + eps () * [-1, 1]);
+    ylim .*= (1 + eps () * [-1, 1]);
   endif
   set (ca, "xlim", xlim, "ylim", ylim)
   nd = __calc_dimensions__ (ca);
@@ -391,7 +391,7 @@
     if (all (zlim == 0))
       zlim = eps () * [-1 1];
     elseif (diff (zlim == 0))
-      zlim = zlim .* (1 + eps () * [-1, 1]);
+      zlim .*= (1 + eps () * [-1, 1]);
     endif
     set (ca, "zlim", zlim);
   endif
--- a/scripts/plot/appearance/caxis.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/appearance/caxis.m	Thu Dec 10 12:50:06 2015 -0800
@@ -80,7 +80,7 @@
   elseif (isvector (ax))
     len = length (ax);
     if (len != 2)
-      error ("caxis: expecting vector with 2 elements");
+      error ("caxis: LIMITS must be a 2-element vector");
     endif
 
     set (ca, "clim", [ax(1), ax(2)]);
--- a/scripts/plot/appearance/datetick.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/appearance/datetick.m	Thu Dec 10 12:50:06 2015 -0800
@@ -132,10 +132,10 @@
   if (! isempty (form))
     if (isnumeric (form))
       if (! isscalar (form) || form < 0 || form != fix (form))
-        error ("datetick: expecting FORM argument to be a positive integer");
+        error ("datetick: FORM argument must be a positive integer");
       endif
     elseif (! ischar (form))
-      error ("datetick: expecting valid date format string");
+      error ("datetick: FORM argument must be a valid date format string");
     endif
   endif
 
--- a/scripts/plot/appearance/hidden.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/appearance/hidden.m	Thu Dec 10 12:50:06 2015 -0800
@@ -45,7 +45,7 @@
     print_usage ();
   elseif (nargin == 1)
     if (! ischar (mode))
-      error ("hidden: expecting MODE to be a string");
+      error ("hidden: MODE must be a string");
     elseif (! any (strcmpi (mode, {"on", "off"})))
       error ('hidden: MODE must be "on" or "off"');
     endif
--- a/scripts/plot/appearance/legend.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/appearance/legend.m	Thu Dec 10 12:50:06 2015 -0800
@@ -195,7 +195,7 @@
       if (pos >= -1 && pos <= 4)
         location = [{"northeastoutside", "best", "northeast",
                      "northwest", "southwest", "southeast"}] {pos + 2};
-        nargs--;
+        nargs -= 1;
       else
         error ("legend: invalid location specified");
       endif
@@ -255,7 +255,7 @@
             delete_leg = true;
           case "hide"
             show = "off";
-            nargs--;
+            nargs -= 1;
           case "show"
             if (! isempty (hlegend))
               show = "on";
@@ -263,7 +263,7 @@
               show = "create";
               textpos = "right";
             endif
-            nargs--;
+            nargs -= 1;
           case "toggle"
             if (isempty (hlegend))
               show = "create";
@@ -273,19 +273,19 @@
             else
               show = "off";
             endif
-            nargs--;
+            nargs -= 1;
           case "boxon"
             box = "on";
-            nargs--;
+            nargs -= 1;
           case "boxoff"
             box = "off";
-            nargs--;
+            nargs -= 1;
           case "left"
             textpos = "left";
-            nargs--;
+            nargs -= 1;
           case "right"
             textpos = "right";
-            nargs--;
+            nargs -= 1;
         endswitch
       else
         ## Character matrix of labels
@@ -297,7 +297,7 @@
       varargin = arg;
       nargs = numel (varargin);
     else
-      error ("legend: expecting argument to be a character string");
+      error ("legend: single argument must be a string or cellstr");
     endif
   elseif (nargs > 1 && iscellstr (varargin{1}))
     ## Cell array of labels followed by property/value pairs
@@ -451,7 +451,7 @@
             break;  # k = 0, no further handles to process
           endif
         else
-          error ("legend: expecting argument to be a character string");
+          error ("legend: expecting argument to be a string");
         endif
       endfor
       if (have_labels && i < nargs)
@@ -586,8 +586,7 @@
                           "xtick", [], "ytick", [],
                           "xlim", [0, 1], "ylim", [0, 1],
                           "visible", ifelse (strcmp (box, "on"), "on", "off"),
-                          "activepositionproperty", "position",
-                          "interpreter", "tex");
+                          "activepositionproperty", "position");
           ## Inherit properties from current axis
           ## "fontunits" shoud be first because it affects interpretation
           ## of "fontsize" property
@@ -595,10 +594,13 @@
                       "fontweight"};
           ca_props = get (ca(1), proplist);
           set (hlegend, proplist, ca_props);
+          old_hplots = [];
         else
           addprops = false;
           axes (hlegend);
           delete (get (hlegend, "children"));
+          ## Hack, to get list of hplots for which addlistener has already been called.
+          old_hplots = [ get(hlegend, "deletefcn"){6:end} ];
         endif
         if (addprops)
           addproperty ("edgecolor", hlegend, "color", [0, 0, 0]);
@@ -613,6 +615,7 @@
           addproperty ("orientation", hlegend, "radio",
                        "{vertical}|horizontal");
           addproperty ("string", hlegend, "any", text_strings);
+          addproperty ("interpreter", hlegend, "textinterpreter");
           addproperty ("textposition", hlegend, "radio", "left|{right}");
         endif
         ## Inherit visual properties from legend object
@@ -715,7 +718,7 @@
           ## This implies that a change in fontsize should trigger a listener
           ## to update the legend.  The "2" was determined using a long legend
           ## key in the absence of any subplots.
-          gnuplot_offset = gnuplot_offset - 2 * fontsize;
+          gnuplot_offset -= 2 * fontsize;
         else
           gnuplot_offset = 0;
         endif
@@ -859,7 +862,7 @@
                 hobjects(end+1) = l1;
               endif
 
-              if (addprops)
+              if (! any (hplots(k) == old_hplots))
                 addlistener (hplots(k), "color",
                              {@updateline, hlegend, linelength, false});
                 addlistener (hplots(k), "linestyle",
@@ -928,16 +931,16 @@
                               [(txoffset + xk * xstep) / lpos(3), ...
                                (lpos(4) - yoffset - yk * ystep) / lpos(4)]);
           if (strcmp (orientation, "vertical"))
-            yk++;
+            yk += 1;
             if (yk > num1)
               yk = 0;
-              xk++;
+              xk += 1;
             endif
           else
-            xk++;
+            xk += 1;
             if (xk > num1)
               xk = 0;
-              yk++;
+              yk += 1;
             endif
           endif
         endfor
@@ -1090,7 +1093,7 @@
           set (hax, "position", position);
           set (hax, "outerposition", outerposition);
       endswitch
-      set (hax, {"units"}, units);
+      set (hax, "units", units);
 
       h = legend (hax(1), hplots, get (h, "string"));
     unwind_protect_cleanup
@@ -1254,7 +1257,7 @@
 %!demo
 %! clf;
 %! plot (rand (3));
-%! title ('legend("show") without inputs creates default labels');
+%! title ('legend ("show") without inputs creates default labels');
 %! h = legend ('show');
 
 %!demo
@@ -1343,12 +1346,6 @@
 
 %!demo
 %! clf;
-%! plot (1:10, 1:10);
-%! title ('a very long label can sometimes cause problems');
-%! legend ('hello very big world', 'location', 'northeastoutside');
-
-%!demo
-%! clf;
 %! labels = {};
 %! colororder = get (gca, 'colororder');
 %! for i = 1:5
@@ -1396,6 +1393,13 @@
 
 %!demo
 %! clf;
+%! colormap (cool (64));
+%! surf (peaks ());
+%! legend ('peaks()')
+%! title ('legend() works for surface objects too');
+
+%!demo
+%! clf reset;  % needed to undo colormap assignment in previous demo
 %! rand_2x3_data2 = [0.44804, 0.84368, 0.23012; 0.72311, 0.58335, 0.90531];
 %! bar (rand_2x3_data2);
 %! ylim ([0 1.2]);
@@ -1455,6 +1459,7 @@
 %! subplot (2,2,4);
 %!  plot (x, rand (numel (x)));
 %!  legend (cellstr (num2str (x)), 'location', 'southeastoutside');
+%! %% Legend works on a per axes basis for each subplot
 
 %!demo
 %! clf;
@@ -1489,6 +1494,12 @@
 %! title ('plotyy legend test #3: Blue and Green labels');
 %! legend ('Blue', 'Green', 'location', 'south');
 
+%!demo
+%! clf;
+%! plot (1:10, 1:10);
+%! title ('a very long label can sometimes cause problems');
+%! legend ('hello very big world', 'location', 'northeastoutside');
+
 %!demo % bug 36408
 %! clf;
 %! option = 'right';
@@ -1496,7 +1507,7 @@
 %!  plot (rand (1,4));
 %!  xlabel xlabel;
 %!  ylabel ylabel;
-%!  title ('Subplots should adjust to the legend placed outside');
+%!  title ('Subplots adjust to the legend placed outside');
 %!  legend ({'1'}, 'location', 'northeastoutside');
 %!  legend (option);
 %! subplot (3,1,2);
@@ -1517,7 +1528,7 @@
 %! option = 'right';
 %! subplot (3,1,1);
 %!  plot (rand (1,4));
-%!  title ('Subplots should adjust to the legend placed outside');
+%!  title ('Subplots adjust to the legend placed outside');
 %!  legend ({'1'}, 'location', 'northwestoutside');
 %!  legend (option);
 %! subplot (3,1,2);
@@ -1537,7 +1548,7 @@
 %!  set (gca (), 'yaxislocation', 'right');
 %!  xlabel ('xlabel');
 %!  ylabel ('ylabel');
-%!  title ('Subplots should adjust to the legend placed outside');
+%!  title ('Subplots adjust to the legend placed outside');
 %!  legend ({'1'}, 'location', 'northeastoutside');
 %!  legend (option);
 %! subplot (3,1,2);
@@ -1563,7 +1574,7 @@
 %!  set (gca (), 'yaxislocation', 'right');
 %!  xlabel ('xlabel');
 %!  ylabel ('ylabel');
-%!  title ('Subplots should adjust to the legend placed outside');
+%!  title ('Subplots adjust to the legend placed outside');
 %!  legend ({'1'}, 'location', 'northwestoutside');
 %!  legend (option);
 %! subplot (3,1,2);
@@ -1589,7 +1600,7 @@
 %!  set (gca (), 'xaxislocation', 'top');
 %!  xlabel ('xlabel');
 %!  ylabel ('ylabel');
-%!  title ('Subplots should adjust to the legend placed outside');
+%!  title ('Subplots adjust to the legend placed outside');
 %!  legend ({'1'}, 'location', 'northwestoutside');
 %!  legend (option);
 %! subplot (3,1,2);
@@ -1611,14 +1622,7 @@
 %! clf;
 %! plot (1:10);
 %! legend ('Legend Text');
-%! title ({'Multi-line', 'titles', 'are a', 'problem'});
-
-%!demo
-%! clf;
-%! colormap (cool (64));
-%! surf (peaks ());
-%! legend ('peaks()')
-%! title ('legend() works for surface objects too');
+%! title ({'Multi-line', 'titles', 'are a', 'problem', 'See bug #39697'});
 
 %!test
 %! toolkit = graphics_toolkit ("gnuplot");
--- a/scripts/plot/appearance/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/appearance/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,43 +1,54 @@
-FCN_FILE_DIRS += plot/appearance
+FCN_FILE_DIRS += \
+  scripts/plot/appearance \
+  scripts/plot/appearance/private
 
-plot_appearance_PRIVATE_FCN_FILES = \
-  plot/appearance/private/__axis_limits__.m \
-  plot/appearance/private/__axis_label__.m
+scripts_plot_appearance_PRIVATE_FCN_FILES = \
+  scripts/plot/appearance/private/__axis_limits__.m \
+  scripts/plot/appearance/private/__axis_label__.m
 
-plot_appearance_FCN_FILES = \
-  plot/appearance/__clabel__.m \
-  plot/appearance/__getlegenddata__.m \
-  plot/appearance/annotation.m \
-  plot/appearance/axis.m \
-  plot/appearance/box.m \
-  plot/appearance/caxis.m \
-  plot/appearance/clabel.m \
-  plot/appearance/daspect.m \
-  plot/appearance/datetick.m \
-  plot/appearance/diffuse.m \
-  plot/appearance/grid.m \
-  plot/appearance/gtext.m \
-  plot/appearance/hidden.m \
-  plot/appearance/legend.m \
-  plot/appearance/orient.m \
-  plot/appearance/pbaspect.m \
-  plot/appearance/shading.m \
-  plot/appearance/specular.m \
-  plot/appearance/text.m \
-  plot/appearance/title.m \
-  plot/appearance/view.m \
-  plot/appearance/whitebg.m \
-  plot/appearance/xlabel.m \
-  plot/appearance/xlim.m \
-  plot/appearance/ylabel.m \
-  plot/appearance/ylim.m \
-  plot/appearance/zlabel.m \
-  plot/appearance/zlim.m \
-  $(plot_appearance_PRIVATE_FCN_FILES)
+scripts_plot_appearance_FCN_FILES = \
+  scripts/plot/appearance/__clabel__.m \
+  scripts/plot/appearance/__getlegenddata__.m \
+  scripts/plot/appearance/annotation.m \
+  scripts/plot/appearance/axis.m \
+  scripts/plot/appearance/box.m \
+  scripts/plot/appearance/caxis.m \
+  scripts/plot/appearance/clabel.m \
+  scripts/plot/appearance/daspect.m \
+  scripts/plot/appearance/datetick.m \
+  scripts/plot/appearance/diffuse.m \
+  scripts/plot/appearance/grid.m \
+  scripts/plot/appearance/gtext.m \
+  scripts/plot/appearance/hidden.m \
+  scripts/plot/appearance/legend.m \
+  scripts/plot/appearance/orient.m \
+  scripts/plot/appearance/pbaspect.m \
+  scripts/plot/appearance/shading.m \
+  scripts/plot/appearance/specular.m \
+  scripts/plot/appearance/text.m \
+  scripts/plot/appearance/title.m \
+  scripts/plot/appearance/view.m \
+  scripts/plot/appearance/whitebg.m \
+  scripts/plot/appearance/xlabel.m \
+  scripts/plot/appearance/xlim.m \
+  scripts/plot/appearance/ylabel.m \
+  scripts/plot/appearance/ylim.m \
+  scripts/plot/appearance/zlabel.m \
+  scripts/plot/appearance/zlim.m
 
-FCN_FILES += $(plot_appearance_FCN_FILES)
+scripts_plot_appearancedir = $(fcnfiledir)/plot/appearance
+
+scripts_plot_appearance_DATA = $(scripts_plot_appearance_FCN_FILES)
+
+scripts_plot_appearance_privatedir = $(fcnfiledir)/plot/appearance/private
+
+scripts_plot_appearance_private_DATA = $(scripts_plot_appearance_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += plot/appearance/PKG_ADD
+FCN_FILES += \
+  $(scripts_plot_appearance_FCN_FILES) \
+  $(scripts_plot_appearance_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += plot/appearance/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/plot/appearance/PKG_ADD
 
+DIRSTAMP_FILES += scripts/plot/appearance/$(octave_dirstamp)
+
--- a/scripts/plot/appearance/orient.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/appearance/orient.m	Thu Dec 10 12:50:06 2015 -0800
@@ -54,7 +54,7 @@
   if (nargs > 0 && numel (varargin{1}) == 1 && isfigure (varargin{1}))
     cf = varargin{1};
     varargin(1) = [];
-    nargs--;
+    nargs -= 1;
   else
     cf = gcf ();
   endif
--- a/scripts/plot/appearance/specular.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/appearance/specular.m	Thu Dec 10 12:50:06 2015 -0800
@@ -88,7 +88,7 @@
 
   ## Allow postive values only
   retval(retval < 0) = 0;
-  retval = retval .^ se;
+  retval .^= se;
 
 endfunction
 
--- a/scripts/plot/appearance/text.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/appearance/text.m	Thu Dec 10 12:50:06 2015 -0800
@@ -97,13 +97,13 @@
       nt = numel (string);
       if (nx == 1)
         ## Single text object with one or more lines
-        string = {string};
+        string = {cellstr(string)};
         nt = 1;
       elseif (nx > 1 && nt == nx)
         ## Mutiple text objects with different strings
       else
         ## Mutiple text objects with same string
-        string = repmat ({string}, [nx, 1]);
+        string = repmat ({cellstr(string)}, [nx, 1]);
         nt = nx;
       endif
 
@@ -271,13 +271,13 @@
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   ## Single object with one line
-%!   h = text (0.5, 0.3, "single object with one line");
+%!   h = text (0.5, 0.5, "single object with one line");
 %!   obs = get (h, "string");
 %!   assert (class (obs), "char");
 %!   assert (obs, "single object with one line");
 %!
 %!   ## Single object with multiple lines
-%!   h = text (0.5, 0.4, ["char row 1"; "char row 2"]);
+%!   h = text (0.5, 0.3, ["char row 1"; "char row 2"]);
 %!   obs = get (h, "string");
 %!   assert (class (obs), "char");
 %!   assert (obs, ["char row 1"; "char row 2"]);
@@ -290,39 +290,52 @@
 %!   assert (get (h(2), "string"), "two objects with same string");
 %!
 %!   ## Multiple objects with multiple lines
-%!   h = text ([0.1, 0.1], [0.3, 0.4], ["string1"; "string2"]);
+%!   h = text ([0.7, 0.7], [0.3, 0.4], ["string1"; "string2"]);
 %!   assert (class (get (h(1), "string")), "char");
 %!   assert (class (get (h(2), "string")), "char");
 %!   assert (get (h(1), "string"), "string1");
 %!   assert (get (h(2), "string"), "string2");
 %!
 %!   ### Tests repeated with cell input ###
+%!   clf;
 %!
 %!   ## Single object with one line
-%!   h = text (0.5, 0.3, {"single object with one line"});
+%!   h = text (0.5, 0.5, {"single object with one line"});
 %!   obs = get (h, "string");
 %!   assert (class (obs), "cell");
 %!   assert (obs, {"single object with one line"});
 %!
 %!   ## Single object with multiple lines
-%!   h = text (0.5, 0.6, {"cell2str (1,1)", "cell2str (1,2)";
+%!   h = text (0.5, 0.3, {"cell2str (1,1)", "cell2str (1,2)";
 %!                        "cell2str (2,1)", "cell2str (2,2)"});
 %!   obs = get (h, "string");
 %!   assert (class (obs), "cell");
 %!   assert (obs, {"cell2str (1,1)"; "cell2str (2,1)";
 %!                 "cell2str (1,2)"; "cell2str (2,2)"});
 %!
+%!   ## Single object with multiple lines including empty cell
+%!   h = text (0.5, 0.9, {"Line1"; []; "Line3"});
+%!   obs = get (h, "string");
+%!   assert (class (obs), "cell");
+%!   assert (obs, {"Line1"; ""; "Line3"});
+%!
 %!   ## Multiple objects with single line
 %!   h = text ([0.1, 0.1], [0.5, 0.6], {"two objects with same cellstr"});
 %!   assert (class (get (h(1), "string")), "cell");
 %!   assert (class (get (h(2), "string")), "cell");
-%!   ## FIXME: is return value of cellstr, rather than string, Matlab-verified?
 %!   assert (get (h(1), "string"), {"two objects with same cellstr"});
 %!   assert (get (h(2), "string"), {"two objects with same cellstr"});
 %!
+%!   ## Multiple objects with same multi-line string which has empty cell
+%!   ## NOTE: Matlab does not support this syntax
+%!   h = text ([0.7, 0.7], [0.3 0.5], {"Line1"; []; "Line3"});
+%!   assert (class (get (h(1), "string")), "cell");
+%!   assert (class (get (h(2), "string")), "cell");
+%!   assert (get (h(1), "string"), {"Line1"; ""; "Line3"});
+%!   assert (get (h(2), "string"), {"Line1"; ""; "Line3"});
+%!
 %!   ## Multiple objects with multiple lines
 %!   h = text ([0.1, 0.1], [0.7, 0.8], {"cellstr1", "cellstr2"});
-%!   ## FIXME: is return value really char in Matlab?
 %!   assert (class (get (h(1), "string")), "char");
 %!   assert (class (get (h(2), "string")), "char");
 %!   assert (get (h(1), "string"), "cellstr1");
--- a/scripts/plot/appearance/whitebg.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/appearance/whitebg.m	Thu Dec 10 12:50:06 2015 -0800
@@ -65,7 +65,7 @@
     isroot = false;
     fig = h;
   else
-    error ("expecting a figure handle");
+    error ("whitebg: HFIF must be a valid figure handle");
   endif
 
   axes = findall (fig, "type", "axes");
--- a/scripts/plot/draw/colorbar.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/colorbar.m	Thu Dec 10 12:50:06 2015 -0800
@@ -109,7 +109,7 @@
           else
             ax = varargin{i++};
             if (! isscalar (ax) && ! isaxes (ax))
-              error ('colorbar: expecting an axes handle following "peer"');
+              error ('colorbar: invalid axes handle following "peer"');
             endif
           endif
         case {"north", "south", "east", "west",
@@ -398,48 +398,48 @@
   switch (cbox)
     case "northoutside"
       origin = pos(1:2) + [0., 0.9] .* sz + [1, -1] .* off;
-      sz = sz .* [1.0, 0.06];
+      sz .*= [1.0, 0.06];
       pos(4) = 0.8 * pos(4);
       mirr = true;
       vertical = false;
     case "north"
       origin = pos(1:2) + [0.05, 0.9] .* sz + [1, -1] .* off;
-      sz = sz .* [1.0, 0.06] * 0.9;
+      sz .*= [1.0, 0.06] * 0.9;
       mirr = false;
       vertical = false;
     case "southoutside"
       origin = pos(1:2) + off;
-      sz = sz .* [1.0, 0.06];
+      sz .*= [1.0, 0.06];
       pos(2) = pos(2) + pos(4) * 0.2;
       pos(4) = 0.8 * pos(4);
       mirr = false;
       vertical = false;
     case "south"
       origin = pos(1:2) + [0.05, 0.05] .* sz + off;
-      sz = sz .* [1.0, 0.06] * 0.9;
+      sz .*= [1.0, 0.06] * 0.9;
       mirr = true;
       vertical = false;
     case "eastoutside"
       origin = pos(1:2) + [0.9, 0] .* sz + [-1, 1] .* off;
-      sz = sz .* [0.06, 1.0];
+      sz .*= [0.06, 1.0];
       pos(3) = 0.8 * pos(3);
       mirr = true;
       vertical = true;
     case "east"
       origin = pos(1:2) + [0.9, 0.05] .* sz + [-1, 1] .* off;
-      sz = sz .* [0.06, 1.0] * 0.9;
+      sz .*= [0.06, 1.0] * 0.9;
       mirr = false;
       vertical = true;
     case "westoutside"
       origin = pos(1:2) + off;
-      sz = sz .* [0.06, 1.0];
+      sz .*= [0.06, 1.0];
       pos(1) = pos(1) + pos(3) * 0.2;
       pos(3) = 0.8 * pos(3);
       mirr = false;
       vertical = true;
     case "west"
       origin = pos(1:2) + [0.05, 0.05] .* sz + off;
-      sz = sz .* [0.06, 1.0] .* 0.9;
+      sz .*= [0.06, 1.0] .* 0.9;
       mirr = true;
       vertical = true;
   endswitch
--- a/scripts/plot/draw/errorbar.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/errorbar.m	Thu Dec 10 12:50:06 2015 -0800
@@ -178,7 +178,7 @@
   unwind_protect
     hax = newplot (hax);
 
-    htmp = __errcomm__ ("errorbar", hax, varargin{:});
+    htmp = __errplot__ ("errorbar", hax, varargin{:});
   unwind_protect_cleanup
     if (! isempty (oldfig))
       set (0, "currentfigure", oldfig);
--- a/scripts/plot/draw/fplot.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/fplot.m	Thu Dec 10 12:50:06 2015 -0800
@@ -70,7 +70,7 @@
 ## Consider this when writing user-defined functions and use @code{.*},
 ## @code{./}, etc.  See the function @code{vectorize} for potentially
 ## converting inline or anonymous functions to vectorized versions.
-##  
+##
 ## @seealso{ezplot, plot, vectorize}
 ## @end deftypefn
 
--- a/scripts/plot/draw/hist.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/hist.m	Thu Dec 10 12:50:06 2015 -0800
@@ -101,7 +101,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 = (max_val - min_val) * x + min_val * ones (size (x));
   else
     ## nargin is either 2 or 3
     x = varargin{iarg++};
@@ -111,7 +111,7 @@
         error ("hist: number of bins NBINS must be positive");
       endif
       x = [0.5:n]'/n;
-      x = x * (max_val - min_val) + ones (size (x)) * min_val;
+      x = (max_val - min_val) * x  + min_val * ones (size (x));
     elseif (isreal (x))
       if (isvector (x))
         x = x(:);
--- a/scripts/plot/draw/loglogerr.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/loglogerr.m	Thu Dec 10 12:50:06 2015 -0800
@@ -66,7 +66,7 @@
     if (! ishold (hax))
       set (hax, "xminortick", "on", "yminortick", "on");
     endif
-    htmp = __errcomm__ ("loglogerr", hax, varargin{:});
+    htmp = __errplot__ ("loglogerr", hax, varargin{:});
 
   unwind_protect_cleanup
     if (! isempty (oldfig))
--- a/scripts/plot/draw/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,104 +1,114 @@
-FCN_FILE_DIRS += plot/draw
+FCN_FILE_DIRS += \
+  scripts/plot/draw \
+  scripts/plot/draw/private
 
-plot_draw_PRIVATE_FCN_FILES = \
-  plot/draw/private/__add_datasource__.m \
-  plot/draw/private/__bar__.m \
-  plot/draw/private/__contour__.m \
-  plot/draw/private/__errcomm__.m \
-  plot/draw/private/__errplot__.m \
-  plot/draw/private/__ezplot__.m \
-  plot/draw/private/__interp_cube__.m \
-  plot/draw/private/__line__.m \
-  plot/draw/private/__marching_cube__.m \
-  plot/draw/private/__patch__.m \
-  plot/draw/private/__pie__.m \
-  plot/draw/private/__plt__.m \
-  plot/draw/private/__quiver__.m \
-  plot/draw/private/__scatter__.m \
-  plot/draw/private/__stem__.m
+scripts_plot_draw_PRIVATE_FCN_FILES = \
+  scripts/plot/draw/private/__add_datasource__.m \
+  scripts/plot/draw/private/__bar__.m \
+  scripts/plot/draw/private/__contour__.m \
+  scripts/plot/draw/private/__errplot__.m \
+  scripts/plot/draw/private/__ezplot__.m \
+  scripts/plot/draw/private/__interp_cube__.m \
+  scripts/plot/draw/private/__line__.m \
+  scripts/plot/draw/private/__marching_cube__.m \
+  scripts/plot/draw/private/__patch__.m \
+  scripts/plot/draw/private/__pie__.m \
+  scripts/plot/draw/private/__plt__.m \
+  scripts/plot/draw/private/__quiver__.m \
+  scripts/plot/draw/private/__scatter__.m \
+  scripts/plot/draw/private/__stem__.m
 
-plot_draw_FCN_FILES = \
-  plot/draw/area.m \
-  plot/draw/barh.m \
-  plot/draw/bar.m \
-  plot/draw/colorbar.m \
-  plot/draw/comet3.m \
-  plot/draw/comet.m \
-  plot/draw/compass.m \
-  plot/draw/contour3.m \
-  plot/draw/contourc.m \
-  plot/draw/contourf.m \
-  plot/draw/contour.m \
-  plot/draw/cylinder.m \
-  plot/draw/ellipsoid.m \
-  plot/draw/errorbar.m \
-  plot/draw/ezcontourf.m \
-  plot/draw/ezcontour.m \
-  plot/draw/ezmeshc.m \
-  plot/draw/ezmesh.m \
-  plot/draw/ezplot3.m \
-  plot/draw/ezplot.m \
-  plot/draw/ezpolar.m \
-  plot/draw/ezsurfc.m \
-  plot/draw/ezsurf.m \
-  plot/draw/feather.m \
-  plot/draw/fill.m \
-  plot/draw/fplot.m \
-  plot/draw/hist.m \
-  plot/draw/isocolors.m \
-  plot/draw/isonormals.m \
-  plot/draw/isosurface.m \
-  plot/draw/line.m \
-  plot/draw/loglogerr.m \
-  plot/draw/loglog.m \
-  plot/draw/meshc.m \
-  plot/draw/mesh.m \
-  plot/draw/meshz.m \
-  plot/draw/pareto.m \
-  plot/draw/patch.m \
-  plot/draw/pcolor.m \
-  plot/draw/peaks.m \
-  plot/draw/pie3.m \
-  plot/draw/pie.m \
-  plot/draw/plot3.m \
-  plot/draw/plot.m \
-  plot/draw/plotmatrix.m \
-  plot/draw/plotyy.m \
-  plot/draw/polar.m \
-  plot/draw/quiver3.m \
-  plot/draw/quiver.m \
-  plot/draw/rectangle.m \
-  plot/draw/ribbon.m \
-  plot/draw/rose.m \
-  plot/draw/scatter3.m \
-  plot/draw/scatter.m \
-  plot/draw/semilogxerr.m \
-  plot/draw/semilogx.m \
-  plot/draw/semilogyerr.m \
-  plot/draw/semilogy.m \
-  plot/draw/shrinkfaces.m \
-  plot/draw/slice.m \
-  plot/draw/sombrero.m \
-  plot/draw/sphere.m \
-  plot/draw/stairs.m \
-  plot/draw/stem3.m \
-  plot/draw/stemleaf.m \
-  plot/draw/stem.m \
-  plot/draw/surface.m \
-  plot/draw/surfc.m \
-  plot/draw/surfl.m \
-  plot/draw/surf.m \
-  plot/draw/surfnorm.m \
-  plot/draw/tetramesh.m \
-  plot/draw/trimesh.m \
-  plot/draw/triplot.m \
-  plot/draw/trisurf.m \
-  plot/draw/waterfall.m \
-  $(plot_draw_PRIVATE_FCN_FILES)
+scripts_plot_draw_FCN_FILES = \
+  scripts/plot/draw/area.m \
+  scripts/plot/draw/barh.m \
+  scripts/plot/draw/bar.m \
+  scripts/plot/draw/colorbar.m \
+  scripts/plot/draw/comet3.m \
+  scripts/plot/draw/comet.m \
+  scripts/plot/draw/compass.m \
+  scripts/plot/draw/contour3.m \
+  scripts/plot/draw/contourc.m \
+  scripts/plot/draw/contourf.m \
+  scripts/plot/draw/contour.m \
+  scripts/plot/draw/cylinder.m \
+  scripts/plot/draw/ellipsoid.m \
+  scripts/plot/draw/errorbar.m \
+  scripts/plot/draw/ezcontourf.m \
+  scripts/plot/draw/ezcontour.m \
+  scripts/plot/draw/ezmeshc.m \
+  scripts/plot/draw/ezmesh.m \
+  scripts/plot/draw/ezplot3.m \
+  scripts/plot/draw/ezplot.m \
+  scripts/plot/draw/ezpolar.m \
+  scripts/plot/draw/ezsurfc.m \
+  scripts/plot/draw/ezsurf.m \
+  scripts/plot/draw/feather.m \
+  scripts/plot/draw/fill.m \
+  scripts/plot/draw/fplot.m \
+  scripts/plot/draw/hist.m \
+  scripts/plot/draw/isocolors.m \
+  scripts/plot/draw/isonormals.m \
+  scripts/plot/draw/isosurface.m \
+  scripts/plot/draw/line.m \
+  scripts/plot/draw/loglogerr.m \
+  scripts/plot/draw/loglog.m \
+  scripts/plot/draw/meshc.m \
+  scripts/plot/draw/mesh.m \
+  scripts/plot/draw/meshz.m \
+  scripts/plot/draw/pareto.m \
+  scripts/plot/draw/patch.m \
+  scripts/plot/draw/pcolor.m \
+  scripts/plot/draw/peaks.m \
+  scripts/plot/draw/pie3.m \
+  scripts/plot/draw/pie.m \
+  scripts/plot/draw/plot3.m \
+  scripts/plot/draw/plot.m \
+  scripts/plot/draw/plotmatrix.m \
+  scripts/plot/draw/plotyy.m \
+  scripts/plot/draw/polar.m \
+  scripts/plot/draw/quiver3.m \
+  scripts/plot/draw/quiver.m \
+  scripts/plot/draw/rectangle.m \
+  scripts/plot/draw/ribbon.m \
+  scripts/plot/draw/rose.m \
+  scripts/plot/draw/scatter3.m \
+  scripts/plot/draw/scatter.m \
+  scripts/plot/draw/semilogxerr.m \
+  scripts/plot/draw/semilogx.m \
+  scripts/plot/draw/semilogyerr.m \
+  scripts/plot/draw/semilogy.m \
+  scripts/plot/draw/shrinkfaces.m \
+  scripts/plot/draw/slice.m \
+  scripts/plot/draw/sombrero.m \
+  scripts/plot/draw/sphere.m \
+  scripts/plot/draw/stairs.m \
+  scripts/plot/draw/stem3.m \
+  scripts/plot/draw/stemleaf.m \
+  scripts/plot/draw/stem.m \
+  scripts/plot/draw/surface.m \
+  scripts/plot/draw/surfc.m \
+  scripts/plot/draw/surfl.m \
+  scripts/plot/draw/surf.m \
+  scripts/plot/draw/surfnorm.m \
+  scripts/plot/draw/tetramesh.m \
+  scripts/plot/draw/trimesh.m \
+  scripts/plot/draw/triplot.m \
+  scripts/plot/draw/trisurf.m \
+  scripts/plot/draw/waterfall.m
 
-FCN_FILES += $(plot_draw_FCN_FILES)
+scripts_plot_drawdir = $(fcnfiledir)/plot/draw
+
+scripts_plot_draw_DATA = $(scripts_plot_draw_FCN_FILES)
+
+scripts_plot_draw_privatedir = $(fcnfiledir)/plot/draw/private
+
+scripts_plot_draw_private_DATA = $(scripts_plot_draw_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += plot/draw/PKG_ADD
+FCN_FILES += \
+  $(scripts_plot_draw_FCN_FILES) \
+  $(scripts_plot_draw_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += plot/draw/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/plot/draw/PKG_ADD
 
+DIRSTAMP_FILES += scripts/plot/draw/$(octave_dirstamp)
+
--- a/scripts/plot/draw/plot.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/plot.m	Thu Dec 10 12:50:06 2015 -0800
@@ -99,8 +99,8 @@
 ## in pairs.  These arguments are applied to the line objects drawn by
 ## @code{plot}.  Useful properties to modify are @qcode{"linestyle"},
 ## @qcode{"linewidth"}, @qcode{"color"}, @qcode{"marker"},
-## @qcode{"markersize"}, @qcode{"markeredgecolor"}, @qcode{"markerfacecolor"}.  
-## @xref{Line Properties}.  
+## @qcode{"markersize"}, @qcode{"markeredgecolor"}, @qcode{"markerfacecolor"}.
+## @xref{Line Properties}.
 ##
 ## The @var{fmt} format argument can also be used to control the plot style.
 ## It is a string composed of four optional parts:
--- a/scripts/plot/draw/plotmatrix.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/plotmatrix.m	Thu Dec 10 12:50:06 2015 -0800
@@ -130,7 +130,8 @@
   have_line_spec = false;
   have_hist = false;
   parent = get (bigax, "parent");
-  for i = 1 : nargin - 1
+  narg = nargin ();
+  for i = 1 : narg - 1
     arg = varargin{i};
     if (ischar (arg) || iscellstr (arg))
       [linespec, valid] = __pltopt__ ("plotmatrix", varargin{i}, false);
@@ -138,7 +139,7 @@
         have_line_spec = true;
         linespec = varargin(i);
         varargin(i) = [];
-        nargin = nargin - 1;
+        narg -= 1;
         break;
       else
         print_usage ("plotmatrix");
@@ -146,11 +147,11 @@
     endif
   endfor
 
-  if (nargin == 2)
+  if (narg == 2)
     X = varargin{1};
     Y = X;
     have_hist = true;
-  elseif (nargin == 3)
+  elseif (narg == 3)
     X = varargin{1};
     Y = varargin{2};
   else
--- a/scripts/plot/draw/polar.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/polar.m	Thu Dec 10 12:50:06 2015 -0800
@@ -127,7 +127,8 @@
       addlistener (hax, "fontsize", {@__update_text__, hg, "fontsize"});
       addlistener (hax, "fontunits", {@__update_text__, hg, "fontunits"});
       addlistener (hax, "fontweight", {@__update_text__, hg, "fontweight"});
-      addlistener (hax, "interpreter", {@__update_text__, hg, "interpreter"});
+      addlistener (hax, "ticklabelinterpreter",
+                   {@__update_text__, hg, "interpreter"});
       addlistener (hax, "layer", {@__update_layer__, hg});
       addlistener (hax, "gridlinestyle",{@__update_lines__,hg,"gridlinestyle"});
       addlistener (hax, "linewidth", {@__update_lines__, hg, "linewidth"});
@@ -155,13 +156,20 @@
 
 function rtick = __calc_rtick__ (hax, maxr)
   ## FIXME: workaround: calculate r(ho)tick from xtick
+  ##        It would be better to just calculate the values,
+  ##        but that code is deep in the C++ for the plot engines.
   savexlim = get (hax, "xlim");
   saveylim = get (hax, "ylim");
   set (hax, "xlim", [-maxr maxr], "ylim", [-maxr maxr]);
   xtick = get (hax, "xtick");
-  rtick = xtick(find (xtick > 0, 1):find (xtick >= maxr, 1));
-  if (isempty (rtick))
-    rtick = [0.5 1];
+  minidx = find (xtick > 0, 1);
+  maxidx = find (xtick >= maxr, 1);
+  if (! isempty (maxidx))
+    rtick = xtick(minidx:maxidx);
+  else
+    ## Add one more tick through linear interpolation
+    rtick = xtick(minidx:end);
+    rtick(end+1) = xtick(end) + diff (xtick(end-1:end));
   endif
   set (hax, "xlim", savexlim, "ylim", saveylim);
 endfunction
@@ -325,8 +333,10 @@
             "linewidth", get(hax, "linewidth")};
   ## "fontunits" should be first because it affects "fontsize" property.
   tprops(1:2:12) = {"fontunits", "fontangle", "fontname", "fontsize", ...
-                    "fontweight", "interpreter"};
+                    "fontweight", "ticklabelinterpreter"};
   tprops(2:2:12) = get (hax, tprops(1:2:12));
+  tprops(1:2:12) = strrep (tprops(1:2:12), "ticklabelinterpreter",
+                           "interpreter");
 
   ## The number of points used for a circle
   circle_points = 50;
@@ -381,7 +391,7 @@
     dellistener (hax, "fontsize");
     dellistener (hax, "fontunits");
     dellistener (hax, "fontweight");
-    dellistener (hax, "interpreter");
+    dellistener (hax, "ticklabelinterpreter");
     dellistener (hax, "layer");
     dellistener (hax, "gridlinestyle");
     dellistener (hax, "linewidth");
--- a/scripts/plot/draw/private/__add_datasource__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/private/__add_datasource__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -28,7 +28,7 @@
   endif
 
   for i = 1 : numel (data)
-    addproperty (strcat (data{i}, "datasource"), h, "string", "");
+    addproperty ([data{i} "datasource"], h, "string", "");
   endfor
 
   i = 0;
@@ -42,11 +42,12 @@
       if (ischar (val))
         set (h, arg, val);
       else
-        error ("%s: expecting data source to be a string", fcn);
+        error ("%s: datasource must be a string", fcn);
       endif
     else
       newargs{end + 1} = arg;
     endif
   endwhile
+
 endfunction
 
--- a/scripts/plot/draw/private/__bar__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/private/__bar__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -69,18 +69,18 @@
   while (idx <= nargin)
     if (ischar (varargin{idx}) && strcmpi (varargin{idx}, "grouped"))
       group = true;
-      idx++;
+      idx += 1;
     elseif (ischar (varargin{idx}) && strcmpi (varargin{idx}, "stacked"))
       group = false;
-      idx++;
+      idx += 1;
     elseif (ischar (varargin{idx}) && strcmpi (varargin{idx}, "histc"))
       group = true;
       histc = true;
-      idx++;
+      idx += 1;
     elseif (ischar (varargin{idx}) && strcmpi (varargin{idx}, "hist"))
       group = true;
       histc = false;
-      idx++;
+      idx += 1;
     else
       if ((ischar (varargin{idx}) || iscellstr (varargin{idx}))
           && ! have_line_spec)
@@ -90,7 +90,7 @@
           ## FIXME: strange parse error requires semicolon to be spaced
           ##        away from closing ']' on next line.
           newargs = [{"facecolor", linespec.color}, newargs] ;
-          idx++;
+          idx += 1;
           continue;
         endif
       endif
--- a/scripts/plot/draw/private/__contour__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/private/__contour__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -28,41 +28,43 @@
 
   linespec.color = "auto";
   linespec.linestyle = "-";
-  for i = 3:2:nargin
-    arg = varargin{i};
-    if (ischar (arg) || iscellstr (arg))
+  opts = {};
+  i = 3;
+  while (i <= length (varargin))
+    if (ischar (varargin{i}) || iscellstr (varargin{i}))
+      arg = varargin{i};
+      if (i < length (varargin))
+        if (strcmpi (arg, "fill"))
+          filled = varargin{i+1};
+          varargin(i:i+1) = [];
+          continue;
+        elseif (strcmpi (arg, "linecolor"))
+          linespec.color = varargin{i+1};
+          varargin(i:i+1) = [];
+          continue;
+        endif
+      endif
+
       [lspec, valid] = __pltopt__ ("__contour__", arg, false);
       if (valid)
-        have_line_spec = true;
         varargin(i) = [];
-        linespec = lspec;
-        if (isempty (linespec.color))
-          linespec.color = "auto";
+        if (! isempty (lspec.color))
+          linespec.color = lspec.color;
+        endif
+        if (! isempty (lspec.linestyle))
+          linespec.linestyle = lspec.linestyle;
         endif
-        if (isempty (linespec.linestyle))
-          linespec.linestyle = "-";
+      else  # unrecognized option, pass unmodified in opts cell array
+        if (i < length (varargin))
+          opts(end+(1:2)) = varargin(i:i+1);
+          varargin(i:i+1) = [];
+        else
+          error ("__contour__: Uneven number of PROP/VAL pairs");
         endif
-        break;
       endif
-    endif
-  endfor
 
-  opts = {};
-  i = 3;
-  while (i < length (varargin))
-    if (ischar (varargin{i}))
-      if (strcmpi (varargin{i}, "fill"))
-        filled = varargin{i+1};
-        varargin(i:i+1) = [];
-      elseif (strcmpi (varargin{i}, "linecolor"))
-        linespec.color = varargin{i+1};
-        varargin(i:i+1) = [];
-      else
-        opts(end+(1:2)) = varargin(i:i+1);
-        varargin(i:i+1) = [];
-      endif
-    else
-      i++;
+    else  # skip numeric arguments
+      i += 1;
     endif
   endwhile
 
@@ -231,7 +233,7 @@
     i = 1;
     ncont = 0;
     while (i < columns (c))
-      ncont++;
+      ncont += 1;
       cont_lev(ncont) = c(1, i);
       cont_len(ncont) = c(2, i);
       cont_idx(ncont) = i+1;
@@ -262,7 +264,7 @@
           in = inpolygon (next_ct_pt_vec(1,:), next_ct_pt_vec(2,:),
                           curr_ct(1, :), curr_ct(2, :));
           mark(b_vec(in)) = ! mark(b_vec(in));
-          a++;
+          a += 1;
         endwhile
         if (numel (mark) > 0)
           ## All marked contours describe a hole in a larger contour of
--- a/scripts/plot/draw/private/__errcomm__.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-## Copyright (C) 2001-2015 Teemu Ikonen
-##
-## 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} {} __errcomm__ (@var{caller}, @var{hax}, @dots{})
-## Undocumented internal function.
-## @end deftypefn
-
-## Created: 20.02.2001
-## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi>
-## Keywords: errorbar, plotting
-
-function retval = __errcomm__ (caller, hax, varargin)
-
-  if (nargin < 4)
-    print_usage (caller);
-  endif
-
-  retval = [];
-  data = cell (6,1);
-  nargs = numel (varargin);
-  k = 1;
-  while (k <= nargs)
-    arg = varargin{k++};
-    if (! isnumeric (arg))
-      error ("%s: data argument %d must be numeric", caller, k-1);
-    endif
-    if (isvector (arg))
-      arg = arg(:);
-    endif
-    sz = size (arg);
-    ndata = 1;
-    data{ndata} = arg;
-    while (k <= nargs)
-      arg = varargin{k++};
-      if (ischar (arg) || iscellstr (arg))
-        retval = [retval; __errplot__(arg, hax, data{1:ndata})];
-        break;
-      endif
-      if (! isnumeric (arg))
-        error ("%s: data argument %d must be numeric", caller, k-1);
-      endif
-      if (isvector (arg))
-        arg = arg(:);
-      endif
-      if (! isscalar (arg) && ((isvector (arg) && numel (arg) != prod (sz))
-          || any (size (arg) != sz)))
-        error ("%s: size of argument %d does not match others", caller, k-1);
-      endif
-      data{++ndata} = arg;
-      if (ndata > 6)
-        error ("%s: too many arguments to plot", caller);
-      endif
-    endwhile
-  endwhile
-
-  ## No format code found, use yerrorbar
-  if (! (ischar (arg) || iscellstr (arg)))
-    retval = [retval; __errplot__("~", hax, data{1:ndata})];
-  endif
-
-  drawnow ();
-
-endfunction
-
--- a/scripts/plot/draw/private/__errplot__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/private/__errplot__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -24,10 +24,62 @@
 ## Created: 18.7.2000
 ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi>
 ## Keywords: errorbar, plotting
+function retval = __errplot__ (caller, hax, varargin)
 
-function h = __errplot__ (fstr, hax, varargin)
+  if (nargin < 4)
+    print_usage (caller);
+  endif
 
-  fmt = __pltopt__ ("__errplot__", fstr);
+  retval = [];
+  data = cell (6,1);
+  nargs = numel (varargin);
+  k = 1;
+  while (k <= nargs)
+    arg = varargin{k++};
+    if (! isnumeric (arg))
+      error ("%s: data argument %d must be numeric", caller, k-1);
+    endif
+    if (isvector (arg))
+      arg = arg(:);
+    endif
+    sz = size (arg);
+    ndata = 1;
+    data{ndata} = arg;
+    while (k <= nargs)
+      arg = varargin{k++};
+      if (ischar (arg) || iscellstr (arg))
+        retval = [retval; __do_errplot__(arg, hax, data{1:ndata})];
+        break;
+      endif
+      if (! isnumeric (arg))
+        error ("%s: data argument %d must be numeric", caller, k-1);
+      endif
+      if (isvector (arg))
+        arg = arg(:);
+      endif
+      if (! isscalar (arg) && ((isvector (arg) && numel (arg) != prod (sz))
+          || any (size (arg) != sz)))
+        error ("%s: size of argument %d does not match others", caller, k-1);
+      endif
+      data{++ndata} = arg;
+      if (ndata > 6)
+        error ("%s: too many arguments to plot", caller);
+      endif
+    endwhile
+  endwhile
+
+  ## No format code found, use yerrorbar
+  if (! (ischar (arg) || iscellstr (arg)))
+    retval = [retval; __do_errplot__("~", hax, data{1:ndata})];
+  endif
+
+  drawnow ();
+
+endfunction
+
+function h = __do_errplot__ (fstr, hax, varargin)
+
+  fmt = __pltopt__ ("__do_errplot__", fstr);
 
   ## Set the plot type based on linestyle.
   switch (fmt.errorstyle)
@@ -66,7 +118,7 @@
     ## Must occur after __next_line_color__ in order to work correctly.
     hg = hggroup ("parent", hax);
     h = [h; hg];
-    args = __add_datasource__ ("__errplot__", hg,
+    args = __add_datasource__ ("__do_errplot__", hg,
                                {"x", "y", "l", "u", "xl", "xu"});
 
     hl = [(__line__ (hg, "color", lc, "linestyle", "-", "marker", "none")),
@@ -233,6 +285,9 @@
                                          xscale, yscale)
   if (strcmp (xscale, "linear"))
     dx = 0.01 * (max (xdata(:)) - min (xdata(:)));
+    if (dx == 0)
+      dx = .1;
+    endif
     xlo = xdata - dx;
     xhi = xdata + dx;
   else
@@ -247,6 +302,9 @@
   endif
   if (strcmp (yscale, "linear"))
     dy = 0.01 * (max (ydata(:)) - min (ydata(:)));
+    if (dy == 0)
+      dy = .1;
+    endif
     ylo = ydata - dy;
     yhi = ydata + dy;
   else
--- a/scripts/plot/draw/private/__ezplot__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/private/__ezplot__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -140,7 +140,7 @@
       yarg = args{2};
     endif
   else
-    error ("%s: expecting string, inline function, or function handle", ezfunc);
+    error ("%s: F must be string, inline function, or function handle", ezfunc);
   endif
 
   if (nargin > 2 || (nargin == 2 && isplot))
@@ -222,7 +222,7 @@
           error ("%s: expecting a function of %d arguments", ezfunc, nargs);
         endif
       else
-        error ("%s: parametric plots expect 3 functions", ezfunc);
+        error ("%s: parametric plots require 3 functions", ezfunc);
       endif
     endif
   endif
@@ -257,7 +257,7 @@
     elseif (numel (arg) == 4)
       domain = arg(:).';
     else
-      error ("%s: expecting scalar, 2-, or 4-element vector", ezfunc);
+      error ("%s: expecting scalar N or 2-, 4-element vector DOM", ezfunc);
     endif
   endwhile
 
--- a/scripts/plot/draw/private/__patch__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/private/__patch__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -75,7 +75,7 @@
         iarg = 3;
         if (rem (nargin - iarg, 2) == 1)
           c = varargin{iarg};
-          iarg++;
+          iarg += 1;
         else
           c = [];
         endif
--- a/scripts/plot/draw/private/__pie__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/private/__pie__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -29,7 +29,7 @@
   iarg = 3;
 
   if (! isvector (x))
-    error ("%s: expecting vector argument", caller);
+    error ("%s: X must be a vector", caller);
   endif
 
   len = length (x);
--- a/scripts/plot/draw/private/__plt__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/private/__plt__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -86,7 +86,7 @@
         error ("%s: plot arrays must have less than 2 dimensions", caller)
       endif
 
-      nargs--;
+      nargs -= 1;
 
       if (ischar (next_arg) || iscellstr (next_arg))
         if (x_set)
@@ -96,7 +96,7 @@
               error ("%s: properties must appear followed by a value", caller);
             endif
             properties = [properties, [next_cell, varargin(k++)]];
-            nargs--;
+            nargs -= 1;
             continue;
           else
             while (nargs > 0 && ischar (varargin{k}))
--- a/scripts/plot/draw/private/__scatter__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/private/__scatter__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -42,7 +42,7 @@
       s = 6;
     endif
     if (! ischar (varargin{istart}))
-      istart++;
+      istart += 1;
     endif
   else
     s = 6;
@@ -79,7 +79,7 @@
           && ! (   strcmpi (varargin{istart}, "filled")
                 || strcmpi (varargin{istart}, "fill")))
     c = varargin{istart};
-    firstnonnumeric++;
+    firstnonnumeric += 1;
   else
     c = [];
   endif
@@ -291,7 +291,7 @@
     toolkit = get (ancestor (hg, "figure"), "__graphics_toolkit__");
     ## 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_axes__.m
+    ##       can be assigned to each vertex, then fix __gnuplot_draw_axes__.m
     gnuplot_hack = (numel (x) > 1 && columns (c) == 3
                     && strcmp (toolkit, "gnuplot"));
     if (ischar (c) || ! isflat || gnuplot_hack)
--- a/scripts/plot/draw/private/__stem__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/private/__stem__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -192,7 +192,7 @@
   else
     caller = "stem";
   endif
-  nargin = nargin - 1;  # account for have_z argument
+  nargin = nargin () - 1;  # account for have_z argument
 
   num_numeric = find (cellfun ("isclass", varargin, "char"), 1) - 1;
   if (isempty (num_numeric))
--- a/scripts/plot/draw/rectangle.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/rectangle.m	Thu Dec 10 12:50:06 2015 -0800
@@ -119,10 +119,10 @@
         parent = varargin{iarg+1};
         varargin(iarg:iarg+1) = [];
       else
-        iarg ++;
+        iarg += 1;
       endif
     else
-      iarg ++;
+      iarg += 1;
     endif
   endwhile
 
--- a/scripts/plot/draw/semilogxerr.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/semilogxerr.m	Thu Dec 10 12:50:06 2015 -0800
@@ -69,7 +69,7 @@
       set (hax, "xminortick", "on");
     endif
 
-    htmp = __errcomm__ ("semilogxerr", hax, varargin{:});
+    htmp = __errplot__ ("semilogxerr", hax, varargin{:});
 
   unwind_protect_cleanup
     if (! isempty (oldfig))
--- a/scripts/plot/draw/semilogyerr.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/semilogyerr.m	Thu Dec 10 12:50:06 2015 -0800
@@ -69,7 +69,7 @@
       set (hax, "yminortick", "on");
     endif
 
-    htmp = __errcomm__ ("semilogyerr", hax, varargin{:});
+    htmp = __errplot__ ("semilogyerr", hax, varargin{:});
 
   unwind_protect_cleanup
     if (! isempty (oldfig))
--- a/scripts/plot/draw/surfc.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/surfc.m	Thu Dec 10 12:50:06 2015 -0800
@@ -93,7 +93,7 @@
     if (isempty (stop_idx))
       stop_idx = nargin;
     else
-      stop_idx--;
+      stop_idx -= 1;
     endif
 
     if (stop_idx - 1 == 1 || stop_idx - 1 == 3)
--- a/scripts/plot/draw/surfnorm.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/draw/surfnorm.m	Thu Dec 10 12:50:06 2015 -0800
@@ -41,7 +41,15 @@
 ##
 ## If output arguments are requested then the components of the normal
 ## vectors are returned in @var{nx}, @var{ny}, and @var{nz} and no plot is
-## made.
+## made.  The normal vectors are unnormalized (magnitude != 1).  To normalize,
+## use
+##
+## @example
+## @group
+## mag = sqrt (nx.^2 + ny.^2 + nz.^2);
+## nx ./= len;  ny ./= len;  nz ./= len;
+## @end group
+## @end example
 ##
 ## An example of the use of @code{surfnorm} is
 ##
@@ -50,10 +58,14 @@
 ## @end example
 ##
 ## Algorithm: The normal vectors are calculated by taking the cross product
-## of the diagonals of each of the quadrilaterals in the meshgrid to find the
-## normal vectors of the centers of these quadrilaterals.  The four nearest
-## normal vectors to the meshgrid points are then averaged to obtain the
-## normal to the surface at the meshgridded points.
+## of the diagonals of each of the quadrilateral faces in the meshgrid to find
+## the normal vectors at the center of each face.  Next, for each meshgrid
+## point the four nearest normal vectors are averaged to obtain the final
+## normal to the surface at the meshgrid point.
+##
+## For surface objects, the @qcode{"VertexNormals"} property contains
+## equivalent information, except possibly near the boundary of the surface
+## where different interpolation schemes may yield slightly different values.
 ##
 ## @seealso{isonormals, quiver3, surf, meshgrid}
 ## @end deftypefn
@@ -84,6 +96,7 @@
     error ("surfnorm: X, Y, and Z must have the same dimensions");
   endif
 
+  ## FIXME: Matlab uses a bicubic interpolation, not linear, along the boundary.
   ## Do a linear extrapolation for mesh points on the boundary so that the mesh
   ## is increased by 1 on each side.  This allows each original meshgrid point
   ## to be surrounded by four quadrilaterals and the same calculation can be
@@ -116,14 +129,6 @@
   nz = (w.z(1:end-1,1:end-1) + w.z(1:end-1,2:end) +
         w.z(2:end,1:end-1) + w.z(2:end,2:end)) / 4;
 
-  ## FIXME: According to Matlab documentation the vertex normals
-  ##        returned are not normalized.
-  ## Normalize the normal vectors
-  len = sqrt (nx.^2 + ny.^2 + nz.^2);
-  nx ./= len;
-  ny ./= len;
-  nz ./= len;
-
   if (nargout == 0)
     oldfig = [];
     if (! isempty (hax))
@@ -137,21 +142,20 @@
       unwind_protect
         set (hax, "nextplot", "add");
 
-        ## FIXME: Scale unit normals by data aspect ratio in order for
-        ##        normals to appear correct.
-        ##daratio = daspect (hax);
-        ##daspect ("manual");
-        ##len = norm (daratio);
-        ## This assumes an even meshgrid which isn't a great assumption
-        ##dx = x(1,2) - x(1,1);
-        ##dy = y(2,1) - y(1,1);
-        ##nx *= daratio(1);
-        ##ny *= daratio(2);
-        ##nz *= daratio(3);
-        ##len = sqrt (nx.^2 + ny.^2 + nz.^2);
-        ##nx ./= len;
-        ##ny ./= len;
-        ##nz ./= len;
+        ## Normalize the normal vectors
+        nmag = sqrt (nx.^2 + ny.^2 + nz.^2);
+
+        ## And correct for the aspect ratio of the display
+        daratio = daspect (hax);
+        damag = sqrt (sumsq (daratio));
+
+        ## FIXME: May also want to normalize the vectors relative to the size
+        ##        of the diagonal.
+
+        nx ./= nmag / (daratio(1)^2 / damag);
+        ny ./= nmag / (daratio(2)^2 / damag);
+        nz ./= nmag / (daratio(3)^2 / damag);
+
         plot3 ([x(:).'; x(:).' + nx(:).' ; NaN(size(x(:).'))](:),
                [y(:).'; y(:).' + ny(:).' ; NaN(size(y(:).'))](:),
                [z(:).'; z(:).' + nz(:).' ; NaN(size(z(:).'))](:),
@@ -177,10 +181,10 @@
 %!demo
 %! clf;
 %! colormap ('default');
-%! surfnorm (peaks (32));
-%! shading interp;
+%! surfnorm (peaks (19));
+%! shading faceted;
 %! title ({'surfnorm() shows surface and normals at each vertex', ...
-%!         'peaks() function with 32 faces'});
+%!         'peaks() function with 19 faces'});
 
 %!demo
 %! clf;
--- a/scripts/plot/util/__actual_axis_position__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/__actual_axis_position__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -67,13 +67,13 @@
     endif
     orig_aspect_ratio_2d = pos_in_pixels(3:4);
     rel_aspect_ratio_2d = aspect_ratio_2d ./ orig_aspect_ratio_2d;
-    rel_aspect_ratio_2d = rel_aspect_ratio_2d ./ max (rel_aspect_ratio_2d);
+    rel_aspect_ratio_2d ./= max (rel_aspect_ratio_2d);
     if (rel_aspect_ratio_2d(1) < rel_aspect_ratio_2d(2));
       dx = (1.0 - rel_aspect_ratio_2d(1)) * pos_in_pixels(3);
-      pos_in_pixels = pos_in_pixels + dx*[0.5, 0.0, -1.0, 0.0];
+      pos_in_pixels += dx*[0.5, 0.0, -1.0, 0.0];
     elseif (rel_aspect_ratio_2d(1) > rel_aspect_ratio_2d(2))
       dy = (1.0 - rel_aspect_ratio_2d(2)) * pos_in_pixels(4);
-      pos_in_pixels = pos_in_pixels + dy*[0.0, 0.5, 0.0, -1.0];
+      pos_in_pixels += dy*[0.0, 0.5, 0.0, -1.0];
     endif
     pos = pos_in_pixels ./ fig_position([3, 4, 3, 4]);
   elseif (strcmp (get (axis_obj.parent, "__graphics_toolkit__"), "gnuplot")
--- a/scripts/plot/util/__gnuplot_drawnow__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/__gnuplot_drawnow__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -40,11 +40,11 @@
       gnuplot_supports_term = __gnuplot_has_terminal__ (term, plot_stream);
       if (gnuplot_supports_term)
         enhanced = gnuplot_set_term (plot_stream(1), true, h, term, file);
-        __go_draw_figure__ (h, plot_stream(1), enhanced, mono);
+        __gnuplot_draw_figure__ (h, plot_stream(1), enhanced, mono);
         if (nargin == 5)
           fid = fopen (debug_file, "wb");
           enhanced = gnuplot_set_term (fid, true, h, term, file);
-          __go_draw_figure__ (h, fid, enhanced, mono);
+          __gnuplot_draw_figure__ (h, fid, enhanced, mono);
         endif
       else
         error ('__gnuplot_drawnow__: the gnuplot terminal, "%s", is not available',
@@ -83,7 +83,7 @@
     else
       enhanced = gnuplot_set_term (plot_stream(1), new_stream, h, term);
     endif
-    __go_draw_figure__ (h, plot_stream(1), enhanced, mono);
+    __gnuplot_draw_figure__ (h, plot_stream(1), enhanced, mono);
     fflush (plot_stream(1));
     if (strcmp (term, "dumb"))
       fid = -1;
--- a/scripts/plot/util/__plt_get_axis_arg__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/__plt_get_axis_arg__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -34,7 +34,7 @@
       && ishandle (varargin{1}) && varargin{1} != 0 && ! isfigure (varargin{1}))
     htmp = varargin{1};
     if (! isaxes (htmp))
-      error ("%s: expecting first argument to be axes handle", caller);
+      error ("%s: first argument must be axes handle", caller);
     endif
     if (! strcmp (get (htmp, "tag"), "legend"))
       h = htmp;
@@ -52,7 +52,7 @@
         h = [ancestor(htmp, "axes"), htmp];
       endif
     else
-      error ("%s: expecting parent value to be axes handle", caller);
+      error ("%s: parent value must be an axes handle", caller);
     endif
   endif
 
--- a/scripts/plot/util/__pltopt__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/__pltopt__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -126,7 +126,7 @@
   have_marker = false;
 
   ## If called by __errplot__, extract the linestyle before proceeding.
-  if (strcmp (caller, "__errplot__"))
+  if (strcmp (caller, "__do_errplot__"))
     if (strncmp (opt, "#~>", 3))
       n = 3;
     elseif (strncmp (opt, "#~", 2) || strncmp (opt, "~>", 2))
@@ -258,7 +258,7 @@
 %! assert (opts.linestyle, []);
 %! assert (opts.marker, []);
 %!test
-%! opts = __pltopt__ ("__errplot__", "~>r");
+%! opts = __pltopt__ ("__do_errplot__", "~>r");
 %! assert (opts.errorstyle, "~>");
 %! assert (opts.color, [1 0 0 ]);
 %! assert (opts.linestyle, []);
--- a/scripts/plot/util/cla.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/cla.m	Thu Dec 10 12:50:06 2015 -0800
@@ -92,16 +92,16 @@
 %! unwind_protect
 %!   hax = gca;
 %!   plot (hax, 1:10);
-%!   set (hax, "interpreter", "tex");
+%!   set (hax, "ticklabelinterpreter", "none");
 %!   cla (hax);
 %!   kids = get (hax, "children");
 %!   assert (numel (kids), 0);
-%!   assert (get (hax, "interpreter"), "tex");
+%!   assert (get (hax, "ticklabelinterpreter"), "none");
 %!   plot (hax, 1:10);
 %!   cla (hax, "reset");
 %!   kids = get (hax, "children");
 %!   assert (numel (kids), 0);
-%!   assert (get (hax, "interpreter"), "none");
+%!   assert (get (hax, "ticklabelinterpreter"), "tex");
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect
--- a/scripts/plot/util/figure.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/figure.m	Thu Dec 10 12:50:06 2015 -0800
@@ -57,12 +57,12 @@
       f = arg;
       init_new_figure = false;
       varargin(1) = [];
-      nargs--;
+      nargs -= 1;
     elseif (isscalar (arg) && isnumeric (arg) && arg > 0 && arg == fix (arg))
       f = arg;
       init_new_figure = true;
       varargin(1) = [];
-      nargs--;
+      nargs -= 1;
     else
       error ("figure: N must be figure handle or figure number");
     endif
--- a/scripts/plot/util/findobj.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/findobj.m	Thu Dec 10 12:50:06 2015 -0800
@@ -99,7 +99,7 @@
       if (ischar (varargin{n1}))
         if (strcmpi (varargin{n1}, "flat"))
           depth = 0;
-          n1 = n1 + 1;
+          n1 += 1;
         endif
       else
         error ("findobj: properties and options must be strings");
@@ -133,32 +133,32 @@
     if (ischar (args{na}))
       if (strcmpi (args{na}, "-property"))
         if (na + 1 <= numel (args))
-          na = na + 1;
+          na += 1;
           property(np) = 1;
           pname{np} = args{na};
-          na = na + 1;
+          na += 1;
           pvalue{np} = [];
-          np = np + 1;
+          np += 1;
         else
           error ("findobj: inconsistent number of arguments");
         endif
       elseif (strcmpi (args{na}, "-regexp"))
         if (na + 2 <= numel (args))
           regularexpression(np) = 1;
-          na = na + 1;
+          na += 1;
           pname{np} = args{na};
-          na = na + 1;
+          na += 1;
           pvalue{np} = args{na};
-          na = na + 1;
-          np = np + 1;
+          na += 1;
+          np += 1;
         else
           error ("findobj: inconsistent number of arguments");
         endif
       elseif (strcmpi (args{na}, "-depth"))
         if (na + 1 <= numel (args))
-          na = na + 1;
+          na += 1;
           depth = args{na};
-          na = na + 1;
+          na += 1;
         else
           error ("findobj: inconsistent number of arguments");
         endif
@@ -166,14 +166,14 @@
         ## Parameter/value pairs.
         if (na + 1 <= numel (args))
           pname{np} = args{na};
-          na = na + 1;
+          na += 1;
           pvalue{np} = args{na};
-          na = na + 1;
+          na += 1;
           if (na <= numel (args))
             if (ischar (args{na}))
               if (any (strcmpi (args{na}, operatorprecedence)))
                 logicaloperator{np} = args{na}(2:end);
-                na = na+1;
+                na += 1;
               endif
             else
               error ("findobj: properties and options must be strings");
@@ -181,7 +181,7 @@
           else
             logicaloperator{np} = "and";
           endif
-          np = np + 1;
+          np += 1;
         else
           error ("findobj: inconsistent number of arguments");
         endif
@@ -189,7 +189,7 @@
         if (strcmpi (args{na}, "-not"))
           extranegation(np) = true;
         endif
-        na = na + 1;
+        na += 1;
       endif
     else
       error ("findobj: properties and options must be strings");
@@ -211,7 +211,7 @@
     endfor
     handles = children;
     h = [h; children];
-    idepth = idepth + 1;
+    idepth += 1;
   endwhile
 
   if (numpairs > 0)
@@ -267,7 +267,7 @@
                                  match(:,np+1));
             logicaloperator(np+1) = [];
             match(:,np+1) = [];
-            numpairs = numpairs - 1;
+            numpairs -= 1;
           endif
           if (numpairs < 2)
             break;
@@ -341,7 +341,6 @@
 %! end_unwind_protect
 
 %!test
-%! toolkit = graphics_toolkit ("gnuplot");
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   h1 = subplot (2,2,1);
@@ -352,11 +351,9 @@
 %!   assert (h, h3);
 %! unwind_protect_cleanup
 %!   close (hf);
-%!   graphics_toolkit (toolkit);
 %! end_unwind_protect
 
 %!test
-%! toolkit = graphics_toolkit ("gnuplot");
 %! hf = figure ("visible", "off");
 %! unwind_protect
 %!   h1 = subplot (2,2,1, "tag", "1");
@@ -367,7 +364,6 @@
 %!   assert (h, [h4; h3; h2])
 %! unwind_protect_cleanup
 %!   close (hf);
-%!   graphics_toolkit (toolkit);
 %! end_unwind_protect
 
 %!test
--- a/scripts/plot/util/ginput.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/ginput.m	Thu Dec 10 12:50:06 2015 -0800
@@ -69,12 +69,15 @@
   ginput_accumulator (0, 0, 0, 0);  # initialize accumulator
 
   orig_windowbuttondownfcn = get (fig, "windowbuttondownfcn");
-  orig_ginput_keypressfcn = get (fig, "keypressfcn");
+  orig_keypressfcn = get (fig, "keypressfcn");
+  orig_closerequestfcn = get (fig, "closerequestfcn");
 
   unwind_protect
 
     set (fig, "windowbuttondownfcn", @ginput_windowbuttondownfcn);
     set (fig, "keypressfcn", @ginput_keypressfcn);
+    set (fig, "closerequestfcn", {@ginput_closerequestfcn,
+                                  orig_closerequestfcn});
 
     do
       if (strcmp (toolkit, "fltk"))
@@ -95,8 +98,12 @@
     endif
 
   unwind_protect_cleanup
-    set (fig, "windowbuttondownfcn", orig_windowbuttondownfcn);
-    set (fig, "keypressfcn", orig_ginput_keypressfcn);
+    if (isfigure (fig))
+      ## Only execute if window still exists
+      set (fig, "windowbuttondownfcn", orig_windowbuttondownfcn);
+      set (fig, "keypressfcn", orig_keypressfcn);
+      set (fig, "closerequestfcn", orig_closerequestfcn);
+    endif
   end_unwind_protect
 
   varargout = {x, y, button};
@@ -123,12 +130,12 @@
 
 endfunction
 
-function ginput_windowbuttondownfcn (src, button)
+function ginput_windowbuttondownfcn (~, button)
   point = get (gca (), "currentpoint");
   ginput_accumulator (1, point(1,1), point(1,2), button);
 endfunction
 
-function ginput_keypressfcn (src, evt)
+function ginput_keypressfcn (~, evt)
   point = get (gca (), "currentpoint");
   if (strcmp (evt.Key, "return"))
     ## Enter key stops ginput.
@@ -141,6 +148,11 @@
   endif
 endfunction
 
+function ginput_closerequestfcn (hfig, ~, orig_closerequestfcn)
+  ginput_accumulator (2, NaN, NaN, NaN);  # Stop ginput
+  feval (orig_closerequestfcn);           # Close window with original fcn
+endfunction
+
 
 ## Remove from test statistics.  No real tests possible.
 %!test
--- a/scripts/plot/util/graphics_toolkit.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/graphics_toolkit.m	Thu Dec 10 12:50:06 2015 -0800
@@ -82,6 +82,14 @@
   endif
 
   if (! any (strcmp (loaded_graphics_toolkits (), name)))
+    ## FIXME: Special gnuplot handling for versions < 4.2.5 (bug #44978).
+    ## This can probably be deleted in the future once RHEL upgrades gnuplot.
+    if (strcmp (name, "gnuplot"))
+      valid_version = __gnuplot_has_feature__ ("minimum_version");
+      if (valid_version != 1)
+        error ("graphics_toolkit: gnuplot version too old.");
+      endif
+    endif
     feval (["__init_", name, "__"]);
     if (! any (strcmp (loaded_graphics_toolkits (), name)))
       error ("graphics_toolkit: %s toolkit was not correctly loaded", name);
--- a/scripts/plot/util/hdl2struct.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/hdl2struct.m	Thu Dec 10 12:50:06 2015 -0800
@@ -59,10 +59,10 @@
   while (nkids)
     if (! any (kids (nkids) == lg) && ! any (kids (nkids) == cb)
           && ! any (kids (nkids) == ui) && ! strcmp (main.type, "hggroup"))
-      ii++;
+      ii += 1;
       s.children(ii) = hdl2struct (kids(nkids));
     endif
-    nkids--;
+    nkids -= 1;
   endwhile
 
   ## add non "children" children objects (title, xlabel, ...) and
@@ -74,10 +74,10 @@
   special = [special getspecial(h)];
   nsp = length (special);
   while (nsp)
-    ii++;
+    ii += 1;
     s.children(ii) = hdl2struct (special(nsp));
     s.special(nsp) = ii;
-    nsp--;
+    nsp -= 1;
   endwhile
 
   ## look for legends and colorbars among "main"'s brothers and add them
@@ -91,7 +91,7 @@
     endif
     nlg = length (lg);
     if (nlg == 1)
-      ii++;
+      ii += 1;
       s.children(ii) = hdl2struct (lg);
     elseif (nlg > 1)
       error ("hdl2struct: more than one legend found");
@@ -105,7 +105,7 @@
 
     ncb = length (cb);
     if (ncb == 1)
-      ii++;
+      ii += 1;
       s.children(ii) = hdl2struct (cb);
     elseif (nlg > 1)
       error ("hdl2struct: more than one colorbar found");
@@ -152,11 +152,11 @@
   while (nflds)
     prop = fields{nflds};
     val = obj.(fields{nflds});
-    ii++;
+    ii += 1;
     if (! any (strcmp (prop, forbid)))
       prpstr.(prop) = val;
     endif
-    nflds--;
+    nflds -= 1;
   endwhile
 
   ## hidden properties
--- a/scripts/plot/util/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,88 +1,100 @@
-FCN_FILE_DIRS += plot
+FCN_FILE_DIRS += \
+  scripts/plot/util \
+  scripts/plot/util/private
 
-plot_util_GEN_FCN_FILES = \
-  plot/util/gnuplot_binary.m
+scripts_plot_util_GEN_FCN_FILES = \
+  scripts/plot/util/gnuplot_binary.m
 
-GEN_FCN_FILES += $(plot_util_GEN_FCN_FILES)
+GEN_FCN_FILES += $(scripts_plot_util_GEN_FCN_FILES)
 
-plot_util_PRIVATE_FCN_FILES = \
-  plot/util/private/__add_default_menu__.m \
-  plot/util/private/__ghostscript__.m \
-  plot/util/private/__gnuplot_get_var__.m \
-  plot/util/private/__gnuplot_ginput__.m \
-  plot/util/private/__gnuplot_has_feature__.m \
-  plot/util/private/__gnuplot_has_terminal__.m \
-  plot/util/private/__gnuplot_open_stream__.m \
-  plot/util/private/__gnuplot_print__.m \
-  plot/util/private/__gnuplot_version__.m \
-  plot/util/private/__go_draw_axes__.m \
-  plot/util/private/__go_draw_figure__.m \
-  plot/util/private/__opengl_print__.m \
-  plot/util/private/__print_parse_opts__.m \
-  plot/util/private/__tight_eps_bbox__.m
+scripts_plot_util_PRIVATE_FCN_FILES = \
+  scripts/plot/util/private/__add_default_menu__.m \
+  scripts/plot/util/private/__ghostscript__.m \
+  scripts/plot/util/private/__gnuplot_get_var__.m \
+  scripts/plot/util/private/__gnuplot_ginput__.m \
+  scripts/plot/util/private/__gnuplot_has_feature__.m \
+  scripts/plot/util/private/__gnuplot_has_terminal__.m \
+  scripts/plot/util/private/__gnuplot_open_stream__.m \
+  scripts/plot/util/private/__gnuplot_print__.m \
+  scripts/plot/util/private/__gnuplot_version__.m \
+  scripts/plot/util/private/__gnuplot_draw_axes__.m \
+  scripts/plot/util/private/__gnuplot_draw_figure__.m \
+  scripts/plot/util/private/__opengl_print__.m \
+  scripts/plot/util/private/__print_parse_opts__.m
 
-plot_util_FCN_FILES = \
-  plot/util/__actual_axis_position__.m \
-  plot/util/allchild.m \
-  plot/util/ancestor.m \
-  plot/util/axes.m \
-  plot/util/cla.m \
-  plot/util/clf.m \
-  plot/util/close.m \
-  plot/util/closereq.m \
-  plot/util/colstyle.m \
-  plot/util/copyobj.m \
-  plot/util/__default_plot_options__.m \
-  plot/util/figure.m \
-  plot/util/findall.m \
-  plot/util/findfigs.m \
-  plot/util/findobj.m \
-  plot/util/frame2im.m \
-  plot/util/gca.m \
-  plot/util/gcbf.m \
-  plot/util/gcbo.m \
-  plot/util/gcf.m \
-  plot/util/gco.m \
-  plot/util/ginput.m \
-  plot/util/__gnuplot_drawnow__.m \
-  plot/util/graphics_toolkit.m \
-  plot/util/hdl2struct.m \
-  plot/util/hggroup.m \
-  plot/util/hgload.m \
-  plot/util/hgsave.m \
-  plot/util/hold.m \
-  plot/util/im2frame.m \
-  plot/util/isaxes.m \
-  plot/util/isfigure.m \
-  plot/util/ishghandle.m \
-  plot/util/ishold.m \
-  plot/util/isprop.m \
-  plot/util/linkaxes.m \
-  plot/util/linkprop.m \
-  plot/util/meshgrid.m \
-  plot/util/ndgrid.m \
-  plot/util/newplot.m \
-  plot/util/__next_line_color__.m \
-  plot/util/__next_line_style__.m \
-  plot/util/pan.m \
-  plot/util/__plt_get_axis_arg__.m \
-  plot/util/__pltopt__.m \
-  plot/util/printd.m \
-  plot/util/print.m \
-  plot/util/refreshdata.m \
-  plot/util/refresh.m \
-  plot/util/rotate.m \
-  plot/util/rotate3d.m \
-  plot/util/saveas.m \
-  plot/util/shg.m \
-  plot/util/struct2hdl.m \
-  plot/util/subplot.m \
-  plot/util/zoom.m \
-  $(plot_util_PRIVATE_FCN_FILES)
+scripts_plot_util_FCN_FILES = \
+  scripts/plot/util/__actual_axis_position__.m \
+  scripts/plot/util/allchild.m \
+  scripts/plot/util/ancestor.m \
+  scripts/plot/util/axes.m \
+  scripts/plot/util/cla.m \
+  scripts/plot/util/clf.m \
+  scripts/plot/util/close.m \
+  scripts/plot/util/closereq.m \
+  scripts/plot/util/colstyle.m \
+  scripts/plot/util/copyobj.m \
+  scripts/plot/util/__default_plot_options__.m \
+  scripts/plot/util/figure.m \
+  scripts/plot/util/findall.m \
+  scripts/plot/util/findfigs.m \
+  scripts/plot/util/findobj.m \
+  scripts/plot/util/frame2im.m \
+  scripts/plot/util/gca.m \
+  scripts/plot/util/gcbf.m \
+  scripts/plot/util/gcbo.m \
+  scripts/plot/util/gcf.m \
+  scripts/plot/util/gco.m \
+  scripts/plot/util/ginput.m \
+  scripts/plot/util/__gnuplot_drawnow__.m \
+  scripts/plot/util/graphics_toolkit.m \
+  scripts/plot/util/hdl2struct.m \
+  scripts/plot/util/hggroup.m \
+  scripts/plot/util/hgload.m \
+  scripts/plot/util/hgsave.m \
+  scripts/plot/util/hold.m \
+  scripts/plot/util/im2frame.m \
+  scripts/plot/util/isaxes.m \
+  scripts/plot/util/isfigure.m \
+  scripts/plot/util/ishghandle.m \
+  scripts/plot/util/ishold.m \
+  scripts/plot/util/isprop.m \
+  scripts/plot/util/linkaxes.m \
+  scripts/plot/util/linkprop.m \
+  scripts/plot/util/meshgrid.m \
+  scripts/plot/util/ndgrid.m \
+  scripts/plot/util/newplot.m \
+  scripts/plot/util/__next_line_color__.m \
+  scripts/plot/util/__next_line_style__.m \
+  scripts/plot/util/pan.m \
+  scripts/plot/util/__plt_get_axis_arg__.m \
+  scripts/plot/util/__pltopt__.m \
+  scripts/plot/util/printd.m \
+  scripts/plot/util/print.m \
+  scripts/plot/util/refreshdata.m \
+  scripts/plot/util/refresh.m \
+  scripts/plot/util/rotate.m \
+  scripts/plot/util/rotate3d.m \
+  scripts/plot/util/saveas.m \
+  scripts/plot/util/shg.m \
+  scripts/plot/util/struct2hdl.m \
+  scripts/plot/util/subplot.m \
+  scripts/plot/util/zoom.m
 
-FCN_FILES += $(plot_util_FCN_FILES)
+scripts_plot_utildir = $(fcnfiledir)/plot/util
+
+scripts_plot_util_DATA = \
+  $(scripts_plot_util_FCN_FILES) \
+  $(scripts_plot_util_GEN_FCN_FILES)
+
+scripts_plot_util_privatedir = $(fcnfiledir)/plot/util/private
 
-PKG_ADD_FILES += plot/util/PKG_ADD
+scripts_plot_util_private_DATA = $(scripts_plot_util_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += plot/util/$(octave_dirstamp)
+FCN_FILES += \
+  $(scripts_plot_util_FCN_FILES) \
+  $(scripts_plot_util_PRIVATE_FCN_FILES)
 
+PKG_ADD_FILES += scripts/plot/util/PKG_ADD
+
+DIRSTAMP_FILES += scripts/plot/util/$(octave_dirstamp)
+
--- a/scripts/plot/util/pan.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/pan.m	Thu Dec 10 12:50:06 2015 -0800
@@ -50,16 +50,16 @@
   endif
 
   if (nargin == 1 && nargout > 0 && isfigure (varargin{1}))
-    error ("pan_object_handle = pan (hfig): not implemented");
+    error ("pan: syntax 'handle = pan (hfig)' not implemented");
   endif
 
   if (nargs == 2)
     hfig = varargin{1};
     if (isfigure (hfig))
       varargin(1) = [];
-      nargs--;
+      nargs -= 1;
     else
-      error ("pan: expecting figure handle as first argument");
+      error ("pan: invalid figure handle HFIG");
     endif
   endif
 
--- a/scripts/plot/util/print.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/print.m	Thu Dec 10 12:50:06 2015 -0800
@@ -26,9 +26,9 @@
 ## Both output formatted for printing (PDF and PostScript), and many bitmapped
 ## and vector image formats are supported.
 ##
-## @var{filename} defines the name of the output file.  If the file name has
+## @var{filename} defines the name of the output file.  If the filename 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
+## filename.  If no filename is specified, the output is sent to the
 ## printer.
 ##
 ## @var{h} specifies the handle of the figure to print.  If no handle is
@@ -412,7 +412,7 @@
         endif
         if (! isempty (opts.scalefontsize) && ! opts.scalefontsize != 1)
           ## This is done to work around the bbox being whole numbers.
-          fontsize = fontsize * opts.scalefontsize;
+          fontsize *= opts.scalefontsize;
         endif
         ## FIXME: legend child objects need to be acted on first.
         ##        or legend fontsize callback will destroy them.
@@ -503,7 +503,7 @@
     endif
   else
     pipein = false;
-    filein = strcat ("'", strtrim (filein), "'");
+    filein = ["'" strtrim(filein) "'"];
   endif
   if (strcmp (fileout, "-"))
     pipeout = true;
@@ -515,7 +515,7 @@
     endif
   else
     pipeout = false;
-    fileout = strcat ("'", strtrim (fileout), "'");
+    fileout = ["'" strtrim(fileout) "'"];
   endif
 
   if (! isempty (opts.preview) && opts.tight_flag)
@@ -648,17 +648,17 @@
   if (! isempty (n))
     opts.name = opts.name(1:n-1);
   endif
-  latexfile = strcat (opts.name, ".tex");
+  latexfile = [opts.name ".tex"];
   switch (opts.devopt)
     case {"pdflatexstandalone"}
       packages = "\\usepackage{graphicx,color}";
-      graphicsfile = strcat (opts.name, "-inc.pdf");
+      graphicsfile = [opts.name "-inc.pdf"];
     case {"pslatexstandalone"}
       packages = "\\usepackage{epsfig,color}";
-      graphicsfile = strcat (opts.name, "-inc.ps");
+      graphicsfile = [opts.name "-inc.ps"];
     otherwise
       packages = "\\usepackage{epsfig,color}";
-      graphicsfile = strcat (opts.name, "-inc.eps");
+      graphicsfile = [opts.name "-inc.eps"];
   endswitch
   papersize = sprintf ("\\usepackage[papersize={%.2fbp,%.2fbp},text={%.2fbp,%.2fbp}]{geometry}",
                        fix (opts.canvas_size), fix (opts.canvas_size));
--- a/scripts/plot/util/printd.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/printd.m	Thu Dec 10 12:50:06 2015 -0800
@@ -43,7 +43,7 @@
 
   ## Extract .suffix from filename
   if ((sufix = rindex (filename, ".")) <= 0)
-    error ("The output filename: %s requires a suffix.\nOptions are: pdf ps eps txt jpg jpeg", filename);
+    error ("printd: output filename '%s' requires a suffix.\nOptions are: pdf ps eps txt jpg jpeg", filename);
   endif
   opt = substr (filename, sufix+1);
   [pf, tempf, mag] = mkstemp ("oct-XXXXXX", 1);
@@ -76,7 +76,7 @@
     otherwise
       fclose (pf);
       delete (tempf);
-      error ("Unknown conversion type: %s.\nOptions are: pdf ps eps txt jpg jpeg", opt);
+      error ("printd: unknown conversion type: %s.\nOptions are: pdf ps eps txt jpg jpeg", opt);
 
   endswitch
   fclose (pf);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,2647 @@
+## Copyright (C) 2005-2015 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} {} __gnuplot_draw_axes__ (@var{h}, @var{plot_stream}, @var{enhanced}, @var{mono})
+## Undocumented internal function.
+## @end deftypefn
+
+## Author: jwe
+
+function __gnuplot_draw_axes__ (h, plot_stream, enhanced, mono,
+                           bg_is_set, fg_is_set, hlgnd)
+
+  showhiddenhandles = get (0, "showhiddenhandles");
+  unwind_protect
+    set (0, "showhiddenhandles", "on");
+    axis_obj = __get__ (h);
+  unwind_protect_cleanup
+    set (0, "showhiddenhandles", showhiddenhandles);
+  end_unwind_protect
+
+  parent_figure_obj = get (axis_obj.parent);
+  gnuplot_term = __gnuplot_get_var__ (axis_obj.parent, "GPVAL_TERM");
+
+  ## Set to false for plotyy axes.
+  ymirror = true;
+  if (isfield (axis_obj, "__plotyy_axes__"))
+    if (all (ishandle (axis_obj.__plotyy_axes__)))
+      ymirror = false;
+    else
+      h = axis_obj.__plotyy_axes__;
+      h = h(ishandle (h));
+      h = h(isprop (h, "__plotyy_axes__"));
+      rmappdata (h, "__plotyy_axes__");
+    endif
+  endif
+
+  nd = __calc_dimensions__ (h);
+
+  if (strcmp (axis_obj.dataaspectratiomode, "manual")
+      && strcmp (axis_obj.xlimmode, "manual")
+      && strcmp (axis_obj.ylimmode, "manual"))
+    ## All can't be "manual"
+    axis_obj.plotboxaspectratiomode = "auto";
+  endif
+
+  if (strcmp (axis_obj.dataaspectratiomode, "manual")
+      && strcmp (axis_obj.xlimmode, "manual")
+      && strcmp (axis_obj.ylimmode, "manual")
+      && (nd == 2 || all (mod (axis_obj.view, 90) == 0)))
+    ## FIXME: adjust plotboxaspectratio to respect other
+    fpos = get (axis_obj.parent, "position");
+    apos = axis_obj.position;
+  endif
+
+  pos = __actual_axis_position__ (h);
+
+  if (strcmpi (axis_obj.dataaspectratiomode, "manual"))
+    dr = axis_obj.dataaspectratio;
+    if (nd == 2 || all (mod (axis_obj.view, 90) == 0))
+      dr = dr(1) / dr(2);
+    else
+      ## FIXME: need to properly implement 3D
+      dr = mean (dr(1:2)) / dr(3);
+    endif
+  else
+    dr = 1;
+  endif
+
+  if (strcmp (axis_obj.activepositionproperty, "position"))
+    if (__gnuplot_has_feature__ ("screen_coordinates_for_{lrtb}margin"))
+      if (nd == 2 || all (mod (axis_obj.view, 90) == 0))
+        x = [1, 1];
+      else
+        ## 3D plots need to be sized down to fit in the window.
+        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);
+      fprintf (plot_stream, "set bmargin screen %.15g;\n",
+               pos(2)+pos(4)/2-x(2)*pos(4)/2);
+      fprintf (plot_stream, "set lmargin screen %.15g;\n",
+               pos(1)+pos(3)/2-x(1)*pos(3)/2);
+      fprintf (plot_stream, "set rmargin screen %.15g;\n",
+               pos(1)+pos(3)/2+x(1)*pos(3)/2);
+      sz_str = "";
+    else
+      fprintf (plot_stream, "set tmargin 0;\n");
+      fprintf (plot_stream, "set bmargin 0;\n");
+      fprintf (plot_stream, "set lmargin 0;\n");
+      fprintf (plot_stream, "set rmargin 0;\n");
+
+      if (nd == 3 && all (axis_obj.view == [0, 90]))
+        ## FIXME: Kludge to allow colorbar to be added to a pcolor() plot
+        pos(3:4) = pos(3:4) * 1.4;
+        pos(1:2) = pos(1:2) - pos(3:4) * 0.125;
+      endif
+
+      fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2));
+
+      if (strcmpi (axis_obj.dataaspectratiomode, "manual"))
+        sz_str = sprintf ("set size ratio %.15g", -dr);
+      else
+        sz_str = "set size noratio";
+      endif
+      sz_str = sprintf ("%s %.15g, %.15g;\n", sz_str, pos(3), pos(4));
+    endif
+  else ## activepositionproperty == outerposition
+    fprintf (plot_stream, "unset tmargin;\n");
+    fprintf (plot_stream, "unset bmargin;\n");
+    fprintf (plot_stream, "unset lmargin;\n");
+    fprintf (plot_stream, "unset rmargin;\n");
+    fprintf (plot_stream, "set origin %g, %g;\n", pos(1:2));
+    sz_str = "";
+    if (strcmpi (axis_obj.dataaspectratiomode, "manual"))
+      sz_str = sprintf ("ratio %g", -dr);
+    else
+      sz_str = "noratio";
+    endif
+    sz_str = sprintf ("set size %s %g, %g;\n", sz_str, pos(3:4));
+  endif
+  if (! isempty (sz_str))
+    fputs (plot_stream, sz_str);
+  endif
+
+  ## Reset all labels, axis-labels, tick-labels, and title
+  ## FIXME: We should have an function to initialize the axis.
+  ##        Presently, this is dispersed in this function.
+  fputs (plot_stream, "unset label;\n");
+  fputs (plot_stream, "unset xtics;\n");
+  fputs (plot_stream, "unset ytics;\n");
+  fputs (plot_stream, "unset ztics;\n");
+  fputs (plot_stream, "unset x2tics;\n");
+  fputs (plot_stream, "unset y2tics;\n");
+
+  if (! isempty (axis_obj.title))
+    t = get (axis_obj.title);
+    if (isempty (t.string))
+      fputs (plot_stream, "unset title;\n");
+    else
+      colorspec = get_text_colorspec (t.color, mono);
+      [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string");
+      fontspec = create_fontspec (f, s, gnuplot_term);
+      fprintf (plot_stream, "set title \"%s\" %s %s %s;\n",
+               undo_string_escapes (tt), fontspec, colorspec,
+               __do_enhanced_option__ (enhanced, t));
+    endif
+  endif
+
+  if (! isempty (axis_obj.xlabel))
+    t = get (axis_obj.xlabel);
+    angle = t.rotation;
+    colorspec = get_text_colorspec (t.color, mono);
+    if (isempty (t.string))
+      fprintf (plot_stream, "unset xlabel;\n");
+      fprintf (plot_stream, "unset x2label;\n");
+    else
+      [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string");
+      fontspec = create_fontspec (f, s, gnuplot_term);
+      if (strcmpi (axis_obj.xaxislocation, "top"))
+        fprintf (plot_stream, "set x2label \"%s\" %s %s %s",
+                 undo_string_escapes (tt), colorspec, fontspec,
+                 __do_enhanced_option__ (enhanced, t));
+      else
+        fprintf (plot_stream, "set xlabel \"%s\" %s %s %s",
+                 undo_string_escapes (tt), colorspec, fontspec,
+                 __do_enhanced_option__ (enhanced, t));
+      endif
+      fprintf (plot_stream, " rotate by %f;\n", angle);
+      if (strcmpi (axis_obj.xaxislocation, "top"))
+        fprintf (plot_stream, "unset xlabel;\n");
+      else
+        fprintf (plot_stream, "unset x2label;\n");
+      endif
+    endif
+  endif
+
+  if (! isempty (axis_obj.ylabel))
+    t = get (axis_obj.ylabel);
+    angle = t.rotation;
+    colorspec = get_text_colorspec (t.color, mono);
+    if (isempty (t.string))
+      fprintf (plot_stream, "unset ylabel;\n");
+      fprintf (plot_stream, "unset y2label;\n");
+    else
+      [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string");
+      fontspec = create_fontspec (f, s, gnuplot_term);
+      if (strcmpi (axis_obj.yaxislocation, "right"))
+        fprintf (plot_stream, "set y2label \"%s\" %s %s %s",
+                 undo_string_escapes (tt), colorspec, fontspec,
+                 __do_enhanced_option__ (enhanced, t));
+      else
+        fprintf (plot_stream, "set ylabel \"%s\" %s %s %s",
+                 undo_string_escapes (tt), colorspec, fontspec,
+                 __do_enhanced_option__ (enhanced, t));
+      endif
+      fprintf (plot_stream, " rotate by %f;\n", angle);
+      if (strcmpi (axis_obj.yaxislocation, "right"))
+        fprintf (plot_stream, "unset ylabel;\n");
+      else
+        fprintf (plot_stream, "unset y2label;\n");
+      endif
+    endif
+  endif
+
+  if (! isempty (axis_obj.zlabel))
+    t = get (axis_obj.zlabel);
+    angle = t.rotation;
+    colorspec = get_text_colorspec (t.color, mono);
+    if (isempty (t.string))
+      fputs (plot_stream, "unset zlabel;\n");
+    else
+      [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string");
+      fontspec = create_fontspec (f, s, gnuplot_term);
+      fprintf (plot_stream, "set zlabel \"%s\" %s %s %s",
+               undo_string_escapes (tt), colorspec, fontspec,
+               __do_enhanced_option__ (enhanced, t));
+      fprintf (plot_stream, " rotate by %f;\n", angle);
+    endif
+  endif
+
+  if (strcmpi (axis_obj.xaxislocation, "top"))
+    xaxisloc = "x2";
+    xaxisloc_using = "x2";
+  else
+    xaxisloc = "x";
+    xaxisloc_using = "x1";
+    if (strcmpi (axis_obj.xaxislocation, "zero"))
+      fputs (plot_stream, "set xzeroaxis;\n");
+    endif
+  endif
+  if (strcmpi (axis_obj.yaxislocation, "right"))
+    yaxisloc = "y2";
+    yaxisloc_using = "y2";
+  else
+    yaxisloc = "y";
+    yaxisloc_using = "y1";
+    if (strcmpi (axis_obj.yaxislocation, "zero"))
+      fputs (plot_stream, "set yzeroaxis;\n");
+    endif
+  endif
+
+  have_grid = false;
+
+  if (strcmpi (axis_obj.xgrid, "on"))
+    have_grid = true;
+    fprintf (plot_stream, "set grid %stics;\n", xaxisloc);
+  else
+    fprintf (plot_stream, "set grid no%stics;\n", xaxisloc);
+  endif
+
+  if (strcmpi (axis_obj.ygrid, "on"))
+    have_grid = true;
+    fprintf (plot_stream, "set grid %stics;\n", yaxisloc);
+  else
+    fprintf (plot_stream, "set grid no%stics;\n", yaxisloc);
+  endif
+
+  if (strcmpi (axis_obj.zgrid, "on"))
+    have_grid = true;
+    fputs (plot_stream, "set grid ztics;\n");
+  else
+    fputs (plot_stream, "set grid noztics;\n");
+  endif
+
+  if (strcmpi (axis_obj.xminorgrid, "on"))
+    have_grid = true;
+    if (strcmp (axis_obj.xscale, "log"))
+      m = 10;
+    else
+      m = 5;
+    endif
+    fprintf (plot_stream, "set m%stics %d;\n", xaxisloc, m);
+    fprintf (plot_stream, "set grid m%stics;\n", xaxisloc);
+  else
+    fprintf (plot_stream, "set grid nom%stics;\n", xaxisloc);
+  endif
+
+  if (strcmpi (axis_obj.yminorgrid, "on"))
+    have_grid = true;
+    if (strcmp (axis_obj.yscale, "log"))
+      m = 10;
+    else
+      m = 5;
+    endif
+    fprintf (plot_stream, "set m%stics %d;\n", yaxisloc, m);
+    fprintf (plot_stream, "set grid m%stics;\n", yaxisloc);
+  else
+    fprintf (plot_stream, "set grid nom%stics;\n", yaxisloc);
+  endif
+
+  if (strcmpi (axis_obj.zminorgrid, "on"))
+    have_grid = true;
+    if (strcmp (axis_obj.zscale, "log"))
+      m = 10;
+    else
+      m = 5;
+    endif
+    fprintf (plot_stream, "set mztics %d;\n", m);
+    fputs (plot_stream, "set grid mztics;\n");
+  else
+    fputs (plot_stream, "set grid nomztics;\n");
+  endif
+
+  ## The grid front/back/layerdefault option also controls the
+  ## appearance of tics, so it is used even if the grid is absent.
+  if (strcmpi (axis_obj.layer, "top"))
+    fputs (plot_stream, "set grid front;\n");
+    fputs (plot_stream, "set border front;\n");
+  else
+    fputs (plot_stream, "set grid layerdefault;\n");
+    ## FIXME: The gnuplot help says that "layerdefault" should work
+    ##        for set border too, but it fails for me with gnuplot 4.2.5.
+    ##        So, use "back" instead.
+    fputs (plot_stream, "set border back;\n");
+  endif
+
+  fprintf (plot_stream, "set grid linewidth %f, linewidth %f;\n",
+           axis_obj.linewidth, axis_obj.linewidth);
+
+  if (! have_grid)
+    fputs (plot_stream, "unset grid;\n");
+  endif
+
+  xlogscale = strcmpi (axis_obj.xscale, "log");
+  ylogscale = strcmpi (axis_obj.yscale, "log");
+  zlogscale = strcmpi (axis_obj.zscale, "log");
+
+  ## Detect logscale and negative lims
+  if (xlogscale && all (axis_obj.xlim < 0))
+    axis_obj.xsgn = -1;
+    if (strcmp (axis_obj.xdir, "reverse"))
+      axis_obj.xdir = "normal";
+    elseif (strcmp (axis_obj.xdir, "normal"))
+      axis_obj.xdir = "reverse";
+    endif
+    axis_obj.xtick = -flip (axis_obj.xtick);
+    axis_obj.xticklabel = flip (axis_obj.xticklabel);
+    axis_obj.xlim = -flip (axis_obj.xlim);
+  else
+    axis_obj.xsgn = 1;
+  endif
+  if (ylogscale && all (axis_obj.ylim < 0))
+    axis_obj.ysgn = -1;
+    if (strcmp (axis_obj.ydir, "reverse"))
+      axis_obj.ydir = "normal";
+    elseif (strcmp (axis_obj.ydir, "normal"))
+      axis_obj.ydir = "reverse";
+    endif
+    axis_obj.ytick = -flip (axis_obj.ytick);
+    axis_obj.yticklabel = flip (axis_obj.yticklabel);
+    axis_obj.ylim = -flip (axis_obj.ylim);
+  else
+    axis_obj.ysgn = 1;
+  endif
+  if (zlogscale && all (axis_obj.zlim < 0))
+    axis_obj.zsgn = -1;
+    if (strcmp (axis_obj.zdir, "reverse"))
+      axis_obj.zdir = "normal";
+    elseif (strcmp (axis_obj.zdir, "normal"))
+      axis_obj.zdir = "reverse";
+    endif
+    axis_obj.ztick = -flip (axis_obj.ztick);
+    axis_obj.zticklabel = flip (axis_obj.zticklabel);
+    axis_obj.zlim = -flip (axis_obj.zlim);
+  else
+    axis_obj.zsgn = 1;
+  endif
+
+  xlim = axis_obj.xlim;
+  ylim = axis_obj.ylim;
+  zlim = axis_obj.zlim;
+  clim = axis_obj.clim;
+
+  do_tics (axis_obj, plot_stream, ymirror, mono, gnuplot_term);
+
+  fputs (plot_stream, "unset logscale;\n");
+  if (xlogscale)
+    fprintf (plot_stream, "set logscale %s;\n", xaxisloc);
+  endif
+  if (ylogscale)
+    fprintf (plot_stream, "set logscale %s;\n", yaxisloc);
+  endif
+  if (zlogscale)
+    fputs (plot_stream, "set logscale z;\n");
+  endif
+
+  xautoscale = strcmpi (axis_obj.xlimmode, "auto");
+  yautoscale = strcmpi (axis_obj.ylimmode, "auto");
+  zautoscale = strcmpi (axis_obj.zlimmode, "auto");
+  cautoscale = strcmpi (axis_obj.climmode, "auto");
+  cdatadirect = false;
+  truecolor = false;
+
+  fputs (plot_stream, "set clip two;\n");
+
+  kids = axis_obj.children;
+  ## Remove the axis labels and title from the children, and
+  ## preserved the original order.
+  [jnk, k] = setdiff (kids, [axis_obj.xlabel; axis_obj.ylabel; ...
+                             axis_obj.zlabel; axis_obj.title]);
+  kids = kids(sort (k));
+
+  if (nd == 3)
+    fputs (plot_stream, "set parametric;\n");
+    fputs (plot_stream, "set style data lines;\n");
+    fputs (plot_stream, "set surface;\n");
+    fputs (plot_stream, "unset contour;\n");
+  endif
+
+  data_idx = 0;
+  data = cell ();
+  is_image_data = [];
+  hidden_removal = NaN;
+  view_map = false;
+
+  if (! cautoscale && clim(1) == clim(2))
+    clim(2)++;
+  endif
+  addedcmap = [];
+
+  ximg_data = {};
+  ximg_data_idx = 0;
+
+  while (! isempty (kids))
+
+    obj = get (kids(end));
+
+    if (isfield (obj, "xdata"))
+      obj.xdata = double (obj.xdata);
+    endif
+    if (isfield (obj, "ydata"))
+      obj.ydata = double (obj.ydata);
+    endif
+    if (isfield (obj, "zdata"))
+      obj.zdata = double (obj.zdata);
+    endif
+
+    if (isfield (obj, "units"))
+      units = obj.units;
+      unwind_protect
+        set (kids(end), "units", "data");
+        obj = get (kids(end));
+      unwind_protect_cleanup
+        set (kids(end), "units", units);
+      end_unwind_protect
+    endif
+    kids = kids(1:(end-1));
+
+    if (strcmp (obj.visible, "off"))
+      continue;
+    endif
+
+    if (xlogscale && isfield (obj, "xdata"))
+      obj.xdata = axis_obj.xsgn * obj.xdata;
+      obj.xdata(obj.xdata<=0) = NaN;
+    endif
+    if (ylogscale && isfield (obj, "ydata"))
+      obj.ydata = axis_obj.ysgn * obj.ydata;
+      obj.ydata(obj.ydata<=0) = NaN;
+    endif
+    if (zlogscale && isfield (obj, "zdata"))
+      obj.zdata = axis_obj.zsgn * obj.zdata;
+      obj.zdata(obj.zdata<=0) = NaN;
+    endif
+
+    ## Check for facecolor interpolation for surfaces.
+    doing_interp_color = ...
+       isfield (obj, "facecolor") && strcmp (obj.facecolor, "interp");
+
+    switch (obj.type)
+      case "image"
+        img_data = obj.cdata;
+        img_xdata = obj.xdata;
+        img_ydata = obj.ydata;
+
+        if (ndims (img_data) == 3)
+          truecolor = true;
+        elseif (strcmpi (obj.cdatamapping, "direct"))
+          cdatadirect = true;
+        endif
+        data_idx += 1;
+        is_image_data(data_idx) = true;
+        parametric(data_idx) = false;
+        have_cdata(data_idx) = false;
+        have_3d_patch(data_idx) = false;
+
+        if (img_xdata(2) < img_xdata(1))
+          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, 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, rows(img_data)-1];
+        endif
+
+        x_origin = min (img_xdata);
+        y_origin = min (img_ydata);
+
+        [y_dim, x_dim] = size (img_data(:,:,1));
+        if (x_dim > 1)
+          dx = abs (img_xdata(2)-img_xdata(1))/(x_dim-1);
+        else
+          x_dim = 2;
+          img_data = [img_data, img_data];
+          dx = abs (img_xdata(2)-img_xdata(1));
+          if (dx < 1)
+            ## Correct gnuplot string for 1-D images
+            dx       = 0.5;
+            x_origin = 0.75;
+          endif
+        endif
+        if (y_dim > 1)
+          dy = abs (img_ydata(2)-img_ydata(1))/(y_dim-1);
+        else
+          y_dim = 2;
+          img_data = [img_data; img_data];
+          dy = abs (img_ydata(2)-img_ydata(1));
+          if (dy < 1)
+            ## Correct gnuplot string for 1-D images
+            dy       = 0.5;
+            y_origin = 0.75;
+          endif
+        endif
+
+        if (ndims (img_data) == 3)
+          data{data_idx} = permute (img_data, [3, 1, 2])(:);
+          format = "1:2:3";
+          imagetype = "rgbimage";
+        else
+          data{data_idx} = img_data(:);
+          format = "1";
+          imagetype = "image";
+        endif
+
+        titlespec{data_idx} = "title \"\"";
+        usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx origin=(%.15g,%.15g) dx=%.15g dy=%.15g using %s",
+            x_dim, y_dim, x_origin, y_origin, dx, dy, format);
+        withclause{data_idx} = sprintf ("with %s;", imagetype);
+
+      case "line"
+        if (strcmp (obj.linestyle, "none")
+            && (! isfield (obj, "marker")
+                || (isfield (obj, "marker")
+                    && strcmp (obj.marker, "none"))))
+          continue;
+        endif
+        data_idx += 1;
+        is_image_data(data_idx) = false;
+        parametric(data_idx) = true;
+        have_cdata(data_idx) = false;
+        have_3d_patch(data_idx) = false;
+        if (isempty (obj.displayname))
+          titlespec{data_idx} = "title \"\"";
+        else
+          tmp = undo_string_escapes (
+                  __maybe_munge_text__ (enhanced, obj, "displayname")
+                );
+          titlespec{data_idx} = ['title "' tmp '"'];
+        endif
+        usingclause{data_idx} = sprintf ("record=%d", numel (obj.xdata));
+        errbars = "";
+        if (nd == 3)
+          xdat = obj.xdata(:);
+          ydat = obj.ydata(:);
+          if (! isempty (obj.zdata))
+            zdat = obj.zdata(:);
+          else
+            zdat = zeros (size (xdat));
+          endif
+          data{data_idx} = [xdat, ydat, zdat]';
+          usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)",
+                                           numel (xdat));
+          hidden_removal = false;
+          ## fputs (plot_stream, "set parametric;\n");
+        else
+          xdat = obj.xdata(:);
+          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);
+        endif
+
+        style = do_linestyle_command (obj, obj.color, data_idx, mono,
+                                      plot_stream, errbars);
+
+        withclause{data_idx} = sprintf ("with %s linestyle %d",
+                                        style{1}, data_idx);
+
+        if (length (style) > 1)
+          data_idx += 1;
+          is_image_data(data_idx) = is_image_data(data_idx - 1);
+          parametric(data_idx) = parametric(data_idx - 1);
+          have_cdata(data_idx) = have_cdata(data_idx - 1);
+          have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
+          titlespec{data_idx} = "title \"\"";
+          usingclause{data_idx} = usingclause{data_idx - 1};
+          data{data_idx} = data{data_idx - 1};
+          withclause{data_idx} = sprintf ("with %s linestyle %d",
+                                          style{2}, data_idx);
+        endif
+        if (length (style) > 2)
+          data_idx += 1;
+          is_image_data(data_idx) = is_image_data(data_idx - 1);
+          parametric(data_idx) = parametric(data_idx - 1);
+          have_cdata(data_idx) = have_cdata(data_idx - 1);
+          have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
+          titlespec{data_idx} = "title \"\"";
+          usingclause{data_idx} = usingclause{data_idx - 1};
+          data{data_idx} = data{data_idx - 1};
+          withclause{data_idx} = sprintf ("with %s linestyle %d",
+                                          style{3}, data_idx);
+        endif
+
+     case "patch"
+       cmap = parent_figure_obj.colormap;
+       [nr, nc] = size (obj.xdata);
+
+       if (! isempty (obj.cdata))
+         cdat = obj.cdata;
+         if (strcmpi (obj.cdatamapping, "direct"))
+           cdatadirect = true;
+         endif
+       else
+         cdat = [];
+       endif
+
+       data_3d_idx = NaN;
+       for i = 1:nc
+         xcol = obj.xdata(:,i);
+         ycol = obj.ydata(:,i);
+         if (nd == 3)
+           if (! isempty (obj.zdata))
+             zcol = obj.zdata(:,i);
+           else
+             zcol = zeros (size (xcol));
+           endif
+         endif
+
+         if (! isnan (xcol) && ! isnan (ycol))
+           ## Is the patch closed or not
+           if (strcmp (obj.facecolor, "none"))
+             hidden_removal = false;
+           else
+
+             if (isnan (hidden_removal))
+               hidden_removal = true;
+             endif
+             if (nd == 3)
+               if (numel (xcol) > 3)
+                 error ("__gnuplot_draw_axes__: gnuplot (as of v4.2) only supports 3-D filled triangular patches");
+               else
+                 if (isnan (data_3d_idx))
+                   data_idx += 1;
+                   data_3d_idx = data_idx;
+                   is_image_data(data_idx) = false;
+                   parametric(data_idx) = false;
+                   have_cdata(data_idx) = true;
+                   have_3d_patch(data_idx) = true;
+                   withclause{data_3d_idx} = sprintf ("with pm3d");
+                   usingclause{data_3d_idx} =  "using 1:2:3:4";
+                   data{data_3d_idx} = [];
+                 endif
+                 local_idx = data_3d_idx;
+                 ccdat = NaN;
+               endif
+             else
+               data_idx += 1;
+               local_idx = data_idx;
+               is_image_data(data_idx) = false;
+               parametric(data_idx) = false;
+               have_cdata(data_idx) = false;
+               have_3d_patch(data_idx) = false;
+             endif
+
+             if (i > 1 || isempty (obj.displayname))
+               titlespec{local_idx} = "title \"\"";
+             else
+               tmp = undo_string_escapes (
+                       __maybe_munge_text__ (enhanced, obj, "displayname")
+                     );
+               titlespec{local_idx} = ['title "' tmp '"'];
+             endif
+             if (isfield (obj, "facecolor"))
+               if ((strcmp (obj.facecolor, "flat")
+                   || strcmp (obj.facecolor, "interp"))
+                   && isfield (obj, "cdata"))
+                 if (ndims (obj.cdata) == 2
+                     && (columns (obj.cdata) == nc
+                         && (rows (obj.cdata) == 1
+                             || rows (obj.cdata) == 3)))
+                   ccol = cdat(:, i);
+                 elseif (ndims (obj.cdata) == 2
+                     && (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]);
+                 else
+                   ccol = cdat;
+                 endif
+                 if (strcmp (obj.facecolor, "flat"))
+                   if (isequal (size (ccol), [1, 3]))
+                     ## RGB Triplet
+                     color = ccol;
+                   elseif (nd == 3 && numel (xcol) == 3)
+                     ccdat = ccol;
+                   else
+                     if (cdatadirect)
+                       r = round (ccol);
+                     else
+                       r = 1 + round ((rows (cmap) - 1)
+                                      * (ccol - clim(1))/(clim(2) - clim(1)));
+                     endif
+                     r = max (1, min (r, rows (cmap)));
+                     color = cmap(r, :);
+                   endif
+                 elseif (strcmp (obj.facecolor, "interp"))
+                   if (nd == 3 && numel (xcol) == 3)
+                     ccdat = ccol;
+                     if (! isvector (ccdat))
+                       tmp = rows (cmap) + rows (addedcmap) + ...
+                            [1 : rows(ccdat)];
+                       addedcmap = [addedcmap; ccdat];
+                       ccdat = tmp(:);
+                     else
+                       ccdat = ccdat(:);
+                     endif
+                   else
+                     if (sum (diff (ccol)))
+                       warning ("\"interp\" not supported, using 1st entry of cdata");
+                     endif
+                     if (cdatadirect)
+                       r = round (ccol);
+                     else
+                       r = 1 + round ((rows (cmap) - 1)
+                                      * (ccol - clim(1))/(clim(2) - clim(1)));
+                     endif
+                     r = max (1, min (r, rows (cmap)));
+                     color = cmap(r(1),:);
+                   endif
+                 endif
+               elseif (isnumeric (obj.facecolor))
+                 color = obj.facecolor;
+               else
+                 color = [0, 1, 0];
+               endif
+             else
+               color = [0, 1, 0];
+             endif
+
+             if (nd == 3 && numel (xcol) == 3)
+               if (isnan (ccdat))
+                 ccdat = (rows (cmap) + rows (addedcmap) + 1) * ones(3, 1);
+                 addedcmap = [addedcmap; reshape(color, 1, 3)];
+               elseif (numel (ccdat) <= 1)
+                 ccdat = zcol;
+               endif
+               data{data_3d_idx} = [data{data_3d_idx}, ...
+                                    [[xcol; xcol(end)], [ycol; ycol(end)], ...
+                                    [zcol; zcol(end)], [ccdat; ccdat(end)]]'];
+             else
+               if (mono)
+                 colorspec = "";
+               elseif (__gnuplot_has_feature__ ("transparent_patches")
+                       && isscalar (obj.facealpha))
+                 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\" fillstyle transparent solid %f",
+                                      round (255*color), obj.facealpha);
+               else
+                 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
+                                      round (255*color));
+               endif
+
+               withclause{data_idx} = sprintf ("with filledcurve %s",
+                                             colorspec);
+               data{data_idx} = [xcol, ycol]';
+               usingclause{data_idx} = sprintf ("record=%d using ($1):($2)",
+                                                numel (xcol));
+             endif
+           endif
+         endif
+
+         ## patch outline
+         if (!(strcmp (obj.edgecolor, "none")
+                && (strcmp (obj.marker, "none")
+                    || (strcmp (obj.markeredgecolor, "none")
+                        && strcmp (obj.markerfacecolor, "none")))))
+
+           data_idx += 1;
+           is_image_data(data_idx) = false;
+           parametric(data_idx) = false;
+           have_cdata(data_idx) = false;
+           have_3d_patch(data_idx) = false;
+           titlespec{data_idx} = "title \"\"";
+           usingclause{data_idx} = sprintf ("record=%d", numel (obj.xdata));
+
+           if (isfield (obj, "markersize"))
+             mdat = obj.markersize / 3;
+           endif
+
+           if (isfield (obj, "edgecolor"))
+             ## FIXME: This is the wrong thing to do as edgecolor,
+             ## markeredgecolor and markerfacecolor can have different values
+             ## and we should treat them seperately. However, the code below
+             ## allows the scatter functions to work as expected, where only
+             ## one of these values is set.
+             if (strcmp (obj.edgecolor, "none"))
+               if (strcmp (obj.markeredgecolor, "none"))
+                 ec = obj.markerfacecolor;
+               else
+                 ec = obj.markeredgecolor;
+               endif
+             else
+               ec = obj.edgecolor;
+             endif
+
+             if ((strcmp (ec, "flat")
+                  || strcmp (ec, "interp"))
+                 && isfield (obj, "cdata"))
+               if (ndims (obj.cdata) == 2
+                   && (columns (obj.cdata) == nc
+                       && (rows (obj.cdata) == 1
+                           || rows (obj.cdata) == 3)))
+                 ccol = cdat(:, i);
+               elseif (ndims (obj.cdata) == 2
+                       && (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]);
+               else
+                 ccol = cdat;
+               endif
+               if (strcmp (ec, "flat"))
+                 if (numel (ccol) == 3)
+                   color = ccol;
+                 else
+                   if (isscalar (ccol))
+                     ccol = repmat (ccol, numel (xcol), 1);
+                   endif
+                   color = "flat";
+                   have_cdata(data_idx) = true;
+                 endif
+               elseif (strcmp (ec, "interp"))
+                 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);
+                   endif
+                   color = "interp";
+                   have_cdata(data_idx) = true;
+                 endif
+               endif
+             elseif (isnumeric (ec))
+               color = ec;
+             else
+               color = [0, 0, 0];
+             endif
+           else
+             color = [0, 0, 0];
+           endif
+
+           if (isfield (obj, "linestyle"))
+             switch (obj.linestyle)
+               case "-"
+                 lt = "lt 1";
+               case "--"
+                 lt = "lt 2";
+               case ":"
+                 lt = "lt 3";
+               case "-."
+                 lt = "lt 6";
+               case "none"
+                 lt = "";
+               otherwise
+                 lt = "";
+             endswitch
+           else
+             lt = "";
+           endif
+
+           if (isfield (obj, "linewidth"))
+             lw = sprintf ("linewidth %f", obj.linewidth);
+           else
+             lw = "";
+           endif
+
+           [pt, pt2, obj] = gnuplot_pointtype (obj);
+           if (! isempty (pt))
+             pt = sprintf ("pointtype %s", pt);
+           endif
+           if (! isempty (pt2))
+             pt2 = sprintf ("pointtype %s", pt2);
+           endif
+
+           if (mono)
+             colorspec = "";
+           else
+             if (ischar (color))
+               colorspec = "palette";
+             else
+               colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
+                                    round (255*color));
+             endif
+           endif
+
+           sidx = 1;
+           if (isempty (lt))
+             style = "";
+           else
+             style = "lines";
+           endif
+           tmpwith = {};
+
+           facesame = true;
+           if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor")
+               && ! strcmp (obj.markerfacecolor, "none"))
+             if (strcmp (obj.markerfacecolor, "auto")
+                 || ! isnumeric (obj.markerfacecolor)
+                 || (isnumeric (obj.markerfacecolor)
+                     && isequal (color, obj.markerfacecolor)))
+               style = [style "points"];
+               if (isfield (obj, "markersize"))
+                 if (length (mdat) == nc)
+                   m = mdat(i);
+                 else
+                   m = mdat;
+                 endif
+                 ps = sprintf ("pointsize %f", m / 3);
+               else
+                 ps = "";
+               endif
+
+               tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
+                                        style, lw, pt2, lt, ps,
+                                        colorspec);
+             else
+               facesame = false;
+               if (! isempty (style))
+                 tmpwith{sidx} = sprintf ("with %s %s %s %s",
+                                          style, lw, lt,
+                                          colorspec);
+                 sidx += 1;
+               endif
+               if (isnumeric (obj.markerfacecolor) && ! mono)
+                 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
+                                      round (255*obj.markerfacecolor));
+               endif
+               style = "points";
+               if (isfield (obj, "markersize"))
+                 if (length (mdat) == nc)
+                   m = mdat(i);
+                 else
+                   m = mdat;
+                 endif
+                 ps = sprintf ("pointsize %f", m / 3);
+               else
+                 ps = "";
+               endif
+               tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
+                                        style, lw, pt2, lt, ps,
+                                        colorspec);
+             endif
+           endif
+
+           if (isfield (obj, "markeredgecolor")
+               && ! strcmp (obj.markeredgecolor, "none"))
+             if (facesame && ! isempty (pt)
+                 && (strcmp (obj.markeredgecolor, "auto")
+                     || ! isnumeric (obj.markeredgecolor)
+                     || (isnumeric (obj.markeredgecolor)
+                         && isequal (color, obj.markeredgecolor))))
+               if (sidx == 1 && ((length (style) == 5
+                        && strncmp (style, "lines", 5))
+                       || isempty (style)))
+                 style = [style, "points"];
+                 if (isfield (obj, "markersize"))
+                   if (length (mdat) == nc)
+                     m = mdat(i);
+                   else
+                     m = mdat;
+                   endif
+                   ps = sprintf ("pointsize %f", m / 3);
+                 else
+                   ps = "";
+                 endif
+                 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
+                                          style, lw, pt, lt, ps,
+                                          colorspec);
+               endif
+             else
+               if (! isempty (style))
+                 if (length (tmpwith) < sidx || isempty (tmpwith{sidx}))
+                   tmpwith{sidx} = sprintf ("with %s %s %s %s",
+                                            style, lw, lt,
+                                            colorspec);
+                 endif
+                 sidx += 1;
+               endif
+
+               if (! isempty (pt))
+                 if (! mono)
+                   if (strcmp (obj.markeredgecolor, "auto"))
+                     colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
+                                          round (255*color));
+                   elseif (isnumeric (obj.markeredgecolor) && ! mono)
+                     colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
+                                          round (255*obj.markeredgecolor));
+                   endif
+                 endif
+                 style = "points";
+                 if (isfield (obj, "markersize"))
+                   if (length (mdat) == nc)
+                     m = mdat(i);
+                   else
+                     m = mdat;
+                   endif
+                   ps = sprintf ("pointsize %f", m / 3);
+                 else
+                   ps = "";
+                 endif
+                 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
+                                          style, lw, pt, lt, ps,
+                                          colorspec);
+               endif
+             endif
+           endif
+
+           if (isempty (tmpwith))
+             withclause{data_idx} = sprintf ("with %s %s %s %s %s",
+                                             style, lw, pt, lt,
+                                             colorspec);
+           else
+             withclause{data_idx} = tmpwith{1};
+           endif
+           if (nd == 3)
+             if (ischar (color))
+               if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol))
+                 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ...
+                                   [zcol; zcol(1)], [ccol; ccol(1)]]';
+               else
+                 data{data_idx} = [xcol, ycol, zcol, ccol]';
+               endif
+               usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3):($4)", columns (data{data_idx}));
+             else
+               if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol))
+                 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ...
+                                   [zcol; zcol(1)]]';
+               else
+                 data{data_idx} = [xcol, ycol, zcol]';
+               endif
+               usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", columns (data{data_idx}));
+             endif
+           else
+             if (ischar (color))
+               if (! isnan (xcol) && ! isnan (ycol))
+                 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ...
+                                   [ccol; ccol(1)]]';
+               else
+                 data{data_idx} = [xcol, ycol, ccol]';
+               endif
+               usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", columns (data{data_idx}));
+             else
+               if (! isnan (xcol) && ! isnan (ycol))
+                 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)]]';
+               else
+                 data{data_idx} = [xcol, ycol]';
+               endif
+               usingclause{data_idx} = sprintf ("record=%d using ($1):($2)", columns (data{data_idx}));
+             endif
+           endif
+
+           if (length (tmpwith) > 1)
+             data_idx += 1;
+             is_image_data(data_idx) = is_image_data(data_idx - 1);
+             parametric(data_idx) = parametric(data_idx - 1);
+             have_cdata(data_idx) = have_cdata(data_idx - 1);
+             have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
+             titlespec{data_idx} = "title \"\"";
+             usingclause{data_idx} = usingclause{data_idx - 1};
+             data{data_idx} = data{data_idx - 1};
+             withclause{data_idx} = tmpwith{2};
+           endif
+           if (length (tmpwith) > 2)
+             data_idx += 1;
+             is_image_data(data_idx) = is_image_data(data_idx - 1);
+             parametric(data_idx) = parametric(data_idx - 1);
+             have_cdata(data_idx) = have_cdata(data_idx - 1);
+             have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
+             titlespec{data_idx} = "title \"\"";
+             usingclause{data_idx} = usingclause{data_idx - 1};
+             data{data_idx} = data{data_idx - 1};
+             withclause{data_idx} = tmpwith{3};
+           endif
+         endif
+       endfor
+
+      case "surface"
+        view_map = true;
+        if (! (strcmp (obj.edgecolor, "none")
+               && strcmp (obj.facecolor, "none")))
+          data_idx += 1;
+          is_image_data(data_idx) = false;
+          parametric(data_idx) = false;
+          have_cdata(data_idx) = true;
+          have_3d_patch(data_idx) = false;
+          style = do_linestyle_command (obj, obj.edgecolor,
+                                        data_idx, mono,
+                                        plot_stream);
+
+          if (isempty (obj.displayname))
+            titlespec{data_idx} = "title \"\"";
+          else
+            tmp = undo_string_escapes (
+                    __maybe_munge_text__ (enhanced, obj, "displayname")
+                  );
+            titlespec{data_idx} = ['title "' tmp '"'];
+          endif
+          withclause{data_idx} = sprintf ("with pm3d linestyle %d",
+                                          data_idx);
+          withpm3d = true;
+          pm3didx = data_idx;
+
+          xdat = obj.xdata;
+          ydat = obj.ydata;
+          zdat = obj.zdata;
+          cdat = obj.cdata;
+
+          err = false;
+          if (! size_equal (zdat, cdat))
+            err = true;
+          endif
+          if (isvector (xdat) && isvector (ydat) && ismatrix (zdat))
+            if (rows (zdat) == length (ydat)
+                && columns (zdat) == length (xdat))
+              [xdat, ydat] = meshgrid (xdat, ydat);
+            else
+              err = true;
+            endif
+          elseif (ismatrix (xdat) && ismatrix (ydat) && ismatrix (zdat))
+            if (! size_equal (xdat, ydat, zdat))
+              err = true;
+            endif
+          else
+            err = true;
+          endif
+          if (err)
+            error ("__gnuplot_draw_axes__: invalid grid data");
+          endif
+          xlen = columns (zdat);
+          ylen = rows (zdat);
+          if (xlen == columns (xdat) && xlen == columns (ydat)
+              && ylen == rows (xdat) && ylen == rows (ydat))
+            len = 4 * xlen;
+            zz = zeros (ylen, len);
+            k = 1;
+            for kk = 1:4:len
+              zz(:,kk)   = xdat(:,k);
+              zz(:,kk+1) = ydat(:,k);
+              zz(:,kk+2) = zdat(:,k);
+              zz(:,kk+3) = cdat(:,k);
+              k += 1;
+            endfor
+            data{data_idx} = zz.';
+          endif
+
+          if (doing_interp_color)
+            interp_str = "interpolate 0, 0";
+          else
+            ## No interpolation of facecolors.
+            interp_str = "";
+          endif
+          usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3):($4)", ylen, xlen);
+
+          flat_interp_face = (strcmp (obj.facecolor, "flat")
+                              || strcmp (obj.facecolor, "interp"));
+          flat_interp_edge = (strcmp (obj.edgecolor, "flat")
+                              || strcmp (obj.edgecolor, "interp"));
+
+          facecolor_none_or_white = (strcmp (obj.facecolor, "none")
+                                     || (isnumeric (obj.facecolor)
+                                         && all (obj.facecolor == 1)));
+          hidden_removal = false;
+          fputs (plot_stream, "set style increment default;\n");
+          if (flat_interp_edge && facecolor_none_or_white)
+            withpm3d = false;
+            withclause{data_idx} = sprintf ("with %s palette", style{1});
+            fputs (plot_stream, "unset pm3d\n");
+            if (all (obj.facecolor == 1))
+              hidden_removal = true;
+            endif
+          elseif (facecolor_none_or_white)
+            if (all (obj.facecolor == 1))
+              hidden_removal = true;
+            endif
+            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);
+            fputs (plot_stream, "unset pm3d\n");
+          endif
+
+          if (doing_interp_color)
+            ## "depthorder" interferes with interpolation of colors.
+            dord = "scansautomatic";
+          else
+            dord = "depthorder";
+          endif
+
+          if (flat_interp_face && strcmp (obj.edgecolor, "flat"))
+            fprintf (plot_stream,
+                     "set pm3d explicit at s %s %s corners2color c3;\n",
+                     interp_str, dord);
+          elseif (! facecolor_none_or_white)
+            if (strcmp (obj.edgecolor, "none"))
+              if (__gnuplot_has_feature__ ("transparent_surface")
+                  && isscalar (obj.facealpha))
+                fprintf (plot_stream,
+                         "set style fill transparent solid %f;\n",
+                         obj.facealpha);
+              endif
+              fprintf (plot_stream,
+                       "set pm3d explicit at s %s corners2color c3;\n",
+                       interp_str, dord);
+            else
+              fprintf (plot_stream,
+                       "set pm3d explicit at s hidden3d %d %s %s corners2color c3;\n",
+                       data_idx, interp_str, dord);
+
+              if (__gnuplot_has_feature__ ("transparent_surface")
+                  && isscalar (obj.facealpha))
+                fprintf (plot_stream,
+                         "set style fill transparent solid %f;\n",
+                         obj.facealpha);
+              endif
+            endif
+          endif
+
+          zz = [];
+          if (length (style) > 1)
+            len = 3 * xlen;
+            zz = zeros (ylen, len);
+            k = 1;
+            for kk = 1:3:len
+              zz(:,kk)   = xdat(:,k);
+              zz(:,kk+1) = ydat(:,k);
+              zz(:,kk+2) = zdat(:,k);
+              k += 1;
+            endfor
+            zz = zz.';
+
+            data_idx += 1;
+            is_image_data(data_idx) = is_image_data(data_idx - 1);
+            parametric(data_idx) = parametric(data_idx - 1);
+            have_cdata(data_idx) = false;
+            have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
+            titlespec{data_idx} = "title \"\"";
+            usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen);
+            data{data_idx} = zz;
+            withclause{data_idx} = sprintf ("with %s linestyle %d",
+                                            style{2}, data_idx);
+
+          endif
+          if (length (style) > 2)
+            data_idx += 1;
+            is_image_data(data_idx) = is_image_data(data_idx - 1);
+            parametric(data_idx) = parametric(data_idx - 1);
+            have_cdata(data_idx) = false;
+            have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
+            titlespec{data_idx} = "title \"\"";
+            usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen);
+            data{data_idx} = zz;
+            withclause{data_idx} = sprintf ("with %s linestyle %d",
+                                            style{3}, data_idx);
+          endif
+          if (withpm3d && strcmp (style{1}, "linespoints"))
+            if (isempty (zz))
+              len = 3 * xlen;
+              zz = zeros (ylen, len);
+              k = 1;
+              for kk = 1:3:len
+                zz(:,kk)   = xdat(:,k);
+                zz(:,kk+1) = ydat(:,k);
+                zz(:,kk+2) = zdat(:,k);
+                k += 1;
+              endfor
+              zz = zz.';
+            endif
+            data_idx += 1;
+            is_image_data(data_idx) = is_image_data(data_idx - 1);
+            parametric(data_idx) = parametric(data_idx - 1);
+            have_cdata(data_idx) = false;
+            have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
+            titlespec{data_idx} = "title \"\"";
+            usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen);
+            data{data_idx} = zz;
+            withclause{data_idx} = sprintf ("with points linestyle %d",
+                                            pm3didx);
+          endif
+        endif
+
+      case "text"
+        [label, f, s] = __maybe_munge_text__ (enhanced, obj, "string");
+        fontspec = create_fontspec (f, s, gnuplot_term);
+        lpos = obj.position;
+        halign = obj.horizontalalignment;
+        valign = obj.verticalalignment;
+        angle = obj.rotation;
+        units = obj.units;
+        color = obj.color;
+        if (strcmpi (units, "normalized"))
+          units = "graph";
+        elseif (strcmp (axis_obj.yaxislocation, "right")
+                && strcmp (units, "data"))
+          units = "second";
+        else
+          units = "";
+        endif
+
+        if (isnumeric (color))
+          colorspec = get_text_colorspec (color, mono);
+        endif
+
+        if (ischar (obj.string))
+          num_lines = rows (obj.string);
+          num_lines += numel (strfind (obj.string, "\n"));
+        else
+          num_lines = numel (obj.string);
+        endif
+        switch (valign)
+          ## Text offset in characters. Relies on gnuplot for font metrics.
+          case "top"
+            dy = -0.5;
+          case "cap"
+            dy = -0.5;
+          case "middle"
+            dy = 0.5 * (num_lines - 1);
+          case "baseline"
+            dy = 0.5 + (num_lines - 1);
+          case "bottom"
+            dy = 0.5 + (num_lines - 1);
+        endswitch
+        ## 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];
+
+        ## FIXME: Multiline text produced the gnuplot
+        ##        "warning: ft_render: skipping glyph"
+        if (nd == 3)
+          ## This produces the desired vertical alignment in 3D.
+          fprintf (plot_stream,
+                   "set label \"%s\" at %s %.15e,%.15e,%.15e %s rotate by %f offset character %f,%f %s %s front %s;\n",
+                   undo_string_escapes (label), units, lpos(1),
+                   lpos(2), lpos(3), halign, angle, dx_and_dy, fontspec,
+                   __do_enhanced_option__ (enhanced, obj), colorspec);
+        else
+          fprintf (plot_stream,
+                   "set label \"%s\" at %s %.15e,%.15e %s rotate by %f offset character %f,%f %s %s front %s;\n",
+                   undo_string_escapes (label), units,
+                   lpos(1), lpos(2), halign, angle, dx_and_dy, fontspec,
+                   __do_enhanced_option__ (enhanced, obj), colorspec);
+        endif
+
+      case "hggroup"
+        ## Push group children into the kid list.
+        if (isempty (kids))
+          kids = obj.children;
+        elseif (! isempty (obj.children))
+          kids = [kids; obj.children];
+        endif
+
+      otherwise
+        error ("__gnuplot_draw_axes__: unknown object class, %s",
+               obj.type);
+    endswitch
+
+  endwhile
+
+  ## This is need to prevent warnings for rotations in 3D plots, while
+  ## allowing colorbars with contours.
+  if (nd == 2 || (data_idx > 1 && ! view_map))
+    fputs (plot_stream, "set pm3d implicit;\n");
+  else
+    fputs (plot_stream, "set pm3d explicit;\n");
+  endif
+
+  if (isnan (hidden_removal) || hidden_removal)
+    fputs (plot_stream, "set hidden3d;\n");
+  else
+    fputs (plot_stream, "unset hidden3d;\n");
+  endif
+
+  have_data = (! (isempty (data) || all (cellfun ("isempty", data))));
+
+  ## Note we don't use the [xy]2range of gnuplot as we don't use the
+  ## dual axis plotting features of gnuplot.
+  if (isempty (xlim))
+    return;
+  endif
+  if (strcmpi (axis_obj.xdir, "reverse"))
+    xlim = flip (xlim);
+  endif
+
+  fprintf (plot_stream, "set xrange [%.15e:%.15e];\n", xlim);
+  if (strcmpi (axis_obj.xaxislocation, "top"))
+    fprintf (plot_stream, "set x2range [%.15e:%.15e];\n", xlim);
+  endif
+
+  if (isempty (ylim))
+    return;
+  endif
+  if (strcmpi (axis_obj.ydir, "reverse"))
+    ylim = flip (ylim);
+  endif
+  fprintf (plot_stream, "set yrange [%.15e:%.15e];\n", ylim);
+  if (strcmpi (axis_obj.yaxislocation, "right"))
+    fprintf (plot_stream, "set y2range [%.15e:%.15e];\n", ylim);
+  endif
+
+  if (nd == 3)
+    if (isempty (zlim))
+      return;
+    endif
+    if (strcmpi (axis_obj.zdir, "reverse"))
+      zlim = flip (zlim);
+    endif
+    fprintf (plot_stream, "set zrange [%.15e:%.15e];\n", zlim);
+  endif
+
+  cmap = parent_figure_obj.colormap;
+  cmap_sz = rows (cmap);
+  if (! any (isinf (clim)))
+    if (truecolor || ! cdatadirect)
+      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 [%.15e:%.15e];\n",
+                 clim(1), clim(2) * (cmap_sz + rows (addedcmap)) / cmap_sz);
+      else
+        fprintf (plot_stream, "set cbrange [%.15e:%.15e];\n", clim);
+      endif
+    else
+      fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz +
+               rows (addedcmap));
+    endif
+  endif
+
+  if (strcmpi (axis_obj.box, "on"))
+    if (nd == 3)
+      fputs (plot_stream, "set border 4095;\n");
+    else
+      fputs (plot_stream, "set border 431;\n");
+    endif
+  else
+    if (nd == 3)
+      fputs (plot_stream, "set border 895;\n");
+    elseif (! isempty (axis_obj.ytick))
+      if (strcmpi (axis_obj.yaxislocation, "right"))
+        fprintf (plot_stream, "unset ytics; set y2tics %s nomirror\n",
+                 axis_obj.tickdir);
+        if (strcmpi (axis_obj.xaxislocation, "top"))
+          maybe_do_x2tick_mirror (plot_stream, axis_obj)
+          fputs (plot_stream, "set border 12;\n");
+        elseif (strcmpi (axis_obj.xaxislocation, "bottom"))
+          maybe_do_xtick_mirror (plot_stream, axis_obj)
+          fputs (plot_stream, "set border 9;\n");
+        else # xaxislocation == zero
+          fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n",
+                   axis_obj.tickdir);
+          fputs (plot_stream, "set border 8;\n");
+          fprintf (plot_stream, "set xzeroaxis lt -1 lw %f;\n",
+                   axis_obj.linewidth);
+        endif
+      elseif (strcmpi (axis_obj.yaxislocation, "left"))
+        fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n",
+                 axis_obj.tickdir);
+        if (strcmpi (axis_obj.xaxislocation, "top"))
+          maybe_do_x2tick_mirror (plot_stream, axis_obj)
+          fputs (plot_stream, "set border 6;\n");
+        elseif (strcmpi (axis_obj.xaxislocation, "bottom"))
+          maybe_do_xtick_mirror (plot_stream, axis_obj)
+          fputs (plot_stream, "set border 3;\n");
+        else # xaxislocation == zero
+          maybe_do_xtick_mirror (plot_stream, axis_obj)
+          fputs (plot_stream, "set border 2;\n");
+          fprintf (plot_stream, "set xzeroaxis lt -1 lw %f;\n",
+                   axis_obj.linewidth);
+        endif
+      else # yaxislocation == zero
+        fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n",
+                 axis_obj.tickdir);
+        if (strcmpi (axis_obj.xaxislocation, "top"))
+          maybe_do_x2tick_mirror (plot_stream, axis_obj)
+          fputs (plot_stream, "set border 4;\n");
+        elseif (strcmpi (axis_obj.xaxislocation, "bottom"))
+          maybe_do_xtick_mirror (plot_stream, axis_obj)
+          fputs (plot_stream, "set border 1;\n");
+        else # xaxislocation == zero
+          maybe_do_xtick_mirror (plot_stream, axis_obj)
+          fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n",
+                   axis_obj.tickdir);
+          fputs (plot_stream, "unset border;\n");
+          fprintf (plot_stream, "set xzeroaxis lt -1 lw %f;\n",
+                   axis_obj.linewidth);
+        endif
+        fprintf (plot_stream, "set yzeroaxis lt -1 lw %f;\n",
+                 axis_obj.linewidth);
+      endif
+    endif
+  endif
+
+  if (strcmpi (axis_obj.visible, "off"))
+    fputs (plot_stream, "unset border; unset tics\n");
+  else
+    fprintf (plot_stream, "set border lw %f;\n", axis_obj.linewidth);
+  endif
+
+  if (! isempty (hlgnd) && ! isempty (hlgnd.children)
+      && any (strcmpi (get (hlgnd.children, "visible"), "on")))
+    if (strcmpi (hlgnd.box, "on"))
+      box = "box";
+    else
+      box = "nobox";
+    endif
+    if (strcmpi (hlgnd.orientation, "vertical"))
+      horzvert = "vertical";
+    else
+      horzvert = "horizontal";
+    endif
+    if (strcmpi (hlgnd.textposition, "right"))
+      reverse = "reverse";
+    else
+      reverse = "noreverse";
+    endif
+    inout = "inside";
+    keypos = hlgnd.location;
+    if (ischar (keypos))
+      keypos = lower (keypos);
+      keyout = strfind (keypos, "outside");
+      if (! isempty (keyout))
+        inout = "outside";
+        keypos = keypos(1:keyout-1);
+      endif
+    endif
+    switch (keypos)
+      case "north"
+        pos = "center top";
+      case "south"
+        pos = "center bottom";
+      case "east"
+        pos = "right center";
+      case "west"
+        pos = "left center";
+      case "northeast"
+        pos = "right top";
+      case "northwest"
+        pos = "left top";
+      case "southeast"
+        pos = "right bottom";
+      case "southwest"
+        pos = "left bottom";
+      case "best"
+        pos = "";
+        warning ("legend: 'Best' not yet implemented for location specifier.\n");
+        ## Least conflict with data in plot.
+        ## Least unused space outside plot.
+      otherwise
+        pos = "";
+    endswitch
+    if (__gnuplot_has_feature__ ("key_has_font_properties"))
+      [fontname, fontsize] = get_fontname_and_size (hlgnd);
+      fontspacespec = [ create_spacingspec(fontname, fontsize, gnuplot_term),...
+                        create_fontspec(fontname, fontsize, gnuplot_term) ];
+    else
+      fontspacespec = "";
+    endif
+    textcolors = get (findobj (hlgnd.children, "type", "text"), "color");
+    if (iscell (textcolors))
+      textcolors = cell2mat (textcolors);
+      textcolors = unique (textcolors, "rows");
+    endif
+    if (rows (textcolors) > 1)
+      ## Gnuplot is unable to assign arbitrary colors to each text entry
+      ## for the key/legend.  But, the text color can be set to match the
+      ## color of the plot object.
+      colorspec = "textcolor variable";
+    else
+      colorspec = get_text_colorspec (textcolors, mono);
+    endif
+    fprintf (plot_stream, "set key %s %s;\nset key %s %s %s %s %s %s;\n",
+             inout, pos, box, reverse, horzvert, fontspacespec, colorspec,
+             __do_enhanced_option__ (enhanced, hlgnd));
+  else
+    fputs (plot_stream, "unset key;\n");
+  endif
+  fputs (plot_stream, "set style data lines;\n");
+
+  cmap = [cmap; addedcmap];
+  cmap_sz += rows (addedcmap);
+  if (mono == false && length (cmap) > 0)
+    fprintf (plot_stream,
+             "set palette positive color model RGB maxcolors %i;\n",
+             cmap_sz);
+    fprintf (plot_stream,
+             "set palette file \"-\" binary record=%d using 1:2:3:4;\n",
+             cmap_sz);
+    fwrite (plot_stream, [1:cmap_sz; cmap.'], "float32");
+    fwrite (plot_stream, "\n");
+  endif
+
+  fputs (plot_stream, "unset colorbox;\n");
+
+  if (have_data)
+    if (nd == 2)
+      plot_cmd = "plot";
+    else
+      plot_cmd = "splot";
+      rot_x = 90 - axis_obj.view(2);
+      rot_z = axis_obj.view(1);
+      while (rot_z < 0)
+        rot_z += 360;
+      endwhile
+      fputs (plot_stream, "set ticslevel 0;\n");
+      if (view_map && rot_x == 0 && rot_z == 0)
+        fputs (plot_stream, "set view map;\n");
+      else
+        fprintf (plot_stream, "set view %.15g, %.15g;\n", rot_x, rot_z);
+      endif
+    endif
+    if (have_3d_patch (1))
+      fputs (plot_stream, "set pm3d depthorder\n");
+      fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd,
+               usingclause{1}, titlespec{1}, withclause{1});
+    elseif (is_image_data (1))
+      if (numel (is_image_data) > 1 && is_image_data(2))
+        ## Remove terminating semicolon
+        n = max (strfind (withclause{1}, ";"));
+        if (! isempty (n))
+          withclause{1} = withclause{1}(1:n-1);
+        endif
+      endif
+      fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd,
+               usingclause{1}, titlespec{1}, withclause{1});
+    else
+      fprintf (plot_stream, "%s \"-\" binary format='%%float64' %s %s %s \\\n",
+               plot_cmd, usingclause{1}, titlespec{1}, withclause{1});
+    endif
+    for i = 2:data_idx
+      if (have_3d_patch (i))
+        fprintf (plot_stream, ", \"-\" %s %s %s \\\n",
+                 usingclause{i}, titlespec{i}, withclause{i});
+      elseif (is_image_data (i))
+        if (! is_image_data (i-1))
+          fputs (plot_stream, "; ");
+          if (bg_is_set)
+            fputs (plot_stream, "unset obj 1; \\\n");
+            bg_is_set = false;
+          endif
+          if (fg_is_set)
+            fputs (plot_stream, "unset obj 2; \\\n");
+            fg_is_set = false;
+          endif
+          if (numel (is_image_data) > i && is_image_data(i+1))
+            ## Remove terminating semicolon
+            n = max (strfind (withclause{i}, ";"));
+            if (! isempty (n))
+              withclause{i} = withclause{i}(1:n-1);
+            endif
+          endif
+          fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd,
+                   usingclause{i}, titlespec{i}, withclause{i});
+        else
+          ## For consecutive images continue with the same plot command
+          fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", ",",
+                   usingclause{i}, titlespec{i}, withclause{i});
+        endif
+      elseif (is_image_data (i-1))
+        if (bg_is_set)
+          fputs (plot_stream, "unset obj 1; \\\n");
+          bg_is_set = false;
+        endif
+        if (fg_is_set)
+          fputs (plot_stream, "unset obj 2; \\\n");
+          fg_is_set = false;
+        endif
+        fprintf (plot_stream,"%s \"-\" binary format='%%float64' %s %s %s \\\n",
+                 plot_cmd, usingclause{i}, titlespec{i}, withclause{i});
+      else
+        fprintf (plot_stream, ", \"-\" binary format='%%float64' %s %s %s \\\n",
+                 usingclause{i}, titlespec{i}, withclause{i});
+      endif
+    endfor
+    fputs (plot_stream, ";\n");
+    for i = 1:data_idx
+      if (have_3d_patch (i))
+        ## 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})
+          if (j != 1)
+            fputs (plot_stream, "\n\n");
+          endif
+          fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data{i}(:,j).');
+          fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n\n",data{i}(:,j+1).');
+          fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data{i}(:,j+2).');
+          fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data{i}(:,j+3).');
+        endfor
+        fputs (plot_stream, "e\n");
+      elseif (is_image_data(i))
+        fwrite (plot_stream, data{i}, "float32");
+      else
+        __gnuplot_write_data__ (plot_stream, data{i}, nd, parametric(i),
+                                have_cdata(i));
+      endif
+    endfor
+  else
+    fputs (plot_stream, "plot \"-\";\nInf Inf\ne\n");
+  endif
+
+  ## Needed to allow mouse rotation with pcolor.
+  if (view_map)
+    fputs (plot_stream, "unset view;\n");
+  endif
+
+  if (bg_is_set)
+    fputs (plot_stream, "unset obj 1;\n");
+    bg_is_set = false;
+  endif
+
+  fflush (plot_stream);
+
+endfunction
+
+function x = flip (x)
+  if (rows (x) == 1)
+    x = fliplr (x);
+  elseif (columns (x) == 1 || ischar (x))
+    x = flipud (x);
+  else
+    x = flipud (fliplr (x));
+  endif
+endfunction
+
+function spacing_spec = create_spacingspec (f, s, gp_term)
+  ## The gnuplot default font size is 10, and default spacing is 1.25.
+  ## gnuplot has a concept of a figure global font, and sizes everything
+  ## appropriate to that, including the legend spacing.
+  ##
+  ## This means that if an alternative size is used, gnuplot will use an
+  ## inappropriate spacing in the legend by default.
+  ##
+  ## FIXME: Are fractional spacing specifications allowed?  Or should this
+  ##        number be rounded?
+  spc = s / 10 * 1.25;
+  spacing_spec = sprintf ("spacing %d", spc);
+
+endfunction
+
+function fontspec = create_fontspec (f, s, gp_term)
+  if (strcmp (f, "*") || strcmp (gp_term, "tikz"))
+    fontspec = sprintf ("font \",%d\"", s);
+  else
+    fontspec = sprintf ("font \"%s,%d\"", f, s);
+  endif
+endfunction
+
+function style = do_linestyle_command (obj, linecolor, idx, mono,
+                                       plot_stream, errbars = "")
+  style = {};
+
+  fprintf (plot_stream, "set style line %d default;\n", idx);
+  fprintf (plot_stream, "set style line %d", idx);
+
+  found_style = false;
+  if (isnumeric (linecolor))
+    color = linecolor;
+    if (! mono)
+      fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
+               round (255*color));
+    endif
+  else
+    color = [0, 0, 0];
+  endif
+
+  if (isfield (obj, "linestyle"))
+    switch (obj.linestyle)
+      case "-"
+        lt = "1";
+      case "--"
+        lt = "2";
+      case ":"
+        lt = "3";
+      case "-."
+        lt = "6";
+      case "none"
+        lt = "";
+      otherwise
+        lt = "";
+    endswitch
+
+    if (! isempty (lt))
+      fprintf (plot_stream, " linetype %s", lt);
+    endif
+
+  else
+    lt = "";
+  endif
+  if (! isempty (errbars))
+    found_style = true;
+  endif
+
+  if (isfield (obj, "linewidth"))
+    fprintf (plot_stream, " linewidth %f", obj.linewidth);
+    found_style = true;
+  endif
+
+  [pt, pt2, obj] = gnuplot_pointtype (obj);
+
+  if (! isempty (pt))
+    found_style = true;
+  endif
+
+  sidx = 1;
+  if (isempty (errbars))
+    if (isempty (lt))
+      style{sidx} = "";
+    else
+      style{sidx} = "lines";
+    endif
+
+    facesame = true;
+    if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor")
+        && ! strcmp (obj.markerfacecolor, "none"))
+      if (strcmp (obj.markerfacecolor, "auto")
+          || ! isnumeric (obj.markerfacecolor)
+          || (isnumeric (obj.markerfacecolor)
+              && isequal (color, obj.markerfacecolor)))
+        if (! isempty (pt2))
+          fprintf (plot_stream, " pointtype %s", pt2);
+          style{sidx} = [style{sidx} "points"];
+        endif
+        if (isfield (obj, "markersize"))
+          fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
+        endif
+      else
+        facesame = false;
+        if (! found_style)
+          fputs (plot_stream, " default");
+        endif
+        fputs (plot_stream, ";\n");
+        if (! isempty (style{sidx}))
+          sidx += 1;
+          idx += 1;
+        else
+          fputs (plot_stream, ";\n");
+        endif
+        fprintf (plot_stream, "set style line %d default;\n", idx);
+        fprintf (plot_stream, "set style line %d", idx);
+        if (isnumeric (obj.markerfacecolor) && ! mono)
+          fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
+                   round (255*obj.markerfacecolor));
+        endif
+        if (! isempty (pt2))
+          style{sidx} = "points";
+          fprintf (plot_stream, " pointtype %s", pt2);
+        endif
+        if (isfield (obj, "markersize"))
+          fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
+        endif
+      endif
+    endif
+    if (isfield (obj, "markeredgecolor")
+        && ! strcmp (obj.markeredgecolor, "none"))
+      if (facesame && ! isempty (pt)
+          && (strcmp (obj.markeredgecolor, "auto")
+              || ! isnumeric (obj.markeredgecolor)
+              || (isnumeric (obj.markeredgecolor)
+                  && isequal (color, obj.markeredgecolor))))
+        if (sidx == 1 && ((length (style{sidx}) == 5
+            && strncmp (style{sidx}, "lines", 5)) || isempty (style{sidx})))
+          if (! isempty (pt))
+            style{sidx} = [style{sidx} "points"];
+            fprintf (plot_stream, " pointtype %s", pt);
+          endif
+          if (isfield (obj, "markersize"))
+            fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
+          endif
+        endif
+      else
+        if (! found_style)
+          fputs (plot_stream, " default");
+        endif
+        fputs (plot_stream, ";\n");
+        if (! isempty (style{sidx}))
+          sidx += 1;
+          idx += 1;
+        else
+          fputs (plot_stream, ";\n");
+        endif
+        fprintf (plot_stream, "set style line %d default;\n", idx);
+        fprintf (plot_stream, "set style line %d", idx);
+        if (! mono)
+          if (strcmp (obj.markeredgecolor, "auto"))
+            fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
+                     round (255*color));
+          elseif (isnumeric (obj.markeredgecolor) && ! mono)
+            fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
+                     round (255*obj.markeredgecolor));
+          endif
+        endif
+        if (! isempty (pt))
+          style{sidx} = "points";
+          fprintf (plot_stream, " pointtype %s", pt);
+        endif
+        if (isfield (obj, "markersize"))
+          fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
+        endif
+      endif
+    endif
+  else
+    style{1} = errbars;
+    fputs (plot_stream, " pointtype 0");
+  endif
+
+  if (! found_style && isempty (style{1}))
+    fputs (plot_stream, " default");
+  endif
+
+  fputs (plot_stream, ";\n");
+
+endfunction
+
+function [pt, pt2, obj] = gnuplot_pointtype (obj)
+  if (isfield (obj, "marker"))
+    switch (obj.marker)
+      case "+"
+        pt = pt2 = "1";
+      case "o"
+        pt = "6";
+        pt2 = "7";
+      case "*"
+        pt = pt2 = "3";
+      case "."
+        pt = "6";
+        pt2 = "7";
+        if (isfield (obj, "markerfacecolor")
+            || strcmp (obj.markerfacecolor, "none"))
+          obj.markerfacecolor = "auto";
+        endif
+        if (isfield (obj, "markersize"))
+          obj.markersize /= 3;
+        else
+          obj.markersize = 5;
+        endif
+      case "x"
+        pt = pt2 = "2";
+      case {"square", "s"}
+        pt = "4";
+        pt2 = "5";
+      case {"diamond", "d"}
+        pt = "12";
+        pt2 = "13";
+      case "^"
+        pt = "8";
+        pt2 = "9";
+      case "v"
+        pt = "10";
+        pt2 = "11";
+      case ">"
+        ## FIXME: Should be triangle pointing right, use triangle pointing up
+        pt = "8";
+        pt2 = "9";
+      case "<"
+        ## FIXME: Should be triangle pointing left, use triangle pointing down
+        pt = "10";
+        pt2 = "11";
+      case {"pentagram", "p"}
+        ## FIXME: Should be pentagram, using pentagon
+        pt = "14";
+        pt2 = "15";
+      case {"hexagram", "h"}
+        ## FIXME: Should be 6 pt start, using "*" instead
+        pt = pt2 = "3";
+      case "none"
+        pt = pt2 = "";
+      otherwise
+        pt = pt2 = "";
+    endswitch
+  else
+    pt = pt2 = "";
+  endif
+endfunction
+
+function __gnuplot_write_data__ (plot_stream, data, nd, parametric, cdata)
+
+  ## DATA is already transposed.
+
+  ## FIXME: this may need to be converted to C++ for speed.
+
+  ## Convert NA elements to normal NaN values because fprintf writes
+  ## "NA" and that confuses gnuplot.
+  idx = find (isna (data));
+  if (any (idx))
+    data(idx) = NaN;
+  endif
+
+  if (nd == 2)
+    fwrite (plot_stream, data, "float64");
+  elseif (nd == 3)
+    if (parametric)
+      fwrite (plot_stream, data, "float64");
+    else
+      nr = rows (data);
+      if (cdata)
+        for j = 1:4:nr
+          fwrite (plot_stream, data(j:j+3,:), "float64");
+        endfor
+      else
+        for j = 1:3:nr
+          fwrite (plot_stream, data(j:j+2,:), "float64");
+        endfor
+      endif
+    endif
+  endif
+
+endfunction
+
+function do_tics (obj, plot_stream, ymirror, mono, gnuplot_term)
+
+  obj.xticklabel = ticklabel_to_cell (obj.xticklabel);
+  obj.yticklabel = ticklabel_to_cell (obj.yticklabel);
+  obj.zticklabel = ticklabel_to_cell (obj.zticklabel);
+
+  if (strcmp (obj.xminorgrid, "on"))
+    obj.xminortick = "on";
+  endif
+  if (strcmp (obj.yminorgrid, "on"))
+    obj.yminortick = "on";
+  endif
+  if (strcmp (obj.zminorgrid, "on"))
+    obj.zminortick = "on";
+  endif
+
+  [fontname, fontsize] = get_fontname_and_size (obj);
+  fontspec = create_fontspec (fontname, fontsize, gnuplot_term);
+
+  ## A Gnuplot tic scale of 69 is equivalent to Octave's 0.5.
+  ticklength = sprintf ("scale %4.1f", (69/0.5)*obj.ticklength(1));
+
+  if (strcmpi (obj.xaxislocation, "top"))
+    do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode,
+               obj.xticklabel, obj.xcolor, "x2", plot_stream, true, mono,
+               "border", obj.tickdir, ticklength, fontname, fontspec,
+               obj.ticklabelinterpreter, obj.xscale, obj.xsgn, gnuplot_term);
+    do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel,
+               obj.xcolor, "x", plot_stream, true, mono, "border",
+               "", "", fontname, fontspec, obj.ticklabelinterpreter,
+               obj.xscale, obj.xsgn, gnuplot_term);
+  elseif (strcmpi (obj.xaxislocation, "zero"))
+    do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode,
+               obj.xticklabel, obj.xcolor, "x", plot_stream, true, mono,
+               "axis", obj.tickdir, ticklength, fontname, fontspec,
+               obj.ticklabelinterpreter, obj.xscale, obj.xsgn, gnuplot_term);
+    do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel,
+               obj.xcolor, "x2", plot_stream, true, mono, "axis",
+               "", "", fontname, fontspec, obj.ticklabelinterpreter,
+               obj.xscale, obj.xsgn, gnuplot_term);
+  else
+    do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode,
+               obj.xticklabel, obj.xcolor, "x", plot_stream, true, mono,
+               "border", obj.tickdir, ticklength, fontname, fontspec,
+               obj.ticklabelinterpreter, obj.xscale, obj.xsgn, gnuplot_term);
+    do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel,
+               obj.xcolor, "x2", plot_stream, true, mono, "border",
+               "", "", fontname, fontspec, obj.ticklabelinterpreter,
+               obj.xscale, obj.xsgn, gnuplot_term);
+  endif
+  if (strcmpi (obj.yaxislocation, "right"))
+    do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode,
+               obj.yticklabel, obj.ycolor, "y2", plot_stream, ymirror, mono,
+               "border", obj.tickdir, ticklength, fontname, fontspec,
+               obj.ticklabelinterpreter, obj.yscale, obj.ysgn, gnuplot_term);
+    do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel,
+               obj.ycolor, "y", plot_stream, ymirror, mono, "border",
+               "", "", fontname, fontspec, obj.ticklabelinterpreter,
+               obj.yscale, obj.ysgn, gnuplot_term);
+  elseif (strcmpi (obj.yaxislocation, "zero"))
+    do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode,
+               obj.yticklabel, obj.ycolor, "y", plot_stream, ymirror, mono,
+               "axis", obj.tickdir, ticklength, fontname, fontspec,
+               obj.ticklabelinterpreter, obj.yscale, obj.ysgn, gnuplot_term);
+    do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel,
+               obj.ycolor, "y2", plot_stream, ymirror, mono, "axis",
+               "", "", fontname, fontspec, obj.ticklabelinterpreter,
+               obj.yscale, obj.ysgn, gnuplot_term);
+  else
+    do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode,
+               obj.yticklabel, obj.ycolor, "y", plot_stream, ymirror, mono,
+               "border", obj.tickdir, ticklength, fontname, fontspec,
+               obj.ticklabelinterpreter, obj.yscale, obj.ysgn, gnuplot_term);
+    do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel,
+               obj.ycolor, "y2", plot_stream, ymirror, mono, "border",
+               "", "", fontname, fontspec, obj.ticklabelinterpreter,
+               obj.yscale, obj.ysgn, gnuplot_term);
+  endif
+  do_tics_1 (obj.ztickmode, obj.ztick, obj.zminortick, obj.zticklabelmode,
+             obj.zticklabel, obj.zcolor, "z", plot_stream, true, mono,
+             "border", obj.tickdir, ticklength, fontname, fontspec,
+             obj.ticklabelinterpreter, obj.zscale, obj.zsgn, gnuplot_term);
+endfunction
+
+function do_tics_1 (ticmode, tics, mtics, labelmode, labels, color, ax,
+                    plot_stream, mirror, mono, axispos, tickdir, ticklength,
+                    fontname, fontspec, interpreter, scale, sgn, gnuplot_term)
+  persistent warned_latex = false;
+
+  ## Avoid emitting anything if the tics are empty, because this undoes the
+  ## effect of the previous unset xtics and thereby adds back in the tics.
+  if (isempty (tics))
+    return;
+  endif
+
+  if (mirror)
+    mirror = "mirror";
+  else
+    mirror = "nomirror";
+  endif
+  if (strcmpi (interpreter, "tex"))
+    for n = 1 : numel (labels)
+      labels{n} = __tex2enhanced__ (labels{n}, fontname, false, false);
+    endfor
+  elseif (strcmpi (interpreter, "latex"))
+    if (! warned_latex)
+      warning ("latex markup not supported for tick marks");
+      warned_latex = true;
+    endif
+  endif
+  if (strcmp (scale, "log"))
+    num_mtics = 10;
+    if (any (strcmp (gnuplot_term, {"tikz", "pstex", "pslatex", "epslatex"})))
+      fmt = "$10^{%T}$";
+    else
+      fmt = "10^{%T}";
+    endif
+    if (sgn < 0)
+      fmt = ["-" fmt];
+    endif
+  else
+    fmt = "%g";
+    num_mtics = 5;
+  endif
+  colorspec = get_text_colorspec (color, mono);
+  fprintf (plot_stream, "set format %s \"%s\";\n", ax, fmt);
+  if (strcmpi (ticmode, "manual"))
+    if (isempty (tics))
+      fprintf (plot_stream, "unset %stics;\nunset m%stics;\n", ax, ax);
+      return
+    endif
+    fprintf (plot_stream, "set %stics %s %s %s %s (", ax, tickdir,
+             ticklength, axispos, mirror);
+    fprintf (plot_stream, " %.15e,", tics(1:end-1));
+    fprintf (plot_stream, " %.15e) %s;\n", tics(end), fontspec);
+  else
+    fprintf (plot_stream, "set %stics %s %s %s %s %s %s;\n", ax,
+             tickdir, ticklength, axispos, mirror, colorspec, fontspec);
+  endif
+  if (strcmpi (labelmode, "manual"))
+    k = 1;
+    ntics = numel (tics);
+    nlabels = numel (labels);
+    fprintf (plot_stream, "set %stics add %s %s %s %s (", ax,
+             tickdir, ticklength, axispos, mirror);
+    labels = strrep (labels, "%", "%%");
+    for i = 1:ntics
+      fprintf (plot_stream, " \"%s\" %.15g", labels{k++}, tics(i));
+      if (i < ntics)
+        fputs (plot_stream, ", ");
+      endif
+      if (k > nlabels)
+        k = 1;
+      endif
+    endfor
+    fprintf (plot_stream, ") %s %s;\n", colorspec, fontspec);
+  endif
+  if (strcmp (mtics, "on"))
+    fprintf (plot_stream, "set m%stics %d;\n", ax, num_mtics);
+  else
+    fprintf (plot_stream, "unset m%stics;\n", ax);
+  endif
+endfunction
+
+function ticklabel = ticklabel_to_cell (ticklabel)
+  if (ischar (ticklabel))
+    ticklabel = cellstr (ticklabel);
+  elseif (iscellstr (ticklabel))
+    ticklabel = ticklabel;
+  else
+    error ("__gnuplot_draw_axes__: unsupported type of ticklabel");
+  endif
+endfunction
+
+function colorspec = get_text_colorspec (color, mono)
+  if (mono)
+    colorspec = "";
+  else
+    colorspec = sprintf ("textcolor rgb \"#%02x%02x%02x\"",
+                         round (255*color));
+  endif
+endfunction
+
+function [f, s, fnt, it, bld] = get_fontname_and_size (t)
+  if (isempty (t.fontname) || strcmp (t.fontname, "*"))
+    fnt = "{}";
+  else
+    fnt = t.fontname;
+  endif
+  f = fnt;
+  it = false;
+  bld = false;
+  if (! isempty (t.fontweight) && strcmpi (t.fontweight, "bold"))
+    if (! isempty (t.fontangle)
+        && (strcmpi (t.fontangle, "italic")
+            || strcmpi (t.fontangle, "oblique")))
+      f = [f "-bolditalic"];
+      it = true;
+      bld = true;
+    else
+      f = [f "-bold"];
+      bld = true;
+    endif
+  elseif (! isempty (t.fontangle)
+          && (strcmpi (t.fontangle, "italic")
+              || strcmpi (t.fontangle, "oblique")))
+    f = [f "-italic"];
+    it = true;
+  endif
+  if (isempty (t.fontsize))
+    s = 10;
+  else
+    s = t.fontsize;
+  endif
+endfunction
+
+function [str, f, s] = __maybe_munge_text__ (enhanced, obj, fld)
+
+  persistent warned_latex = false;
+
+  if (strcmp (fld, "string"))
+    [f, s, fnt, it, bld] = get_fontname_and_size (obj);
+  else
+    f = "Helvetica";
+    s = 10;
+    fnt = f;
+    it = false;
+    bld = false;
+  endif
+
+  ## The text object may be multiline, and may be of any class
+  str = getfield (obj, fld);
+  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)
+      if (isnumeric (str{n}))
+        str{n} = num2str (str{n});
+      endif
+    endfor
+    str = sprintf ("%s\n", str{:})(1:end-1);
+  endif
+
+  if (enhanced)
+    str = regexprep (str, '(?<!\\)@', '\@');
+  endif
+
+  if (enhanced)
+    if (strcmpi (obj.interpreter, "tex"))
+      if (iscellstr (str))
+        for n = 1:numel (str)
+          str{n} = __tex2enhanced__ (str{n}, fnt, it, bld);
+        endfor
+      else
+        str = __tex2enhanced__ (str, fnt, it, bld);
+      endif
+    elseif (strcmpi (obj.interpreter, "latex"))
+      if (! warned_latex)
+        warning ("latex markup not supported for text objects");
+        warned_latex = true;
+      endif
+    endif
+  endif
+endfunction
+
+function str = __tex2enhanced__ (str, fnt, it, bld)
+  persistent sym = __setup_sym_table__ ();
+  persistent flds = fieldnames (sym);
+
+  [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 empty set "{/Symbol \306}'
+    if (strncmp (m{i}, '\0', 2))
+      str = [str(1:s(i) - 1) '{/Symbol \306}' str(s(i) + 2:end)];
+    else
+      f = m{i}(2:end);
+      if (isfield (sym, f))
+        g = getfield (sym, f);
+        ## FIXME: The symbol font doesn't seem to support bold or italic
+        ##if (bld)
+        ##  if (it)
+        ##    g = strrep (g, '/Symbol', '/Symbol-bolditalic');
+        ##  else
+        ##    g = strrep (g, '/Symbol', '/Symbol-bold');
+        ##  endif
+        ##elseif (it)
+        ##  g = strrep (g, '/Symbol', '/Symbol-italic');
+        ##endif
+        str = [str(1:s(i) - 1) g str(e(i) + 1:end)];
+      elseif (strncmp (f, "rm", 2))
+        bld = false;
+        it = false;
+        str = [str(1:s(i) - 1) '/' fnt ' ' str(s(i) + 3:end)];
+      elseif (strncmp (f, "it", 2) || strncmp (f, "sl", 2))
+        it = true;
+        if (bld)
+          str = [str(1:s(i) - 1) '/' fnt '-bolditalic ' str(s(i) + 3:end)];
+        else
+          str = [str(1:s(i) - 1) '/' fnt '-italic ' str(s(i) + 3:end)];
+        endif
+      elseif (strncmp (f, "bf", 2))
+        bld = true;
+        if (it)
+          str = [str(1:s(i) - 1) '/' fnt '-bolditalic ' str(s(i) + 3:end)];
+        else
+          str = [str(1:s(i) - 1) '/' fnt '-bold ' 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),'}');
+        if (isempty (d))
+          warning ('syntax error in \color argument');
+        else
+          str = [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))
+          warning ('syntax error in \fontname argument');
+        else
+          str = [str(1:s(i) - 1), '/', 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))
+          warning ('syntax error in \fontname argument');
+        else
+          str = [str(1:s(i) - 1), '/=', 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});
+            ## FIXME: The symbol font doesn't seem to support bold or italic
+            ##if (bld)
+            ##  if (it)
+            ##    g = strrep (g, '/Symbol', '/Symbol-bolditalic');
+            ##  else
+            ##    g = strrep (g, '/Symbol', '/Symbol-bold');
+            ##  endif
+            ##elseif (it)
+            ##  g = strrep (g, '/Symbol', '/Symbol-italic');
+            ##endif
+            str = [str(1:s(i) - 1) g str(s(i) + length (flds{j}) + 1:end)];
+            break;
+          endif
+        endfor
+      endif
+    endif
+  endfor
+
+  ## Prepend @ to things like _0^x or _{-100}^{100} for alignment.
+  ## But need to put the shorter of the two arguments first.
+  ## Careful of nested {} and unprinted characters when defining
+  ## shortest..  Don't have to worry about things like ^\theta as they
+  ## are already converted to ^{/Symbol q}.
+
+  ## FIXME: This is a mess... Is it worth it just for a "@" character?
+
+  [s, m] = regexp (str,'[_\^]','start','matches');
+  i = 1;
+  p = 0;
+  while (i < length (s))
+    if (i < length (s))
+      if (str(s(i) + p + 1) == "{")
+        s1 = strfind (str(s(i) + p + 2:end),'{');
+        si = 1;
+        l1 = strfind (str(s(i) + p + 1:end),'}');
+        li = 1;
+        while (li <= length (l1) && si <= length (s1))
+          if (l1(li) < s1(si))
+            if (li == si)
+              break;
+            endif
+            li += 1;
+          else
+            si += 1;
+          endif
+        endwhile
+        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),'{');
+            si = 1;
+            l2 = strfind (str(s(i + 1) + p + 1:end),'}');
+            li = 1;
+            while (li <= length (l2) && si <= length (s2))
+              if (l2(li) < s2(si))
+                if (li == si)
+                  break;
+                endif
+                li += 1;
+              else
+                si += 1;
+              endif
+            endwhile
+            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)))
+              ## Shortest already first!
+              str = [str(1:s(i)+p-1) "@" str(s(i)+p:end)];
+            else
+              ## Have to swap sub/super-script to get shortest first.
+              str = [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)];
+            endif
+          else
+            ## Have to swap sub/super-script to get shortest first.
+            str = [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)];
+          endif
+          i += 2;
+          p += 1;
+        else
+          i += 1;
+        endif
+      else
+        if (s(i+1) == s(i) + 2)
+          ## Shortest already first!
+          str = [str(1:s(i)+p-1) "@" str(s(i)+p:end)];
+          p += 1;
+          i += 2;
+        else
+          i += 1;
+        endif
+      endif
+    else
+      i += 1;
+    endif
+  endwhile
+
+endfunction
+
+function l = length_string (s)
+  l = length (s) - length (strfind (s,'{')) - length (strfind (s,'}'));
+  m = regexp (s, '/([\w-]+|[\w-]+=\d+)', 'matches');
+  if (! isempty (m))
+    l -= sum (cellfun ("length", m));
+  endif
+endfunction
+
+function sym = __setup_sym_table__ ()
+  ## Setup the translation table for TeX to gnuplot enhanced mode.
+  sym.forall = '{/Symbol \042}';
+  sym.exists = '{/Symbol \044}';
+  sym.ni = '{/Symbol \047}';
+  sym.cong = '{/Symbol \100}';
+  sym.Delta = '{/Symbol D}';
+  sym.Phi = '{/Symbol F}';
+  sym.Gamma = '{/Symbol G}';
+  sym.vartheta = '{/Symbol J}';
+  sym.Lambda = '{/Symbol L}';
+  sym.Pi = '{/Symbol P}';
+  sym.Theta = '{/Symbol Q}';
+  sym.Sigma = '{/Symbol S}';
+  sym.varsigma = '{/Symbol V}';
+  sym.Omega = '{/Symbol W}';
+  sym.Xi = '{/Symbol X}';
+  sym.Psi = '{/Symbol Y}';
+  sym.perp = '{/Symbol \136}';
+  sym.alpha = '{/Symbol a}';
+  sym.beta = '{/Symbol b}';
+  sym.chi = '{/Symbol c}';
+  sym.delta = '{/Symbol d}';
+  sym.epsilon = '{/Symbol e}';
+  sym.phi = '{/Symbol f}';
+  sym.gamma = '{/Symbol g}';
+  sym.eta = '{/Symbol h}';
+  sym.iota = '{/Symbol i}';
+  sym.varphi = '{/Symbol j}';              # Not in OpenGL
+  sym.kappa = '{/Symbol k}';
+  sym.lambda = '{/Symbol l}';
+  sym.mu = '{/Symbol m}';
+  sym.nu = '{/Symbol n}';
+  sym.o = '{/Symbol o}';
+  sym.pi = '{/Symbol p}';
+  sym.theta = '{/Symbol q}';
+  sym.rho = '{/Symbol r}';
+  sym.sigma = '{/Symbol s}';
+  sym.tau = '{/Symbol t}';
+  sym.upsilon = '{/Symbol u}';
+  sym.varpi = '{/Symbol v}';
+  sym.omega = '{/Symbol w}';
+  sym.xi = '{/Symbol x}';
+  sym.psi = '{/Symbol y}';
+  sym.zeta = '{/Symbol z}';
+  sym.sim = '{/Symbol \176}';
+  sym.Upsilon = '{/Symbol \241}';
+  sym.prime = '{/Symbol \242}';
+  sym.leq = '{/Symbol \243}';
+  sym.infty = '{/Symbol \245}';
+  sym.clubsuit = '{/Symbol \247}';
+  sym.diamondsuit = '{/Symbol \250}';
+  sym.heartsuit = '{/Symbol \251}';
+  sym.spadesuit = '{/Symbol \252}';
+  sym.leftrightarrow = '{/Symbol \253}';
+  sym.leftarrow = '{/Symbol \254}';
+  sym.uparrow = '{/Symbol \255}';
+  sym.rightarrow = '{/Symbol \256}';
+  sym.downarrow = '{/Symbol \257}';
+  sym.circ = '{/Symbol \260}';         # degree symbol, not circ as in FLTK
+  sym.deg = '{/Symbol \260}';
+  sym.ast = '{/Symbol *}';
+  sym.pm = '{/Symbol \261}';
+  sym.geq = '{/Symbol \263}';
+  sym.times = '{/Symbol \264}';
+  sym.propto = '{/Symbol \265}';
+  sym.partial = '{/Symbol \266}';
+  sym.bullet = '{/Symbol \267}';
+  sym.div = '{/Symbol \270}';
+  sym.neq = '{/Symbol \271}';
+  sym.equiv = '{/Symbol \272}';
+  sym.approx = '{/Symbol \273}';
+  sym.ldots = '{/Symbol \274}';
+  sym.mid = '{/Symbol \275}';
+  sym.aleph = '{/Symbol \300}';
+  sym.Im = '{/Symbol \301}';
+  sym.Re = '{/Symbol \302}';
+  sym.wp = '{/Symbol \303}';
+  sym.otimes = '{/Symbol \304}';
+  sym.oplus = '{/Symbol \305}';
+  ## empty set, not circled slash division operator as in FLTK.
+  sym.oslash = '{/Symbol \306}';
+  sym.cap = '{/Symbol \307}';
+  sym.cup = '{/Symbol \310}';
+  sym.supset = '{/Symbol \311}';
+  sym.supseteq = '{/Symbol \312}';
+  sym.subset = '{/Symbol \314}';
+  sym.subseteq = '{/Symbol \315}';
+  sym.in = '{/Symbol \316}';
+  sym.notin = '{/Symbol \317}';            # Not in OpenGL
+  sym.angle = '{/Symbol \320}';
+  sym.bigtriangledown = '{/Symbol \321}';  # Not in OpenGL
+  sym.langle = '{/Symbol \341}';
+  sym.rangle = '{/Symbol \361}';
+  sym.nabla = '{/Symbol \321}';
+  sym.prod = '{/Symbol \325}';             # Not in OpenGL
+  sym.surd = '{/Symbol \326}';
+  sym.cdot = '{/Symbol \327}';
+  sym.neg = '{/Symbol \330}';
+  sym.wedge = '{/Symbol \331}';
+  sym.vee = '{/Symbol \332}';
+  sym.Leftrightarrow = '{/Symbol \333}';   # Not in OpenGL
+  sym.Leftarrow = '{/Symbol \334}';
+  sym.Uparrow = '{/Symbol \335}';          # Not in OpenGL
+  sym.Rightarrow = '{/Symbol \336}';
+  sym.Downarrow = '{/Symbol \337}';        # Not in OpenGL
+  sym.diamond = '{/Symbol \340}';          # Not in OpenGL
+  sym.copyright = '{/Symbol \343}';
+  sym.lfloor = '{/Symbol \353}';
+  sym.lceil = '{/Symbol \351}';
+  sym.rfloor = '{/Symbol \373}';
+  sym.rceil = '{/Symbol \371}';
+  sym.int = '{/Symbol \362}';
+endfunction
+
+function retval = __do_enhanced_option__ (enhanced, obj)
+  retval = "";
+  if (enhanced)
+    if (strcmpi (obj.interpreter, "none"))
+      retval = "noenhanced";
+    else
+      retval = "enhanced";
+    endif
+  endif
+endfunction
+
+function maybe_do_xtick_mirror (plot_stream, axis_obj)
+  if (! isempty(axis_obj.xtick))
+    fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n",
+                          axis_obj.tickdir);
+  endif
+endfunction
+
+function maybe_do_x2tick_mirror (plot_stream, axis_obj)
+  if (! isempty(axis_obj.xtick))
+    fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n",
+                          axis_obj.tickdir);
+  endif
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/util/private/__gnuplot_draw_figure__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,206 @@
+## Copyright (C) 2005-2015 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} {} __gnuplot_draw_figure__ (@var{h}, @var{plot_stream}, @var{enhanced}, @var{mono})
+## Undocumented internal function.
+## @end deftypefn
+
+## Author: jwe
+
+function __gnuplot_draw_figure__ (h, plot_stream, enhanced, mono)
+
+  htype = get (h, "type");
+  if (strcmp (htype, "figure"))
+    ## Get complete list of children.
+    kids = allchild (h);
+    nkids = length (kids);
+
+    if (nkids > 0)
+      fputs (plot_stream, "\nreset;\n");
+      fputs (plot_stream, "set autoscale keepfix;\n");
+      fputs (plot_stream, "set origin 0, 0\n");
+      fputs (plot_stream, "set size 1, 1\n");
+      bg = get (h, "color");
+      if (isnumeric (bg))
+        fprintf (plot_stream, "set obj 1 rectangle from screen 0,0 to screen 1,1 behind fc rgb \"#%02x%02x%02x\" fs solid noborder\n", round (255 * bg));
+        bg_is_set = true;
+      else
+        bg_is_set = false;
+      endif
+      fg_was_set = false;
+
+      for i = nkids:-1:1
+        type = get (kids(i), "type");
+        switch (type)
+          case "axes"
+            if (strcmpi (get (kids (i), "tag"), "legend"))
+              ## This is so ugly. If there was a way of getting
+              ## gnuplot to give us the text extents of strings
+              ## then we could get rid of this mess.
+              lh = getfield (get (kids(i), "userdata"), "handle");
+              if (isscalar (lh))
+                ## We have a legend with a single parent. It'll be handled
+                ## below as a gnuplot key to the axis it corresponds to
+                continue;
+              else
+                ca = lh(1);
+                ## Rely upon listener to convert axes position
+                ## to "normalized" units.
+                legend_axes_units = get (kids(i), "units");
+                legend_axes_position = get (kids(i), "position");
+                legend_axes_outerposition = get (kids(i), "outerposition");
+                legend_axes_box = get (kids(i), "box");
+                legend_axes_ylim = get (kids(i), "ylim");
+                orig_axes_units = get (ca, "units");
+                hlgnd = get (kids(i));
+
+                unwind_protect
+                  set (ca, "units", "normalized");
+                  set (kids(i), "units", "normalized", "box", "off",
+                       "ylim", [-2, -1], "position", get (ca(1), "position"),
+                       "outerposition", get (ca(1), "outerposition"));
+
+                  ## Create a new set of lines with the appropriate
+                  ## displaynames, etc
+                  toberm = [];
+                  hobj = get (kids(i), "children");
+                  for j = numel (hobj) : -1 : 1
+                    if (! strcmp (get (hobj(j), "type"), "text"))
+                      continue;
+                    endif
+                    displayname = get (hobj(j), "string");
+                    ll = [];
+                    lm = [];
+                    for k = numel (hobj) : -1 : 1
+                      if (! strcmp (get (hobj(k), "type"), "line"))
+                        continue;
+                      endif
+                      if (get (hobj(j), "userdata")
+                          != get (hobj(k), "userdata"))
+                        continue;
+                      endif
+                      if (! strcmp (get (hobj(k), "linestyle"), "none"))
+                        ll = hobj(k);
+                      endif
+                      if (! strcmp (get (hobj(k), "marker"), "none"))
+                        lm = hobj(k);
+                      endif
+                    endfor
+
+                    if (! isempty (ll))
+                      if (! isempty (lm))
+                        toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(lm,"color"), "linestyle", get(ll,"linestyle"), "marker", get(lm,"marker"), "markeredgecolor", get(lm,"markeredgecolor"), "markerfacecolor", get(lm,"markerfacecolor"), "markersize", get (lm, "markersize"), "displayname", displayname, "parent", kids(i))];
+                      else
+                        toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(ll,"color"), "linestyle", get(ll,"linestyle"), "marker", "none", "displayname", displayname, "parent", kids(i))];
+                      endif
+                    elseif (! isempty (lm))
+                      toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(lm,"color"), "linestyle", "none", "marker", get(lm,"marker"), "markeredgecolor", get(lm,"markeredgecolor"), "markerfacecolor", get(lm,"markerfacecolor"), "markersize", get (lm, "markersize"), "displayname", displayname, "parent", kids(i))];
+                    endif
+                  endfor
+                  if (bg_is_set)
+                    fprintf (plot_stream, "set border linecolor rgb \"#%02x%02x%02x\"\n", round (255 * (1 - bg)));
+                  endif
+                  __gnuplot_draw_axes__ (kids(i), plot_stream, enhanced, mono,
+                                    bg_is_set, false, hlgnd);
+                unwind_protect_cleanup
+                  ## Return axes "units" and "position" back to
+                  ## their original values.
+                  set (ca, "units", orig_axes_units);
+                  set (kids(i), "units", legend_axes_units,
+                       "box", legend_axes_box,
+                       "ylim", legend_axes_ylim,
+                       "position", legend_axes_position,
+                       "outerposition", legend_axes_outerposition);
+                  delete (toberm);
+                  bg_is_set = false;
+                end_unwind_protect
+              endif
+            else
+              ## Rely upon listener to convert axes position
+              ## to "normalized" units.
+              orig_axes_units = get (kids(i), "units");
+              orig_axes_position = get (kids(i), "position");
+              unwind_protect
+                set (kids(i), "units", "normalized");
+                fg = get (kids(i), "color");
+                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\" fs solid noborder\n", round (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
+                if (bg_is_set)
+                  fprintf (plot_stream, "set border linecolor rgb \"#%02x%02x%02x\"\n", round (255 * (1 - bg)));
+                endif
+                ## Find if this axes has an associated legend axes and pass it
+                ## to __gnuplot_draw_axes__
+                hlegend = [];
+                fkids = get (h, "children");
+                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)
+                        && ! isempty (intersect (udata.handle, kids (i))))
+                      hlegend = get (fkids (j));
+                      break;
+                    endif
+                  endif
+                endfor
+                __gnuplot_draw_axes__ (kids(i), plot_stream, enhanced, mono,
+                                  bg_is_set, fg_is_set, hlegend);
+              unwind_protect_cleanup
+                ## Return axes "units" and "position" back to
+                ## their original values.
+                set (kids(i), "units", orig_axes_units);
+                set (kids(i), "position", orig_axes_position);
+                bg_is_set = false;
+                fg_is_set = false;
+              end_unwind_protect
+            endif
+          case {"uimenu", "uicontextmenu"}
+            ## ignore uimenu objects
+            kids(i) = [];
+          otherwise
+            error ("__gnuplot_draw_figure__: unknown object class, %s", type);
+        endswitch
+      endfor
+      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);
+    endif
+  else
+    error ("__gnuplot_draw_figure__: expecting figure object, found '%s'",
+           htype);
+  endif
+
+endfunction
+
--- a/scripts/plot/util/private/__gnuplot_get_var__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/private/__gnuplot_get_var__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -52,8 +52,7 @@
   if (use_mkfifo)
     gpin_name = tempname ();
 
-    ## Mode: 0600 == 6*8*8
-    [err, msg] = mkfifo (gpin_name, 6*8*8);
+    [err, msg] = mkfifo (gpin_name, 600);
 
     if (err)
       error ("__gnuplot_get_var__: Can not make FIFO (%s)", msg);
--- a/scripts/plot/util/private/__gnuplot_ginput__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/private/__gnuplot_ginput__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -63,8 +63,7 @@
   if (use_mkfifo)
     gpin_name = tempname ();
 
-    ##Mode: 6*8*8 ==  0600
-    [err, msg] = mkfifo (gpin_name, 6*8*8);
+    [err, msg] = mkfifo (gpin_name, 600);
 
     if (err)
       error ("ginput: Can not open fifo (%s)", msg);
@@ -75,7 +74,7 @@
 
     k = 0;
     while (true)
-      k++;
+      k += 1;
 
       ## Notes: MOUSE_* can be undefined if user closes gnuplot by "q"
       ## or Alt-F4. Further, this abrupt close also requires the leading
--- a/scripts/plot/util/private/__gnuplot_has_feature__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/private/__gnuplot_has_feature__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -25,7 +25,8 @@
 ## Created: 2009-01-27
 
 function res = __gnuplot_has_feature__ (feature)
-  persistent features = {"x11_figure_position",
+  persistent features = {"minimum_version",
+                         "x11_figure_position",
                          "wxt_figure_size",
                          "transparent_patches",
                          "transparent_surface",
@@ -45,8 +46,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", "4.4", "4.3"};
-    operators = {">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">="};
+    versions = {"4.2.5", "4.2.5", "4.4", "4.4", "4.4", "4.2", "4.2", "4.4", "4.4", "4.4", "4.4", "4.3"};
+    operators = {">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">="};
     have_features = false (size (features));
     for n = 1 : numel (have_features)
       has_features(n) = compare_versions (gnuplot_version, versions{n}, operators{n});
--- a/scripts/plot/util/private/__gnuplot_print__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/private/__gnuplot_print__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -71,15 +71,23 @@
       dot = find (opts.name == ".", 1, "last");
       n = find (opts.devopt == "l", 1);
       suffix = opts.devopt(1:n-1);
-      if (! isempty (dot))
-        if (any (strcmpi (opts.name(dot:end), {["." suffix], ".tex", "."})))
-          name = opts.name(1:dot-1);
-        else
-          error ("print:invalid-suffix",
-                 "invalid suffix '%s' for device '%s'.",
-                 opts.name(dot:end), lower (opts.devopt));
+      [ndir, name, ext] = fileparts (opts.name);
+      if (isempty (ext))
+        ext = "tex";
+      else
+        ext = ext(2:end);  # remove leading '.'
+      endif
+      if (any (strcmpi (ext, {suffix, "tex"})))
+        name = fullfile (ndir, name);
+        if (any (strcmpi (ext, {"eps", "ps", "pdf"})))
+          suffix = ext;  # If user provides eps/ps/pdf suffix, use it.
         endif
+      else
+        error ("print:invalid-suffix",
+               "invalid suffix '%s' for device '%s'.",
+               ext, lower (opts.devopt));
       endif
+
       if (strfind (opts.devopt, "standalone"))
         term = sprintf ("%s ",
                         strrep (opts.devopt, "standalone", " standalone"));
@@ -93,7 +101,7 @@
         suffix = "eps";
       endif
       local_drawnow ([term " " gp_opts],
-                     strcat (name, ".", suffix), opts);
+                     [name "." suffix], opts);
     case "tikz"
       if (__gnuplot_has_terminal__ ("tikz"))
         local_drawnow (["lua tikz " gp_opts], opts.name, opts);
--- a/scripts/plot/util/private/__go_draw_axes__.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2652 +0,0 @@
-## Copyright (C) 2005-2015 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} {} __go_draw_axes__ (@var{h}, @var{plot_stream}, @var{enhanced}, @var{mono})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function __go_draw_axes__ (h, plot_stream, enhanced, mono,
-                           bg_is_set, fg_is_set, hlgnd)
-
-  showhiddenhandles = get (0, "showhiddenhandles");
-  unwind_protect
-    set (0, "showhiddenhandles", "on");
-    axis_obj = __get__ (h);
-  unwind_protect_cleanup
-    set (0, "showhiddenhandles", showhiddenhandles);
-  end_unwind_protect
-
-  parent_figure_obj = get (axis_obj.parent);
-  gnuplot_term = __gnuplot_get_var__ (axis_obj.parent, "GPVAL_TERM");
-
-  ## Set to false for plotyy axes.
-  ymirror = true;
-  if (isfield (axis_obj, "__plotyy_axes__"))
-    if (all (ishandle (axis_obj.__plotyy_axes__)))
-      ymirror = false;
-    else
-      h = axis_obj.__plotyy_axes__;
-      h = h(ishandle (h));
-      h = h(isprop (h, "__plotyy_axes__"));
-      rmappdata (h, "__plotyy_axes__");
-    endif
-  endif
-
-  nd = __calc_dimensions__ (h);
-
-  if (strcmp (axis_obj.dataaspectratiomode, "manual")
-      && strcmp (axis_obj.xlimmode, "manual")
-      && strcmp (axis_obj.ylimmode, "manual"))
-    ## All can't be "manual"
-    axis_obj.plotboxaspectratiomode = "auto";
-  endif
-
-  if (strcmp (axis_obj.dataaspectratiomode, "manual")
-      && strcmp (axis_obj.xlimmode, "manual")
-      && strcmp (axis_obj.ylimmode, "manual")
-      && (nd == 2 || all (mod (axis_obj.view, 90) == 0)))
-    ## FIXME: adjust plotboxaspectratio to respect other
-    fpos = get (axis_obj.parent, "position");
-    apos = axis_obj.position;
-  endif
-
-  pos = __actual_axis_position__ (h);
-
-  if (strcmpi (axis_obj.dataaspectratiomode, "manual"))
-    dr = axis_obj.dataaspectratio;
-    if (nd == 2 || all (mod (axis_obj.view, 90) == 0))
-      dr = dr(1) / dr(2);
-    else
-      ## FIXME: need to properly implement 3D
-      dr = mean (dr(1:2)) / dr(3);
-    endif
-  else
-    dr = 1;
-  endif
-
-  if (strcmp (axis_obj.activepositionproperty, "position"))
-    if (__gnuplot_has_feature__ ("screen_coordinates_for_{lrtb}margin"))
-      if (nd == 2 || all (mod (axis_obj.view, 90) == 0))
-        x = [1, 1];
-      else
-        ## 3D plots need to be sized down to fit in the window.
-        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);
-      fprintf (plot_stream, "set bmargin screen %.15g;\n",
-               pos(2)+pos(4)/2-x(2)*pos(4)/2);
-      fprintf (plot_stream, "set lmargin screen %.15g;\n",
-               pos(1)+pos(3)/2-x(1)*pos(3)/2);
-      fprintf (plot_stream, "set rmargin screen %.15g;\n",
-               pos(1)+pos(3)/2+x(1)*pos(3)/2);
-      sz_str = "";
-    else
-      fprintf (plot_stream, "set tmargin 0;\n");
-      fprintf (plot_stream, "set bmargin 0;\n");
-      fprintf (plot_stream, "set lmargin 0;\n");
-      fprintf (plot_stream, "set rmargin 0;\n");
-
-      if (nd == 3 && all (axis_obj.view == [0, 90]))
-        ## FIXME: Kludge to allow colorbar to be added to a pcolor() plot
-        pos(3:4) = pos(3:4) * 1.4;
-        pos(1:2) = pos(1:2) - pos(3:4) * 0.125;
-      endif
-
-      fprintf (plot_stream, "set origin %.15g, %.15g;\n", pos(1), pos(2));
-
-      if (strcmpi (axis_obj.dataaspectratiomode, "manual"))
-        sz_str = sprintf ("set size ratio %.15g", -dr);
-      else
-        sz_str = "set size noratio";
-      endif
-      sz_str = sprintf ("%s %.15g, %.15g;\n", sz_str, pos(3), pos(4));
-    endif
-  else ## activepositionproperty == outerposition
-    fprintf (plot_stream, "unset tmargin;\n");
-    fprintf (plot_stream, "unset bmargin;\n");
-    fprintf (plot_stream, "unset lmargin;\n");
-    fprintf (plot_stream, "unset rmargin;\n");
-    fprintf (plot_stream, "set origin %g, %g;\n", pos(1:2));
-    sz_str = "";
-    if (strcmpi (axis_obj.dataaspectratiomode, "manual"))
-      sz_str = sprintf ("ratio %g", -dr);
-    else
-      sz_str = "noratio";
-    endif
-    sz_str = sprintf ("set size %s %g, %g;\n", sz_str, pos(3:4));
-  endif
-  if (! isempty (sz_str))
-    fputs (plot_stream, sz_str);
-  endif
-
-  ## Reset all labels, axis-labels, tick-labels, and title
-  ## FIXME: We should have an function to initialize the axis.
-  ##        Presently, this is dispersed in this function.
-  fputs (plot_stream, "unset label;\n");
-  fputs (plot_stream, "unset xtics;\n");
-  fputs (plot_stream, "unset ytics;\n");
-  fputs (plot_stream, "unset ztics;\n");
-  fputs (plot_stream, "unset x2tics;\n");
-  fputs (plot_stream, "unset y2tics;\n");
-
-  if (! isempty (axis_obj.title))
-    t = get (axis_obj.title);
-    if (isempty (t.string))
-      fputs (plot_stream, "unset title;\n");
-    else
-      colorspec = get_text_colorspec (t.color, mono);
-      [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string");
-      fontspec = create_fontspec (f, s, gnuplot_term);
-      fprintf (plot_stream, "set title \"%s\" %s %s %s;\n",
-               undo_string_escapes (tt), fontspec, colorspec,
-               __do_enhanced_option__ (enhanced, t));
-    endif
-  endif
-
-  if (! isempty (axis_obj.xlabel))
-    t = get (axis_obj.xlabel);
-    angle = t.rotation;
-    colorspec = get_text_colorspec (t.color, mono);
-    if (isempty (t.string))
-      fprintf (plot_stream, "unset xlabel;\n");
-      fprintf (plot_stream, "unset x2label;\n");
-    else
-      [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string");
-      fontspec = create_fontspec (f, s, gnuplot_term);
-      if (strcmpi (axis_obj.xaxislocation, "top"))
-        fprintf (plot_stream, "set x2label \"%s\" %s %s %s",
-                 undo_string_escapes (tt), colorspec, fontspec,
-                 __do_enhanced_option__ (enhanced, t));
-      else
-        fprintf (plot_stream, "set xlabel \"%s\" %s %s %s",
-                 undo_string_escapes (tt), colorspec, fontspec,
-                 __do_enhanced_option__ (enhanced, t));
-      endif
-      fprintf (plot_stream, " rotate by %f;\n", angle);
-      if (strcmpi (axis_obj.xaxislocation, "top"))
-        fprintf (plot_stream, "unset xlabel;\n");
-      else
-        fprintf (plot_stream, "unset x2label;\n");
-      endif
-    endif
-  endif
-
-  if (! isempty (axis_obj.ylabel))
-    t = get (axis_obj.ylabel);
-    angle = t.rotation;
-    colorspec = get_text_colorspec (t.color, mono);
-    if (isempty (t.string))
-      fprintf (plot_stream, "unset ylabel;\n");
-      fprintf (plot_stream, "unset y2label;\n");
-    else
-      [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string");
-      fontspec = create_fontspec (f, s, gnuplot_term);
-      if (strcmpi (axis_obj.yaxislocation, "right"))
-        fprintf (plot_stream, "set y2label \"%s\" %s %s %s",
-                 undo_string_escapes (tt), colorspec, fontspec,
-                 __do_enhanced_option__ (enhanced, t));
-      else
-        fprintf (plot_stream, "set ylabel \"%s\" %s %s %s",
-                 undo_string_escapes (tt), colorspec, fontspec,
-                 __do_enhanced_option__ (enhanced, t));
-      endif
-      fprintf (plot_stream, " rotate by %f;\n", angle);
-      if (strcmpi (axis_obj.yaxislocation, "right"))
-        fprintf (plot_stream, "unset ylabel;\n");
-      else
-        fprintf (plot_stream, "unset y2label;\n");
-      endif
-    endif
-  endif
-
-  if (! isempty (axis_obj.zlabel))
-    t = get (axis_obj.zlabel);
-    angle = t.rotation;
-    colorspec = get_text_colorspec (t.color, mono);
-    if (isempty (t.string))
-      fputs (plot_stream, "unset zlabel;\n");
-    else
-      [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string");
-      fontspec = create_fontspec (f, s, gnuplot_term);
-      fprintf (plot_stream, "set zlabel \"%s\" %s %s %s",
-               undo_string_escapes (tt), colorspec, fontspec,
-               __do_enhanced_option__ (enhanced, t));
-      fprintf (plot_stream, " rotate by %f;\n", angle);
-    endif
-  endif
-
-  if (strcmpi (axis_obj.xaxislocation, "top"))
-    xaxisloc = "x2";
-    xaxisloc_using = "x2";
-  else
-    xaxisloc = "x";
-    xaxisloc_using = "x1";
-    if (strcmpi (axis_obj.xaxislocation, "zero"))
-      fputs (plot_stream, "set xzeroaxis;\n");
-    endif
-  endif
-  if (strcmpi (axis_obj.yaxislocation, "right"))
-    yaxisloc = "y2";
-    yaxisloc_using = "y2";
-  else
-    yaxisloc = "y";
-    yaxisloc_using = "y1";
-    if (strcmpi (axis_obj.yaxislocation, "zero"))
-      fputs (plot_stream, "set yzeroaxis;\n");
-    endif
-  endif
-
-  have_grid = false;
-
-  if (strcmpi (axis_obj.xgrid, "on"))
-    have_grid = true;
-    fprintf (plot_stream, "set grid %stics;\n", xaxisloc);
-  else
-    fprintf (plot_stream, "set grid no%stics;\n", xaxisloc);
-  endif
-
-  if (strcmpi (axis_obj.ygrid, "on"))
-    have_grid = true;
-    fprintf (plot_stream, "set grid %stics;\n", yaxisloc);
-  else
-    fprintf (plot_stream, "set grid no%stics;\n", yaxisloc);
-  endif
-
-  if (strcmpi (axis_obj.zgrid, "on"))
-    have_grid = true;
-    fputs (plot_stream, "set grid ztics;\n");
-  else
-    fputs (plot_stream, "set grid noztics;\n");
-  endif
-
-  if (strcmpi (axis_obj.xminorgrid, "on"))
-    have_grid = true;
-    if (strcmp (axis_obj.xscale, "log"))
-      m = 10;
-    else
-      m = 5;
-    endif
-    fprintf (plot_stream, "set m%stics %d;\n", xaxisloc, m);
-    fprintf (plot_stream, "set grid m%stics;\n", xaxisloc);
-  else
-    fprintf (plot_stream, "set grid nom%stics;\n", xaxisloc);
-  endif
-
-  if (strcmpi (axis_obj.yminorgrid, "on"))
-    have_grid = true;
-    if (strcmp (axis_obj.yscale, "log"))
-      m = 10;
-    else
-      m = 5;
-    endif
-    fprintf (plot_stream, "set m%stics %d;\n", yaxisloc, m);
-    fprintf (plot_stream, "set grid m%stics;\n", yaxisloc);
-  else
-    fprintf (plot_stream, "set grid nom%stics;\n", yaxisloc);
-  endif
-
-  if (strcmpi (axis_obj.zminorgrid, "on"))
-    have_grid = true;
-    if (strcmp (axis_obj.zscale, "log"))
-      m = 10;
-    else
-      m = 5;
-    endif
-    fprintf (plot_stream, "set mztics %d;\n", m);
-    fputs (plot_stream, "set grid mztics;\n");
-  else
-    fputs (plot_stream, "set grid nomztics;\n");
-  endif
-
-  ## The grid front/back/layerdefault option also controls the
-  ## appearance of tics, so it is used even if the grid is absent.
-  if (strcmpi (axis_obj.layer, "top"))
-    fputs (plot_stream, "set grid front;\n");
-    fputs (plot_stream, "set border front;\n");
-  else
-    fputs (plot_stream, "set grid layerdefault;\n");
-    ## FIXME: The gnuplot help says that "layerdefault" should work
-    ##        for set border too, but it fails for me with gnuplot 4.2.5.
-    ##        So, use "back" instead.
-    fputs (plot_stream, "set border back;\n");
-  endif
-
-  fprintf (plot_stream, "set grid linewidth %f, linewidth %f;\n",
-           axis_obj.linewidth, axis_obj.linewidth);
-
-  if (! have_grid)
-    fputs (plot_stream, "unset grid;\n");
-  endif
-
-  xlogscale = strcmpi (axis_obj.xscale, "log");
-  ylogscale = strcmpi (axis_obj.yscale, "log");
-  zlogscale = strcmpi (axis_obj.zscale, "log");
-
-  ## Detect logscale and negative lims
-  if (xlogscale && all (axis_obj.xlim < 0))
-    axis_obj.xsgn = -1;
-    if (strcmp (axis_obj.xdir, "reverse"))
-      axis_obj.xdir = "normal";
-    elseif (strcmp (axis_obj.xdir, "normal"))
-      axis_obj.xdir = "reverse";
-    endif
-    axis_obj.xtick = -flip (axis_obj.xtick);
-    axis_obj.xticklabel = flip (axis_obj.xticklabel);
-    axis_obj.xlim = -flip (axis_obj.xlim);
-  else
-    axis_obj.xsgn = 1;
-  endif
-  if (ylogscale && all (axis_obj.ylim < 0))
-    axis_obj.ysgn = -1;
-    if (strcmp (axis_obj.ydir, "reverse"))
-      axis_obj.ydir = "normal";
-    elseif (strcmp (axis_obj.ydir, "normal"))
-      axis_obj.ydir = "reverse";
-    endif
-    axis_obj.ytick = -flip (axis_obj.ytick);
-    axis_obj.yticklabel = flip (axis_obj.yticklabel);
-    axis_obj.ylim = -flip (axis_obj.ylim);
-  else
-    axis_obj.ysgn = 1;
-  endif
-  if (zlogscale && all (axis_obj.zlim < 0))
-    axis_obj.zsgn = -1;
-    if (strcmp (axis_obj.zdir, "reverse"))
-      axis_obj.zdir = "normal";
-    elseif (strcmp (axis_obj.zdir, "normal"))
-      axis_obj.zdir = "reverse";
-    endif
-    axis_obj.ztick = -flip (axis_obj.ztick);
-    axis_obj.zticklabel = flip (axis_obj.zticklabel);
-    axis_obj.zlim = -flip (axis_obj.zlim);
-  else
-    axis_obj.zsgn = 1;
-  endif
-
-  xlim = axis_obj.xlim;
-  ylim = axis_obj.ylim;
-  zlim = axis_obj.zlim;
-  clim = axis_obj.clim;
-
-  do_tics (axis_obj, plot_stream, ymirror, mono, gnuplot_term);
-
-  fputs (plot_stream, "unset logscale;\n");
-  if (xlogscale)
-    fprintf (plot_stream, "set logscale %s;\n", xaxisloc);
-  endif
-  if (ylogscale)
-    fprintf (plot_stream, "set logscale %s;\n", yaxisloc);
-  endif
-  if (zlogscale)
-    fputs (plot_stream, "set logscale z;\n");
-  endif
-
-  xautoscale = strcmpi (axis_obj.xlimmode, "auto");
-  yautoscale = strcmpi (axis_obj.ylimmode, "auto");
-  zautoscale = strcmpi (axis_obj.zlimmode, "auto");
-  cautoscale = strcmpi (axis_obj.climmode, "auto");
-  cdatadirect = false;
-  truecolor = false;
-
-  fputs (plot_stream, "set clip two;\n");
-
-  kids = axis_obj.children;
-  ## Remove the axis labels and title from the children, and
-  ## preserved the original order.
-  [jnk, k] = setdiff (kids, [axis_obj.xlabel; axis_obj.ylabel; ...
-                             axis_obj.zlabel; axis_obj.title]);
-  kids = kids (sort (k));
-
-  if (nd == 3)
-    fputs (plot_stream, "set parametric;\n");
-    fputs (plot_stream, "set style data lines;\n");
-    fputs (plot_stream, "set surface;\n");
-    fputs (plot_stream, "unset contour;\n");
-  endif
-
-  data_idx = 0;
-  data = cell ();
-  is_image_data = [];
-  hidden_removal = NaN;
-  view_map = false;
-
-  if (! cautoscale && clim(1) == clim(2))
-    clim(2)++;
-  endif
-  addedcmap = [];
-
-  ximg_data = {};
-  ximg_data_idx = 0;
-
-  while (! isempty (kids))
-
-    obj = get (kids(end));
-
-    if (isfield (obj, "xdata"))
-      obj.xdata = double (obj.xdata);
-    endif
-    if (isfield (obj, "ydata"))
-      obj.ydata = double (obj.ydata);
-    endif
-    if (isfield (obj, "zdata"))
-      obj.zdata = double (obj.zdata);
-    endif
-
-    if (isfield (obj, "units"))
-      units = obj.units;
-      unwind_protect
-        set (kids(end), "units", "data");
-        obj = get (kids(end));
-      unwind_protect_cleanup
-        set (kids(end), "units", units);
-      end_unwind_protect
-    endif
-    kids = kids(1:(end-1));
-
-    if (strcmp (obj.visible, "off"))
-      continue;
-    endif
-
-    if (xlogscale && isfield (obj, "xdata"))
-      obj.xdata = axis_obj.xsgn * obj.xdata;
-      obj.xdata(obj.xdata<=0) = NaN;
-    endif
-    if (ylogscale && isfield (obj, "ydata"))
-      obj.ydata = axis_obj.ysgn * obj.ydata;
-      obj.ydata(obj.ydata<=0) = NaN;
-    endif
-    if (zlogscale && isfield (obj, "zdata"))
-      obj.zdata = axis_obj.zsgn * obj.zdata;
-      obj.zdata(obj.zdata<=0) = NaN;
-    endif
-
-    ## Check for facecolor interpolation for surfaces.
-    doing_interp_color = ...
-       isfield (obj, "facecolor") && strcmp (obj.facecolor, "interp");
-
-    switch (obj.type)
-      case "image"
-        img_data = obj.cdata;
-        img_xdata = obj.xdata;
-        img_ydata = obj.ydata;
-
-        if (ndims (img_data) == 3)
-          truecolor = true;
-        elseif (strcmpi (obj.cdatamapping, "direct"))
-          cdatadirect = true;
-        endif
-        data_idx++;
-        is_image_data(data_idx) = true;
-        parametric(data_idx) = false;
-        have_cdata(data_idx) = false;
-        have_3d_patch(data_idx) = false;
-
-        if (img_xdata(2) < img_xdata(1))
-          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, 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, rows(img_data)-1];
-        endif
-
-        x_origin = min (img_xdata);
-        y_origin = min (img_ydata);
-
-        [y_dim, x_dim] = size (img_data(:,:,1));
-        if (x_dim > 1)
-          dx = abs (img_xdata(2)-img_xdata(1))/(x_dim-1);
-        else
-          x_dim = 2;
-          img_data = [img_data, img_data];
-          dx = abs (img_xdata(2)-img_xdata(1));
-          if (dx < 1)
-            ## Correct gnuplot string for 1-D images
-            dx       = 0.5;
-            x_origin = 0.75;
-          endif
-        endif
-        if (y_dim > 1)
-          dy = abs (img_ydata(2)-img_ydata(1))/(y_dim-1);
-        else
-          y_dim = 2;
-          img_data = [img_data; img_data];
-          dy = abs (img_ydata(2)-img_ydata(1));
-          if (dy < 1)
-            ## Correct gnuplot string for 1-D images
-            dy       = 0.5;
-            y_origin = 0.75;
-          endif
-        endif
-
-        if (ndims (img_data) == 3)
-          data{data_idx} = permute (img_data, [3, 1, 2])(:);
-          format = "1:2:3";
-          imagetype = "rgbimage";
-        else
-          data{data_idx} = img_data(:);
-          format = "1";
-          imagetype = "image";
-        endif
-
-        titlespec{data_idx} = "title \"\"";
-        usingclause{data_idx} = sprintf ("binary array=%dx%d scan=yx origin=(%.15g,%.15g) dx=%.15g dy=%.15g using %s",
-            x_dim, y_dim, x_origin, y_origin, dx, dy, format);
-        withclause{data_idx} = sprintf ("with %s;", imagetype);
-
-      case "line"
-        if (strcmp (obj.linestyle, "none")
-            && (! isfield (obj, "marker")
-                || (isfield (obj, "marker")
-                    && strcmp (obj.marker, "none"))))
-          continue;
-        endif
-        data_idx++;
-        is_image_data(data_idx) = false;
-        parametric(data_idx) = true;
-        have_cdata(data_idx) = false;
-        have_3d_patch(data_idx) = false;
-        if (isempty (obj.displayname))
-          titlespec{data_idx} = "title \"\"";
-        else
-          tmp = undo_string_escapes (
-                  __maybe_munge_text__ (enhanced, obj, "displayname")
-                );
-          titlespec{data_idx} = ['title "' tmp '"'];
-        endif
-        usingclause{data_idx} = sprintf ("record=%d", numel (obj.xdata));
-        errbars = "";
-        if (nd == 3)
-          xdat = obj.xdata(:);
-          ydat = obj.ydata(:);
-          if (! isempty (obj.zdata))
-            zdat = obj.zdata(:);
-          else
-            zdat = zeros (size (xdat));
-          endif
-          data{data_idx} = [xdat, ydat, zdat]';
-          usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)",
-                                           numel (xdat));
-          hidden_removal = false;
-          ## fputs (plot_stream, "set parametric;\n");
-        else
-          xdat = obj.xdata(:);
-          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);
-        endif
-
-        style = do_linestyle_command (obj, obj.color, data_idx, mono,
-                                      plot_stream, errbars);
-
-        withclause{data_idx} = sprintf ("with %s linestyle %d",
-                                        style{1}, data_idx);
-
-        if (length (style) > 1)
-          data_idx++;
-          is_image_data(data_idx) = is_image_data(data_idx - 1);
-          parametric(data_idx) = parametric(data_idx - 1);
-          have_cdata(data_idx) = have_cdata(data_idx - 1);
-          have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
-          titlespec{data_idx} = "title \"\"";
-          usingclause{data_idx} = usingclause{data_idx - 1};
-          data{data_idx} = data{data_idx - 1};
-          withclause{data_idx} = sprintf ("with %s linestyle %d",
-                                          style{2}, data_idx);
-        endif
-        if (length (style) > 2)
-          data_idx++;
-          is_image_data(data_idx) = is_image_data(data_idx - 1);
-          parametric(data_idx) = parametric(data_idx - 1);
-          have_cdata(data_idx) = have_cdata(data_idx - 1);
-          have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
-          titlespec{data_idx} = "title \"\"";
-          usingclause{data_idx} = usingclause{data_idx - 1};
-          data{data_idx} = data{data_idx - 1};
-          withclause{data_idx} = sprintf ("with %s linestyle %d",
-                                          style{3}, data_idx);
-        endif
-
-     case "patch"
-       cmap = parent_figure_obj.colormap;
-       [nr, nc] = size (obj.xdata);
-
-       if (! isempty (obj.cdata))
-         cdat = obj.cdata;
-         if (strcmpi (obj.cdatamapping, "direct"))
-           cdatadirect = true;
-         endif
-       else
-         cdat = [];
-       endif
-
-       data_3d_idx = NaN;
-       for i = 1:nc
-         xcol = obj.xdata(:,i);
-         ycol = obj.ydata(:,i);
-         if (nd == 3)
-           if (! isempty (obj.zdata))
-             zcol = obj.zdata(:,i);
-           else
-             zcol = zeros (size (xcol));
-           endif
-         endif
-
-         if (! isnan (xcol) && ! isnan (ycol))
-           ## Is the patch closed or not
-           if (strcmp (obj.facecolor, "none"))
-             hidden_removal = false;
-           else
-
-             if (isnan (hidden_removal))
-               hidden_removal = true;
-             endif
-             if (nd == 3)
-               if (numel (xcol) > 3)
-                 error ("__go_draw_axes__: gnuplot (as of v4.2) only supports 3-D filled triangular patches");
-               else
-                 if (isnan (data_3d_idx))
-                   data_idx++;
-                   data_3d_idx = data_idx;
-                   is_image_data(data_idx) = false;
-                   parametric(data_idx) = false;
-                   have_cdata(data_idx) = true;
-                   have_3d_patch(data_idx) = true;
-                   withclause{data_3d_idx} = sprintf ("with pm3d");
-                   usingclause{data_3d_idx} =  "using 1:2:3:4";
-                   data{data_3d_idx} = [];
-                 endif
-                 local_idx = data_3d_idx;
-                 ccdat = NaN;
-               endif
-             else
-               data_idx++;
-               local_idx = data_idx;
-               is_image_data(data_idx) = false;
-               parametric(data_idx) = false;
-               have_cdata(data_idx) = false;
-               have_3d_patch(data_idx) = false;
-             endif
-
-             if (i > 1 || isempty (obj.displayname))
-               titlespec{local_idx} = "title \"\"";
-             else
-               tmp = undo_string_escapes (
-                       __maybe_munge_text__ (enhanced, obj, "displayname")
-                     );
-               titlespec{local_idx} = ['title "' tmp '"'];
-             endif
-             if (isfield (obj, "facecolor"))
-               if ((strcmp (obj.facecolor, "flat")
-                   || strcmp (obj.facecolor, "interp"))
-                   && isfield (obj, "cdata"))
-                 if (ndims (obj.cdata) == 2
-                     && (columns (obj.cdata) == nc
-                         && (rows (obj.cdata) == 1
-                             || rows (obj.cdata) == 3)))
-                   ccol = cdat(:, i);
-                 elseif (ndims (obj.cdata) == 2
-                     && (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]);
-                 else
-                   ccol = cdat;
-                 endif
-                 if (strcmp (obj.facecolor, "flat"))
-                   if (isequal (size (ccol), [1, 3]))
-                     ## RGB Triplet
-                     color = ccol;
-                   elseif (nd == 3 && numel (xcol) == 3)
-                     ccdat = ccol;
-                   else
-                     if (cdatadirect)
-                       r = round (ccol);
-                     else
-                       r = 1 + round ((rows (cmap) - 1)
-                                      * (ccol - clim(1))/(clim(2) - clim(1)));
-                     endif
-                     r = max (1, min (r, rows (cmap)));
-                     color = cmap(r, :);
-                   endif
-                 elseif (strcmp (obj.facecolor, "interp"))
-                   if (nd == 3 && numel (xcol) == 3)
-                     ccdat = ccol;
-                     if (! isvector (ccdat))
-                       tmp = rows (cmap) + rows (addedcmap) + ...
-                            [1 : rows(ccdat)];
-                       addedcmap = [addedcmap; ccdat];
-                       ccdat = tmp(:);
-                     else
-                       ccdat = ccdat(:);
-                     endif
-                   else
-                     if (sum (diff (ccol)))
-                       warning ("\"interp\" not supported, using 1st entry of cdata");
-                     endif
-                     if (cdatadirect)
-                       r = round (ccol);
-                     else
-                       r = 1 + round ((rows (cmap) - 1)
-                                      * (ccol - clim(1))/(clim(2) - clim(1)));
-                     endif
-                     r = max (1, min (r, rows (cmap)));
-                     color = cmap(r(1),:);
-                   endif
-                 endif
-               elseif (isnumeric (obj.facecolor))
-                 color = obj.facecolor;
-               else
-                 color = [0, 1, 0];
-               endif
-             else
-               color = [0, 1, 0];
-             endif
-
-             if (nd == 3 && numel (xcol) == 3)
-               if (isnan (ccdat))
-                 ccdat = (rows (cmap) + rows (addedcmap) + 1) * ones(3, 1);
-                 addedcmap = [addedcmap; reshape(color, 1, 3)];
-               elseif (numel (ccdat) <= 1)
-                 ccdat = zcol;
-               endif
-               data{data_3d_idx} = [data{data_3d_idx}, ...
-                                    [[xcol; xcol(end)], [ycol; ycol(end)], ...
-                                    [zcol; zcol(end)], [ccdat; ccdat(end)]]'];
-             else
-               if (mono)
-                 colorspec = "";
-               elseif (__gnuplot_has_feature__ ("transparent_patches")
-                       && isscalar (obj.facealpha))
-                 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\" fillstyle transparent solid %f",
-                                      round (255*color), obj.facealpha);
-               else
-                 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
-                                      round (255*color));
-               endif
-
-               withclause{data_idx} = sprintf ("with filledcurve %s",
-                                             colorspec);
-               data{data_idx} = [xcol, ycol]';
-               usingclause{data_idx} = sprintf ("record=%d using ($1):($2)",
-                                                numel (xcol));
-             endif
-           endif
-         endif
-
-         ## patch outline
-         if (!(strcmp (obj.edgecolor, "none")
-                && (strcmp (obj.marker, "none")
-                    || (strcmp (obj.markeredgecolor, "none")
-                        && strcmp (obj.markerfacecolor, "none")))))
-
-           data_idx++;
-           is_image_data(data_idx) = false;
-           parametric(data_idx) = false;
-           have_cdata(data_idx) = false;
-           have_3d_patch(data_idx) = false;
-           titlespec{data_idx} = "title \"\"";
-           usingclause{data_idx} = sprintf ("record=%d", numel (obj.xdata));
-
-           if (isfield (obj, "markersize"))
-             mdat = obj.markersize / 3;
-           endif
-
-           if (isfield (obj, "edgecolor"))
-             ## FIXME: This is the wrong thing to do as edgecolor,
-             ## markeredgecolor and markerfacecolor can have different values
-             ## and we should treat them seperately. However, the code below
-             ## allows the scatter functions to work as expected, where only
-             ## one of these values is set.
-             if (strcmp (obj.edgecolor, "none"))
-               if (strcmp (obj.markeredgecolor, "none"))
-                 ec = obj.markerfacecolor;
-               else
-                 ec = obj.markeredgecolor;
-               endif
-             else
-               ec = obj.edgecolor;
-             endif
-
-             if ((strcmp (ec, "flat")
-                  || strcmp (ec, "interp"))
-                 && isfield (obj, "cdata"))
-               if (ndims (obj.cdata) == 2
-                   && (columns (obj.cdata) == nc
-                       && (rows (obj.cdata) == 1
-                           || rows (obj.cdata) == 3)))
-                 ccol = cdat(:, i);
-               elseif (ndims (obj.cdata) == 2
-                       && (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]);
-               else
-                 ccol = cdat;
-               endif
-               if (strcmp (ec, "flat"))
-                 if (numel (ccol) == 3)
-                   color = ccol;
-                 else
-                   if (isscalar (ccol))
-                     ccol = repmat (ccol, numel (xcol), 1);
-                   endif
-                   color = "flat";
-                   have_cdata(data_idx) = true;
-                 endif
-               elseif (strcmp (ec, "interp"))
-                 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);
-                   endif
-                   color = "interp";
-                   have_cdata(data_idx) = true;
-                 endif
-               endif
-             elseif (isnumeric (ec))
-               color = ec;
-             else
-               color = [0, 0, 0];
-             endif
-           else
-             color = [0, 0, 0];
-           endif
-
-           if (isfield (obj, "linestyle"))
-             switch (obj.linestyle)
-               case "-"
-                 lt = "lt 1";
-               case "--"
-                 lt = "lt 2";
-               case ":"
-                 lt = "lt 3";
-               case "-."
-                 lt = "lt 6";
-               case "none"
-                 lt = "";
-               otherwise
-                 lt = "";
-             endswitch
-           else
-             lt = "";
-           endif
-
-           if (isfield (obj, "linewidth"))
-             lw = sprintf ("linewidth %f", obj.linewidth);
-           else
-             lw = "";
-           endif
-
-           [pt, pt2, obj] = gnuplot_pointtype (obj);
-           if (! isempty (pt))
-             pt = sprintf ("pointtype %s", pt);
-           endif
-           if (! isempty (pt2))
-             pt2 = sprintf ("pointtype %s", pt2);
-           endif
-
-           if (mono)
-             colorspec = "";
-           else
-             if (ischar (color))
-               colorspec = "palette";
-             else
-               colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
-                                    round (255*color));
-             endif
-           endif
-
-           sidx = 1;
-           if (isempty (lt))
-             style = "";
-           else
-             style = "lines";
-           endif
-           tmpwith = {};
-
-           facesame = true;
-           if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor")
-               && ! strcmp (obj.markerfacecolor, "none"))
-             if (strcmp (obj.markerfacecolor, "auto")
-                 || ! isnumeric (obj.markerfacecolor)
-                 || (isnumeric (obj.markerfacecolor)
-                     && isequal (color, obj.markerfacecolor)))
-               style = strcat (style, "points");
-               if (isfield (obj, "markersize"))
-                 if (length (mdat) == nc)
-                   m = mdat(i);
-                 else
-                   m = mdat;
-                 endif
-                 ps = sprintf ("pointsize %f", m / 3);
-               else
-                 ps = "";
-               endif
-
-               tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
-                                        style, lw, pt2, lt, ps,
-                                        colorspec);
-             else
-               facesame = false;
-               if (! isempty (style))
-                 tmpwith{sidx} = sprintf ("with %s %s %s %s",
-                                          style, lw, lt,
-                                          colorspec);
-                 sidx ++;
-               endif
-               if (isnumeric (obj.markerfacecolor) && ! mono)
-                 colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
-                                      round (255*obj.markerfacecolor));
-               endif
-               style = "points";
-               if (isfield (obj, "markersize"))
-                 if (length (mdat) == nc)
-                   m = mdat(i);
-                 else
-                   m = mdat;
-                 endif
-                 ps = sprintf ("pointsize %f", m / 3);
-               else
-                 ps = "";
-               endif
-               tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
-                                        style, lw, pt2, lt, ps,
-                                        colorspec);
-             endif
-           endif
-
-           if (isfield (obj, "markeredgecolor")
-               && ! strcmp (obj.markeredgecolor, "none"))
-             if (facesame && ! isempty (pt)
-                 && (strcmp (obj.markeredgecolor, "auto")
-                     || ! isnumeric (obj.markeredgecolor)
-                     || (isnumeric (obj.markeredgecolor)
-                         && isequal (color, obj.markeredgecolor))))
-               if (sidx == 1 && ((length (style) == 5
-                        && strncmp (style, "lines", 5))
-                       || isempty (style)))
-                 style = strcat (style, "points");
-                 if (isfield (obj, "markersize"))
-                   if (length (mdat) == nc)
-                     m = mdat(i);
-                   else
-                     m = mdat;
-                   endif
-                   ps = sprintf ("pointsize %f", m / 3);
-                 else
-                   ps = "";
-                 endif
-                 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
-                                          style, lw, pt, lt, ps,
-                                          colorspec);
-               endif
-             else
-               if (! isempty (style))
-                 if (length (tmpwith) < sidx || isempty (tmpwith{sidx}))
-                   tmpwith{sidx} = sprintf ("with %s %s %s %s",
-                                            style, lw, lt,
-                                            colorspec);
-                 endif
-                 sidx ++;
-               endif
-
-               if (! isempty (pt))
-                 if (! mono)
-                   if (strcmp (obj.markeredgecolor, "auto"))
-                     colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
-                                          round (255*color));
-                   elseif (isnumeric (obj.markeredgecolor) && ! mono)
-                     colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"",
-                                          round (255*obj.markeredgecolor));
-                   endif
-                 endif
-                 style = "points";
-                 if (isfield (obj, "markersize"))
-                   if (length (mdat) == nc)
-                     m = mdat(i);
-                   else
-                     m = mdat;
-                   endif
-                   ps = sprintf ("pointsize %f", m / 3);
-                 else
-                   ps = "";
-                 endif
-                 tmpwith{sidx} = sprintf ("with %s %s %s %s %s %s",
-                                          style, lw, pt, lt, ps,
-                                          colorspec);
-               endif
-             endif
-           endif
-
-           if (isempty (tmpwith))
-             withclause{data_idx} = sprintf ("with %s %s %s %s %s",
-                                             style, lw, pt, lt,
-                                             colorspec);
-           else
-             withclause{data_idx} = tmpwith{1};
-           endif
-           if (nd == 3)
-             if (ischar (color))
-               if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol))
-                 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ...
-                                   [zcol; zcol(1)], [ccol; ccol(1)]]';
-               else
-                 data{data_idx} = [xcol, ycol, zcol, ccol]';
-               endif
-               usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3):($4)", columns (data{data_idx}));
-             else
-               if (! isnan (xcol) && ! isnan (ycol) && ! isnan (zcol))
-                 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ...
-                                   [zcol; zcol(1)]]';
-               else
-                 data{data_idx} = [xcol, ycol, zcol]';
-               endif
-               usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", columns (data{data_idx}));
-             endif
-           else
-             if (ischar (color))
-               if (! isnan (xcol) && ! isnan (ycol))
-                 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)], ...
-                                   [ccol; ccol(1)]]';
-               else
-                 data{data_idx} = [xcol, ycol, ccol]';
-               endif
-               usingclause{data_idx} = sprintf ("record=%d using ($1):($2):($3)", columns (data{data_idx}));
-             else
-               if (! isnan (xcol) && ! isnan (ycol))
-                 data{data_idx} = [[xcol; xcol(1)], [ycol; ycol(1)]]';
-               else
-                 data{data_idx} = [xcol, ycol]';
-               endif
-               usingclause{data_idx} = sprintf ("record=%d using ($1):($2)", columns (data{data_idx}));
-             endif
-           endif
-
-           if (length (tmpwith) > 1)
-             data_idx++;
-             is_image_data(data_idx) = is_image_data(data_idx - 1);
-             parametric(data_idx) = parametric(data_idx - 1);
-             have_cdata(data_idx) = have_cdata(data_idx - 1);
-             have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
-             titlespec{data_idx} = "title \"\"";
-             usingclause{data_idx} = usingclause{data_idx - 1};
-             data{data_idx} = data{data_idx - 1};
-             withclause{data_idx} = tmpwith{2};
-           endif
-           if (length (tmpwith) > 2)
-             data_idx++;
-             is_image_data(data_idx) = is_image_data(data_idx - 1);
-             parametric(data_idx) = parametric(data_idx - 1);
-             have_cdata(data_idx) = have_cdata(data_idx - 1);
-             have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
-             titlespec{data_idx} = "title \"\"";
-             usingclause{data_idx} = usingclause{data_idx - 1};
-             data{data_idx} = data{data_idx - 1};
-             withclause{data_idx} = tmpwith{3};
-           endif
-         endif
-       endfor
-
-      case "surface"
-        view_map = true;
-        if (! (strcmp (obj.edgecolor, "none")
-               && strcmp (obj.facecolor, "none")))
-          data_idx++;
-          is_image_data(data_idx) = false;
-          parametric(data_idx) = false;
-          have_cdata(data_idx) = true;
-          have_3d_patch(data_idx) = false;
-          style = do_linestyle_command (obj, obj.edgecolor,
-                                        data_idx, mono,
-                                        plot_stream);
-
-          if (isempty (obj.displayname))
-            titlespec{data_idx} = "title \"\"";
-          else
-            tmp = undo_string_escapes (
-                    __maybe_munge_text__ (enhanced, obj, "displayname")
-                  );
-            titlespec{data_idx} = ['title "' tmp '"'];
-          endif
-          withclause{data_idx} = sprintf ("with pm3d linestyle %d",
-                                          data_idx);
-          withpm3d = true;
-          pm3didx = data_idx;
-
-          xdat = obj.xdata;
-          ydat = obj.ydata;
-          zdat = obj.zdata;
-          cdat = obj.cdata;
-
-          err = false;
-          if (! size_equal (zdat, cdat))
-            err = true;
-          endif
-          if (isvector (xdat) && isvector (ydat) && ismatrix (zdat))
-            if (rows (zdat) == length (ydat)
-                && columns (zdat) == length (xdat))
-              [xdat, ydat] = meshgrid (xdat, ydat);
-            else
-              err = true;
-            endif
-          elseif (ismatrix (xdat) && ismatrix (ydat) && ismatrix (zdat))
-            if (! size_equal (xdat, ydat, zdat))
-              err = true;
-            endif
-          else
-            err = true;
-          endif
-          if (err)
-            error ("__go_draw_axes__: invalid grid data");
-          endif
-          xlen = columns (zdat);
-          ylen = rows (zdat);
-          if (xlen == columns (xdat) && xlen == columns (ydat)
-              && ylen == rows (xdat) && ylen == rows (ydat))
-            len = 4 * xlen;
-            zz = zeros (ylen, len);
-            k = 1;
-            for kk = 1:4:len
-              zz(:,kk)   = xdat(:,k);
-              zz(:,kk+1) = ydat(:,k);
-              zz(:,kk+2) = zdat(:,k);
-              zz(:,kk+3) = cdat(:,k);
-              k++;
-            endfor
-            data{data_idx} = zz.';
-          endif
-
-          if (doing_interp_color)
-            interp_str = "interpolate 0, 0";
-          else
-            ## No interpolation of facecolors.
-            interp_str = "";
-          endif
-          usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3):($4)", ylen, xlen);
-
-          flat_interp_face = (strcmp (obj.facecolor, "flat")
-                              || strcmp (obj.facecolor, "interp"));
-          flat_interp_edge = (strcmp (obj.edgecolor, "flat")
-                              || strcmp (obj.edgecolor, "interp"));
-
-          facecolor_none_or_white = (strcmp (obj.facecolor, "none")
-                                     || (isnumeric (obj.facecolor)
-                                         && all (obj.facecolor == 1)));
-          hidden_removal = false;
-          fputs (plot_stream, "set style increment default;\n");
-          if (flat_interp_edge && facecolor_none_or_white)
-            withpm3d = false;
-            withclause{data_idx} = sprintf ("with %s palette", style{1});
-            fputs (plot_stream, "unset pm3d\n");
-            if (all (obj.facecolor == 1))
-              hidden_removal = true;
-            endif
-          elseif (facecolor_none_or_white)
-            if (all (obj.facecolor == 1))
-              hidden_removal = true;
-            endif
-            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);
-            fputs (plot_stream, "unset pm3d\n");
-          endif
-
-          if (doing_interp_color)
-            ## "depthorder" interferes with interpolation of colors.
-            dord = "scansautomatic";
-          else
-            dord = "depthorder";
-          endif
-
-          if (flat_interp_face && strcmp (obj.edgecolor, "flat"))
-            fprintf (plot_stream,
-                     "set pm3d explicit at s %s %s corners2color c3;\n",
-                     interp_str, dord);
-          elseif (! facecolor_none_or_white)
-            if (strcmp (obj.edgecolor, "none"))
-              if (__gnuplot_has_feature__ ("transparent_surface")
-                  && isscalar (obj.facealpha))
-                fprintf (plot_stream,
-                         "set style fill transparent solid %f;\n",
-                         obj.facealpha);
-              endif
-              fprintf (plot_stream,
-                       "set pm3d explicit at s %s corners2color c3;\n",
-                       interp_str, dord);
-            else
-              fprintf (plot_stream,
-                       "set pm3d explicit at s hidden3d %d %s %s corners2color c3;\n",
-                       data_idx, interp_str, dord);
-
-              if (__gnuplot_has_feature__ ("transparent_surface")
-                  && isscalar (obj.facealpha))
-                fprintf (plot_stream,
-                         "set style fill transparent solid %f;\n",
-                         obj.facealpha);
-              endif
-            endif
-          endif
-
-          zz = [];
-          if (length (style) > 1)
-            len = 3 * xlen;
-            zz = zeros (ylen, len);
-            k = 1;
-            for kk = 1:3:len
-              zz(:,kk)   = xdat(:,k);
-              zz(:,kk+1) = ydat(:,k);
-              zz(:,kk+2) = zdat(:,k);
-              k++;
-            endfor
-            zz = zz.';
-
-            data_idx++;
-            is_image_data(data_idx) = is_image_data(data_idx - 1);
-            parametric(data_idx) = parametric(data_idx - 1);
-            have_cdata(data_idx) = false;
-            have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
-            titlespec{data_idx} = "title \"\"";
-            usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen);
-            data{data_idx} = zz;
-            withclause{data_idx} = sprintf ("with %s linestyle %d",
-                                            style{2}, data_idx);
-
-          endif
-          if (length (style) > 2)
-            data_idx++;
-            is_image_data(data_idx) = is_image_data(data_idx - 1);
-            parametric(data_idx) = parametric(data_idx - 1);
-            have_cdata(data_idx) = false;
-            have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
-            titlespec{data_idx} = "title \"\"";
-            usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen);
-            data{data_idx} = zz;
-            withclause{data_idx} = sprintf ("with %s linestyle %d",
-                                            style{3}, data_idx);
-          endif
-          if (withpm3d && strcmp (style{1}, "linespoints"))
-            if (isempty (zz))
-              len = 3 * xlen;
-              zz = zeros (ylen, len);
-              k = 1;
-              for kk = 1:3:len
-                zz(:,kk)   = xdat(:,k);
-                zz(:,kk+1) = ydat(:,k);
-                zz(:,kk+2) = zdat(:,k);
-                k++;
-              endfor
-              zz = zz.';
-            endif
-            data_idx++;
-            is_image_data(data_idx) = is_image_data(data_idx - 1);
-            parametric(data_idx) = parametric(data_idx - 1);
-            have_cdata(data_idx) = false;
-            have_3d_patch(data_idx) = have_3d_patch(data_idx - 1);
-            titlespec{data_idx} = "title \"\"";
-            usingclause{data_idx} = sprintf ("record=%dx%d using ($1):($2):($3)", ylen, xlen);
-            data{data_idx} = zz;
-            withclause{data_idx} = sprintf ("with points linestyle %d",
-                                            pm3didx);
-          endif
-        endif
-
-      case "text"
-        [label, f, s] = __maybe_munge_text__ (enhanced, obj, "string");
-        fontspec = create_fontspec (f, s, gnuplot_term);
-        lpos = obj.position;
-        halign = obj.horizontalalignment;
-        valign = obj.verticalalignment;
-        angle = obj.rotation;
-        units = obj.units;
-        color = obj.color;
-        if (strcmpi (units, "normalized"))
-          units = "graph";
-        elseif (strcmp (axis_obj.yaxislocation, "right")
-                && strcmp (units, "data"))
-          units = "second";
-        else
-          units = "";
-        endif
-
-        if (isnumeric (color))
-          colorspec = get_text_colorspec (color, mono);
-        endif
-
-        if (ischar (obj.string))
-          num_lines = rows (obj.string);
-          num_lines += numel (strfind (obj.string, "\n"));
-        else
-          num_lines = numel (obj.string);
-        endif
-        switch (valign)
-          ## Text offset in characters. Relies on gnuplot for font metrics.
-          case "top"
-            dy = -0.5;
-          case "cap"
-            dy = -0.5;
-          case "middle"
-            dy = 0.5 * (num_lines - 1);
-          case "baseline"
-            dy = 0.5 + (num_lines - 1);
-          case "bottom"
-            dy = 0.5 + (num_lines - 1);
-        endswitch
-        ## 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];
-
-        ## FIXME: Multiline text produced the gnuplot
-        ##        "warning: ft_render: skipping glyph"
-        if (nd == 3)
-          ## This produces the desired vertical alignment in 3D.
-          fprintf (plot_stream,
-                   "set label \"%s\" at %s %.15e,%.15e,%.15e %s rotate by %f offset character %f,%f %s %s front %s;\n",
-                   undo_string_escapes (label), units, lpos(1),
-                   lpos(2), lpos(3), halign, angle, dx_and_dy, fontspec,
-                   __do_enhanced_option__ (enhanced, obj), colorspec);
-        else
-          fprintf (plot_stream,
-                   "set label \"%s\" at %s %.15e,%.15e %s rotate by %f offset character %f,%f %s %s front %s;\n",
-                   undo_string_escapes (label), units,
-                   lpos(1), lpos(2), halign, angle, dx_and_dy, fontspec,
-                   __do_enhanced_option__ (enhanced, obj), colorspec);
-        endif
-
-      case "hggroup"
-        ## Push group children into the kid list.
-        if (isempty (kids))
-          kids = obj.children;
-        elseif (! isempty (obj.children))
-          kids = [kids; obj.children];
-        endif
-
-      otherwise
-        error ("__go_draw_axes__: unknown object class, %s",
-               obj.type);
-    endswitch
-
-  endwhile
-
-  ## This is need to prevent warnings for rotations in 3D plots, while
-  ## allowing colorbars with contours.
-  if (nd == 2 || (data_idx > 1 && ! view_map))
-    fputs (plot_stream, "set pm3d implicit;\n");
-  else
-    fputs (plot_stream, "set pm3d explicit;\n");
-  endif
-
-  if (isnan (hidden_removal) || hidden_removal)
-    fputs (plot_stream, "set hidden3d;\n");
-  else
-    fputs (plot_stream, "unset hidden3d;\n");
-  endif
-
-  have_data = (! (isempty (data) || all (cellfun ("isempty", data))));
-
-  ## Note we don't use the [xy]2range of gnuplot as we don't use the
-  ## dual axis plotting features of gnuplot.
-  if (isempty (xlim))
-    return;
-  endif
-  if (strcmpi (axis_obj.xdir, "reverse"))
-    xdir = "reverse";
-  else
-    xdir = "noreverse";
-  endif
-  fprintf (plot_stream, "set xrange [%.15e:%.15e] %s;\n", xlim, xdir);
-  if (strcmpi (axis_obj.xaxislocation, "top"))
-    fprintf (plot_stream, "set x2range [%.15e:%.15e] %s;\n", xlim, xdir);
-  endif
-
-  if (isempty (ylim))
-    return;
-  endif
-  if (strcmpi (axis_obj.ydir, "reverse"))
-    ydir = "reverse";
-  else
-    ydir = "noreverse";
-  endif
-  fprintf (plot_stream, "set yrange [%.15e:%.15e] %s;\n", ylim, ydir);
-  if (strcmpi (axis_obj.yaxislocation, "right"))
-    fprintf (plot_stream, "set y2range [%.15e:%.15e] %s;\n", ylim, ydir);
-  endif
-
-  if (nd == 3)
-    if (isempty (zlim))
-      return;
-    endif
-    if (strcmpi (axis_obj.zdir, "reverse"))
-      zdir = "reverse";
-    else
-      zdir = "noreverse";
-    endif
-    fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir);
-  endif
-
-  cmap = parent_figure_obj.colormap;
-  cmap_sz = rows (cmap);
-  if (! any (isinf (clim)))
-    if (truecolor || ! cdatadirect)
-      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 [%.15e:%.15e];\n",
-                 clim(1), clim(2) * (cmap_sz + rows (addedcmap)) / cmap_sz);
-      else
-        fprintf (plot_stream, "set cbrange [%.15e:%.15e];\n", clim);
-      endif
-    else
-      fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz +
-               rows (addedcmap));
-    endif
-  endif
-
-  if (strcmpi (axis_obj.box, "on"))
-    if (nd == 3)
-      fputs (plot_stream, "set border 4095;\n");
-    else
-      fputs (plot_stream, "set border 431;\n");
-    endif
-  else
-    if (nd == 3)
-      fputs (plot_stream, "set border 895;\n");
-    elseif (! isempty (axis_obj.ytick))
-      if (strcmpi (axis_obj.yaxislocation, "right"))
-        fprintf (plot_stream, "unset ytics; set y2tics %s nomirror\n",
-                 axis_obj.tickdir);
-        if (strcmpi (axis_obj.xaxislocation, "top"))
-          maybe_do_x2tick_mirror (plot_stream, axis_obj)
-          fputs (plot_stream, "set border 12;\n");
-        elseif (strcmpi (axis_obj.xaxislocation, "bottom"))
-          maybe_do_xtick_mirror (plot_stream, axis_obj)
-          fputs (plot_stream, "set border 9;\n");
-        else # xaxislocation == zero
-          fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n",
-                   axis_obj.tickdir);
-          fputs (plot_stream, "set border 8;\n");
-          fprintf (plot_stream, "set xzeroaxis lt -1 lw %f;\n",
-                   axis_obj.linewidth);
-        endif
-      elseif (strcmpi (axis_obj.yaxislocation, "left"))
-        fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n",
-                 axis_obj.tickdir);
-        if (strcmpi (axis_obj.xaxislocation, "top"))
-          maybe_do_x2tick_mirror (plot_stream, axis_obj)
-          fputs (plot_stream, "set border 6;\n");
-        elseif (strcmpi (axis_obj.xaxislocation, "bottom"))
-          maybe_do_xtick_mirror (plot_stream, axis_obj)
-          fputs (plot_stream, "set border 3;\n");
-        else # xaxislocation == zero
-          maybe_do_xtick_mirror (plot_stream, axis_obj)
-          fputs (plot_stream, "set border 2;\n");
-          fprintf (plot_stream, "set xzeroaxis lt -1 lw %f;\n",
-                   axis_obj.linewidth);
-        endif
-      else # yaxislocation == zero
-        fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n",
-                 axis_obj.tickdir);
-        if (strcmpi (axis_obj.xaxislocation, "top"))
-          maybe_do_x2tick_mirror (plot_stream, axis_obj)
-          fputs (plot_stream, "set border 4;\n");
-        elseif (strcmpi (axis_obj.xaxislocation, "bottom"))
-          maybe_do_xtick_mirror (plot_stream, axis_obj)
-          fputs (plot_stream, "set border 1;\n");
-        else # xaxislocation == zero
-          maybe_do_xtick_mirror (plot_stream, axis_obj)
-          fprintf (plot_stream, "unset y2tics; set ytics %s nomirror\n",
-                   axis_obj.tickdir);
-          fputs (plot_stream, "unset border;\n");
-          fprintf (plot_stream, "set xzeroaxis lt -1 lw %f;\n",
-                   axis_obj.linewidth);
-        endif
-        fprintf (plot_stream, "set yzeroaxis lt -1 lw %f;\n",
-                 axis_obj.linewidth);
-      endif
-    endif
-  endif
-
-  if (strcmpi (axis_obj.visible, "off"))
-    fputs (plot_stream, "unset border; unset tics\n");
-  else
-    fprintf (plot_stream, "set border lw %f;\n", axis_obj.linewidth);
-  endif
-
-  if (! isempty (hlgnd) && ! isempty (hlgnd.children)
-      && any (strcmpi (get (hlgnd.children, "visible"), "on")))
-    if (strcmpi (hlgnd.box, "on"))
-      box = "box";
-    else
-      box = "nobox";
-    endif
-    if (strcmpi (hlgnd.orientation, "vertical"))
-      horzvert = "vertical";
-    else
-      horzvert = "horizontal";
-    endif
-    if (strcmpi (hlgnd.textposition, "right"))
-      reverse = "reverse";
-    else
-      reverse = "noreverse";
-    endif
-    inout = "inside";
-    keypos = hlgnd.location;
-    if (ischar (keypos))
-      keypos = lower (keypos);
-      keyout = strfind (keypos, "outside");
-      if (! isempty (keyout))
-        inout = "outside";
-        keypos = keypos(1:keyout-1);
-      endif
-    endif
-    switch (keypos)
-      case "north"
-        pos = "center top";
-      case "south"
-        pos = "center bottom";
-      case "east"
-        pos = "right center";
-      case "west"
-        pos = "left center";
-      case "northeast"
-        pos = "right top";
-      case "northwest"
-        pos = "left top";
-      case "southeast"
-        pos = "right bottom";
-      case "southwest"
-        pos = "left bottom";
-      case "best"
-        pos = "";
-        warning ("legend: 'Best' not yet implemented for location specifier.\n");
-        ## Least conflict with data in plot.
-        ## Least unused space outside plot.
-      otherwise
-        pos = "";
-    endswitch
-    if (__gnuplot_has_feature__ ("key_has_font_properties"))
-      [fontname, fontsize] = get_fontname_and_size (hlgnd);
-      fontspacespec = [ create_spacingspec(fontname, fontsize, gnuplot_term),...
-                        create_fontspec(fontname, fontsize, gnuplot_term) ];
-    else
-      fontspacespec = "";
-    endif
-    textcolors = get (findobj (hlgnd.children, "type", "text"), "color");
-    if (iscell (textcolors))
-      textcolors = cell2mat (textcolors);
-      textcolors = unique (textcolors, "rows");
-    endif
-    if (rows (textcolors) > 1)
-      ## Gnuplot is unable to assign arbitrary colors to each text entry
-      ## for the key/legend.  But, the text color can be set to match the
-      ## color of the plot object.
-      colorspec = "textcolor variable";
-    else
-      colorspec = get_text_colorspec (textcolors, mono);
-    endif
-    fprintf (plot_stream, "set key %s %s;\nset key %s %s %s %s %s %s;\n",
-             inout, pos, box, reverse, horzvert, fontspacespec, colorspec,
-             __do_enhanced_option__ (enhanced, hlgnd));
-  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 (mono == false && length (cmap) > 0)
-    fprintf (plot_stream,
-             "set palette positive color model RGB maxcolors %i;\n",
-             cmap_sz);
-    fprintf (plot_stream,
-             "set palette file \"-\" binary record=%d using 1:2:3:4;\n",
-             cmap_sz);
-    fwrite (plot_stream, [1:cmap_sz; cmap.'], "float32");
-    fwrite (plot_stream, "\n");
-  endif
-
-  fputs (plot_stream, "unset colorbox;\n");
-
-  if (have_data)
-    if (nd == 2)
-      plot_cmd = "plot";
-    else
-      plot_cmd = "splot";
-      rot_x = 90 - axis_obj.view(2);
-      rot_z = axis_obj.view(1);
-      while (rot_z < 0)
-        rot_z += 360;
-      endwhile
-      fputs (plot_stream, "set ticslevel 0;\n");
-      if (view_map && rot_x == 0 && rot_z == 0)
-        fputs (plot_stream, "set view map;\n");
-      else
-        fprintf (plot_stream, "set view %.15g, %.15g;\n", rot_x, rot_z);
-      endif
-    endif
-    if (have_3d_patch (1))
-      fputs (plot_stream, "set pm3d depthorder\n");
-      fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd,
-               usingclause{1}, titlespec{1}, withclause{1});
-    elseif (is_image_data (1))
-      if (numel (is_image_data) > 1 && is_image_data(2))
-        ## Remove terminating semicolon
-        n = max (strfind (withclause{1}, ";"));
-        if (! isempty (n))
-          withclause{1} = withclause{1}(1:n-1);
-        endif
-      endif
-      fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd,
-               usingclause{1}, titlespec{1}, withclause{1});
-    else
-      fprintf (plot_stream, "%s \"-\" binary format='%%float64' %s %s %s \\\n",
-               plot_cmd, usingclause{1}, titlespec{1}, withclause{1});
-    endif
-    for i = 2:data_idx
-      if (have_3d_patch (i))
-        fprintf (plot_stream, ", \"-\" %s %s %s \\\n",
-                 usingclause{i}, titlespec{i}, withclause{i});
-      elseif (is_image_data (i))
-        if (! is_image_data (i-1))
-          fputs (plot_stream, "; ");
-          if (bg_is_set)
-            fputs (plot_stream, "unset obj 1; \\\n");
-            bg_is_set = false;
-          endif
-          if (fg_is_set)
-            fputs (plot_stream, "unset obj 2; \\\n");
-            fg_is_set = false;
-          endif
-          if (numel (is_image_data) > i && is_image_data(i+1))
-            ## Remove terminating semicolon
-            n = max (strfind (withclause{i}, ";"));
-            if (! isempty (n))
-              withclause{i} = withclause{i}(1:n-1);
-            endif
-          endif
-          fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", plot_cmd,
-                   usingclause{i}, titlespec{i}, withclause{i});
-        else
-          ## For consecutive images continue with the same plot command
-          fprintf (plot_stream, "%s \"-\" %s %s %s \\\n", ",",
-                   usingclause{i}, titlespec{i}, withclause{i});
-        endif
-      elseif (is_image_data (i-1))
-        if (bg_is_set)
-          fputs (plot_stream, "unset obj 1; \\\n");
-          bg_is_set = false;
-        endif
-        if (fg_is_set)
-          fputs (plot_stream, "unset obj 2; \\\n");
-          fg_is_set = false;
-        endif
-        fprintf (plot_stream,"%s \"-\" binary format='%%float64' %s %s %s \\\n",
-                 plot_cmd, usingclause{i}, titlespec{i}, withclause{i});
-      else
-        fprintf (plot_stream, ", \"-\" binary format='%%float64' %s %s %s \\\n",
-                 usingclause{i}, titlespec{i}, withclause{i});
-      endif
-    endfor
-    fputs (plot_stream, ";\n");
-    for i = 1:data_idx
-      if (have_3d_patch (i))
-        ## 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})
-          if (j != 1)
-            fputs (plot_stream, "\n\n");
-          endif
-          fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data{i}(:,j).');
-          fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n\n",data{i}(:,j+1).');
-          fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data{i}(:,j+2).');
-          fprintf (plot_stream, "%.15g %.15g %.15g %.15g\n", data{i}(:,j+3).');
-        endfor
-        fputs (plot_stream, "e\n");
-      elseif (is_image_data(i))
-        fwrite (plot_stream, data{i}, "float32");
-      else
-        __gnuplot_write_data__ (plot_stream, data{i}, nd, parametric(i),
-                                have_cdata(i));
-      endif
-    endfor
-  else
-    fputs (plot_stream, "plot \"-\";\nInf Inf\ne\n");
-  endif
-
-  ## Needed to allow mouse rotation with pcolor.
-  if (view_map)
-    fputs (plot_stream, "unset view;\n");
-  endif
-
-  if (bg_is_set)
-    fputs (plot_stream, "unset obj 1;\n");
-    bg_is_set = false;
-  endif
-
-  fflush (plot_stream);
-
-endfunction
-
-function x = flip (x)
-  if (rows (x) == 1)
-    x = fliplr (x);
-  elseif (columns (x) == 1 || ischar (x))
-    x = flipud (x);
-  else
-    x = flipud (fliplr (x));
-  endif
-endfunction
-
-function spacing_spec = create_spacingspec (f, s, gp_term)
-  ## The gnuplot default font size is 10, and default spacing is 1.25.
-  ## gnuplot has a concept of a figure global font, and sizes everything
-  ## appropriate to that, including the legend spacing.
-  ##
-  ## This means that if an alternative size is used, gnuplot will use an
-  ## inappropriate spacing in the legend by default.
-  ##
-  ## FIXME: Are fractional spacing specifications allowed?  Or should this
-  ##        number be rounded?
-  spc = s / 10 * 1.25;
-  spacing_spec = sprintf ("spacing %d", spc);
-
-endfunction
-
-function fontspec = create_fontspec (f, s, gp_term)
-  if (strcmp (f, "*") || strcmp (gp_term, "tikz"))
-    fontspec = sprintf ("font \",%d\"", s);
-  else
-    fontspec = sprintf ("font \"%s,%d\"", f, s);
-  endif
-endfunction
-
-function style = do_linestyle_command (obj, linecolor, idx, mono,
-                                       plot_stream, errbars = "")
-  style = {};
-
-  fprintf (plot_stream, "set style line %d default;\n", idx);
-  fprintf (plot_stream, "set style line %d", idx);
-
-  found_style = false;
-  if (isnumeric (linecolor))
-    color = linecolor;
-    if (! mono)
-      fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
-               round (255*color));
-    endif
-  else
-    color = [0, 0, 0];
-  endif
-
-  if (isfield (obj, "linestyle"))
-    switch (obj.linestyle)
-      case "-"
-        lt = "1";
-      case "--"
-        lt = "2";
-      case ":"
-        lt = "3";
-      case "-."
-        lt = "6";
-      case "none"
-        lt = "";
-      otherwise
-        lt = "";
-    endswitch
-
-    if (! isempty (lt))
-      fprintf (plot_stream, " linetype %s", lt);
-    endif
-
-  else
-    lt = "";
-  endif
-  if (! isempty (errbars))
-    found_style = true;
-  endif
-
-  if (isfield (obj, "linewidth"))
-    fprintf (plot_stream, " linewidth %f", obj.linewidth);
-    found_style = true;
-  endif
-
-  [pt, pt2, obj] = gnuplot_pointtype (obj);
-
-  if (! isempty (pt))
-    found_style = true;
-  endif
-
-  sidx = 1;
-  if (isempty (errbars))
-    if (isempty (lt))
-      style{sidx} = "";
-    else
-      style{sidx} = "lines";
-    endif
-
-    facesame = true;
-    if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor")
-        && ! strcmp (obj.markerfacecolor, "none"))
-      if (strcmp (obj.markerfacecolor, "auto")
-          || ! isnumeric (obj.markerfacecolor)
-          || (isnumeric (obj.markerfacecolor)
-              && isequal (color, obj.markerfacecolor)))
-        if (! isempty (pt2))
-          fprintf (plot_stream, " pointtype %s", pt2);
-          style{sidx} = strcat (style{sidx}, "points");
-        endif
-        if (isfield (obj, "markersize"))
-          fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
-        endif
-      else
-        facesame = false;
-        if (! found_style)
-          fputs (plot_stream, " default");
-        endif
-        fputs (plot_stream, ";\n");
-        if (! isempty (style{sidx}))
-          sidx ++;
-          idx ++;
-        else
-          fputs (plot_stream, ";\n");
-        endif
-        fprintf (plot_stream, "set style line %d default;\n", idx);
-        fprintf (plot_stream, "set style line %d", idx);
-        if (isnumeric (obj.markerfacecolor) && ! mono)
-          fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
-                   round (255*obj.markerfacecolor));
-        endif
-        if (! isempty (pt2))
-          style{sidx} = "points";
-          fprintf (plot_stream, " pointtype %s", pt2);
-        endif
-        if (isfield (obj, "markersize"))
-          fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
-        endif
-      endif
-    endif
-    if (isfield (obj, "markeredgecolor")
-        && ! strcmp (obj.markeredgecolor, "none"))
-      if (facesame && ! isempty (pt)
-          && (strcmp (obj.markeredgecolor, "auto")
-              || ! isnumeric (obj.markeredgecolor)
-              || (isnumeric (obj.markeredgecolor)
-                  && isequal (color, obj.markeredgecolor))))
-        if (sidx == 1 && ((length (style{sidx}) == 5
-            && strncmp (style{sidx}, "lines", 5)) || isempty (style{sidx})))
-          if (! isempty (pt))
-            style{sidx} = strcat (style{sidx}, "points");
-            fprintf (plot_stream, " pointtype %s", pt);
-          endif
-          if (isfield (obj, "markersize"))
-            fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
-          endif
-        endif
-      else
-        if (! found_style)
-          fputs (plot_stream, " default");
-        endif
-        fputs (plot_stream, ";\n");
-        if (! isempty (style{sidx}))
-          sidx ++;
-          idx ++;
-        else
-          fputs (plot_stream, ";\n");
-        endif
-        fprintf (plot_stream, "set style line %d default;\n", idx);
-        fprintf (plot_stream, "set style line %d", idx);
-        if (! mono)
-          if (strcmp (obj.markeredgecolor, "auto"))
-            fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
-                     round (255*color));
-          elseif (isnumeric (obj.markeredgecolor) && ! mono)
-            fprintf (plot_stream, " linecolor rgb \"#%02x%02x%02x\"",
-                     round (255*obj.markeredgecolor));
-          endif
-        endif
-        if (! isempty (pt))
-          style{sidx} = "points";
-          fprintf (plot_stream, " pointtype %s", pt);
-        endif
-        if (isfield (obj, "markersize"))
-          fprintf (plot_stream, " pointsize %f", obj.markersize / 3);
-        endif
-      endif
-    endif
-  else
-    style{1} = errbars;
-    fputs (plot_stream, " pointtype 0");
-  endif
-
-  if (! found_style && isempty (style{1}))
-    fputs (plot_stream, " default");
-  endif
-
-  fputs (plot_stream, ";\n");
-
-endfunction
-
-function [pt, pt2, obj] = gnuplot_pointtype (obj)
-  if (isfield (obj, "marker"))
-    switch (obj.marker)
-      case "+"
-        pt = pt2 = "1";
-      case "o"
-        pt = "6";
-        pt2 = "7";
-      case "*"
-        pt = pt2 = "3";
-      case "."
-        pt = "6";
-        pt2 = "7";
-        if (isfield (obj, "markerfacecolor")
-            || strcmp (obj.markerfacecolor, "none"))
-          obj.markerfacecolor = "auto";
-        endif
-        if (isfield (obj, "markersize"))
-          obj.markersize /= 3;
-        else
-          obj.markersize = 5;
-        endif
-      case "x"
-        pt = pt2 = "2";
-      case {"square", "s"}
-        pt = "4";
-        pt2 = "5";
-      case {"diamond", "d"}
-        pt = "12";
-        pt2 = "13";
-      case "^"
-        pt = "8";
-        pt2 = "9";
-      case "v"
-        pt = "10";
-        pt2 = "11";
-      case ">"
-        ## FIXME: Should be triangle pointing right, use triangle pointing up
-        pt = "8";
-        pt2 = "9";
-      case "<"
-        ## FIXME: Should be triangle pointing left, use triangle pointing down
-        pt = "10";
-        pt2 = "11";
-      case {"pentagram", "p"}
-        ## FIXME: Should be pentagram, using pentagon
-        pt = "14";
-        pt2 = "15";
-      case {"hexagram", "h"}
-        ## FIXME: Should be 6 pt start, using "*" instead
-        pt = pt2 = "3";
-      case "none"
-        pt = pt2 = "";
-      otherwise
-        pt = pt2 = "";
-    endswitch
-  else
-    pt = pt2 = "";
-  endif
-endfunction
-
-function __gnuplot_write_data__ (plot_stream, data, nd, parametric, cdata)
-
-  ## DATA is already transposed.
-
-  ## FIXME: this may need to be converted to C++ for speed.
-
-  ## Convert NA elements to normal NaN values because fprintf writes
-  ## "NA" and that confuses gnuplot.
-  idx = find (isna (data));
-  if (any (idx))
-    data(idx) = NaN;
-  endif
-
-  if (nd == 2)
-    fwrite (plot_stream, data, "float64");
-  elseif (nd == 3)
-    if (parametric)
-      fwrite (plot_stream, data, "float64");
-    else
-      nr = rows (data);
-      if (cdata)
-        for j = 1:4:nr
-          fwrite (plot_stream, data(j:j+3,:), "float64");
-        endfor
-      else
-        for j = 1:3:nr
-          fwrite (plot_stream, data(j:j+2,:), "float64");
-        endfor
-      endif
-    endif
-  endif
-
-endfunction
-
-function do_tics (obj, plot_stream, ymirror, mono, gnuplot_term)
-
-  obj.xticklabel = ticklabel_to_cell (obj.xticklabel);
-  obj.yticklabel = ticklabel_to_cell (obj.yticklabel);
-  obj.zticklabel = ticklabel_to_cell (obj.zticklabel);
-
-  if (strcmp (obj.xminorgrid, "on"))
-    obj.xminortick = "on";
-  endif
-  if (strcmp (obj.yminorgrid, "on"))
-    obj.yminortick = "on";
-  endif
-  if (strcmp (obj.zminorgrid, "on"))
-    obj.zminortick = "on";
-  endif
-
-  [fontname, fontsize] = get_fontname_and_size (obj);
-  fontspec = create_fontspec (fontname, fontsize, gnuplot_term);
-
-  ## A Gnuplot tic scale of 69 is equivalent to Octave's 0.5.
-  ticklength = sprintf ("scale %4.1f", (69/0.5)*obj.ticklength(1));
-
-  if (strcmpi (obj.xaxislocation, "top"))
-    do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode,
-               obj.xticklabel, obj.xcolor, "x2", plot_stream, true, mono,
-               "border", obj.tickdir, ticklength, fontname, fontspec,
-               obj.interpreter, obj.xscale, obj.xsgn, gnuplot_term);
-    do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel,
-               obj.xcolor, "x", plot_stream, true, mono, "border",
-               "", "", fontname, fontspec, obj.interpreter, obj.xscale,
-               obj.xsgn, gnuplot_term);
-  elseif (strcmpi (obj.xaxislocation, "zero"))
-    do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode,
-               obj.xticklabel, obj.xcolor, "x", plot_stream, true, mono,
-               "axis", obj.tickdir, ticklength, fontname, fontspec,
-               obj.interpreter, obj.xscale, obj.xsgn, gnuplot_term);
-    do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel,
-               obj.xcolor, "x2", plot_stream, true, mono, "axis",
-               "", "", fontname, fontspec, obj.interpreter, obj.xscale,
-               obj.xsgn, gnuplot_term);
-  else
-    do_tics_1 (obj.xtickmode, obj.xtick, obj.xminortick, obj.xticklabelmode,
-               obj.xticklabel, obj.xcolor, "x", plot_stream, true, mono,
-               "border", obj.tickdir, ticklength, fontname, fontspec,
-               obj.interpreter, obj.xscale, obj.xsgn, gnuplot_term);
-    do_tics_1 ("manual", [], "off", obj.xticklabelmode, obj.xticklabel,
-               obj.xcolor, "x2", plot_stream, true, mono, "border",
-               "", "", fontname, fontspec, obj.interpreter, obj.xscale,
-               obj.xsgn, gnuplot_term);
-  endif
-  if (strcmpi (obj.yaxislocation, "right"))
-    do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode,
-               obj.yticklabel, obj.ycolor, "y2", plot_stream, ymirror, mono,
-               "border", obj.tickdir, ticklength, fontname, fontspec,
-               obj.interpreter, obj.yscale, obj.ysgn, gnuplot_term);
-    do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel,
-               obj.ycolor, "y", plot_stream, ymirror, mono, "border",
-               "", "", fontname, fontspec, obj.interpreter, obj.yscale,
-               obj.ysgn, gnuplot_term);
-  elseif (strcmpi (obj.yaxislocation, "zero"))
-    do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode,
-               obj.yticklabel, obj.ycolor, "y", plot_stream, ymirror, mono,
-               "axis", obj.tickdir, ticklength, fontname, fontspec,
-               obj.interpreter, obj.yscale, obj.ysgn, gnuplot_term);
-    do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel,
-               obj.ycolor, "y2", plot_stream, ymirror, mono, "axis",
-               "", "", fontname, fontspec, obj.interpreter, obj.yscale,
-               obj.ysgn, gnuplot_term);
-  else
-    do_tics_1 (obj.ytickmode, obj.ytick, obj.yminortick, obj.yticklabelmode,
-               obj.yticklabel, obj.ycolor, "y", plot_stream, ymirror, mono,
-               "border", obj.tickdir, ticklength, fontname, fontspec,
-               obj.interpreter, obj.yscale, obj.ysgn, gnuplot_term);
-    do_tics_1 ("manual", [], "off", obj.yticklabelmode, obj.yticklabel,
-               obj.ycolor, "y2", plot_stream, ymirror, mono, "border",
-               "", "", fontname, fontspec, obj.interpreter, obj.yscale,
-               obj.ysgn, gnuplot_term);
-  endif
-  do_tics_1 (obj.ztickmode, obj.ztick, obj.zminortick, obj.zticklabelmode,
-             obj.zticklabel, obj.zcolor, "z", plot_stream, true, mono,
-             "border", obj.tickdir, ticklength, fontname, fontspec,
-             obj.interpreter, obj.zscale, obj.zsgn, gnuplot_term);
-endfunction
-
-function do_tics_1 (ticmode, tics, mtics, labelmode, labels, color, ax,
-                    plot_stream, mirror, mono, axispos, tickdir, ticklength,
-                    fontname, fontspec, interpreter, scale, sgn, gnuplot_term)
-  persistent warned_latex = false;
-
-  ## Avoid emitting anything if the tics are empty, because this undoes the
-  ## effect of the previous unset xtics and thereby adds back in the tics.
-  if (isempty (tics))
-    return;
-  endif
-
-  if (mirror)
-    mirror = "mirror";
-  else
-    mirror = "nomirror";
-  endif
-  if (strcmpi (interpreter, "tex"))
-    for n = 1 : numel (labels)
-      labels{n} = __tex2enhanced__ (labels{n}, fontname, false, false);
-    endfor
-  elseif (strcmpi (interpreter, "latex"))
-    if (! warned_latex)
-      warning ("latex markup not supported for tick marks");
-      warned_latex = true;
-    endif
-  endif
-  if (strcmp (scale, "log"))
-    num_mtics = 10;
-    if (any (strcmp (gnuplot_term, {"tikz", "pstex", "pslatex", "epslatex"})))
-      fmt = "$10^{%T}$";
-    else
-      fmt = "10^{%T}";
-    endif
-    if (sgn < 0)
-      fmt = strcat ("-", fmt);
-    endif
-  else
-    fmt = "%g";
-    num_mtics = 5;
-  endif
-  colorspec = get_text_colorspec (color, mono);
-  fprintf (plot_stream, "set format %s \"%s\";\n", ax, fmt);
-  if (strcmpi (ticmode, "manual"))
-    if (isempty (tics))
-      fprintf (plot_stream, "unset %stics;\nunset m%stics;\n", ax, ax);
-      return
-    endif
-    fprintf (plot_stream, "set %stics %s %s %s %s (", ax, tickdir,
-             ticklength, axispos, mirror);
-    fprintf (plot_stream, " %.15e,", tics(1:end-1));
-    fprintf (plot_stream, " %.15e) %s;\n", tics(end), fontspec);
-  else
-    fprintf (plot_stream, "set %stics %s %s %s %s %s %s;\n", ax,
-             tickdir, ticklength, axispos, mirror, colorspec, fontspec);
-  endif
-  if (strcmpi (labelmode, "manual"))
-    k = 1;
-    ntics = numel (tics);
-    nlabels = numel (labels);
-    fprintf (plot_stream, "set %stics add %s %s %s %s (", ax,
-             tickdir, ticklength, axispos, mirror);
-    labels = strrep (labels, "%", "%%");
-    for i = 1:ntics
-      fprintf (plot_stream, " \"%s\" %.15g", labels{k++}, tics(i));
-      if (i < ntics)
-        fputs (plot_stream, ", ");
-      endif
-      if (k > nlabels)
-        k = 1;
-      endif
-    endfor
-    fprintf (plot_stream, ") %s %s;\n", colorspec, fontspec);
-  endif
-  if (strcmp (mtics, "on"))
-    fprintf (plot_stream, "set m%stics %d;\n", ax, num_mtics);
-  else
-    fprintf (plot_stream, "unset m%stics;\n", ax);
-  endif
-endfunction
-
-function ticklabel = ticklabel_to_cell (ticklabel)
-  if (ischar (ticklabel))
-    ticklabel = cellstr (ticklabel);
-  elseif (iscellstr (ticklabel))
-    ticklabel = ticklabel;
-  else
-    error ("__go_draw_axes__: unsupported type of ticklabel");
-  endif
-endfunction
-
-function colorspec = get_text_colorspec (color, mono)
-  if (mono)
-    colorspec = "";
-  else
-    colorspec = sprintf ("textcolor rgb \"#%02x%02x%02x\"",
-                         round (255*color));
-  endif
-endfunction
-
-function [f, s, fnt, it, bld] = get_fontname_and_size (t)
-  if (isempty (t.fontname) || strcmp (t.fontname, "*"))
-    fnt = "{}";
-  else
-    fnt = t.fontname;
-  endif
-  f = fnt;
-  it = false;
-  bld = false;
-  if (! isempty (t.fontweight) && strcmpi (t.fontweight, "bold"))
-    if (! isempty (t.fontangle)
-        && (strcmpi (t.fontangle, "italic")
-            || strcmpi (t.fontangle, "oblique")))
-      f = [f "-bolditalic"];
-      it = true;
-      bld = true;
-    else
-      f = [f "-bold"];
-      bld = true;
-    endif
-  elseif (! isempty (t.fontangle)
-          && (strcmpi (t.fontangle, "italic")
-              || strcmpi (t.fontangle, "oblique")))
-    f = [f "-italic"];
-    it = true;
-  endif
-  if (isempty (t.fontsize))
-    s = 10;
-  else
-    s = t.fontsize;
-  endif
-endfunction
-
-function [str, f, s] = __maybe_munge_text__ (enhanced, obj, fld)
-
-  persistent warned_latex = false;
-
-  if (strcmp (fld, "string"))
-    [f, s, fnt, it, bld] = get_fontname_and_size (obj);
-  else
-    f = "Helvetica";
-    s = 10;
-    fnt = f;
-    it = false;
-    bld = false;
-  endif
-
-  ## The text object may be multiline, and may be of any class
-  str = getfield (obj, fld);
-  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)
-      if (isnumeric (str{n}))
-        str{n} = num2str (str{n});
-      endif
-    endfor
-    str = sprintf ("%s\n", str{:})(1:end-1);
-  endif
-
-  if (enhanced)
-    str = regexprep (str, '(?<!\\)@', '\@');
-  endif
-
-  if (enhanced)
-    if (strcmpi (obj.interpreter, "tex"))
-      if (iscellstr (str))
-        for n = 1:numel (str)
-          str{n} = __tex2enhanced__ (str{n}, fnt, it, bld);
-        endfor
-      else
-        str = __tex2enhanced__ (str, fnt, it, bld);
-      endif
-    elseif (strcmpi (obj.interpreter, "latex"))
-      if (! warned_latex)
-        warning ("latex markup not supported for text objects");
-        warned_latex = true;
-      endif
-    endif
-  endif
-endfunction
-
-function str = __tex2enhanced__ (str, fnt, it, bld)
-  persistent sym = __setup_sym_table__ ();
-  persistent flds = fieldnames (sym);
-
-  [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 empty set "{/Symbol \306}'
-    if (strncmp (m{i}, '\0', 2))
-      str = [str(1:s(i) - 1) '{/Symbol \306}' str(s(i) + 2:end)];
-    else
-      f = m{i}(2:end);
-      if (isfield (sym, f))
-        g = getfield (sym, f);
-        ## FIXME: The symbol font doesn't seem to support bold or italic
-        ##if (bld)
-        ##  if (it)
-        ##    g = regexprep (g, '/Symbol', '/Symbol-bolditalic');
-        ##  else
-        ##    g = regexprep (g, '/Symbol', '/Symbol-bold');
-        ##  endif
-        ##elseif (it)
-        ##  g = regexprep (g, '/Symbol', '/Symbol-italic');
-        ##endif
-        str = [str(1:s(i) - 1) g str(e(i) + 1:end)];
-      elseif (strncmp (f, "rm", 2))
-        bld = false;
-        it = false;
-        str = [str(1:s(i) - 1) '/' fnt ' ' str(s(i) + 3:end)];
-      elseif (strncmp (f, "it", 2) || strncmp (f, "sl", 2))
-        it = true;
-        if (bld)
-          str = [str(1:s(i) - 1) '/' fnt '-bolditalic ' str(s(i) + 3:end)];
-        else
-          str = [str(1:s(i) - 1) '/' fnt '-italic ' str(s(i) + 3:end)];
-        endif
-      elseif (strncmp (f, "bf", 2))
-        bld = true;
-        if (it)
-          str = [str(1:s(i) - 1) '/' fnt '-bolditalic ' str(s(i) + 3:end)];
-        else
-          str = [str(1:s(i) - 1) '/' fnt '-bold ' 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),'}');
-        if (isempty (d))
-          warning ('syntax error in \color argument');
-        else
-          str = [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))
-          warning ('syntax error in \fontname argument');
-        else
-          str = [str(1:s(i) - 1), '/', 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))
-          warning ('syntax error in \fontname argument');
-        else
-          str = [str(1:s(i) - 1), '/=', 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});
-            ## FIXME: The symbol font doesn't seem to support bold or italic
-            ##if (bld)
-            ##  if (it)
-            ##    g = regexprep (g, '/Symbol', '/Symbol-bolditalic');
-            ##  else
-            ##    g = regexprep (g, '/Symbol', '/Symbol-bold');
-            ##  endif
-            ##elseif (it)
-            ##  g = regexprep (g, '/Symbol', '/Symbol-italic');
-            ##endif
-            str = [str(1:s(i) - 1) g str(s(i) + length (flds{j}) + 1:end)];
-            break;
-          endif
-        endfor
-      endif
-    endif
-  endfor
-
-  ## Prepend @ to things like _0^x or _{-100}^{100} for alignment.
-  ## But need to put the shorter of the two arguments first.
-  ## Careful of nested {} and unprinted characters when defining
-  ## shortest..  Don't have to worry about things like ^\theta as they
-  ## are already converted to ^{/Symbol q}.
-
-  ## FIXME: This is a mess... Is it worth it just for a "@" character?
-
-  [s, m] = regexp (str,'[_\^]','start','matches');
-  i = 1;
-  p = 0;
-  while (i < length (s))
-    if (i < length (s))
-      if (str(s(i) + p + 1) == "{")
-        s1 = strfind (str(s(i) + p + 2:end),'{');
-        si = 1;
-        l1 = strfind (str(s(i) + p + 1:end),'}');
-        li = 1;
-        while (li <= length (l1) && si <= length (s1))
-          if (l1(li) < s1(si))
-            if (li == si)
-              break;
-            endif
-            li++;
-          else
-            si++;
-          endif
-        endwhile
-        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),'{');
-            si = 1;
-            l2 = strfind (str(s(i + 1) + p + 1:end),'}');
-            li = 1;
-            while (li <= length (l2) && si <= length (s2))
-              if (l2(li) < s2(si))
-                if (li == si)
-                  break;
-                endif
-                li++;
-              else
-                si++;
-              endif
-            endwhile
-            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)))
-              ## Shortest already first!
-              str = [str(1:s(i)+p-1) "@" str(s(i)+p:end)];
-            else
-              ## Have to swap sub/super-script to get shortest first.
-              str = [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)];
-            endif
-          else
-            ## Have to swap sub/super-script to get shortest first.
-            str = [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)];
-          endif
-          i += 2;
-          p ++;
-        else
-          i++;
-        endif
-      else
-        if (s(i+1) == s(i) + 2)
-          ## Shortest already first!
-          str = [str(1:s(i)+p-1) "@" str(s(i)+p:end)];
-          p ++;
-          i += 2;
-        else
-          i ++;
-        endif
-      endif
-    else
-      i ++;
-    endif
-  endwhile
-
-endfunction
-
-function l = length_string (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));
-  endif
-endfunction
-
-function sym = __setup_sym_table__ ()
-  ## Setup the translation table for TeX to gnuplot enhanced mode.
-  sym.forall = '{/Symbol \042}';
-  sym.exists = '{/Symbol \044}';
-  sym.ni = '{/Symbol \047}';
-  sym.cong = '{/Symbol \100}';
-  sym.Delta = '{/Symbol D}';
-  sym.Phi = '{/Symbol F}';
-  sym.Gamma = '{/Symbol G}';
-  sym.vartheta = '{/Symbol J}';
-  sym.Lambda = '{/Symbol L}';
-  sym.Pi = '{/Symbol P}';
-  sym.Theta = '{/Symbol Q}';
-  sym.Sigma = '{/Symbol S}';
-  sym.varsigma = '{/Symbol V}';
-  sym.Omega = '{/Symbol W}';
-  sym.Xi = '{/Symbol X}';
-  sym.Psi = '{/Symbol Y}';
-  sym.perp = '{/Symbol \136}';
-  sym.alpha = '{/Symbol a}';
-  sym.beta = '{/Symbol b}';
-  sym.chi = '{/Symbol c}';
-  sym.delta = '{/Symbol d}';
-  sym.epsilon = '{/Symbol e}';
-  sym.phi = '{/Symbol f}';
-  sym.gamma = '{/Symbol g}';
-  sym.eta = '{/Symbol h}';
-  sym.iota = '{/Symbol i}';
-  sym.varphi = '{/Symbol j}';              # Not in OpenGL
-  sym.kappa = '{/Symbol k}';
-  sym.lambda = '{/Symbol l}';
-  sym.mu = '{/Symbol m}';
-  sym.nu = '{/Symbol n}';
-  sym.o = '{/Symbol o}';
-  sym.pi = '{/Symbol p}';
-  sym.theta = '{/Symbol q}';
-  sym.rho = '{/Symbol r}';
-  sym.sigma = '{/Symbol s}';
-  sym.tau = '{/Symbol t}';
-  sym.upsilon = '{/Symbol u}';
-  sym.varpi = '{/Symbol v}';
-  sym.omega = '{/Symbol w}';
-  sym.xi = '{/Symbol x}';
-  sym.psi = '{/Symbol y}';
-  sym.zeta = '{/Symbol z}';
-  sym.sim = '{/Symbol \176}';
-  sym.Upsilon = '{/Symbol \241}';
-  sym.prime = '{/Symbol \242}';
-  sym.leq = '{/Symbol \243}';
-  sym.infty = '{/Symbol \245}';
-  sym.clubsuit = '{/Symbol \247}';
-  sym.diamondsuit = '{/Symbol \250}';
-  sym.heartsuit = '{/Symbol \251}';
-  sym.spadesuit = '{/Symbol \252}';
-  sym.leftrightarrow = '{/Symbol \253}';
-  sym.leftarrow = '{/Symbol \254}';
-  sym.uparrow = '{/Symbol \255}';
-  sym.rightarrow = '{/Symbol \256}';
-  sym.downarrow = '{/Symbol \257}';
-  sym.circ = '{/Symbol \260}';         # degree symbol, not circ as in FLTK
-  sym.deg = '{/Symbol \260}';
-  sym.ast = '{/Symbol *}';
-  sym.pm = '{/Symbol \261}';
-  sym.geq = '{/Symbol \263}';
-  sym.times = '{/Symbol \264}';
-  sym.propto = '{/Symbol \265}';
-  sym.partial = '{/Symbol \266}';
-  sym.bullet = '{/Symbol \267}';
-  sym.div = '{/Symbol \270}';
-  sym.neq = '{/Symbol \271}';
-  sym.equiv = '{/Symbol \272}';
-  sym.approx = '{/Symbol \273}';
-  sym.ldots = '{/Symbol \274}';
-  sym.mid = '{/Symbol \275}';
-  sym.aleph = '{/Symbol \300}';
-  sym.Im = '{/Symbol \301}';
-  sym.Re = '{/Symbol \302}';
-  sym.wp = '{/Symbol \303}';
-  sym.otimes = '{/Symbol \304}';
-  sym.oplus = '{/Symbol \305}';
-  ## empty set, not circled slash division operator as in FLTK.
-  sym.oslash = '{/Symbol \306}';
-  sym.cap = '{/Symbol \307}';
-  sym.cup = '{/Symbol \310}';
-  sym.supset = '{/Symbol \311}';
-  sym.supseteq = '{/Symbol \312}';
-  sym.subset = '{/Symbol \314}';
-  sym.subseteq = '{/Symbol \315}';
-  sym.in = '{/Symbol \316}';
-  sym.notin = '{/Symbol \317}';            # Not in OpenGL
-  sym.angle = '{/Symbol \320}';
-  sym.bigtriangledown = '{/Symbol \321}';  # Not in OpenGL
-  sym.langle = '{/Symbol \341}';
-  sym.rangle = '{/Symbol \361}';
-  sym.nabla = '{/Symbol \321}';
-  sym.prod = '{/Symbol \325}';             # Not in OpenGL
-  sym.surd = '{/Symbol \326}';
-  sym.cdot = '{/Symbol \327}';
-  sym.neg = '{/Symbol \330}';
-  sym.wedge = '{/Symbol \331}';
-  sym.vee = '{/Symbol \332}';
-  sym.Leftrightarrow = '{/Symbol \333}';   # Not in OpenGL
-  sym.Leftarrow = '{/Symbol \334}';
-  sym.Uparrow = '{/Symbol \335}';          # Not in OpenGL
-  sym.Rightarrow = '{/Symbol \336}';
-  sym.Downarrow = '{/Symbol \337}';        # Not in OpenGL
-  sym.diamond = '{/Symbol \340}';          # Not in OpenGL
-  sym.copyright = '{/Symbol \343}';
-  sym.lfloor = '{/Symbol \353}';
-  sym.lceil = '{/Symbol \351}';
-  sym.rfloor = '{/Symbol \373}';
-  sym.rceil = '{/Symbol \371}';
-  sym.int = '{/Symbol \362}';
-endfunction
-
-function retval = __do_enhanced_option__ (enhanced, obj)
-  retval = "";
-  if (enhanced)
-    if (strcmpi (obj.interpreter, "none"))
-      retval = "noenhanced";
-    else
-      retval = "enhanced";
-    endif
-  endif
-endfunction
-
-function maybe_do_xtick_mirror (plot_stream, axis_obj)
-  if (! isempty(axis_obj.xtick))
-    fprintf (plot_stream, "unset x2tics; set xtics %s nomirror\n",
-                          axis_obj.tickdir);
-  endif
-endfunction
-
-function maybe_do_x2tick_mirror (plot_stream, axis_obj)
-  if (! isempty(axis_obj.xtick))
-    fprintf (plot_stream, "unset xtics; set x2tics %s nomirror\n",
-                          axis_obj.tickdir);
-  endif
-endfunction
--- a/scripts/plot/util/private/__go_draw_figure__.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,206 +0,0 @@
-## Copyright (C) 2005-2015 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} {} __go_draw_figure__ (@var{h}, @var{plot_stream}, @var{enhanced}, @var{mono})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: jwe
-
-function __go_draw_figure__ (h, plot_stream, enhanced, mono)
-
-  htype = get (h, "type");
-  if (strcmp (htype, "figure"))
-    ## Get complete list of children.
-    kids = allchild (h);
-    nkids = length (kids);
-
-    if (nkids > 0)
-      fputs (plot_stream, "\nreset;\n");
-      fputs (plot_stream, "set autoscale keepfix;\n");
-      fputs (plot_stream, "set origin 0, 0\n");
-      fputs (plot_stream, "set size 1, 1\n");
-      bg = get (h, "color");
-      if (isnumeric (bg))
-        fprintf (plot_stream, "set obj 1 rectangle from screen 0,0 to screen 1,1 behind fc rgb \"#%02x%02x%02x\" fs solid noborder\n", round (255 * bg));
-        bg_is_set = true;
-      else
-        bg_is_set = false;
-      endif
-      fg_was_set = false;
-
-      for i = nkids:-1:1
-        type = get (kids(i), "type");
-        switch (type)
-          case "axes"
-            if (strcmpi (get (kids (i), "tag"), "legend"))
-              ## This is so ugly. If there was a way of getting
-              ## gnuplot to give us the text extents of strings
-              ## then we could get rid of this mess.
-              lh = getfield (get (kids(i), "userdata"), "handle");
-              if (isscalar (lh))
-                ## We have a legend with a single parent. It'll be handled
-                ## below as a gnuplot key to the axis it corresponds to
-                continue;
-              else
-                ca = lh(1);
-                ## Rely upon listener to convert axes position
-                ## to "normalized" units.
-                legend_axes_units = get (kids(i), "units");
-                legend_axes_position = get (kids(i), "position");
-                legend_axes_outerposition = get (kids(i), "outerposition");
-                legend_axes_box = get (kids(i), "box");
-                legend_axes_ylim = get (kids(i), "ylim");
-                orig_axes_units = get (ca, "units");
-                hlgnd = get (kids(i));
-
-                unwind_protect
-                  set (ca, "units", "normalized");
-                  set (kids(i), "units", "normalized", "box", "off",
-                       "ylim", [-2, -1], "position", get (ca(1), "position"),
-                       "outerposition", get (ca(1), "outerposition"));
-
-                  ## Create a new set of lines with the appropriate
-                  ## displaynames, etc
-                  toberm = [];
-                  hobj = get (kids(i), "children");
-                  for j = numel (hobj) : -1 : 1
-                    if (! strcmp (get (hobj(j), "type"), "text"))
-                      continue;
-                    endif
-                    displayname = get (hobj(j), "string");
-                    ll = [];
-                    lm = [];
-                    for k = numel (hobj) : -1 : 1
-                      if (! strcmp (get (hobj(k), "type"), "line"))
-                        continue;
-                      endif
-                      if (get (hobj(j), "userdata")
-                          != get (hobj(k), "userdata"))
-                        continue;
-                      endif
-                      if (! strcmp (get (hobj(k), "linestyle"), "none"))
-                        ll = hobj(k);
-                      endif
-                      if (! strcmp (get (hobj(k), "marker"), "none"))
-                        lm = hobj(k);
-                      endif
-                    endfor
-
-                    if (! isempty (ll))
-                      if (! isempty (lm))
-                        toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(lm,"color"), "linestyle", get(ll,"linestyle"), "marker", get(lm,"marker"), "markeredgecolor", get(lm,"markeredgecolor"), "markerfacecolor", get(lm,"markerfacecolor"), "markersize", get (lm, "markersize"), "displayname", displayname, "parent", kids(i))];
-                      else
-                        toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(ll,"color"), "linestyle", get(ll,"linestyle"), "marker", "none", "displayname", displayname, "parent", kids(i))];
-                      endif
-                    elseif (! isempty (lm))
-                      toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(lm,"color"), "linestyle", "none", "marker", get(lm,"marker"), "markeredgecolor", get(lm,"markeredgecolor"), "markerfacecolor", get(lm,"markerfacecolor"), "markersize", get (lm, "markersize"), "displayname", displayname, "parent", kids(i))];
-                    endif
-                  endfor
-                  if (bg_is_set)
-                    fprintf (plot_stream, "set border linecolor rgb \"#%02x%02x%02x\"\n", round (255 * (1 - bg)));
-                  endif
-                  __go_draw_axes__ (kids(i), plot_stream, enhanced, mono,
-                                    bg_is_set, false, hlgnd);
-                unwind_protect_cleanup
-                  ## Return axes "units" and "position" back to
-                  ## their original values.
-                  set (ca, "units", orig_axes_units);
-                  set (kids(i), "units", legend_axes_units,
-                       "box", legend_axes_box,
-                       "ylim", legend_axes_ylim,
-                       "position", legend_axes_position,
-                       "outerposition", legend_axes_outerposition);
-                  delete (toberm);
-                  bg_is_set = false;
-                end_unwind_protect
-              endif
-            else
-              ## Rely upon listener to convert axes position
-              ## to "normalized" units.
-              orig_axes_units = get (kids(i), "units");
-              orig_axes_position = get (kids(i), "position");
-              unwind_protect
-                set (kids(i), "units", "normalized");
-                fg = get (kids(i), "color");
-                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\" fs solid noborder\n", round (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
-                if (bg_is_set)
-                  fprintf (plot_stream, "set border linecolor rgb \"#%02x%02x%02x\"\n", round (255 * (1 - bg)));
-                endif
-                ## Find if this axes has an associated legend axes and pass it
-                ## to __go_draw_axes__
-                hlegend = [];
-                fkids = get (h, "children");
-                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)
-                        && ! isempty (intersect (udata.handle, kids (i))))
-                      hlegend = get (fkids (j));
-                      break;
-                    endif
-                  endif
-                endfor
-                __go_draw_axes__ (kids(i), plot_stream, enhanced, mono,
-                                  bg_is_set, fg_is_set, hlegend);
-              unwind_protect_cleanup
-                ## Return axes "units" and "position" back to
-                ## their original values.
-                set (kids(i), "units", orig_axes_units);
-                set (kids(i), "position", orig_axes_position);
-                bg_is_set = false;
-                fg_is_set = false;
-              end_unwind_protect
-            endif
-          case "uimenu"
-            ## ignore uimenu objects
-            kids(i) = [];
-          otherwise
-            error ("__go_draw_figure__: unknown object class, %s", type);
-        endswitch
-      endfor
-      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);
-    endif
-  else
-    error ("__go_draw_figure__: expecting figure object, found '%s'",
-           htype);
-  endif
-
-endfunction
-
--- a/scripts/plot/util/private/__opengl_print__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/private/__opengl_print__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -48,20 +48,21 @@
       ## format GL2PS_TEX
       n = find (opts.devopt == "l", 1);
       suffix = opts.devopt(1:n-1);
-      dot = find (opts.name == ".", 1, "last");
-      if ((! isempty (dot))
-          && any (strcmpi (opts.name(dot:end), ...
-                  {strcat(".", suffix), ".tex", "."})))
-        name = opts.name(1:dot-1);
-        if (dot < numel (opts.name)
-            && any (strcmpi (opts.name(dot+1:end), {"eps", "ps", "pdf"})))
-          ## If user provides eps/ps/pdf suffix, use it.
-          suffix = opts.name(dot+1:end);
+      [ndir, name, ext] = fileparts (opts.name);
+      if (isempty (ext))
+        ext = "tex";
+      else
+        ext = ext(2:end);  # remove leading '.'
+      endif
+      if (any (strcmpi (ext, {suffix, "tex"})))
+        name = fullfile (ndir, name);
+        if (any (strcmpi (ext, {"eps", "ps", "pdf"})))
+          suffix = ext;  # If user provides eps/ps/pdf suffix, use it.
         endif
       else
         error ("print:invalid-suffix",
                "invalid suffix '%s' for device '%s'.",
-               opts.name(dot:end), lower (opts.devopt));
+               ext, lower (opts.devopt));
       endif
       gl2ps_device = {sprintf("%snotxt", lower (suffix))};
       gl2ps_device{2} = "tex";
@@ -89,7 +90,7 @@
         if (any (strcmpi (ext, {".ps", ".tex", "."})))
           opts.name = opts.name(1:end-numel(ext));
         endif
-        opts.name = strcat (opts.name, ".ps");
+        opts.name = [opts.name ".ps"];
         cmd = sprintf ("%s | %s > %s", cmd_pstoedit, cmd_fig2dev, opts.name);
         gl2ps_device = {"eps"};
         pipeline = {cmd};
--- a/scripts/plot/util/private/__print_parse_opts__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/private/__print_parse_opts__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -168,7 +168,7 @@
     elseif (isfigure (arg))
       arg_st.figure = arg;
     else
-      error ("print: expecting inputs to be character string options or a figure handle");
+      error ("print: first argument must be string or figure handle");
     endif
   endfor
 
@@ -263,7 +263,7 @@
   endif
 
   if (dot == 0 && ! isempty (arg_st.name))
-    arg_st.name = strcat (arg_st.name, ".", default_suffix);
+    arg_st.name = [arg_st.name "." default_suffix];
   endif
 
   if (arg_st.append_to_file)
@@ -329,14 +329,14 @@
       ## Pipe the ghostscript output
       arg_st.name = "-";
     else
-      error ("print: a file name may not specified when spooling to a printer")
+      error ("print: a filename may not specified when spooling to a printer")
     endif
     if (! any (strcmp (arg_st.devopt, gs_device_list)))
       ## Only supported ghostscript devices
       error ("print: format must be a valid Ghostscript format for spooling to a printer")
     endif
   elseif (isempty (arg_st.name))
-    error ("print: an output file name must be specified")
+    error ("print: an output filename must be specified")
   endif
 
   if (isempty (arg_st.canvas_size))
@@ -460,7 +460,7 @@
         cmd = strrep (cmd, "/", "\\");
       endif
       if (any (cmd == " "))
-        cmd = strcat ('"', strrep (cmd, '"', '""') ,'"');
+        cmd = ['"' strrep(cmd, '"', '""') '"'];
       endif
     endif
   endif
@@ -495,7 +495,7 @@
     endif
     n = 0;
     while (n < numel (gs_binaries) && isempty (ghostscript_binary))
-      n = n + 1;
+      n += 1;
       ghostscript_binary = file_in_path (getenv ("PATH"), gs_binaries{n});
     endwhile
     if (warn_on_no_ghostscript && isempty (ghostscript_binary))
@@ -529,7 +529,7 @@
     endif
     n = 0;
     while (n < numel (binaries) && isempty (data.(binary).bin))
-      n = n + 1;
+      n += 1;
       data.(binary).bin = file_in_path (getenv ("PATH"), binaries{n});
     endwhile
     if (isempty (data.(binary).bin) && data.(binary).warn_on_absence)
@@ -574,7 +574,7 @@
   endif
 
   if (strcmp (paperunits, "normalized"))
-    paperposition = paperposition .* papersize([1,2,1,2]);
+    paperposition .*= papersize([1,2,1,2]);
   else
     paperposition = convert2points (paperposition, paperunits);
   endif
@@ -599,7 +599,7 @@
       case {"b", "tabloid"}
         papersize = "11x17";
       case {"c", "d", "e"}
-        papersize = strcat ("arch", papersize);
+        papersize = ["arch" papersize];
     endswitch
     if (strncmp (papersize, "arch", 4))
       papersize(end) = upper (papersize(end));
@@ -611,9 +611,9 @@
 function value = convert2points (value, units)
   switch (units)
     case "inches"
-      value = value * 72;
+      value *= 72;
     case "centimeters"
-      value = value * 72 / 2.54;
+      value *= 72 / 2.54;
     case "normalized"
       error ("print:customnormalized",
              "print.m: papersize=='<custom>' and paperunits='normalized' may not be combined");
--- a/scripts/plot/util/private/__tight_eps_bbox__.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-## Copyright (C) 2010-2015 Ben Abbott
-##
-## 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{bbox} =} __tight_eps_bbox__ (@var{@dots{}})
-## Undocumented internal function.
-## @end deftypefn
-
-## Author: Ben Abbott <bpabbott@mac.com>
-## Created: 2010-07-26
-
-function bb = __tight_eps_bbox__ (opts, eps_file_name)
-
-  box_string = "%%BoundingBox:";
-
-  cmd = sprintf ("\"%s\" \"%s\" 2>&1", "head", eps_file_name);
-  [status, output] = system (cmd);
-
-  if (status == 0)
-    orig_bbox_line = get_bbox (output);
-  else
-    error ("print:noboundingbox",
-           "print.m: no bounding box found in '%s'", eps_file_name);
-  endif
-
-  ghostscript_options = "-q -dBATCH -dSAFER -dNOPAUSE -dTextAlphaBits=4 -sDEVICE=bbox";
-  cmd = sprintf ("\"%s\" %s \"%s\" 2>&1", opts.ghostscript.binary,
-                 ghostscript_options, eps_file_name);
-  [status, output] = system (cmd);
-
-  if (status == 0)
-    tight_bbox_line = get_bbox (output);
-  else
-    warning ("print:nogsboundingbox",
-             "print.m: ghostscript failed to determine the bounding for '%s'",
-             eps_file_name);
-  endif
-
-  ## Attempt to fix the bbox in place.
-  fid = fopen (eps_file_name, "r+");
-  unwind_protect
-    bbox_replaced = false;
-    looking_for_bbox = true;
-    while (looking_for_bbox)
-      current_line = fgetl (fid);
-      if (strncmpi (current_line, box_string, length (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)) = " ";
-          bbox_replaced = true;
-          ## Back up to the beginning of the line (include EOL characters).
-          if (ispc ())
-            fseek (fid, -line_length-2, "cof");
-          else
-            fseek (fid, -line_length-1, "cof");
-          endif
-          count = fprintf (fid, "%s", new_line);
-        endif
-        looking_for_bbox = false;
-      elseif (! ischar (current_line))
-        looking_for_bbox = false;
-      endif
-    endwhile
-  unwind_protect_cleanup
-    fclose (fid);
-  end_unwind_protect
-
-  ## If necessary load the eps-file and replace the bbox (can be slow).
-  if (! bbox_replaced)
-    fid = fopen (eps_file_name, "r");
-    unwind_protect
-      data = char (fread (fid, Inf)).';
-    unwind_protect_cleanup
-      fclose (fid);
-    end_unwind_protect
-    n = strfind (data, box_string);
-    if (numel (n) > 1)
-      ## Only replace one instance.
-      n = n(1);
-    elseif (isempty (n))
-      error ("print:noboundingbox", ...
-             "print.m: no bounding box found in '%s'.", eps_file_name);
-    endif
-    m = numel (orig_bbox_line);
-    data = horzcat (data(1:(n-1)), tight_bbox_line, data((n+m):end));
-    fid = fopen (eps_file_name, "w");
-    unwind_protect
-      fprintf (fid, "%s", data);
-    unwind_protect_cleanup
-      fclose (fid);
-    end_unwind_protect
-  endif
-
-endfunction
-
-function bbox_line = get_bbox (lines)
-  box_string = "%%BoundingBox:";
-  pattern = strcat (box_string, "[^%]*");
-  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) = "";
-endfunction
-
--- a/scripts/plot/util/rotate.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/rotate.m	Thu Dec 10 12:50:06 2015 -0800
@@ -111,7 +111,7 @@
     origin = [a, b, c];
   endif
 
-  direction = direction / norm (direction);
+  direction /= norm (direction);
 
   u = direction(1);
   v = direction(2);
--- a/scripts/plot/util/rotate3d.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/rotate3d.m	Thu Dec 10 12:50:06 2015 -0800
@@ -45,16 +45,16 @@
   endif
 
   if (nargin == 1 && nargout > 0 && isfigure (varargin{1}))
-    error ("rotate_object_handle = rotate3d (hfig): not implemented");
+    error ("rotate3d: syntax 'handle = rotate3d (hfig)' not implemented");
   endif
 
   if (nargs == 2)
     hfig = varargin{1};
     if (isfigure (hfig))
       varargin(1) = [];
-      nargs--;
+      nargs -= 1;
     else
-      error ("rotate3d: expecting figure handle as first argument");
+      error ("rotate3d: invalid figure handle HFIG");
     endif
   endif
 
--- a/scripts/plot/util/saveas.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/saveas.m	Thu Dec 10 12:50:06 2015 -0800
@@ -96,11 +96,11 @@
     [~, ~, ext] = fileparts (filename);
 
     if (isempty (ext))
-      filename = strcat (filename, ".", fmt);
+      filename = [filename "." fmt];
     endif
   endif
 
-  prt_opt = strcat ("-d", tolower (fmt));
+  prt_opt = ["-d" tolower(fmt)];
 
   print (fig, filename, prt_opt);
 
--- a/scripts/plot/util/struct2hdl.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/struct2hdl.m	Thu Dec 10 12:50:06 2015 -0800
@@ -162,11 +162,11 @@
   nkids = length (kids);
   ii = 0;
   while (nkids)
-    ii++;
+    ii += 1;
     if (! any (ii == s.special))
       [h2, p] = struct2hdl (s.children(ii), [p [s.handle; h]], hilev);
     endif
-    nkids--;
+    nkids -= 1;
   endwhile
 
   ## paste properties
@@ -587,7 +587,7 @@
            h2 = get (h , field);
            set (h2, spec.properties);
         endif
-        nf--;
+        nf -= 1;
       endwhile
 
       ## If hggroup children  were created by high level functions,
@@ -607,7 +607,7 @@
               catch
                 sprintf ("struct2hdl: couldn't set hggroup children #%d props.", ii);
               end_try_catch
-              ii ++;
+              ii += 1;
             endwhile
 
           else
--- a/scripts/plot/util/subplot.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/subplot.m	Thu Dec 10 12:50:06 2015 -0800
@@ -148,7 +148,7 @@
       varargin(1) = [];
       initial_args_decoded = true;
     else
-      error ("subplot: expecting axes handle or RCN argument");
+      error ("subplot: invalid axes handle or RCN argument");
     endif
   endif
 
--- a/scripts/plot/util/zoom.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/plot/util/zoom.m	Thu Dec 10 12:50:06 2015 -0800
@@ -65,7 +65,7 @@
   endif
 
   if (nargs == 1 && nargout > 0 && isfigure (varargin{1}))
-    error ("zoom_object_handle = zoom (hfig): not implemented");
+    error ("zoom: syntax 'handle = zoom (hfig)' not implemented");
   endif
 
   hfig = NaN;
@@ -73,9 +73,9 @@
     hfig = varargin{1};
     if (isfigure (hfig))
       varargin(1) = [];
-      nargs--;
+      nargs -= 1;
     else
-      error ("zoom: expecting figure handle as first argument");
+      error ("zoom: invalid figure handle HFIG");
     endif
   endif
 
--- a/scripts/polynomial/compan.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/polynomial/compan.m	Thu Dec 10 12:50:06 2015 -0800
@@ -65,7 +65,7 @@
   endif
 
   if (! isvector (c))
-    error ("compan: expecting a vector argument");
+    error ("compan: C must be a vector");
   endif
 
   n = length (c);
--- a/scripts/polynomial/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/polynomial/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,39 +1,50 @@
-FCN_FILE_DIRS += polynomial
+FCN_FILE_DIRS += \
+  scripts/polynomial \
+  scripts/polynomial/private
 
-polynomial_PRIVATE_FCN_FILES = \
-  polynomial/private/__splinefit__.m
+scripts_polynomial_PRIVATE_FCN_FILES = \
+  scripts/polynomial/private/__splinefit__.m
 
-polynomial_FCN_FILES = \
-  polynomial/compan.m \
-  polynomial/conv.m \
-  polynomial/deconv.m \
-  polynomial/mkpp.m \
-  polynomial/mpoles.m \
-  polynomial/pchip.m \
-  polynomial/poly.m \
-  polynomial/polyaffine.m \
-  polynomial/polyder.m \
-  polynomial/polyeig.m \
-  polynomial/polyfit.m \
-  polynomial/polygcd.m \
-  polynomial/polyint.m \
-  polynomial/polyout.m \
-  polynomial/polyreduce.m \
-  polynomial/polyval.m \
-  polynomial/polyvalm.m \
-  polynomial/ppval.m \
-  polynomial/ppder.m \
-  polynomial/ppint.m \
-  polynomial/ppjumps.m \
-  polynomial/residue.m \
-  polynomial/roots.m \
-  polynomial/spline.m \
-  polynomial/splinefit.m \
-  polynomial/unmkpp.m \
-  $(polynomial_PRIVATE_FCN_FILES)
+scripts_polynomial_FCN_FILES = \
+  scripts/polynomial/compan.m \
+  scripts/polynomial/conv.m \
+  scripts/polynomial/deconv.m \
+  scripts/polynomial/mkpp.m \
+  scripts/polynomial/mpoles.m \
+  scripts/polynomial/pchip.m \
+  scripts/polynomial/poly.m \
+  scripts/polynomial/polyaffine.m \
+  scripts/polynomial/polyder.m \
+  scripts/polynomial/polyeig.m \
+  scripts/polynomial/polyfit.m \
+  scripts/polynomial/polygcd.m \
+  scripts/polynomial/polyint.m \
+  scripts/polynomial/polyout.m \
+  scripts/polynomial/polyreduce.m \
+  scripts/polynomial/polyval.m \
+  scripts/polynomial/polyvalm.m \
+  scripts/polynomial/ppval.m \
+  scripts/polynomial/ppder.m \
+  scripts/polynomial/ppint.m \
+  scripts/polynomial/ppjumps.m \
+  scripts/polynomial/residue.m \
+  scripts/polynomial/roots.m \
+  scripts/polynomial/spline.m \
+  scripts/polynomial/splinefit.m \
+  scripts/polynomial/unmkpp.m
 
-FCN_FILES += $(polynomial_FCN_FILES)
+scripts_polynomialdir = $(fcnfiledir)/polynomial
+
+scripts_polynomial_DATA = $(scripts_polynomial_FCN_FILES)
+
+scripts_polynomial_privatedir = $(fcnfiledir)/polynomial/private
+
+scripts_polynomial_private_DATA = $(scripts_polynomial_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += polynomial/PKG_ADD
+FCN_FILES += \
+  $(scripts_polynomial_FCN_FILES) \
+  $(scripts_polynomial_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += polynomial/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/polynomial/PKG_ADD
+
+DIRSTAMP_FILES += scripts/polynomial/$(octave_dirstamp)
--- a/scripts/polynomial/pchip.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/polynomial/pchip.m	Thu Dec 10 12:50:06 2015 -0800
@@ -116,7 +116,7 @@
   del2 = (d2 - delta) / h;
   c3 = del1 + del2;
   c2 = -c3 - del1;
-  c3 = c3 / h;
+  c3 /= h;
   coeffs = cat (3, c3, c2, d1, f1);
 
   ret = mkpp (x, coeffs, szy(1:end-1));
--- a/scripts/polynomial/polyaffine.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/polynomial/polyaffine.m	Thu Dec 10 12:50:06 2015 -0800
@@ -56,7 +56,7 @@
 
    ## Scale.
    if (mu(2) != 1)
-     g = g ./ (mu(2) .^ (lf-1:-1:0));
+     g ./= mu(2) .^ (lf-1:-1:0);
    endif
 
    ## Translate.
--- a/scripts/polynomial/polyder.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/polynomial/polyder.m	Thu Dec 10 12:50:06 2015 -0800
@@ -69,8 +69,8 @@
         endif
 
         ## move all the gain into the numerator
-        q = q/d(1);
-        d = d/d(1);
+        q /= d(1);
+        d /= d(1);
       endif
     else
       lp = numel (p);
--- a/scripts/polynomial/private/__splinefit__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/polynomial/private/__splinefit__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -151,7 +151,7 @@
     % Solve constraints
     [Z,u0] = solvecon(B,constr);
     % Solve Min norm(u*A-y), subject to u*B = yc
-    y = y - u0*A;
+    y -= u0*A;
     A = Z*A;
     v = lsqsolve(A,y,beta);
     u = u0 + v*Z;
@@ -487,7 +487,7 @@
 end
 
 % Reduce number of pieces
-pieces = pieces - 2*deg;
+pieces -= 2*deg;
 
 % Sort coefficients by interval number
 ii = [n*(1:pieces); deg*ones(deg,pieces)];
@@ -517,7 +517,7 @@
 B0 = zeros(n,nx);
 for k = 1:size(cc,1)
     if any(cc(k,:))
-        B0 = B0 + repmat(cc(k,:),n,1).*ppval(base,xc);
+        B0 += repmat(cc(k,:),n,1).*ppval(base,xc);
     end
     % Differentiate base
     coefs = base.coefs(:,1:n-k);
--- a/scripts/polynomial/residue.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/polynomial/residue.m	Thu Dec 10 12:50:06 2015 -0800
@@ -170,8 +170,8 @@
   a = polyreduce (a);
   b = polyreduce (b);
 
-  b = b / a(1);
-  a = a / a(1);
+  b /= a(1);
+  a /= a(1);
 
   la = length (a);
   lb = length (b);
@@ -329,13 +329,13 @@
     endfor
     pn = deconv (pden, pm);
     pn = r(n) * pn;
-    pnum = pnum + prepad (pn, N+1, 0, 2);
+    pnum += prepad (pn, N+1, 0, 2);
   endfor
 
   ## Add the direct term.
 
   if (numel (k))
-    pnum = pnum + conv (pden, k);
+    pnum += conv (pden, k);
   endif
 
   ## Check for leading zeros and trim the polynomial coefficients.
--- a/scripts/prefs/addpref.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/prefs/addpref.m	Thu Dec 10 12:50:06 2015 -0800
@@ -17,18 +17,20 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} addpref (@var{group}, @var{pref}, @var{val})
-## Add a preference @var{pref} and associated value @var{val} to the named
+## @deftypefn  {Function File} {} addpref ("@var{group}", "@var{pref}", @var{val})
+## @deftypefnx {Function File} {} addpref ("@var{group}", @{"@var{pref1}", "@var{pref2}", @dots{}@}, @{@var{val1}, @var{val2}, @dots{}@})
+## Add the preference @var{pref} and associated value @var{val} to the named
 ## preference group @var{group}.
 ##
-## The named preference group must be a character string.
+## The named preference group must be a string.
+##
+## The preference @var{pref} may be a string or a cell array of strings.  An
+## error will be issued if the preference already exists.
 ##
-## The preference @var{pref} may be a character string or a cell array of
-## character strings.
-##
-## The corresponding value @var{val} may be any value, or, if @var{pref} is a
-## cell array of strings, @var{val} must be a cell array of values with the
-## same size as @var{pref}.
+## The corresponding value @var{val} may be any Octave value, .e.g., double,
+## struct, cell array, object, etc.  Or, if @var{pref} is a cell array of
+## strings then @var{val} must be a cell array of values with the same size as
+## @var{pref}.
 ## @seealso{setpref, getpref, ispref, rmpref}
 ## @end deftypefn
 
@@ -36,43 +38,75 @@
 
 function addpref (group, pref, val)
 
-  if (nargin == 3)
-    if (ischar (group))
-      prefs = loadprefs ();
-      if (ischar (pref))
-        if (isfield (group, pref))
-          error ("preference %s already exists in group %s", pref, group);
-        else
-          prefs.(group).(pref) = val;
-        endif
-      elseif (iscellstr (pref))
-        if (size_equal (pref, val))
-          for i = 1:numel (pref)
-            if (isfield (group, pref{i}))
-              error ("preference %s already exists in group %s",
-                     pref{i}, group);
-            else
-              prefs.(group).(pref{i}) = val;
-            endif
-          endfor
-        else
-          error ("size mismatch for pref and val");
-        endif
-      else
-        error ("expecting pref to be a character string or cellstr");
-      endif
-      saveprefs (prefs);
+  if (nargin != 3)
+    print_usage ();
+  endif
+
+  if (! ischar (group))
+    error ("addpref: GROUP must be a string");
+  elseif (! (ischar (pref) || iscellstr (pref)))
+    error ("addpref: PREF must be a string or cellstr");
+  endif
+
+  prefs = loadprefs ();
+
+  if (ischar (pref))
+    if (isfield (prefs, group) && isfield (prefs.(group), pref))
+      error ("addpref: preference %s already exists in group %s", pref, group);
     else
-      error ("expecting group to be a character string");
+      prefs.(group).(pref) = val;
     endif
   else
-    print_usage ();
+    if (! size_equal (pref, val))
+      error ("addpref: size mismatch for PREF and VAL");
+    endif
+    for i = 1:numel (pref)
+      if (isfield (prefs, group) && isfield (prefs.(group), pref{i}))
+        error ("addpref: preference %s already exists in group %s",
+               pref{i}, group);
+      else
+        prefs.(group).(pref{i}) = val{i};
+      endif
+    endfor
   endif
 
+  saveprefs (prefs);
+
 endfunction
 
 
-## Testing these functions will require some care to avoid wiping out
-## existing (or creating unwanted) preferences for the user running the
-## tests.
+%!test
+%! HOME = getenv ("HOME");
+%! unwind_protect
+%!   setenv ("HOME", P_tmpdir ());
+%!
+%!   addpref ("group1", "pref1", [1 2 3]);
+%!   assert (getpref ("group1", "pref1"), [1 2 3]);
+%!
+%!   addpref ("group2", {"prefA", "prefB"}, {"StringA", {"StringB"}});
+%!   assert (getpref ("group2", "prefA"), "StringA");
+%!   assert (getpref ("group2", "prefB"), {"StringB"});
+%!
+%!   fail ('addpref ("group1", "pref1", 4)', ...
+%!         "preference pref1 already exists in group group1");
+%!   fail ('setpref ("group1", {"p1", "p2"}, 1)', ...
+%!         "size mismatch for PREF and VAL");
+%!   fail ('addpref ("group2", {"prefC", "prefA"}, {1, 2})',
+%!         "preference prefA already exists in group group2");
+%!
+%! unwind_protect_cleanup
+%!   unlink (fullfile (P_tmpdir (), ".octave_prefs"));
+%!   if (isempty (HOME))
+%!     unsetenv ("HOME");
+%!   else
+%!     setenv ("HOME", HOME);
+%!   endif
+%! end_unwind_protect
 
+%!error addpref ()
+%!error addpref (1)
+%!error addpref (1,2)
+%!error addpref (1,2,3,4)
+%!error <GROUP must be a string> addpref (1, "pref1", 2)
+%!error <PREF must be a string> addpref ("group1", 1, 2)
+
--- a/scripts/prefs/getpref.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/prefs/getpref.m	Thu Dec 10 12:50:06 2015 -0800
@@ -17,23 +17,26 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {} getpref (@var{group}, @var{pref})
-## @deftypefnx {Function File} {} getpref (@var{group}, @var{pref}, @var{default})
-## @deftypefnx {Function File} {} getpref (@var{group})
+## @deftypefn  {Function File} {@var{val} =} getpref ("@var{group}", "@var{pref}")
+## @deftypefnx {Function File} {@var{val} =} getpref ("@var{group}", "@var{pref}", @var{default})
+## @deftypefnx {Function File} {@{@var{val1}, @var{val2}, @dots{}@} =} getpref ("@var{group}", @{"@var{pref1}", "@var{pref2"}, @dots{}@})
+## @deftypefnx {Function File} {@var{prefstruct} =} getpref ("@var{group}")
+## @deftypefnx {Function File} {@var{prefstruct} =} getpref ()
 ## Return the preference value corresponding to the named preference @var{pref}
 ## in the preference group @var{group}.
 ##
-## The named preference group must be a character string.
+## The named preference group must be a string.
 ##
-## If @var{pref} does not exist in @var{group} and @var{default} is
-## specified, return @var{default}.
+## If @var{pref} does not exist in @var{group} and @var{default} is specified,
+## create the preference with value @var{default} and return @var{default}.
 ##
-## The preference @var{pref} may be a character string or a cell array of
-## character strings.
+## The preference @var{pref} may be a string or cell array of strings.  If it
+## is a cell array of strings then a cell array of preferences is returned.
 ##
-## The corresponding default value @var{default} may be any value, or, if
-## @var{pref} is a cell array of strings, @var{default} must be a cell array
-## of values with the same size as @var{pref}.
+## The corresponding default value @var{default} may be any Octave value,
+## .e.g., double, struct, cell array, object, etc.  Or, if @var{pref} is a cell
+## array of strings then @var{default} must be a cell array of values with the
+## same size as @var{pref}.
 ##
 ## If neither @var{pref} nor @var{default} are specified, return a structure
 ## of preferences for the preference group @var{group}.
@@ -47,54 +50,106 @@
 
 function retval = getpref (group, pref, default)
 
+  if (nargin > 3)
+    print_usage ();
+  endif
+
   if (nargin == 0)
     retval = loadprefs ();
   elseif (nargin == 1)
-    if (ischar (group))
-      prefs = loadprefs ();
-      if (isfield (prefs, group))
-        retval = prefs.(group);
-      else
-        retval = [];
-      endif
+    if (! ischar (group))
+      error ("getpref: GROUP must be a string");
+    endif
+    prefs = loadprefs ();
+    if (isfield (prefs, group))
+      retval = prefs.(group);
     else
-      error ("expecting group to be a character string");
+      ## FIXME: Is this the right behavior, or should it produce an error?
+      retval = [];
     endif
-  elseif (nargin == 2 || nargin == 3)
+  else
+    if (! (ischar (pref) || iscellstr (pref)))
+      error ("getpref: PREF must be a string or cellstr");
+    endif
+
     grp = getpref (group);
+
     if (ischar (pref))
       if (isfield (grp, pref))
         retval = grp.(pref);
       elseif (nargin == 3)
+        addpref (group, pref, default);
         retval = default;
       else
-        error ("preference %s does not exist in group %s", pref, group);
-      endif
-    elseif (iscellstr (pref))
-      if (nargin == 2 || size_equal (pref, default))
-        for i = 1:numel (pref)
-          if (isfield (grp, pref{i}))
-            retval.(pref) = grp.(pref{i});
-          elseif (nargin == 3)
-            retval.(pref) = default{i};
-          else
-            error ("preference %s does not exist in group %s", pref{i}, group);
-          endif
-        endfor
-      else
-        error ("size mismatch for pref and default");
+        error ("getpref: preference %s does not exist in group %s",
+               pref, group);
       endif
     else
-      error ("expecting pref to be a character string or cellstr");
+      if (nargin != 2 && ! size_equal (pref, default))
+        error ("getpref: size mismatch for PREF and DEFAULT");
+      endif
+
+      for i = 1:numel (pref)
+        if (isfield (grp, pref{i}))
+          retval{i} = grp.(pref{i});
+        elseif (nargin == 3)
+          addpref (group, pref{i}, default{i});
+          retval{i} = default{i};
+        else
+          error ("getpref: preference %s does not exist in group %s",
+                 pref{i}, group);
+        endif
+      endfor
     endif
-  else
-    print_usage ();
   endif
 
 endfunction
 
 
-## Testing these functions will require some care to avoid wiping out
-## existing (or creating unwanted) preferences for the user running the
-## tests.
+%!test
+%! HOME = getenv ("HOME");
+%! unwind_protect
+%!   setenv ("HOME", P_tmpdir ());
+%!   addpref ("group1", "pref1", [1 2 3]);
+%!   addpref ("group2", {"prefA", "prefB"}, {"StringA", {"StringB"}});
+%!
+%!   exp.group1.pref1 = [1 2 3];
+%!   exp.group2.prefA = "StringA";
+%!   exp.group2.prefB = {"StringB"};
+%!   obs = getpref ();
+%!   assert (obs, exp);
+%!
+%!   assert (getpref ("group1"), exp.group1);
+%!   assert (getpref ("group2"), exp.group2);
+%!   assert (getpref ("group3"), []);
+%!
+%!   assert (getpref ("group1", "pref1"), [1 2 3]);
+%!   assert (getpref ("group2", "prefA"), "StringA");
+%!   assert (getpref ("group2", "prefB"), {"StringB"});
+%!   assert (getpref ("group1", "pref2", "New_Value"), "New_Value");
+%!   assert (getpref ("group1", "pref2"), "New_Value");
+%!   fail ('getpref ("group1", "no_such_pref")', ...
+%!         "preference no_such_pref does not exist in group group1");
+%!
+%!   assert (getpref ("group2", {"prefA", "prefB"}), {"StringA", {"StringB"}});
+%!   assert (getpref ("group2", {"prefA", "prefC"}, {1, "StringC"}),
+%!           {"StringA", "StringC"});
+%!   assert (getpref ("group2", "prefC"), "StringC");
+%!   fail ('getpref ("group1", {"p1", "p2"}, 1)', ...
+%!         "size mismatch for PREF and DEFAULT");
+%!   fail ('getpref ("group2", {"prefA", "prefD"})',
+%!         "preference prefD does not exist in group group2");
+%!
+%! unwind_protect_cleanup
+%!   unlink (fullfile (P_tmpdir (), ".octave_prefs"));
+%!   if (isempty (HOME))
+%!     unsetenv ("HOME");
+%!   else
+%!     setenv ("HOME", HOME);
+%!   endif
+%! end_unwind_protect
 
+%!error getpref (1,2,3,4)
+%!error <GROUP must be a string> getpref (1)
+%!error <PREF must be a string> getpref ("group1", 1, 2)
+
--- a/scripts/prefs/ispref.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/prefs/ispref.m	Thu Dec 10 12:50:06 2015 -0800
@@ -17,15 +17,15 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {} ispref (@var{group}, @var{pref})
-## @deftypefnx {Function File} {} ispref (@var{group})
+## @deftypefn  {Function File} {} ispref ("@var{group}", "@var{pref}")
+## @deftypefnx {Function File} {} ispref ("@var{group}", @{"@var{pref1}", "@var{pref2"}, @dots{}@})
+## @deftypefnx {Function File} {} ispref ("@var{group}")
 ## Return true if the named preference @var{pref} exists in the preference
 ## group @var{group}.
 ##
-## The named preference group must be a character string.
+## The named preference group must be a string.
 ##
-## The preference @var{pref} may be a character string or a cell array of
-## character strings.
+## The preference @var{pref} may be a string or a cell array of strings.
 ##
 ## If @var{pref} is not specified, return true if the preference group
 ## @var{group} exists.
@@ -34,30 +34,66 @@
 
 ## Author: jwe
 
-function retval = ispref (group, pref)
+function retval = ispref (group, pref = "")
+
+  if (nargin == 0 || nargin > 2)
+    print_usage ();
+  endif
+
+  if (! ischar (group))
+    error ("ispref: GROUP must be a string");
+  endif
+  if (! (ischar (pref) || iscellstr (pref)))
+    error ("ispref: PREF must be a string or cellstr");
+  endif
 
   if (nargin == 1)
     retval = isfield (loadprefs (), group);
-  elseif (nargin == 2)
+  else
     prefs = loadprefs ();
     if (isfield (prefs, group))
-      grp = prefs.(group);
-      if (ischar (pref) || iscellstr (pref))
-        retval = isfield (grp, pref);
+      retval = isfield (prefs.(group), pref);
+    else
+      if (ischar (pref))
+        retval = false;
       else
-        retval = false;
+        retval = false (size (pref));
       endif
-    else
-      retval = false;
     endif
-  else
-    print_usage ();
   endif
 
 endfunction
 
 
-## Testing these functions will require some care to avoid wiping out
-## existing (or creating unwanted) preferences for the user running the
-## tests.
+%!test
+%! HOME = getenv ("HOME");
+%! unwind_protect
+%!   setenv ("HOME", P_tmpdir ());
+%!   addpref ("group1", "pref1", [1 2 3]);
+%!   addpref ("group2", {"prefA", "prefB"}, {"StringA", {"StringB"}});
+%!
+%!   assert (ispref ("group1"));
+%!   assert (! ispref ("group3"));
+%!
+%!   assert (ispref ("group2", "prefB"));
+%!   assert (! ispref ("group2", "prefC"));
+%!
+%!   assert (ispref ("group2", {"prefB", "prefC"}), [true, false]);
+%!
+%!   assert (ispref ("group3", "prefB"), false);
+%!   assert (ispref ("group3", {"prefB", "prefC"}), [false, false]);
+%!
+%! unwind_protect_cleanup
+%!   unlink (fullfile (P_tmpdir (), ".octave_prefs"));
+%!   if (isempty (HOME))
+%!     unsetenv ("HOME");
+%!   else
+%!     setenv ("HOME", HOME);
+%!   endif
+%! end_unwind_protect
 
+%!error ispref ()
+%!error ispref (1,2,3)
+%!error <GROUP must be a string> ispref (1, "pref1")
+%!error <PREF must be a string> ispref ("group1", 1)
+
--- a/scripts/prefs/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/prefs/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,22 +1,33 @@
-FCN_FILE_DIRS += prefs
+FCN_FILE_DIRS += \
+  scripts/prefs \
+  scripts/prefs/private
 
-prefs_PRIVATE_FCN_FILES = \
-  prefs/private/loadprefs.m \
-  prefs/private/prefsfile.m \
-  prefs/private/saveprefs.m
+scripts_prefs_PRIVATE_FCN_FILES = \
+  scripts/prefs/private/loadprefs.m \
+  scripts/prefs/private/prefdir.m \
+  scripts/prefs/private/prefsfile.m \
+  scripts/prefs/private/saveprefs.m
 
-prefs_FCN_FILES = \
-  prefs/addpref.m \
-  prefs/getpref.m \
-  prefs/ispref.m \
-  prefs/prefdir.m \
-  prefs/preferences.m \
-  prefs/rmpref.m \
-  prefs/setpref.m \
-  $(prefs_PRIVATE_FCN_FILES)
+scripts_prefs_FCN_FILES = \
+  scripts/prefs/addpref.m \
+  scripts/prefs/getpref.m \
+  scripts/prefs/ispref.m \
+  scripts/prefs/preferences.m \
+  scripts/prefs/rmpref.m \
+  scripts/prefs/setpref.m
+
+scripts_prefsdir = $(fcnfiledir)/prefs
+
+scripts_prefs_DATA = $(scripts_prefs_FCN_FILES)
 
-FCN_FILES += $(prefs_FCN_FILES)
+scripts_prefs_privatedir = $(fcnfiledir)/prefs/private
+
+scripts_prefs_private_DATA = $(scripts_prefs_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += prefs/PKG_ADD
+FCN_FILES += \
+  $(scripts_prefs_FCN_FILES) \
+  $(scripts_prefs_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += prefs/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/prefs/PKG_ADD
+
+DIRSTAMP_FILES += scripts/prefs/$(octave_dirstamp)
--- a/scripts/prefs/prefdir.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-## Copyright (C) 2013-2015 John Donoghue
-##
-## 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  {Command} {} prefdir
-## @deftypefnx {Command} {@var{dir} =} prefdir
-## Return the directory that contains the preferences for Octave.
-##
-## Examples:
-##
-## Display the preferences directory
-##
-## @example
-## prefdir
-## @end example
-##
-## Change to the preferences folder
-##
-## @example
-## cd (prefdir)
-## @end example
-## @seealso{getpref, setpref, addpref, rmpref, ispref}
-## @end deftypefn
-
-## Author: John Donoghue
-## Version: 0.01
-
-function folder = prefdir ()
-
-  folder = get_home_directory ();
-
-endfunction
-
--- a/scripts/prefs/preferences.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/prefs/preferences.m	Thu Dec 10 12:50:06 2015 -0800
@@ -22,13 +22,21 @@
 ## @end deftypefn
 
 ## Author: John Donoghue
-## Version: 0.01
 
 function preferences ()
+
   if (isguirunning ())
     __octave_link_show_preferences__ ();
   else
     warning ("preferences: GUI must be running to use preferences dialog");
   endif
+
 endfunction
 
+
+%!test
+%! if (isguirunning ())
+%!   return;
+%! endif
+%! fail ("preferences ()", "warning", "GUI must be running");
+
--- a/scripts/prefs/private/loadprefs.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/prefs/private/loadprefs.m	Thu Dec 10 12:50:06 2015 -0800
@@ -17,8 +17,8 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} loadprefs ()
-## Undocumented internal function.
+## @deftypefn {Function File} {@var{prefs} =} loadprefs ()
+## Return a structure containing all user configured preferences.
 ## @end deftypefn
 
 ## Author: jwe
@@ -31,15 +31,10 @@
 
   if (isstruct (s) && S_ISREG (s.mode))
     tmp = load (file);
-    retval= tmp.prefs;
+    retval = tmp.prefs;
   else
     retval = [];
   endif
 
 endfunction
 
-
-## Testing these functions will require some care to avoid wiping out
-## existing (or creating unwanted) preferences for the user running the
-## tests.
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/prefs/private/prefdir.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,47 @@
+## Copyright (C) 2013-2015 John Donoghue
+##
+## 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  {Command} {} prefdir
+## @deftypefnx {Command} {@var{dir} =} prefdir
+## Return the directory that holds the preferences for Octave.
+##
+## Examples:
+##
+## Display the preferences directory
+##
+## @example
+## prefdir
+## @end example
+##
+## Change to the preferences folder
+##
+## @example
+## cd (prefdir)
+## @end example
+## @seealso{getpref, setpref, addpref, rmpref, ispref}
+## @end deftypefn
+
+## Author: John Donoghue
+
+function dir = prefdir ()
+
+  dir = get_home_directory ();
+
+endfunction
+
--- a/scripts/prefs/private/prefsfile.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/prefs/private/prefsfile.m	Thu Dec 10 12:50:06 2015 -0800
@@ -18,7 +18,7 @@
 
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} prefsfile ()
-## Undocumented internal function.
+## Return the full path and name of the file containing Octave preferences.
 ## @end deftypefn
 
 ## Author: jwe
@@ -29,8 +29,3 @@
 
 endfunction
 
-
-## Testing these functions will require some care to avoid wiping out
-## existing (or creating unwanted) preferences for the user running the
-## tests.
-
--- a/scripts/prefs/private/saveprefs.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/prefs/private/saveprefs.m	Thu Dec 10 12:50:06 2015 -0800
@@ -17,13 +17,13 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} saveprefs ()
-## Undocumented internal function.
+## @deftypefn {Function File} {} saveprefs (@var{s})
+## Save user preferences in the structure @var{s} to Octave's preference file.
 ## @end deftypefn
 
 ## Author: jwe
 
-function retval = saveprefs (s)
+function saveprefs (s)
 
   prefs = s;
 
@@ -31,8 +31,3 @@
 
 endfunction
 
-
-## Testing these functions will require some care to avoid wiping out
-## existing (or creating unwanted) preferences for the user running the
-## tests.
-
--- a/scripts/prefs/rmpref.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/prefs/rmpref.m	Thu Dec 10 12:50:06 2015 -0800
@@ -17,13 +17,14 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {} rmpref (@var{group}, @var{pref})
-## @deftypefnx {Function File} {} rmpref (@var{group})
+## @deftypefn  {Function File} {} rmpref ("@var{group}", "@var{pref}")
+## @deftypefnx {Function File} {} rmpref ("@var{group}", @{"@var{pref1}", "@var{pref2}", @dots{}@})
+## @deftypefnx {Function File} {} rmpref ("@var{group}")
 ## Remove the named preference @var{pref} from the preference group @var{group}.
 ##
-## The named preference group must be a character string.
+## The named preference group must be a string.
 ##
-## The preference @var{pref} may be a character string or cell array of strings.
+## The preference @var{pref} may be a string or cell array of strings.
 ##
 ## If @var{pref} is not specified, remove the preference group @var{group}.
 ##
@@ -33,7 +34,7 @@
 
 ## Author: jwe
 
-function retval = rmpref (group, pref)
+function rmpref (group, pref)
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
@@ -44,13 +45,12 @@
   endif
 
   if (nargin == 1)
-    if (ispref (group))
-      prefs = loadprefs ();
-      prefs = rmfield (prefs, group);
-      saveprefs (prefs);
-    else
-      error ("rmpref: group <%s> does not exist", group);
+    if (! ispref (group))
+      error ("rmpref: group %s does not exist", group);
     endif
+    prefs = loadprefs ();
+    prefs = rmfield (prefs, group);
+    saveprefs (prefs);
   else
     valid = ispref (group, pref);
     if (all (valid))
@@ -59,10 +59,12 @@
       saveprefs (prefs);
     else
       if (! ispref (group))
-        error ("rmpref: group <%s> does not exist", group);
+        error ("rmpref: group %s does not exist", group);
+      elseif (ischar (pref))
+        error ("rmpref: preference %s does not exist", pref);
       else
         idx = find (! valid, 1);
-        error ("rmpref: pref <%s> does not exist", (cellstr (pref)){idx} );
+        error ("rmpref: preference %s does not exist", pref{idx});
       endif
     endif
   endif
@@ -70,13 +72,42 @@
 endfunction
 
 
-## Testing these functions will require some care to avoid wiping out
-## existing (or creating unwanted) preferences for the user running the
-## tests.
+%!test
+%! HOME = getenv ("HOME");
+%! unwind_protect
+%!   setenv ("HOME", P_tmpdir ());
+%!   addpref ("group1", "pref1", [1 2 3]);
+%!   addpref ("group2", {"prefA", "prefB", "prefC"}, {"strA", "strB", "strC"});
+%!
+%!   assert (ispref ("group1"));
+%!   rmpref ("group1");
+%!   assert (! ispref ("group1"));
+%!
+%!   assert (ispref ("group2", "prefB"));
+%!   rmpref ("group2", "prefB");
+%!   assert (! ispref ("group2", "prefB"));
+%!
+%!   fail ('rmpref ("group3")', ...
+%!         "group group3 does not exist");
+%!   fail ('rmpref ("group3", "prefA")', ...
+%!         "group group3 does not exist");
+%!   fail ('rmpref ("group2", "prefB")',
+%!         "preference prefB does not exist");
+%!   fail ('rmpref ("group2", {"prefA", "prefB"})',
+%!         "preference prefB does not exist");
+%!
+%! unwind_protect_cleanup
+%!   unlink (fullfile (P_tmpdir (), ".octave_prefs"));
+%!   if (isempty (HOME))
+%!     unsetenv ("HOME");
+%!   else
+%!     setenv ("HOME", HOME);
+%!   endif
+%! end_unwind_protect
 
 ## Test input validation
 %!error rmpref ()
 %!error rmpref (1,2,3)
-%!error rmpref ({"__group1__"})
-%!error rmpref ("__group1__", 1)
+%!error <GROUP must be a string> rmpref (1)
+%!error <PREF must be a string> rmpref ("group1", 1)
 
--- a/scripts/prefs/setpref.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/prefs/setpref.m	Thu Dec 10 12:50:06 2015 -0800
@@ -17,18 +17,19 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} setpref (@var{group}, @var{pref}, @var{val})
-## Set a preference @var{pref} to the given @var{val} in the named preference
+## @deftypefn  {Function File} {} setpref ("@var{group}", "@var{pref}", @var{val})
+## @deftypefnx {Function File} {} addpref ("@var{group}", @{"@var{pref1}", "@var{pref2}", @dots{}@}, @{@var{val1}, @var{val2}, @dots{}@})
+## Set the preference @var{pref} to the given @var{val} in the named preference
 ## group @var{group}.
 ##
-## The named preference group must be a character string.
+## The named preference group must be a string.
+##
+## The preference @var{pref} may be a string or a cell array of strings.
 ##
-## The preference @var{pref} may be a character string or a cell array of
-## character strings.
-##
-## The corresponding value @var{val} may be any value, or, if @var{pref} is a
-## cell array of strings, @var{val} must be a cell array of values with the
-## same size as @var{pref}.
+## The corresponding value @var{val} may be any Octave value, .e.g., double,
+## struct, cell array, object, etc.  Or, if @var{pref} is a cell array of
+## strings then @var{val} must be a cell array of values with the same size as
+## @var{pref}.
 ##
 ## If the named preference or group does not exist, it is added.
 ## @seealso{addpref, getpref, ispref, rmpref}
@@ -38,34 +39,67 @@
 
 function setpref (group, pref, val)
 
-  if (nargin == 3)
-    if (ischar (group))
-      prefs = loadprefs ();
-      if (ischar (pref))
-        prefs.(group).(pref) = val;
-      elseif (iscellstr (pref))
-        if (size_equal (pref, val))
-          for i = 1:numel (pref)
-            prefs.(group).(pref{i}) = val;
-          endfor
-        else
-          error ("size mismatch for pref and val");
-        endif
-      else
-        error ("expecting pref to be a character string or cellstr");
-      endif
-      saveprefs (prefs);
-    else
-      error ("expecting group to be a character string");
-    endif
-  else
+  if (nargin != 3)
     print_usage ();
   endif
 
+  if (! ischar (group))
+    error ("setpref: GROUP must be a string");
+  endif
+  if (! (ischar (pref) || iscellstr (pref)))
+    error ("setpref: PREF must be a string or cellstr");
+  endif
+
+  prefs = loadprefs ();
+
+  if (ischar (pref))
+    prefs.(group).(pref) = val;
+  else
+    if (! size_equal (pref, val))
+      error ("setpref: size mismatch for PREF and VAL");
+    endif
+
+    for i = 1:numel (pref)
+      prefs.(group).(pref{i}) = val{i};
+    endfor
+  endif
+
+  saveprefs (prefs);
+
 endfunction
 
 
-## Testing these functions will require some care to avoid wiping out
-## existing (or creating unwanted) preferences for the user running the
-## tests.
+%!test
+%! HOME = getenv ("HOME");
+%! unwind_protect
+%!   setenv ("HOME", P_tmpdir ());
+%!
+%!   setpref ("group1", "pref1", [1 2 3]);
+%!   assert (getpref ("group1", "pref1"), [1 2 3]);
+%!
+%!   setpref ("group2", {"prefA", "prefB"}, {"StringA", {"StringB"}});
+%!   assert (getpref ("group2", "prefA"), "StringA");
+%!   assert (getpref ("group2", "prefB"), {"StringB"});
+%!
+%!   setpref ("group1", {"pref1", "pref2"}, {1, 2});
+%!   assert (getpref ("group1", "pref1"), 1);
+%!   assert (getpref ("group1", "pref2"), 2);
+%!
+%!   fail ('setpref ("group1", {"p1", "p2"}, 1)', ...
+%!         "size mismatch for PREF and VAL");
+%! unwind_protect_cleanup
+%!   unlink (fullfile (P_tmpdir (), ".octave_prefs"));
+%!   if (isempty (HOME))
+%!     unsetenv ("HOME");
+%!   else
+%!     setenv ("HOME", HOME);
+%!   endif
+%! end_unwind_protect
 
+%!error setpref ()
+%!error setpref (1)
+%!error setpref (1,2)
+%!error setpref (1,2,3,4)
+%!error <GROUP must be a string> setpref (1, "pref1", 2)
+%!error <PREF must be a string> setpref ("group1", 1, 2)
+
--- a/scripts/set/intersect.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/set/intersect.m	Thu Dec 10 12:50:06 2015 -0800
@@ -47,10 +47,19 @@
   [a, b] = validsetargs ("intersect", a, b, varargin{:});
 
   if (isempty (a) || isempty (b))
-    c = ia = ib = [];
+    ## Special case shortcuts algorithm.
+    ## Lots of type checking required for Matlab compatibility.
+    if (isnumeric (a) && isnumeric (b))
+      c = [];
+    elseif (iscell (b))
+      c = {};
+    else
+      c = "";
+    endif
+    ia = ib = [];
   else
     by_rows = nargin == 3;
-    isrowvec = isvector (a) && isvector (b) && isrow (a) && isrow (b);
+    isrowvec = isrow (a) && isrow (b);
 
     ## Form A and B into sets
     if (nargout > 1)
@@ -141,3 +150,11 @@
 %! assert (ia, [1:3]');
 %! assert (ib, [1:3]');
 
+## Test return type of empty intersections
+%!assert (intersect (['a', 'b'], {}), {})
+%!assert (intersect ([], {'a', 'b'}), {})
+%!assert (intersect ([], {}), {})
+%!assert (intersect ({'a', 'b'}, []), {})
+%!assert (intersect ([], ['a', 'b']), "")
+%!assert (intersect ({}, []), {})
+%!assert (intersect (['a', 'b'], []), "")
--- a/scripts/set/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/set/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,17 +1,30 @@
-FCN_FILE_DIRS += set
+FCN_FILE_DIRS += \
+  scripts/set \
+  scripts/set/private
+
+scripts_set_PRIVATE_FCN_FILES = scripts/set/private/validsetargs.m
+
+scripts_set_FCN_FILES = \
+  scripts/set/intersect.m \
+  scripts/set/ismember.m \
+  scripts/set/powerset.m \
+  scripts/set/setdiff.m \
+  scripts/set/setxor.m \
+  scripts/set/union.m \
+  scripts/set/unique.m
 
-set_FCN_FILES = \
-  set/intersect.m \
-  set/ismember.m \
-  set/powerset.m \
-  set/setdiff.m \
-  set/setxor.m \
-  set/union.m \
-  set/unique.m \
-  set/private/validsetargs.m
+scripts_setdir = $(fcnfiledir)/set
+
+scripts_set_DATA = $(scripts_set_FCN_FILES)
+
+scripts_set_privatedir = $(fcnfiledir)/set/private
+
+scripts_set_private_DATA = $(scripts_set_PRIVATE_FCN_FILES)
 
-FCN_FILES += $(set_FCN_FILES)
+FCN_FILES += \
+  $(scripts_set_FCN_FILES) \
+  $(scripts_set_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += set/PKG_ADD
+PKG_ADD_FILES += scripts/set/PKG_ADD
 
-DIRSTAMP_FILES += set/$(octave_dirstamp)
+DIRSTAMP_FILES += scripts/set/$(octave_dirstamp)
--- a/scripts/set/powerset.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/set/powerset.m	Thu Dec 10 12:50:06 2015 -0800
@@ -40,7 +40,7 @@
   byrows = false;
   if (nargin == 2)
     if (! strcmpi (byrows_arg, "rows"))
-      error ('powerset: expecting second argument to be "rows"');
+      error ('powerset: optional second argument must be "rows"');
     elseif (iscell (a))
       error ('powerset: "rows" not valid for cell arrays');
     else
@@ -103,7 +103,7 @@
 ## Test input validation
 %!error powerset ()
 %!error powerset (1,2,3)
-%!error <expecting second argument to be "rows"> powerset (1, "cols")
+%!error <second argument must be "rows"> powerset (1, "cols")
 %!error <"rows" not valid for cell arrays> powerset ({1}, "rows")
 %!error <cell arrays can only be used for character> powerset ({1})
 %!error <not implemented for more than 32 elements> powerset (1:33)
--- a/scripts/set/private/validsetargs.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/set/private/validsetargs.m	Thu Dec 10 12:50:06 2015 -0800
@@ -31,6 +31,10 @@
         y = cellstr (y);
       elseif (icy && ischar (x))
         x = cellstr (x);
+      elseif (icy && isempty (x))
+        x = {};
+      elseif (icx && isempty (y))
+        y = {};
       elseif (! (icx && icy))
         error ("%s: cell array of strings cannot be combined with a nonstring value", caller);
       endif
--- a/scripts/set/setdiff.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/set/setdiff.m	Thu Dec 10 12:50:06 2015 -0800
@@ -48,7 +48,7 @@
   [a, b] = validsetargs ("setdiff", a, b, varargin{:});
 
   by_rows = nargin == 3;
-  isrowvec = isvector (a) && isrow (a);
+  isrowvec = isrow (a);
 
   if (by_rows)
     if (nargout > 1)
--- a/scripts/set/setxor.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/set/setxor.m	Thu Dec 10 12:50:06 2015 -0800
@@ -50,7 +50,7 @@
   [a, b] = validsetargs ("setxor", a, b, varargin{:});
 
   by_rows = nargin == 3;
-  isrowvec = isvector (a) && isvector (b) && isrow (a) && isrow (b);
+  isrowvec = isrow (a) && isrow (b);
 
   ## Form A and B into sets.
   if (nargout > 1)
--- a/scripts/set/union.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/set/union.m	Thu Dec 10 12:50:06 2015 -0800
@@ -51,7 +51,7 @@
   [a, b] = validsetargs ("union", a, b, varargin{:});
 
   by_rows = nargin == 3;
-  isrowvec = isvector (a) && isvector (b) && isrow (a) && isrow (b);
+  isrowvec = isrow (a) && isrow (b);
 
   if (by_rows)
     y = [a; b];
@@ -94,6 +94,14 @@
 %! assert (y, [1; 2; 3; 4; 5]);
 %! assert (y, sort ([a(ia)'; b(ib)']));
 
+## Test empty cell string array unions
+%!assert (union ({}, []), cell (0,1))
+%!assert (union ([], {}), cell (0,1))
+%!assert (union ([], {'a', 'b'}), {'a';'b'})
+%!assert (union ({'a', 'b'}, []), {'a';'b'})
+%!assert (union (['a', 'b'], {}), {'ab'})
+%!assert (union ({}, ['a', 'b']), {'ab'})
+
 ## Test common input validation for set routines contained in validsetargs
 %!error <cell array of strings cannot be combined> union ({"a"}, 1)
 %!error <A and B must be arrays or cell arrays> union (@sin, 1)
--- a/scripts/signal/arch_fit.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/signal/arch_fit.m	Thu Dec 10 12:50:06 2015 -0800
@@ -96,17 +96,17 @@
     tmp = esq ./ h.^2 - 1 ./ h;
     s   = 1 ./ h(1:T-p);
     for j = 1 : p;
-      s = s - a(j+1) * tmp(j+1:T-p+j);
+      s -= a(j+1) * tmp(j+1:T-p+j);
     endfor
     r = 1 ./ h(1:T-p);
     for j = 1:p;
-      r = r + 2 * h(j+1:T-p+j).^2 .* esq(1:T-p);
+      r += 2 * h(j+1:T-p+j).^2 .* esq(1:T-p);
     endfor
     r = sqrt (r);
     X_tilde = x(1:T-p, :) .* (r * ones (1,k));
     e_tilde = e(1:T-p) .*s ./ r;
     delta_b = inv (X_tilde' * X_tilde) * X_tilde' * e_tilde;
-    b   = b + gamma * delta_b;
+    b  += gamma * delta_b;
     e   = y - x * b;
     esq = e .^ 2;
     Z   = autoreg_matrix (esq, p);
@@ -114,7 +114,7 @@
     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 += gamma * delta_a;
   endfor
 
 endfunction
--- a/scripts/signal/arch_rnd.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/signal/arch_rnd.m	Thu Dec 10 12:50:06 2015 -0800
@@ -63,14 +63,14 @@
   a  = reshape (a, 1, la);
   if (la == 1)
     a  = [a, 0];
-    la = la + 1;
+    la += 1;
   endif
 
   lb = length (b);
   b  = reshape (b, 1, lb);
   if (lb == 1)
     b  = [b, 0];
-    lb = lb + 1;
+    lb += 1;
   endif
   m = max ([la, lb]);
 
--- a/scripts/signal/bartlett.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/signal/bartlett.m	Thu Dec 10 12:50:06 2015 -0800
@@ -42,7 +42,7 @@
   if (m == 1)
     c = 1;
   else
-    m = m - 1;
+    m -= 1;
     n = fix (m / 2);
     c = [2*(0:n)/m, 2-2*(n+1:m)/m]';
   endif
--- a/scripts/signal/blackman.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/signal/blackman.m	Thu Dec 10 12:50:06 2015 -0800
@@ -60,7 +60,7 @@
   if (m == 1)
     c = 1;
   else
-    m = m - 1;
+    m -= 1;
     k = (0 : m)' / N;
     c = 0.42 - 0.5 * cos (2 * pi * k) + 0.08 * cos (4 * pi * k);
   endif
--- a/scripts/signal/freqz.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/signal/freqz.m	Thu Dec 10 12:50:06 2015 -0800
@@ -152,7 +152,7 @@
     k = max (length (b), length (a));
     if (k > n/2 && nargout == 0)
       ## Ensure a causal phase response.
-      n = n * 2 .^ ceil (log2 (2*k/n));
+      n *= 2 .^ ceil (log2 (2*k/n));
     endif
 
     if (whole_region)
@@ -165,7 +165,7 @@
     else
       N = 2*n;
       if (plot_output)
-        n++;
+        n += 1;
       endif
       f = Fs * (0:n-1).' / N;
     endif
@@ -178,8 +178,8 @@
     ha = zeros (n, 1);
 
     for i = 1:N:pad_sz
-      hb = hb + fft (postpad (b(i:i+N-1), N))(1:n);
-      ha = ha + fft (postpad (a(i:i+N-1), N))(1:n);
+      hb += fft (postpad (b(i:i+N-1), N))(1:n);
+      ha += fft (postpad (a(i:i+N-1), N))(1:n);
     endfor
 
   endif
--- a/scripts/signal/hamming.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/signal/hamming.m	Thu Dec 10 12:50:06 2015 -0800
@@ -60,7 +60,7 @@
   if (m == 1)
     c = 1;
   else
-    m = m - 1;
+    m -= 1;
     c = 0.54 - 0.46 * cos (2 * pi * (0 : m)' / N);
   endif
 
--- a/scripts/signal/hanning.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/signal/hanning.m	Thu Dec 10 12:50:06 2015 -0800
@@ -60,7 +60,7 @@
   if (m == 1)
     c = 1;
   else
-    m = m - 1;
+    m -= 1;
     c = 0.5 - 0.5 * cos (2 * pi * (0 : m)' / N);
   endif
 
--- a/scripts/signal/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/signal/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,48 +1,59 @@
-FCN_FILE_DIRS += signal
+FCN_FILE_DIRS += \
+  scripts/signal \
+  scripts/signal/private
 
-signal_PRIVATE_FCN_FILES = \
-  signal/private/rectangle_lw.m  \
-  signal/private/rectangle_sw.m  \
-  signal/private/triangle_lw.m  \
-  signal/private/triangle_sw.m
+scripts_signal_PRIVATE_FCN_FILES = \
+  scripts/signal/private/rectangle_lw.m  \
+  scripts/signal/private/rectangle_sw.m  \
+  scripts/signal/private/triangle_lw.m  \
+  scripts/signal/private/triangle_sw.m
 
-signal_FCN_FILES = \
-  signal/arch_fit.m \
-  signal/arch_rnd.m \
-  signal/arch_test.m \
-  signal/arma_rnd.m \
-  signal/autoreg_matrix.m \
-  signal/bartlett.m \
-  signal/blackman.m \
-  signal/detrend.m \
-  signal/diffpara.m \
-  signal/durbinlevinson.m \
-  signal/fftconv.m \
-  signal/fftfilt.m \
-  signal/fftshift.m \
-  signal/filter2.m \
-  signal/fractdiff.m \
-  signal/freqz.m \
-  signal/freqz_plot.m \
-  signal/hamming.m \
-  signal/hanning.m \
-  signal/hurst.m \
-  signal/ifftshift.m \
-  signal/periodogram.m \
-  signal/sinc.m \
-  signal/sinetone.m \
-  signal/sinewave.m \
-  signal/spectral_adf.m \
-  signal/spectral_xdf.m \
-  signal/spencer.m \
-  signal/stft.m \
-  signal/synthesis.m \
-  signal/unwrap.m \
-  signal/yulewalker.m \
-  $(signal_PRIVATE_FCN_FILES)
+scripts_signal_FCN_FILES = \
+  scripts/signal/arch_fit.m \
+  scripts/signal/arch_rnd.m \
+  scripts/signal/arch_test.m \
+  scripts/signal/arma_rnd.m \
+  scripts/signal/autoreg_matrix.m \
+  scripts/signal/bartlett.m \
+  scripts/signal/blackman.m \
+  scripts/signal/detrend.m \
+  scripts/signal/diffpara.m \
+  scripts/signal/durbinlevinson.m \
+  scripts/signal/fftconv.m \
+  scripts/signal/fftfilt.m \
+  scripts/signal/fftshift.m \
+  scripts/signal/filter2.m \
+  scripts/signal/fractdiff.m \
+  scripts/signal/freqz.m \
+  scripts/signal/freqz_plot.m \
+  scripts/signal/hamming.m \
+  scripts/signal/hanning.m \
+  scripts/signal/hurst.m \
+  scripts/signal/ifftshift.m \
+  scripts/signal/periodogram.m \
+  scripts/signal/sinc.m \
+  scripts/signal/sinetone.m \
+  scripts/signal/sinewave.m \
+  scripts/signal/spectral_adf.m \
+  scripts/signal/spectral_xdf.m \
+  scripts/signal/spencer.m \
+  scripts/signal/stft.m \
+  scripts/signal/synthesis.m \
+  scripts/signal/unwrap.m \
+  scripts/signal/yulewalker.m
 
-FCN_FILES += $(signal_FCN_FILES)
+scripts_signaldir = $(fcnfiledir)/signal
+
+scripts_signal_DATA = $(scripts_signal_FCN_FILES)
+
+scripts_signal_privatedir = $(fcnfiledir)/signal/private
+
+scripts_signal_private_DATA = $(scripts_signal_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += signal/PKG_ADD
+FCN_FILES += \
+  $(scripts_signal_FCN_FILES) \
+  $(scripts_signal_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += signal/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/signal/PKG_ADD
+
+DIRSTAMP_FILES += scripts/signal/$(octave_dirstamp)
--- a/scripts/signal/periodogram.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/signal/periodogram.m	Thu Dec 10 12:50:06 2015 -0800
@@ -98,7 +98,7 @@
         case 4
           fs     = varargin{k};
       endswitch
-      j++;
+      j += 1;
     endif
   endfor
 
--- a/scripts/signal/spectral_adf.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/signal/spectral_adf.m	Thu Dec 10 12:50:06 2015 -0800
@@ -60,7 +60,7 @@
     w = feval (win, cr, b);
   endif
 
-  c = c .* w;
+  c .*= w;
 
   retval = 2 * real (fft (c)) - c(1);
   retval = [(zeros (cr, 1)), retval];
--- a/scripts/signal/spectral_xdf.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/signal/spectral_xdf.m	Thu Dec 10 12:50:06 2015 -0800
@@ -60,7 +60,7 @@
     w = feval (win, xr, b);
   endif
 
-  x = x - sum (x) / xr;
+  x -= sum (x) / xr;
 
   retval = (abs (fft (x)) / xr).^2;
   retval = real (ifft (fft (retval) .* fft (w)));
--- a/scripts/signal/stft.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/signal/stft.m	Thu Dec 10 12:50:06 2015 -0800
@@ -101,7 +101,7 @@
   start = 1;
   for i = 0:num_win
     z(1:win_size, i+1) = x(start:start+win_size-1) .* win_coef;
-    start = start + inc;
+    start += inc;
   endfor
 
   y = fft (z);
--- a/scripts/sparse/bicg.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/bicg.m	Thu Dec 10 12:50:06 2015 -0800
@@ -88,8 +88,7 @@
       Ax  = @(x) feval (A, x, "notransp");
       Atx = @(x) feval (A, x, "transp");
     else
-      error (["bicg: first argument is expected to " ...
-              "be a function or a square matrix"]);
+      error ("bicg: A must be a square matrix or function");
     endif
 
     if (nargin < 3 || isempty (tol))
@@ -116,8 +115,7 @@
       M1m1x  = @(x) feval (M1, x, "notransp");
       M1tm1x = @(x) feval (M1, x, "transp");
     else
-      error (["bicg: preconditioner is expected to " ...
-              "be a function or matrix"]);
+      error ("bicg: preconditioner must be a function or matrix");
     endif
 
     if (nargin < 6 || isempty (M2))
@@ -134,8 +132,7 @@
       M2m1x  = @(x) feval (M2, x, "notransp");
       M2tm1x = @(x) feval (M2, x, "transp");
     else
-      error (["bicg: preconditioner is expected to " ...
-              "be a function or matrix"]);
+      error ("bicg: preconditioner must be a function or matrix");
     endif
 
     Pm1x  = @(x) M2m1x  (M1m1x (x));
--- a/scripts/sparse/bicgstab.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/bicgstab.m	Thu Dec 10 12:50:06 2015 -0800
@@ -81,8 +81,7 @@
     elseif (isa (A, "function_handle"))
       Ax  = @(x) feval (A, x);
     else
-      error (["bicgstab: first argument is expected " ...
-              "to be a function or a square matrix"]);
+      error ("bicgstab: A must be a square matrix or function");
     endif
 
     if (nargin < 3 || isempty (tol))
@@ -102,8 +101,7 @@
     elseif (isa (M1, "function_handle"))
       M1m1x = @(x) feval (M1, x);
     else
-      error (["bicgstab: preconditioner is " ...
-              "expected to be a function or matrix"]);
+      error ("bicgstab: preconditioner must be a function or matrix");
     endif
 
     if (nargin < 6 || isempty (M2))
@@ -115,8 +113,7 @@
     elseif (isa (M2, "function_handle"))
       M2m1x = @(x) feval (M2, x);
     else
-      error (["bicgstab: preconditioner is "...
-              "expected to be a function or matrix"]);
+      error ("bicgstab: preconditioner must be a function or matrix");
     endif
 
     precon = @(x) M2m1x (M1m1x (x));
@@ -163,7 +160,7 @@
 
       t = Ax (shat);
       omega = (s' * t) / (t' * t);
-      x = x + alpha * phat + omega * shat;
+      x += alpha * phat + omega * shat;
       res = s - omega * t;
       rho_2 = rho_1;
 
--- a/scripts/sparse/cgs.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/cgs.m	Thu Dec 10 12:50:06 2015 -0800
@@ -79,8 +79,7 @@
     elseif (isa (A, "function_handle"))
       Ax = @(x) feval (A, x);
     else
-      error (["cgs: first argument is expected to "...
-              "be a function or a square matrix"]);
+      error ("cgs: A must be a square matrix or function");
     endif
 
     if (nargin < 3 || isempty (tol))
@@ -100,7 +99,7 @@
     elseif (isa (M1, "function_handle"))
       M1m1x = @(x) feval (M1, x);
     else
-      error ("cgs: preconditioner is expected to be a function or matrix");
+      error ("cgs: preconditioner must be a function or matrix");
     endif
 
     if (nargin < 6 || isempty (M2))
@@ -112,7 +111,7 @@
     elseif (isa (M2, "function_handle"))
       M2m1x = @(x) feval (M2, x);
     else
-      error ("cgs: preconditioner is expected to be a function or matrix");
+      error ("cgs: preconditioner must be a function or matrix");
     endif
 
     precon = @(x) M2m1x (M1m1x (x));
@@ -147,9 +146,9 @@
       ## Cache.
       q = Ax (p);
       alpha = ro / (p' * q);
-      x = x + alpha * p;
+      x += alpha * p;
 
-      res = res - alpha * q;
+      res -= alpha * q;
       relres = norm (res) / norm_b;
       resvec = [resvec; relres];
 
--- a/scripts/sparse/eigs.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/eigs.m	Thu Dec 10 12:50:06 2015 -0800
@@ -286,53 +286,53 @@
         if (real_valued && symmetric)
           [~, idx] = sort (real (d), "descend");
         else
-          error ('sigma = "la" requires real symmetric problem');
+          error ('eigs: sigma = "la" requires real symmetric problem');
         endif
 
       case "sa"
         if (real_valued && symmetric)
           [~, idx] = sort (real (d), "ascend");
         else
-          error ('sigma = "sa" requires real symmetric problem');
+          error ('eigs: sigma = "sa" requires real symmetric problem');
         endif
 
       case "be"
         if (real_valued && symmetric)
           [~, idx] = sort (real (d), "ascend");
         else
-          error ('sigma = "be" requires real symmetric problem');
+          error ('eigs: sigma = "be" requires real symmetric problem');
         endif
 
       case "lr"
         if (! (real_valued || symmetric))
           [~, idx] = sort (real (d), "descend");
         else
-          error ('sigma = "lr" requires complex or unsymmetric problem');
+          error ('eigs: sigma = "lr" requires complex or unsymmetric problem');
         endif
 
       case "sr"
         if (! (real_valued || symmetric))
           [~, idx] = sort (real (d), "ascend");
         else
-          error ('sigma = "sr" requires complex or unsymmetric problem');
+          error ('eigs: sigma = "sr" requires complex or unsymmetric problem');
         endif
 
       case "li"
         if (! (real_valued || symmetric))
           [~, idx] = sort (imag (d), "descend");
         else
-          error ('sigma = "li" requires complex or unsymmetric problem');
+          error ('eigs: sigma = "li" requires complex or unsymmetric problem');
         endif
 
       case "si"
         if (! (real_valued || symmetric))
           [~, idx] = sort (imag (d), "ascend");
         else
-          error ('sigma = "si" requires complex or unsymmetric problem');
+          error ('eigs: sigma = "si" requires complex or unsymmetric problem');
         endif
 
       otherwise
-        error ("unrecognized value for sigma: %s", sigma);
+        error ("eigs: unrecognized value for sigma: %s", sigma);
     endswitch
   else
     ## numeric sigma, find k closest values
--- a/scripts/sparse/gmres.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/gmres.m	Thu Dec 10 12:50:06 2015 -0800
@@ -179,8 +179,8 @@
       break;
     endif
 
-    restart_it++ ;
-    iter++;
+    restart_it += 1;
+    iter += 1;
   endwhile
 
   if (nargout > 1)
--- a/scripts/sparse/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,41 +1,52 @@
-FCN_FILE_DIRS += sparse
+FCN_FILE_DIRS += \
+  scripts/sparse \
+  scripts/sparse/private
 
-sparse_PRIVATE_FCN_FILES = \
-  sparse/private/__sprand_impl__.m
+scripts_sparse_PRIVATE_FCN_FILES = \
+  scripts/sparse/private/__sprand__.m
 
-sparse_FCN_FILES = \
-  sparse/bicg.m \
-  sparse/bicgstab.m \
-  sparse/cgs.m \
-  sparse/colperm.m \
-  sparse/eigs.m \
-  sparse/etreeplot.m \
-  sparse/gmres.m \
-  sparse/gplot.m \
-  sparse/ichol.m \
-  sparse/ilu.m \
-  sparse/nonzeros.m \
-  sparse/pcg.m \
-  sparse/pcr.m \
-  sparse/qmr.m \
-  sparse/spaugment.m \
-  sparse/spconvert.m \
-  sparse/spdiags.m \
-  sparse/speye.m \
-  sparse/spfun.m \
-  sparse/spones.m \
-  sparse/sprand.m \
-  sparse/sprandn.m \
-  sparse/sprandsym.m \
-  sparse/spstats.m \
-  sparse/spy.m \
-  sparse/svds.m \
-  sparse/treelayout.m \
-  sparse/treeplot.m \
-  $(sparse_PRIVATE_FCN_FILES)
+scripts_sparse_FCN_FILES = \
+  scripts/sparse/bicg.m \
+  scripts/sparse/bicgstab.m \
+  scripts/sparse/cgs.m \
+  scripts/sparse/colperm.m \
+  scripts/sparse/eigs.m \
+  scripts/sparse/etreeplot.m \
+  scripts/sparse/gmres.m \
+  scripts/sparse/gplot.m \
+  scripts/sparse/ichol.m \
+  scripts/sparse/ilu.m \
+  scripts/sparse/nonzeros.m \
+  scripts/sparse/pcg.m \
+  scripts/sparse/pcr.m \
+  scripts/sparse/qmr.m \
+  scripts/sparse/spaugment.m \
+  scripts/sparse/spconvert.m \
+  scripts/sparse/spdiags.m \
+  scripts/sparse/speye.m \
+  scripts/sparse/spfun.m \
+  scripts/sparse/spones.m \
+  scripts/sparse/sprand.m \
+  scripts/sparse/sprandn.m \
+  scripts/sparse/sprandsym.m \
+  scripts/sparse/spstats.m \
+  scripts/sparse/spy.m \
+  scripts/sparse/svds.m \
+  scripts/sparse/treelayout.m \
+  scripts/sparse/treeplot.m
 
-FCN_FILES += $(sparse_FCN_FILES)
+scripts_sparsedir = $(fcnfiledir)/sparse
+
+scripts_sparse_DATA = $(scripts_sparse_FCN_FILES)
+
+scripts_sparse_privatedir = $(fcnfiledir)/sparse/private
+
+scripts_sparse_private_DATA = $(scripts_sparse_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += sparse/PKG_ADD
+FCN_FILES += \
+  $(scripts_sparse_FCN_FILES) \
+  $(scripts_sparse_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += sparse/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/sparse/PKG_ADD
+
+DIRSTAMP_FILES += scripts/sparse/$(octave_dirstamp)
--- a/scripts/sparse/pcg.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/pcg.m	Thu Dec 10 12:50:06 2015 -0800
@@ -319,7 +319,7 @@
       ## fprintf (stderr,"PCG condest: %g (iteration: %d)\n", max (EVS)/min (EVS),iter);
     endif
     resvec(iter,1) = norm (r);
-    iter++;
+    iter += 1;
   endwhile
 
   if (nargout > 5)
@@ -370,12 +370,12 @@
     flag = 1;
     if (nargout < 2)
       warning ("pcg: maximum number of iterations (%d) reached\n", iter);
-      warning ("the initial residual norm was reduced %g times.\n", ...
+      warning ("pcg: the initial residual norm was reduced %g times.\n",
                1.0 / relres);
     endif
   elseif (nargout < 2)
     fprintf (stderr, "pcg: converged in %d iterations. ", iter);
-    fprintf (stderr, "the initial residual norm was reduced %g times.\n",...
+    fprintf (stderr, "pcg: the initial residual norm was reduced %g times.\n",
              1.0/relres);
   endif
 
--- a/scripts/sparse/pcr.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/pcr.m	Thu Dec 10 12:50:06 2015 -0800
@@ -275,7 +275,7 @@
     b_bot_old = b_bot;
 
     resvec(iter) = abs (norm (r));
-    iter++;
+    iter += 1;
   endwhile
 
   flag = 0;
@@ -285,11 +285,12 @@
     flag = 1;
     if (nargout < 2)
       warning ("pcr: maximum number of iterations (%d) reached\n", iter);
-      warning ("the initial residual norm was reduced %g times.\n", 1.0/relres);
+      warning ("pcr: the initial residual norm was reduced %g times\n",
+               1.0/relres);
     endif
   elseif (nargout < 2 && ! breakdown)
     fprintf (stderr, "pcr: converged in %d iterations. \n", iter);
-    fprintf (stderr, "the initial residual norm was reduced %g times.\n",
+    fprintf (stderr, "pcr: the initial residual norm was reduced %g times\n",
              1.0 / relres);
   endif
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/sparse/private/__sprand__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,145 @@
+## Copyright (C) 2004-2015 Paul Kienzle
+## Copyright (C) 2012 Jordi Gutiérrez Hermoso
+##
+## This file is part of Octave.
+##
+## Octave is free software; you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 3 of the License, or (at
+## your option) any later version.
+##
+## Octave is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+##
+## Original version by Paul Kienzle distributed as free software in the
+## public domain.
+
+## -*- texinfo -*-
+## @deftypefn  {Function File} {} __sprand__ (@var{s}, @var{randfun})
+## @deftypefnx {Function File} {} __sprand__ (@var{m}, @var{n}, @var{d}, @var{fcnname}, @var{randfun})
+## @deftypefnx {Function File} {} __sprand__ (@var{m}, @var{n}, @var{d}, @var{rc}, @var{fcnname}, @var{randfun})
+## Undocumented internal function.
+## @end deftypefn
+
+## Actual implementation of sprand and sprandn happens here.
+
+function S = __sprand__ (varargin)
+
+  if (nargin == 2)
+    [m, randfun] = deal (varargin{1:2});
+    [i, j] = find (m);
+    [nr, nc] = size (m);
+    S = sparse (i, j, randfun (size (i)), nr, nc);
+  else
+    if (nargin == 5)
+      [m, n, d, fcnname, randfun] = deal (varargin{:});
+    else
+      [m, n, d, rc, fcnname, randfun] = deal (varargin{:});
+    endif
+
+    if (! (isscalar (m) && m == fix (m) && m > 0))
+      error ("%s: M must be an integer greater than 0", fcnname);
+    endif
+    if (! (isscalar (n) && n == fix (n) && n > 0))
+      error ("%s: N must be an integer greater than 0", fcnname);
+    endif
+    if (d < 0 || d > 1)
+      error ("%s: density D must be between 0 and 1", fcnname);
+    endif
+
+    if (nargin == 5)
+      mn = m*n;
+      k = round (d*mn);
+      if (mn > sizemax ())
+        ## randperm will overflow, so use alternative methods
+
+        idx = unique (fix (rand (1.01*k, 1) * mn)) + 1;
+
+        ## idx contains random numbers in [1,mn]
+        ## Generate 1% more random values than necessary in order to reduce the
+        ## probability that there are less than k distinct values; maybe a
+        ## better strategy could be used but I don't think it's worth the price.
+
+        ## actual number of entries in S
+        k = min (length (idx), k);
+        j = floor ((idx(1:k) - 1) / m);
+        i = idx(1:k) - j * m;
+        j += 1;
+      else
+        idx = randperm (mn, k);
+        [i, j] = ind2sub ([m, n], idx);
+      endif
+
+      S = sparse (i, j, randfun (k, 1), m, n);
+
+    elseif (nargin == 6)
+      ## Create a matrix with specified reciprocal condition number.
+
+      if (! isscalar (rc) && ! isvector (rc))
+        error ("%s: RC must be a scalar or vector", fcnname);
+      endif
+
+      ## We want to reverse singular valued decomposition A=U*S*V'.
+      ## First, first S is constructed and then U = U1*U2*..Un and
+      ## V' = V1*V2*..Vn are seen as Jacobi rotation matrices with angles and
+      ## planes of rotation randomized.  Repeatedly apply rotations until the
+      ## required density for A is achieved.
+
+      if (isscalar (rc))
+        if (rc < 0 || rc > 1)
+          error ("%s: reciprocal condition number RC must be between 0 and 1", fcnname);
+        endif
+        ## Reciprocal condition number is ratio of smallest SV to largest SV
+        ## Generate singular values randomly and sort them to build S
+        ## Random singular values in range [rc, 1].
+        v = rand (1, min (m,n)) * (1 - rc) + rc;
+        v(1) = 1;
+        v(end) = rc;
+        v = sort (v, "descend");
+        S = sparse (diag (v, m, n));
+      else
+        ## Only the min (m, n) greater singular values from rc vector are used.
+        if (length (rc) > min (m,n))
+          rc = rc(1:min(m, n));
+        endif
+        S = sparse (diag (sort (rc, "descend"), m, n));
+      endif
+
+      Uinit = speye (m);
+      Vinit = speye (n);
+      k = round (d*m*n);
+      while (nnz (S) < k)
+        if (m > 1)
+          ## Construct U randomized rotation matrix
+          rot_angleu = 2 * pi * rand ();
+          cu = cos (rot_angleu); su = sin (rot_angleu);
+          rndtmp = randperm (m, 2);
+          i = rndtmp(1); j = rndtmp(2);
+          U = Uinit;
+          U(i, i) = cu; U(i, j) = -su;
+          U(j, i) = su; U(j, j) = cu;
+          S = U * S;
+        endif
+        if (n > 1)
+          ## Construct V' randomized rotation matrix
+          rot_anglev = 2 * pi * rand ();
+          cv = cos (rot_anglev); sv = sin (rot_anglev);
+          rndtmp = randperm (n, 2);
+          i = rndtmp(1); j = rndtmp(2);
+          V = Vinit;
+          V(i, i) = cv;  V(i, j) = sv;
+          V(j, i) = -sv; V(j, j) = cv;
+          S *= V;
+        endif
+      endwhile
+    endif
+  endif
+
+endfunction
+
--- a/scripts/sparse/private/__sprand_impl__.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-## Copyright (C) 2004-2015 Paul Kienzle
-## Copyright (C) 2012 Jordi Gutiérrez Hermoso
-##
-## This file is part of Octave.
-##
-## Octave is free software; you can redistribute it and/or modify it
-## under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 3 of the License, or (at
-## your option) any later version.
-##
-## Octave is distributed in the hope that it will be useful, but
-## WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-## General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with Octave; see the file COPYING.  If not, see
-## <http://www.gnu.org/licenses/>.
-##
-## Original version by Paul Kienzle distributed as free software in the
-## public domain.
-
-## -*- texinfo -*-
-## @deftypefn  {Function File} {} __sprand_impl__ (@var{s}, @var{randfun})
-## @deftypefnx {Function File} {} __sprand_impl__ (@var{m}, @var{n}, @var{d}, @var{fcnname}, @var{randfun})
-## @deftypefnx {Function File} {} __sprand_impl__ (@var{m}, @var{n}, @var{d}, @var{rc}, @var{fcnname}, @var{randfun})
-## Undocumented internal function.
-## @end deftypefn
-
-## Actual implementation of sprand and sprandn happens here.
-
-function S = __sprand_impl__ (varargin)
-
-  if (nargin == 2)
-    [m, randfun] = deal (varargin{1:2});
-    [i, j] = find (m);
-    [nr, nc] = size (m);
-    S = sparse (i, j, randfun (size (i)), nr, nc);
-  else
-    if (nargin == 5)
-      [m, n, d, fcnname, randfun] = deal (varargin{:});
-    else
-      [m, n, d, rc, fcnname, randfun] = deal (varargin{:});
-    endif
-
-    if (! (isscalar (m) && m == fix (m) && m > 0))
-      error ("%s: M must be an integer greater than 0", fcnname);
-    endif
-    if (! (isscalar (n) && n == fix (n) && n > 0))
-      error ("%s: N must be an integer greater than 0", fcnname);
-    endif
-    if (d < 0 || d > 1)
-      error ("%s: density D must be between 0 and 1", fcnname);
-    endif
-
-    if (nargin == 5)
-      mn = m*n;
-      k = round (d*mn);
-      if (mn > sizemax ())
-        ## randperm will overflow, so use alternative methods
-
-        idx = unique (fix (rand (1.01*k, 1) * mn)) + 1;
-
-        ## idx contains random numbers in [1,mn]
-        ## Generate 1% more random values than necessary in order to reduce the
-        ## probability that there are less than k distinct values; maybe a
-        ## better strategy could be used but I don't think it's worth the price.
-
-        ## actual number of entries in S
-        k = min (length (idx), k);
-        j = floor ((idx(1:k) - 1) / m);
-        i = idx(1:k) - j * m;
-        j++;
-      else
-        idx = randperm (mn, k);
-        [i, j] = ind2sub ([m, n], idx);
-      endif
-
-      S = sparse (i, j, randfun (k, 1), m, n);
-
-    elseif (nargin == 6)
-      ## Create a matrix with specified reciprocal condition number.
-
-      if (! isscalar (rc) && ! isvector (rc))
-        error ("%s: RC must be a scalar or vector", fcnname);
-      endif
-
-      ## We want to reverse singular valued decomposition A=U*S*V'.
-      ## First, first S is constructed and then U = U1*U2*..Un and
-      ## V' = V1*V2*..Vn are seen as Jacobi rotation matrices with angles and
-      ## planes of rotation randomized.  Repeatedly apply rotations until the
-      ## required density for A is achieved.
-
-      if (isscalar (rc))
-        if (rc < 0 || rc > 1)
-          error ("%s: reciprocal condition number RC must be between 0 and 1", fcnname);
-        endif
-        ## Reciprocal condition number is ratio of smallest SV to largest SV
-        ## Generate singular values randomly and sort them to build S
-        ## Random singular values in range [rc, 1].
-        v = rand (1, min (m,n)) * (1 - rc) + rc;
-        v(1) = 1;
-        v(end) = rc;
-        v = sort (v, "descend");
-        S = sparse (diag (v, m, n));
-      else
-        ## Only the min (m, n) greater singular values from rc vector are used.
-        if (length (rc) > min (m,n))
-          rc = rc(1:min(m, n));
-        endif
-        S = sparse (diag (sort (rc, "descend"), m, n));
-      endif
-
-      Uinit = speye (m);
-      Vinit = speye (n);
-      k = round (d*m*n);
-      while (nnz (S) < k)
-        if (m > 1)
-          ## Construct U randomized rotation matrix
-          rot_angleu = 2 * pi * rand ();
-          cu = cos (rot_angleu); su = sin (rot_angleu);
-          rndtmp = randperm (m, 2);
-          i = rndtmp(1); j = rndtmp(2);
-          U = Uinit;
-          U(i, i) = cu; U(i, j) = -su;
-          U(j, i) = su; U(j, j) = cu;
-          S = U * S;
-        endif
-        if (n > 1)
-          ## Construct V' randomized rotation matrix
-          rot_anglev = 2 * pi * rand ();
-          cv = cos (rot_anglev); sv = sin (rot_anglev);
-          rndtmp = randperm (n, 2);
-          i = rndtmp(1); j = rndtmp(2);
-          V = Vinit;
-          V(i, i) = cv;  V(i, j) = sv;
-          V(j, i) = -sv; V(j, j) = cv;
-          S = S * V;
-        endif
-      endwhile
-    endif
-  endif
-
-endfunction
-
--- a/scripts/sparse/qmr.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/qmr.m	Thu Dec 10 12:50:06 2015 -0800
@@ -101,8 +101,7 @@
       Ax  = @(x) A  * x;
       Atx = @(x) A' * x;
     else
-      error (["qmr: first argument is expected to " ...
-                "be a function or a square matrix"]);
+      error ("qmr: A must be a square matrix or function");
     endif
 
     if (nargin < 3 || isempty (tol))
@@ -129,8 +128,7 @@
       M1m1x  = @(x) M1  \ x;
       M1tm1x = @(x) M1' \ x;
     else
-      error (["qmr: preconditioner is expected to " ...
-                "be a function or matrix"]);
+      error ("qmr: preconditioner must be a function or matrix");
     endif
 
     if (nargin < 6 || isempty (M2))
@@ -147,8 +145,7 @@
       M2m1x  = @(x) M2  \ x;
       M2tm1x = @(x) M2' \ x;
     else
-      error (["qmr: preconditioner is expected to " ...
-                "be a function or matrix"]);
+      error ("qmr: preconditioner must be a function or matrix");
     endif
 
 
@@ -181,9 +178,9 @@
     for iter=1:1:maxit
       ## If rho0 == 0 or xi1 == 0, method fails.
       v = vt / rho0;
-      y = y / rho0;
+      y /= rho0;
       w = wt / xi1;
-      z = z / xi1;
+      z /= xi1;
 
       delta1 = z' * y;   # If delta1 == 0, method fails.
 
--- a/scripts/sparse/spaugment.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/spaugment.m	Thu Dec 10 12:50:06 2015 -0800
@@ -80,7 +80,7 @@
       c = max (max (abs (A))) / 1000;
     else
       if (ndims (A) != 2)
-        error ("spaugment: expecting 2-dimenisional matrix");
+        error ("spaugment: A must be a 2-D matrix");
       else
         c = max (abs (A(:))) / 1000;
       endif
--- a/scripts/sparse/sprand.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/sprand.m	Thu Dec 10 12:50:06 2015 -0800
@@ -53,11 +53,11 @@
 function s = sprand (m, n, d, rc)
 
   if (nargin == 1 )
-    s = __sprand_impl__ (m, @rand);
+    s = __sprand__ (m, @rand);
   elseif ( nargin == 3)
-    s = __sprand_impl__ (m, n, d, "sprand", @rand);
+    s = __sprand__ (m, n, d, "sprand", @rand);
   elseif (nargin == 4)
-    s = __sprand_impl__ (m, n, d, rc, "sprand", @rand);
+    s = __sprand__ (m, n, d, rc, "sprand", @rand);
   else
     print_usage ();
   endif
--- a/scripts/sparse/sprandn.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/sprandn.m	Thu Dec 10 12:50:06 2015 -0800
@@ -45,11 +45,11 @@
 function s = sprandn (m, n, d, rc)
 
   if (nargin == 1 )
-    s = __sprand_impl__ (m, @randn);
+    s = __sprand__ (m, @randn);
   elseif ( nargin == 3)
-    s = __sprand_impl__ (m, n, d, "sprandn", @randn);
+    s = __sprand__ (m, n, d, "sprandn", @randn);
   elseif (nargin == 4)
-    s = __sprand_impl__ (m, n, d, rc, "sprandn", @randn);
+    s = __sprand__ (m, n, d, rc, "sprandn", @randn);
   else
     print_usage ();
   endif
--- a/scripts/sparse/sprandsym.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/sprandsym.m	Thu Dec 10 12:50:06 2015 -0800
@@ -41,7 +41,7 @@
     [i, j] = find (tril (n));
     [nr, nc] = size (n);
     S = sparse (i, j, randn (size (i)), nr, nc);
-    S = S + tril (S, -1)';
+    S += tril (S, -1)';
     return;
   endif
 
@@ -134,7 +134,7 @@
   ## order to avoid overflow (underflow is fine, just means effectively
   ## zero probabilities).
   [~, midx] = max (cumsum (log (q))) ;
-  midx++;
+  midx += 1;
   lc = fliplr (cumprod (1./q(midx-1:-1:1)));
   rc = cumprod (q(midx:end));
 
--- a/scripts/sparse/svds.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/svds.m	Thu Dec 10 12:50:06 2015 -0800
@@ -162,7 +162,7 @@
     b_opts.issym = true;
     b_sigma = sigma;
     if (! ischar (b_sigma))
-      b_sigma = b_sigma / max_a;
+      b_sigma /= max_a;
     endif
 
     if (b_sigma == 0)
@@ -219,13 +219,13 @@
     s = s(ind);
 
     if (length (s) < k)
-      warning ("returning fewer singular values than requested");
+      warning ("svds: returning fewer singular values than requested");
       if (! ischar (sigma))
-        warning ("try increasing the value of sigma");
+        warning ("svds: try increasing the value of sigma");
       endif
     endif
 
-    s = s * max_a;
+    s *= max_a;
   endif
 
   if (nargout < 2)
--- a/scripts/sparse/treelayout.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/treelayout.m	Thu Dec 10 12:50:06 2015 -0800
@@ -144,14 +144,14 @@
       ## We are in top level separator when we have one child and the
       ## flag is 1
       if (columns (idx) == 1 && top_level == 1)
-        s++;
+        s += 1;
       else
         ## We aren't in top level separator now.
         top_level = 0;
       endif
       ## If there is not any descendant of "parent node":
       if (stk(end,2) != par_number)
-       left_most++;
+       left_most += 1;
        x_coordinate_r(par_number) = left_most;
        max_ht = min (max_ht, level);
        if (length (stk) > 1 && find ((shift (stk,1) - stk) == 0) > 1
@@ -189,7 +189,7 @@
 
         ## There were descendants of "parent nod" choose the last of
         ## them and go on through it.
-        level--;
+        level -= 1;
         par_number = stk(end,1);
         y_coordinate(par_number) = level;
         x_coordinate_l(par_number) = left_most + 1;
--- a/scripts/sparse/treeplot.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/sparse/treeplot.m	Thu Dec 10 12:50:06 2015 -0800
@@ -118,7 +118,7 @@
 
     ## If there is not any descendant of "parent node":
     if (stk(end,2) != par_number)
-      left_most++;
+      left_most += 1;
       x_coordinate_r(par_number) = left_most;
       max_ht = min (max_ht, level);
       if (length (stk) > 1 && find ((shift (stk,1) - stk) == 0) > 1
@@ -150,7 +150,7 @@
     else
       ## There were descendants of "parent nod" choose the last of
       ## them and go on through it.
-      level--;
+      level -= 1;
       par_number = stk(end,1);
       y_coordinate(par_number) = level;
       x_coordinate_l(par_number) = left_most + 1;
--- a/scripts/specfun/factor.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/specfun/factor.m	Thu Dec 10 12:50:06 2015 -0800
@@ -29,7 +29,7 @@
 ## their multiplicities.  That is, @code{prod (@var{pf} .^ @var{n}) == @var{q}}.
 ##
 ## Implementation Note: The input @var{q} must be less than
-## @code{bitmax} (9.0072e+15) in order to factor correctly.
+## @code{flintmax} (9.0072e+15) in order to factor correctly.
 ## @seealso{gcd, lcm, isprime, primes}
 ## @end deftypefn
 
@@ -82,7 +82,7 @@
   q = prod (pf);
   if (q != qorig)
     error ("factor: Q too large to factor");
-  elseif (q > bitmax)
+  elseif (q >= flintmax ())
     warning ("factor: Q too large.  Answer is unreliable");
   endif
 
--- a/scripts/specfun/legendre.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/specfun/legendre.m	Thu Dec 10 12:50:06 2015 -0800
@@ -192,7 +192,7 @@
       error ('legendre: NORMALIZATION option must be "unnorm", "norm", or "sch"');
   endswitch
 
-  scale = scale * ones (size (x));
+  scale *= ones (size (x));
 
   ## Based on the recurrence relation below
   ##            m                 m              m
--- a/scripts/specfun/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/specfun/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,27 +1,31 @@
-FCN_FILE_DIRS += specfun
+FCN_FILE_DIRS += scripts/specfun
 
-specfun_FCN_FILES = \
-  specfun/bessel.m \
-  specfun/beta.m \
-  specfun/betaln.m \
-  specfun/ellipke.m \
-  specfun/expint.m \
-  specfun/factor.m \
-  specfun/factorial.m \
-  specfun/isprime.m \
-  specfun/lcm.m \
-  specfun/legendre.m \
-  specfun/nchoosek.m \
-  specfun/nthroot.m \
-  specfun/perms.m \
-  specfun/pow2.m \
-  specfun/primes.m \
-  specfun/reallog.m \
-  specfun/realpow.m \
-  specfun/realsqrt.m
+scripts_specfun_FCN_FILES = \
+  scripts/specfun/bessel.m \
+  scripts/specfun/beta.m \
+  scripts/specfun/betaln.m \
+  scripts/specfun/ellipke.m \
+  scripts/specfun/expint.m \
+  scripts/specfun/factor.m \
+  scripts/specfun/factorial.m \
+  scripts/specfun/isprime.m \
+  scripts/specfun/lcm.m \
+  scripts/specfun/legendre.m \
+  scripts/specfun/nchoosek.m \
+  scripts/specfun/nthroot.m \
+  scripts/specfun/perms.m \
+  scripts/specfun/pow2.m \
+  scripts/specfun/primes.m \
+  scripts/specfun/reallog.m \
+  scripts/specfun/realpow.m \
+  scripts/specfun/realsqrt.m
 
-FCN_FILES += $(specfun_FCN_FILES)
+scripts_specfundir = $(fcnfiledir)/specfun
+
+scripts_specfun_DATA = $(scripts_specfun_FCN_FILES)
 
-PKG_ADD_FILES += specfun/PKG_ADD
+FCN_FILES += $(scripts_specfun_FCN_FILES)
 
-DIRSTAMP_FILES += specfun/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/specfun/PKG_ADD
+
+DIRSTAMP_FILES += scripts/specfun/$(octave_dirstamp)
--- a/scripts/special-matrix/gallery.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/special-matrix/gallery.m	Thu Dec 10 12:50:06 2015 -0800
@@ -592,10 +592,10 @@
     case (0), # do nothing
     case (1), n = n + 1;
     otherwise
-      error ("gallery: unknown K '%d' for chebspec matrix.", k);
+      error ("gallery: K should be either 0 or 1 for chebspec matrix.");
   endswitch
 
-  n = n-1;
+  n -= 1;
   C = zeros (n+1);
 
   one    = ones (n+1, 1);
@@ -773,7 +773,7 @@
     error ("gallery: K must be a numeric scalar for clement matrix.");
   endif
 
-  n = n-1;
+  n -= 1;
   x = n:-1:1;
   z = 1:n;
 
@@ -911,7 +911,7 @@
   endif
 endfunction
 
-function A = cycol (n, k)
+function A = cycol (n, k = max (round (n(end)/4), 1))
   ## CYCOL   Matrix whose columns repeat cyclically.
   ##   A = CYCOL([M N], K) is an M-by-N matrix of the form A = B(1:M,1:N)
   ##   where B = [C C C...] and C = RANDN(M, K).  Thus A's columns repeat
@@ -934,10 +934,6 @@
   m = n(1);
   n = n(end);
 
-  if (nargin < 2)
-    k = max (round (n/4), 1);
-  endif
-
   A = randn (m, k);
   for i = 2:ceil (n/k)
     A = [A A(:,1:k)];
@@ -1215,9 +1211,9 @@
     error ("gallery: 1 to 3 arguments are required for gearmat matrix.");
   elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n)
     error ("gallery: N must be an integer for gearmat matrix.");
-  elseif (! isnumeric (i) || ! isscalar (i) || i == 0 || abs (i) <= n)
+  elseif (! isnumeric (i) || ! isscalar (i) || i == 0 || abs (i) > n)
     error ("gallery: I must be a nonzero scalar, and abs (I) <= N for gearmat matrix.");
-  elseif (! isnumeric (j) || ! isscalar (j) || i == 0 || abs (j) <= n)
+  elseif (! isnumeric (j) || ! isscalar (j) || i == 0 || abs (j) > n)
     error ("gallery: J must be a nonzero scalar, and abs (J) <= N for gearmat matrix.");
   endif
 
@@ -1271,7 +1267,7 @@
     error ("gallery: N must be an integer for hanowa matrix.");
   elseif (rem (n, 2) != 0)
     error ("gallery: N must be even for hanowa matrix.");
-  elseif (! isnumeric (lambda) || ! isscalar (lambda))
+  elseif (! isnumeric (d) || ! isscalar (d))
     error ("gallery: D must be a numeric scalar for hanowa matrix.");
   endif
 
@@ -1307,7 +1303,7 @@
 
   if (nargin != 1)
     error ("gallery: 1 argument is required for house matrix.");
-  elseif (! isnumeric (x) || ! isvector (x) || numel (x) <= 1)
+  elseif (! isnumeric (x) || ! isvector (x))
     error ("gallery: X must be a vector for house matrix.");
   endif
 
@@ -1402,7 +1398,7 @@
     n = x;
     x = 1:n;
   elseif (! isscalar (x) && isvector (x))
-    n = numel (n);
+    n = numel (x);
   else
     error ("gallery: X must be an integer scalar, or a vector for invhess matrix.");
   endif
@@ -1493,13 +1489,13 @@
 
     if (k == 0)
       for i = 1:n-1
-        d = d * prod (1:i+1) * prod (1:n-i);
+        d *= prod (1:i+1) * prod (1:n-i);
       endfor
-      d = d * prod (1:n+1);
+      d *= prod (1:n+1);
 
     elseif (k == 1)
       for i = 0:n-1
-        d = d * prod (1:i) / prod (1:n+1+i);
+        d *= prod (1:i) / prod (1:n+1+i);
       endfor
       if (rem (n*(n-1)/2, 2))
         d = -d;
@@ -1605,8 +1601,8 @@
     error ("gallery: 1 to 2 arguments are required for lauchli matrix.");
   elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n)
     error ("gallery: N must be an integer for lauchli matrix.")
-  elseif (! isscalar (mu))
-    error ("gallery: MU must be a scalar for lauchli matrix.")
+  elseif (! isscalar (rho))
+    error ("gallery: RHO must be a scalar for lauchli matrix.")
   endif
 
   A = (1:n)'*ones (1,n);
@@ -2015,7 +2011,7 @@
     error ("gallery: 1 to 2 arguments are required for pei matrix.");
   elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n)
     error ("gallery: N must be an integer for pei matrix.");
-  elseif (! isnumeric (w) || ! isscalar (w))
+  elseif (! isnumeric (alpha) || ! isscalar (alpha))
     error ("gallery: ALPHA must be a scalar for pei matrix.");
   endif
 
@@ -2154,7 +2150,8 @@
 
 endfunction
 
-function A = randsvd (n, kappa = sqrt (1/eps), mode = 3, kl = n-1, ku = kl)
+function A = randsvd (n, kappa = sqrt (1/eps), mode = 3, kl = max (n) -1,
+                      ku = kl)
   ## RANDSVD  Random matrix with pre-assigned singular values.
   ##   RANDSVD(N, KAPPA, MODE, KL, KU) is a (banded) random matrix of order N
   ##   with COND(A) = KAPPA and singular values from the distribution MODE.
@@ -2218,7 +2215,7 @@
   ## If A will be a vector
   if (p == 1)
     A = randn (m, n);
-    A = A / norm (A);
+    A /= norm (A);
     return;
   endif
 
@@ -2339,7 +2336,7 @@
     error ("gallery: N must be an integer for riemann matrix.");
   endif
 
-  n = n+1;
+  n += 1;
   i = (2:n)' * ones (1, n-1);
   j = i';
   A = i .* (! rem (j, i)) - ones (n-1);
@@ -2435,7 +2432,7 @@
   E = 2*pi * ((1:n)' * ones (1, n) - ones (n, 1) * (1:n));
 
   for i = 1:m
-    T = T + w(i) * cos (theta(i)*E);
+    T += w(i) * cos (theta(i)*E);
   endfor
 endfunction
 
@@ -2855,6 +2852,53 @@
   endif
 endfunction
 
+## NOTE: qmult is part of the Test Matrix Toolbox and is used by randsvd()
+function B = qmult (A)
+  ## QMULT  Pre-multiply by random orthogonal matrix.
+  ##   QMULT(A) is Q*A where Q is a random real orthogonal matrix from
+  ##   the Haar distribution, of dimension the number of rows in A.
+  ##   Special case: if A is a scalar then QMULT(A) is the same as
+  ##   QMULT(EYE(A)).
+  ##
+  ##   Called by RANDSVD.
+  ##
+  ## Reference:
+  ##   G.W. Stewart, The efficient generation of random
+  ##   orthogonal matrices with an application to condition estimators,
+  ##   SIAM J. Numer. Anal., 17 (1980), 403-409.
+
+  [n, m] = size (A);
+
+  ##  Handle scalar A
+  if (isscalar (A))
+    n = A;
+    A = eye (n);
+  endif
+
+  d = zeros (n);
+
+  for k = n-1:-1:1
+    ## Generate random Householder transformation.
+    x = randn (n-k+1, 1);
+    s = norm (x);
+    sgn = sign (x(1)) + (x(1) == 0); # Modification for sign(1)=1.
+    s = sgn*s;
+    d(k) = -sgn;
+    x(1) = x(1) + s;
+    beta = s*x(1);
+
+    ## Apply the transformation to A.
+    y = x'*A(k:n,:);
+    A(k:n,:) = A(k:n,:) - x*(y/beta);
+  endfor
+
+  ## Tidy up signs
+  for i = 1:n-1
+    A(i,:) = d(i)*A(i,:);
+  endfor
+  A(n,:) = A(n,:) * sign (randn);
+  B = A;
+endfunction
 
 ## BIST testing for just a few functions to verify that the main gallery
 ## dispatch function works.
@@ -2871,3 +2915,167 @@
 %!assert (gallery ("minij", 1), 1)
 %!assert (gallery ("minij", 0), [])
 %!assert (gallery ("minij", -1), [])
+
+%!assert (size (gallery ("cauchy", 5)), [5 5])
+%!assert (size (gallery ("cauchy", 2:5, 5:8)), [4 4])
+
+%!assert (size (gallery ("chebspec", 5)), [5 5])
+%!assert (size (gallery ("chebspec", 5, 1)), [5 5])
+%!assert (size (gallery ("chebspec", 5, 0)), [5 5])
+
+%!assert (size (gallery ("chebvand", 7)), [7 7])
+%!assert (size (gallery ("chebvand", 1:7)), [7 7])
+%!assert (size (gallery ("chebvand", 5, 7)), [5 7])
+
+%!assert (size (gallery ("chow", 5)), [5 5])
+%!assert (size (gallery ("chow", 5, 6)), [5 5])
+%!assert (size (gallery ("chow", 5, 6, 7)), [5 5])
+
+%!assert (gallery ("circul", 3), [1 2 3; 3 1 2; 2 3 1])
+%!assert (gallery ("circul", [1 3 6]), [1 3 6; 6 1 3; 3 6 1])
+
+%!assert (size (gallery ("clement", 5)), [5 5])
+%!assert (size (gallery ("clement", 5, 1)), [5 5])
+%!assert (size (gallery ("clement", 5, 0)), [5 5])
+
+%!assert (size (gallery ("compar", ones (5))), [5 5])
+%!assert (size (gallery ("compar", ones (5), 0)), [5 5])
+%!assert (size (gallery ("compar", ones (5), 1)), [5 5])
+
+%!assert (size (gallery ("condex", 4)), [4 4])
+%!assert (size (gallery ("condex", 4, 1)), [4 4])
+%!assert (size (gallery ("condex", 4, 1, 50)), [4 4])
+
+%!assert (size (gallery ("cycol", [4 5])), [4 5])
+%!assert (size (gallery ("cycol", [4 5], 1)), [4 5])
+%!assert (size (gallery ("cycol", 4)), [4 4])
+%!assert (size (gallery ("cycol", 4, 1)), [4 4])
+
+%!assert (size (gallery ("dorr", 4)), [4 4])
+%!assert (cellfun (@rows, nthargout (1:3, @gallery, "dorr", 4)), [3 4 3])
+
+%!assert (size (gallery ("dramadah", 5)), [5 5])
+%!assert (size (gallery ("dramadah", 5, 2)), [5 5])
+
+%!assert (size (gallery ("fiedler", 5)), [5 5])
+%!assert (size (gallery ("fiedler", 2:5)), [4 4])
+
+%!assert (size (gallery ("forsythe", 5)), [5 5])
+%!assert (size (gallery ("forsythe", 5, 1, 0.5)), [5 5])
+%!assert (size (gallery ("forsythe", 5, 4, 7)), [5 5])
+
+%!assert (size (gallery ("frank", 5)), [5 5])
+%!assert (size (gallery ("frank", 5, 1)), [5 5])
+
+%!assert (size (gallery ("gcdmat", 5)), [5 5])
+
+%!assert (size (gallery ("gearmat", 5)), [5 5])
+%!assert (size (gallery ("gearmat", 5, 4)), [5 5])
+%!assert (size (gallery ("gearmat", 5, 4, 3)), [5 5])
+
+%!assert (size (gallery ("grcar", 5)), [5 5])
+%!assert (size (gallery ("grcar", 5, 2)), [5 5])
+
+%!error <N must be even> gallery ("hanowa", 5)
+%!assert (size (gallery ("hanowa", 6, 5)), [6 6])
+%!assert (size (gallery ("hanowa", 6, 5)), [6 6])
+
+%!assert (size (gallery ("house", [1:5]')), [5 1])
+%!assert (cellfun (@rows, nthargout (1:2, @gallery, "house", [1:5]')), [5 1])
+
+%!assert (size (gallery ("integerdata", 5, [3 2], 5)), [3 2])
+%!assert (size (gallery ("integerdata", 5, [3 2 6], 5)), [3 2 6])
+
+%!assert (size (gallery ("invhess", 1:4, 1:3)), [4 4])
+
+%!assert (size (gallery ("invol", 4)), [4 4])
+
+%!assert (size (gallery ("ipjfact", 4)), [4 4])
+%!assert (size (gallery ("ipjfact", 4, 0)), [4 4])
+%!assert (size (gallery ("ipjfact", 4, 1)), [4 4])
+
+%!assert (size (gallery ("jordbloc", 4)), [4 4])
+%!assert (size (gallery ("jordbloc", 4, 1)), [4 4])
+%!assert (size (gallery ("jordbloc", 4, 3)), [4 4])
+
+%!assert (size (gallery ("kahan", 4)), [4 4])
+%!assert (size (gallery ("kahan", [4 5])), [4 5])
+%!assert (size (gallery ("kahan", [4 5], 1)), [4 5])
+%!assert (size (gallery ("kahan", [4 5], 1, 30)), [4 5])
+
+%!assert (size (gallery ("kms", 5)), [5 5])
+%!assert (size (gallery ("kms", 5, 0.2)), [5 5])
+
+%!assert (size (gallery ("krylov", 4)), [4 4])
+%!assert (size (gallery ("krylov", ones (4)), [4 4]))
+%!assert (size (gallery ("krylov", ones (4), [.2 .3 .4 .5], 3), [4 4]))
+
+%!assert (size (gallery ("lauchli", 5)), [6 5])
+%!assert (size (gallery ("lauchli", 5, 3)), [6 5])
+
+%!assert (size (gallery ("lehmer", 5)), [5 5])
+
+%!assert (size (gallery ("lesp", 5)), [5 5])
+
+%!assert (size (gallery ("lotkin", 5)), [5 5])
+
+%!assert (size (gallery ("minij", 5)), [5 5])
+
+%!assert (size (gallery ("moler", 5)), [5 5])
+%!assert (size (gallery ("moler", 5, 0.2)), [5 5])
+
+%!assert (size (gallery ("neumann", 4)), [4 4])
+
+%!assert (size (gallery ("normaldata", [5 4 6], 3)), [5 4 6])
+
+%!assert (size (gallery ("orthog", 5)), [5 5])
+%!assert (size (gallery ("orthog", 5, 2)), [5 5])
+%!assert (size (gallery ("orthog", 5, -2)), [5 5])
+
+%!assert (size (gallery ("parter", 5)), [5 5])
+
+%!assert (size (gallery ("pei", 5)), [5 5])
+%!assert (size (gallery ("pei", 5, 4)), [5 5])
+
+%!assert (size (gallery ("poisson", 1)), [1 1])
+%!assert (size (gallery ("poisson", 4)), [16 16])
+%!assert (size (gallery ("poisson", 5)), [25 25])
+
+%!assert (size (gallery ("prolate", 5)), [5 5])
+%!assert (size (gallery ("prolate", 5, 0.5)), [5 5])
+
+%!assert (size (gallery ("randhess", 5)), [5 5])
+%!assert (size (gallery ("randhess", 2:5)), [4 4])
+
+%!assert (size (gallery ("rando", 5)), [5 5])
+%!assert (size (gallery ("rando", 5, 2)), [5 5])
+
+%!assert (size (gallery ("randsvd", 5)), [5 5])
+%!assert (size (gallery ("randsvd", [5 3])), [5 3])
+
+%!assert (size (gallery ("redheff", 5)), [5 5])
+%!assert (size (gallery ("riemann", 5)), [5 5])
+%!assert (size (gallery ("ris", 5)), [5 5])
+
+%!assert (size (gallery ("smoke", 5)), [5 5])
+%!assert (size (gallery ("smoke", 5, 1)), [5 5])
+%!assert (gallery ("smoke", 5, 1)(5, 1), 0)
+
+%!assert (size (gallery ("toeppd", 5)), [5 5])
+
+%!assert (size (gallery ("toeppen", 5)), [5 5])
+
+%!assert (size (gallery ("tridiag", 5)), [5 5])
+%!assert (size (gallery ("tridiag", 1:4, 1:5, 1:4)), [5 5])
+%!assert (gallery ("tridiag", 5), gallery ("tridiag", 5, -1, 2, -1))
+
+%!assert (size (gallery ("triw", 5)), [5 5])
+
+%!assert (size (gallery ("uniformdata", [5 3 4], 3)), [5 3 4])
+
+%!assert (size (gallery ("wathen", 2, 3)), [29 29])
+
+%!assert (cellfun (@rows, nthargout (1:2, @gallery, "wilk", 3)), [3 3])
+%!assert (cellfun (@rows, nthargout (1:2, @gallery, "wilk", 4)), [4 4])
+%!assert (size (gallery ("wilk", 5)), [5 5])
+%!assert (size (gallery ("wilk", 21)), [21 21])
--- a/scripts/special-matrix/hadamard.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/special-matrix/hadamard.m	Thu Dec 10 12:50:06 2015 -0800
@@ -68,7 +68,7 @@
   ## Find k if n = 2^k*p.
   k = 0;
   while (n > 1 && fix (n/2) == n/2)
-    k++;
+    k += 1;
     n /= 2;
   endwhile
 
--- a/scripts/special-matrix/hilb.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/special-matrix/hilb.m	Thu Dec 10 12:50:06 2015 -0800
@@ -65,7 +65,7 @@
   tmp = 1:n;
   for i = 1:n
     retval(i, :) = 1.0 ./ tmp;
-    tmp++;
+    tmp += 1;
   endfor
 
 endfunction
--- a/scripts/special-matrix/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/special-matrix/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,20 +1,24 @@
-FCN_FILE_DIRS += special-matrix
+FCN_FILE_DIRS += scripts/special-matrix
 
-special_matrix_FCN_FILES = \
-  special-matrix/gallery.m \
-  special-matrix/hadamard.m \
-  special-matrix/hankel.m \
-  special-matrix/hilb.m \
-  special-matrix/invhilb.m \
-  special-matrix/magic.m \
-  special-matrix/pascal.m \
-  special-matrix/rosser.m \
-  special-matrix/toeplitz.m \
-  special-matrix/vander.m \
-  special-matrix/wilkinson.m
+scripts_special_matrix_FCN_FILES = \
+  scripts/special-matrix/gallery.m \
+  scripts/special-matrix/hadamard.m \
+  scripts/special-matrix/hankel.m \
+  scripts/special-matrix/hilb.m \
+  scripts/special-matrix/invhilb.m \
+  scripts/special-matrix/magic.m \
+  scripts/special-matrix/pascal.m \
+  scripts/special-matrix/rosser.m \
+  scripts/special-matrix/toeplitz.m \
+  scripts/special-matrix/vander.m \
+  scripts/special-matrix/wilkinson.m
 
-FCN_FILES += $(special_matrix_FCN_FILES)
+scripts_special_matrixdir = $(fcnfiledir)/special-matrix
+
+scripts_special_matrix_DATA = $(scripts_special_matrix_FCN_FILES)
 
-PKG_ADD_FILES += special-matrix/PKG_ADD
+FCN_FILES += $(scripts_special_matrix_FCN_FILES)
 
-DIRSTAMP_FILES += special-matrix/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/special-matrix/PKG_ADD
+
+DIRSTAMP_FILES += scripts/special-matrix/$(octave_dirstamp)
--- a/scripts/special-matrix/pascal.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/special-matrix/pascal.m	Thu Dec 10 12:50:06 2015 -0800
@@ -49,7 +49,7 @@
   elseif (! (isscalar (n) && isscalar (t)))
     error ("pascal: N and T must be scalars");
   elseif (! any (t == [-1, 0, 1, 2]))
-    error ("pascal: expecting T to be -1, 0, 1, or 2, found %d", t);
+    error ("pascal: T must be -1, 0, 1, or 2, found %d", t);
   endif
 
   retval = zeros (n);
@@ -91,6 +91,6 @@
 %!error pascal (1,2,3)
 %!error <N and T must be scalars> pascal ([1 2])
 %!error <N and T must be scalars> pascal (1, [1 2])
-%!error <expecting T to be> pascal (3,-2)
-%!error <expecting T to be> pascal (3,4)
+%!error <T must be -1> pascal (3,-2)
+%!error <T must be .* or 2> pascal (3,4)
 
--- a/scripts/startup/local-rcfile	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-## System-wide startup file for Octave.
-##
-## This file should contain any commands that should be executed each
-## time Octave starts for every user at this site.
--- a/scripts/startup/main-rcfile	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-## System-wide startup file for Octave.
-##
-## This file should contain any commands that should be executed each
-## time Octave starts for every user at this site.
-
-## Configure readline using the file inputrc in the Octave startup
-## directory.
-
-readline_read_init_file (sprintf ("%s%s%s",
-                                  octave_config_info ("startupfiledir"),
-                                  filesep, "inputrc"));
-
-if (strcmp (PAGER (), "less") && isempty (getenv ("LESS")))
-  PAGER_FLAGS ('-e -X -P"-- less ?pB(%pB\\%):--. (f)orward, (b)ack, (q)uit$"');
-endif
-
-## This appears here instead of in the pkg/PKG_ADD file so that --norc
-## will also skip automatic loading of packages.
-
-pkg ("load", "auto");
-
-atexit ("__finish__");
--- a/scripts/startup/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/startup/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,25 +1,54 @@
-FCN_FILE_DIRS += startup
+FCN_FILE_DIRS += scripts/startup
 
-startup_FCN_FILES = \
-  startup/__finish__.m
+scripts_startup_FCN_FILES = \
+  scripts/startup/__finish__.m
 
-LOCAL_STARTUP_FILE_SRC  = startup/local-rcfile
+SITE_STARTUP_FILE_SRC  = scripts/startup/site-rcfile
 
-SYSTEM_STARTUP_FILE_SRC = startup/main-rcfile
+VERSION_STARTUP_FILE_SRC = scripts/startup/version-rcfile
 
-SYSTEM_INPUTRC_FILE_SRC = startup/inputrc
+SYSTEM_INPUTRC_FILE_SRC = scripts/startup/inputrc
 
 STARTUP_FILE_SRC = \
-  $(LOCAL_STARTUP_FILE_SRC) \
-  $(SYSTEM_STARTUP_FILE_SRC) \
+  $(SITE_STARTUP_FILE_SRC) \
+  $(VERSION_STARTUP_FILE_SRC) \
   $(SYSTEM_INPUTRC_FILE_SRC)
 
-FCN_FILES += \
-  $(startup_FCN_FILES)
+scripts_startupdir = $(fcnfiledir)/startup
+
+scripts_startup_DATA = $(scripts_startup_FCN_FILES)
+
+FCN_FILES += $(scripts_startup_FCN_FILES)
+
+PKG_ADD_FILES += scripts/startup/PKG_ADD
+
+DIRSTAMP_FILES += scripts/startup/$(octave_dirstamp)
+
+scripts_EXTRA_DIST += $(STARTUP_FILE_SRC)
 
-EXTRA_DIST += \
-  $(STARTUP_FILE_SRC)
+install-startup-files:
+	$(MKDIR_P) $(DESTDIR)$(fcnfiledir)/startup
+	if test -f $(DESTDIR)$(fcnfiledir)/startup/octaverc; then true; \
+	else \
+	  $(INSTALL_DATA) $(srcdir)/$(VERSION_STARTUP_FILE_SRC) \
+	    $(DESTDIR)$(fcnfiledir)/startup/octaverc; \
+	fi
+	if test -f $(DESTDIR)$(fcnfiledir)/startup/inputrc; then true; \
+	else \
+	  $(INSTALL_DATA) $(srcdir)/$(SYSTEM_INPUTRC_FILE_SRC) \
+	    $(DESTDIR)$(fcnfiledir)/startup/inputrc; \
+	fi
+	$(MKDIR_P) $(DESTDIR)$(localfcnfiledir)/startup
+	if test -f $(DESTDIR)$(localfcnfiledir)/startup/octaverc; \
+	then true; \
+	else \
+	  $(INSTALL_DATA) $(srcdir)/$(SITE_STARTUP_FILE_SRC) \
+	    $(DESTDIR)$(localfcnfiledir)/startup/octaverc; \
+	fi
+.PHONY: install-startup-files
 
-PKG_ADD_FILES += startup/PKG_ADD
-
-DIRSTAMP_FILES += startup/$(octave_dirstamp)
+uninstall-startup-files:
+	rm -f $(DESTDIR)$(fcnfiledir)/startup/octaverc
+	rm -f $(DESTDIR)$(fcnfiledir)/startup/inputrc
+	rm -f $(DESTDIR)$(localfcnfiledir)/startup/octaverc
+.PHONY: uninstall-startup-files
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/startup/site-rcfile	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,7 @@
+## System-wide startup file for Octave.
+##
+## If the environment variable OCTAVE_SITE_INITFILE is set when Octave
+## starts, then that file is executed instead of this file.
+##
+## This file should contain any commands that should be executed each
+## time Octave starts for every user at this site.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/startup/version-rcfile	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,25 @@
+## System-wide startup file for Octave.
+##
+## If the environment variable OCTAVE_VERSION_INITFILE is set when Octave
+## starts, then that file is executed instead of this file.
+##
+## This file should contain any commands that should be executed each
+## time Octave starts for every user at this site.
+
+## Configure readline using the file inputrc in the Octave startup
+## directory.
+
+readline_read_init_file (sprintf ("%s%s%s",
+                                  octave_config_info ("startupfiledir"),
+                                  filesep, "inputrc"));
+
+if (strcmp (PAGER (), "less") && isempty (getenv ("LESS")))
+  PAGER_FLAGS ('-e -X -P"-- less ?pB(%pB\\%):--. (f)orward, (b)ack, (q)uit$"');
+endif
+
+## This appears here instead of in the pkg/PKG_ADD file so that --norc
+## will also skip automatic loading of packages.
+
+pkg ("load", "auto");
+
+atexit ("__finish__");
--- a/scripts/statistics/base/center.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/base/center.m	Thu Dec 10 12:50:06 2015 -0800
@@ -70,7 +70,7 @@
   if (n == 0)
     retval = x;
   else
-    retval = bsxfun (@minus, x, mean (x, dim));
+    retval = x - mean (x, dim);
   endif
 
 endfunction
--- a/scripts/statistics/base/gls.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/base/gls.m	Thu Dec 10 12:50:06 2015 -0800
@@ -99,7 +99,7 @@
   endif
 
   ## Start of algorithm
-  o = o^(-1/2);
+  o ^= -1/2;
   z = kron (eye (cy), x);
   z = o * z;
   y1 = o * reshape (y, ry*cy, 1);
--- a/scripts/statistics/base/iqr.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/base/iqr.m	Thu Dec 10 12:50:06 2015 -0800
@@ -73,7 +73,7 @@
     offset2 = 0;
     while (offset > stride)
       offset -= stride;
-      offset2++;
+      offset2 += 1;
     endwhile
     offset += offset2 * stride * n;
     rng = [0 : n-1] * stride + offset;
--- a/scripts/statistics/base/kurtosis.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/base/kurtosis.m	Thu Dec 10 12:50:06 2015 -0800
@@ -151,15 +151,10 @@
 
 ## Verify no "divide-by-zero" warnings
 %!test
-%! wstate = warning ("query", "Octave:divide-by-zero");
-%! warning ("on", "Octave:divide-by-zero");
-%! unwind_protect
-%!   lastwarn ("");  # clear last warning
-%!   kurtosis (1);
-%!   assert (lastwarn (), "");
-%! unwind_protect_cleanup
-%!   warning (wstate, "Octave:divide-by-zero");
-%! end_unwind_protect
+%! warning ("on", "Octave:divide-by-zero", "local");
+%! lastwarn ("");  # clear last warning
+%! kurtosis (1);
+%! assert (lastwarn (), "");
 
 ## Test input validation
 %!error kurtosis ()
@@ -171,3 +166,4 @@
 %!error <DIM must be an integer> kurtosis (1, [], 1.5)
 %!error <DIM must be .* a valid dimension> kurtosis (1, [], 0)
 %!error <DIM must be .* a valid dimension> kurtosis (1, [], 3)
+
--- a/scripts/statistics/base/mahalanobis.m	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-## Copyright (C) 1996-2015 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} {} mahalanobis (@var{x}, @var{y})
-## Return the Mahalanobis' D-square distance between the multivariate
-## samples @var{x} and @var{y}.
-##
-## The data @var{x} and @var{y} must have the same number of components
-## (columns), but may have a different number of observations (rows).
-## @end deftypefn
-
-## Author: Friedrich Leisch <leisch@ci.tuwien.ac.at>
-## Created: July 1993
-## Adapted-By: jwe
-
-function retval = mahalanobis (x, y)
-
-  if (nargin != 2)
-    print_usage ();
-  endif
-
-  if (   ! (isnumeric (x) || islogical (x))
-      || ! (isnumeric (y) || islogical (y)))
-    error ("mahalanobis: X and Y must be numeric matrices or vectors");
-  endif
-
-  if (ndims (x) != 2 || ndims (y) != 2)
-    error ("mahalanobis: X and Y must be 2-D matrices or vectors");
-  endif
-
-  [xr, xc] = size (x);
-  [yr, yc] = size (y);
-
-  if (xc != yc)
-    error ("mahalanobis: X and Y must have the same number of columns");
-  endif
-
-  if (isinteger (x))
-    x = double (x);
-  endif
-
-  xm = mean (x);
-  ym = mean (y);
-
-  ## Center data by subtracting means
-  x = bsxfun (@minus, x, xm);
-  y = bsxfun (@minus, y, ym);
-
-  w = (x' * x + y' * y) / (xr + yr - 2);
-
-  winv = inv (w);
-
-  retval = (xm - ym) * winv * (xm - ym)';
-
-endfunction
-
-
-## 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))
-
--- a/scripts/statistics/base/mode.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/base/mode.m	Thu Dec 10 12:50:06 2015 -0800
@@ -111,11 +111,12 @@
 %! assert (c, {[1;2;3;4;5];[2];[2;3];[2];[1;2;3;4;5]});
 %!test
 %! a = sprandn (32, 32, 0.05);
+%! sp0 = sparse (0);
 %! [m, f, c] = mode (a);
 %! [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)) = { sp0 };
 %! assert (c ,c_exp);
 %! assert (c2,c_exp );
 
--- a/scripts/statistics/base/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/base/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,43 +1,46 @@
-FCN_FILE_DIRS += statistics/base
+FCN_FILE_DIRS += scripts/statistics/base
 
-statistics_base_FCN_FILES = \
-  statistics/base/center.m \
-  statistics/base/cloglog.m \
-  statistics/base/corr.m \
-  statistics/base/cov.m \
-  statistics/base/gls.m \
-  statistics/base/histc.m \
-  statistics/base/iqr.m \
-  statistics/base/kendall.m \
-  statistics/base/kurtosis.m \
-  statistics/base/logit.m \
-  statistics/base/lscov.m \
-  statistics/base/mahalanobis.m \
-  statistics/base/mean.m \
-  statistics/base/meansq.m \
-  statistics/base/median.m \
-  statistics/base/mode.m \
-  statistics/base/moment.m \
-  statistics/base/ols.m \
-  statistics/base/ppplot.m \
-  statistics/base/prctile.m \
-  statistics/base/probit.m \
-  statistics/base/qqplot.m \
-  statistics/base/quantile.m \
-  statistics/base/range.m \
-  statistics/base/ranks.m \
-  statistics/base/run_count.m \
-  statistics/base/runlength.m \
-  statistics/base/skewness.m \
-  statistics/base/spearman.m \
-  statistics/base/statistics.m \
-  statistics/base/std.m \
-  statistics/base/table.m \
-  statistics/base/var.m \
-  statistics/base/zscore.m
+scripts_statistics_base_FCN_FILES = \
+  scripts/statistics/base/center.m \
+  scripts/statistics/base/cloglog.m \
+  scripts/statistics/base/corr.m \
+  scripts/statistics/base/cov.m \
+  scripts/statistics/base/gls.m \
+  scripts/statistics/base/histc.m \
+  scripts/statistics/base/iqr.m \
+  scripts/statistics/base/kendall.m \
+  scripts/statistics/base/kurtosis.m \
+  scripts/statistics/base/logit.m \
+  scripts/statistics/base/lscov.m \
+  scripts/statistics/base/mean.m \
+  scripts/statistics/base/meansq.m \
+  scripts/statistics/base/median.m \
+  scripts/statistics/base/mode.m \
+  scripts/statistics/base/moment.m \
+  scripts/statistics/base/ols.m \
+  scripts/statistics/base/ppplot.m \
+  scripts/statistics/base/prctile.m \
+  scripts/statistics/base/probit.m \
+  scripts/statistics/base/qqplot.m \
+  scripts/statistics/base/quantile.m \
+  scripts/statistics/base/range.m \
+  scripts/statistics/base/ranks.m \
+  scripts/statistics/base/run_count.m \
+  scripts/statistics/base/runlength.m \
+  scripts/statistics/base/skewness.m \
+  scripts/statistics/base/spearman.m \
+  scripts/statistics/base/statistics.m \
+  scripts/statistics/base/std.m \
+  scripts/statistics/base/table.m \
+  scripts/statistics/base/var.m \
+  scripts/statistics/base/zscore.m
 
-FCN_FILES += $(statistics_base_FCN_FILES)
+scripts_statistics_basedir = $(fcnfiledir)/statistics/base
+
+scripts_statistics_base_DATA = $(scripts_statistics_base_FCN_FILES)
 
-PKG_ADD_FILES += statistics/base/PKG_ADD
+FCN_FILES += $(scripts_statistics_base_FCN_FILES)
 
-DIRSTAMP_FILES += statistics/base/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/statistics/base/PKG_ADD
+
+DIRSTAMP_FILES += scripts/statistics/base/$(octave_dirstamp)
--- a/scripts/statistics/base/moment.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/base/moment.m	Thu Dec 10 12:50:06 2015 -0800
@@ -151,7 +151,7 @@
       type = opt2;
       dim = opt1;
     else
-      error ("moment: expecting TYPE to be a string");
+      error ("moment: TYPE must be a string");
     endif
   endif
 
@@ -199,7 +199,7 @@
 %!error <X must be a non-empty numeric matrix> moment (ones (2,0,3), 2)
 %!error <P must be a numeric scalar> moment (1, true)
 %!error <P must be a numeric scalar> moment (1, ones (2,2))
-%!error <expecting TYPE to be a string> moment (1, 2, 3, 4)
+%!error <TYPE must be a string> moment (1, 2, 3, 4)
 %!error <DIM must be an integer and a valid dimension> moment (1, 2, ones (2,2))
 %!error <DIM must be an integer and a valid dimension> moment (1, 2, 1.5)
 %!error <DIM must be an integer and a valid dimension> moment (1, 2, 4)
--- a/scripts/statistics/base/quantile.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/base/quantile.m	Thu Dec 10 12:50:06 2015 -0800
@@ -321,7 +321,7 @@
 %! yexp = median (x, dim);
 %! assert (yobs, yexp);
 
-## Bug #45455 
+## Bug #45455
 %!assert (quantile ([1 3 2], 0.5, 1), [1 3 2])
 
 ## Test input validation
--- a/scripts/statistics/base/skewness.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/base/skewness.m	Thu Dec 10 12:50:06 2015 -0800
@@ -152,15 +152,10 @@
 
 ## Verify no "divide-by-zero" warnings
 %!test
-%! wstate = warning ("query", "Octave:divide-by-zero");
-%! warning ("on", "Octave:divide-by-zero");
-%! unwind_protect
-%!   lastwarn ("");  # clear last warning
-%!   skewness (1);
-%!   assert (lastwarn (), "");
-%! unwind_protect_cleanup
-%!   warning (wstate, "Octave:divide-by-zero");
-%! end_unwind_protect
+%! warning ("on", "Octave:divide-by-zero", "local");
+%! lastwarn ("");  # clear last warning
+%! skewness (1);
+%! assert (lastwarn (), "");
 
 ## Test input validation
 %!error skewness ()
@@ -172,3 +167,4 @@
 %!error <DIM must be an integer> skewness (1, [], 1.5)
 %!error <DIM must be .* a valid dimension> skewness (1, [], 0)
 %!error <DIM must be .* a valid dimension> skewness (1, [], 3)
+
--- a/scripts/statistics/base/zscore.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/base/zscore.m	Thu Dec 10 12:50:06 2015 -0800
@@ -86,8 +86,7 @@
     sigma = std (x, opt, dim);
     s = sigma;
     s(s==0) = 1;
-    ## FIXME: Use normal broadcasting once we can disable that warning
-    z = bsxfun (@rdivide, bsxfun (@minus, x, mu), s);
+    z = (x - mu) ./ s;
   endif
 
 endfunction
--- a/scripts/statistics/distributions/betainv.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/distributions/betainv.m	Thu Dec 10 12:50:06 2015 -0800
@@ -56,7 +56,7 @@
   inv(k) = 1;
 
   k = find ((x > 0) & (x < 1) & (a > 0) & (b > 0));
-  if (any (k))
+  if (! isempty (k))
     if (! isscalar (a) || ! isscalar (b))
       a = a(k);
       b = b(k);
@@ -81,8 +81,10 @@
       y(l) = 1 - sqrt (myeps) * ones (length (l), 1);
     endif
 
-    y_old = y;
-    for i = 1 : 10000
+    y_new = y;
+    loopcnt = 0;
+    do
+      y_old = y_new;
       h     = (betacdf (y_old, a, b) - x) ./ betapdf (y_old, a, b);
       y_new = y_old - h;
       ind   = find (y_new <= myeps);
@@ -94,11 +96,11 @@
         y_new(ind) = 1 - (1 - y_old(ind)) / 10;
       endif
       h = y_old - y_new;
-      if (max (abs (h)) < sqrt (myeps))
-        break;
-      endif
-      y_old = y_new;
-    endfor
+    until (max (abs (h)) < sqrt (myeps) || ++loopcnt == 40)
+
+    if (loopcnt == 40)
+      warning ("betainv: calculation failed to converge for some values");
+    endif
 
     inv(k) = y_new;
   endif
--- a/scripts/statistics/distributions/binoinv.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/distributions/binoinv.m	Thu Dec 10 12:50:06 2015 -0800
@@ -1,5 +1,6 @@
-## Copyright (C) 2012 Rik Wehbring
-## Copyright (C) 1995-2015 Kurt Hornik
+## Copyright (C) 2015 Lachlan Andrew
+## Copyright (C) 2012-2015 Rik Wehbring
+## Copyright (C) 1995-2012 Kurt Hornik
 ##
 ## This file is part of Octave.
 ##
@@ -25,9 +26,6 @@
 ## @var{p} is the probability of success.
 ## @end deftypefn
 
-## Author: KH <Kurt.Hornik@wu-wien.ac.at>
-## Description: Quantile function of the binomial distribution
-
 function inv = binoinv (x, n, p)
 
   if (nargin != 3)
@@ -57,34 +55,108 @@
 
   k = find ((x >= 0) & (x <= 1) & (n >= 0) & (n == fix (n)
              & (p >= 0) & (p <= 1)));
-  if (any (k))
+  if (! isempty (k))
+    x = x(k);
     if (isscalar (n) && isscalar (p))
-      cdf = binopdf (0, n, p) * ones (size (k));
-      while (any (inv(k) < n))
-        m = find (cdf < x(k));
-        if (any (m))
-          inv(k(m)) = inv(k(m)) + 1;
-          cdf(m) = cdf(m) + binopdf (inv(k(m)), n, p);
-        else
-          break;
-        endif
-      endwhile
+      [inv(k), unfinished] = scalar_binoinv (x(:), n, p);
+      k = k(unfinished);
+      if (! isempty (k))
+        inv(k) = bin_search_binoinv (x(k), n, p);
+      endif
     else
-      cdf = binopdf (0, n(k), p(k));
-      while (any (inv(k) < n(k)))
-        m = find (cdf < x(k));
-        if (any (m))
-          inv(k(m)) = inv(k(m)) + 1;
-          cdf(m) = cdf(m) + binopdf (inv(k(m)), n(k(m)), p(k(m)));
-        else
-          break;
-        endif
-      endwhile
+      [inv(k), unfinished] = vector_binoinv (x(:), n(:), p(:));
+      k = k(unfinished);
+      if (! isempty (k))
+        inv(k) = bin_search_binoinv (x(k), n(k), p(k));
+      endif
     endif
   endif
 
 endfunction
 
+## Core algorithm to calculate the inverse binomial, for n and p real scalars
+## and y a column vector, and for which the output is not NaN or Inf.
+## Compute CDF in batches of doubling size until CDF > x, or answer > 500
+## Return the locations of unfinished cases in k.
+function [m, k] = scalar_binoinv (x, n, p)
+  k = 1:length (x);
+  m = zeros (size (x));
+  prev_limit = 0;
+  limit = 10;
+  cdf = 0;
+  v = 0;
+  do
+    cdf = binocdf (prev_limit:limit-1, n, p);
+    r = bsxfun (@le, x(k), cdf);
+    [v, m(k)] = max (r, [], 2);     # find first instance of x <= cdf
+    m(k) += prev_limit - 1;
+    k = k(v == 0);
+
+    prev_limit = limit;
+    limit += limit;
+  until (isempty (k) || limit >= 1000)
+
+endfunction
+
+## Core algorithm to calculate the inverse binomial, for n, p, and y column
+## vectors, and for which the output is not NaN or Inf.
+## Compute CDF in batches of doubling size until CDF > x, or answer > 500
+## Return the locations of unfinished cases in k.
+## Calculates CDF by summing PDF, which is faster than calls to binocdf.
+function [m, k] = vector_binoinv (x, n, p)
+  k = 1:length(x);
+  m = zeros (size (x));
+  prev_limit = 0;
+  limit = 10;
+  cdf = 0;
+  v = 0;
+  do
+    xx = repmat (prev_limit:limit-1, [length(k), 1]);
+    nn = kron (ones (1, limit-prev_limit), n(k));
+    pp = kron (ones (1, limit-prev_limit), p(k));
+    pdf = binopdf (xx, nn, pp);
+    pdf(:,1) += cdf(v==0, end);
+    cdf = cumsum (pdf, 2);
+    r = bsxfun (@le, x(k), cdf);
+    [v, m(k)] = max (r, [], 2);     # find first instance of x <= cdf
+    m(k) += prev_limit - 1;
+    k = k(v == 0);
+
+    prev_limit = limit;
+    limit += min (limit, max (1e4/numel (k), 10));  # limit memory use
+  until (isempty (k) || limit >= 1000)
+
+endfunction
+
+## Vectorized binary search.
+## Can handle vectors n and p, and is faster than the scalar case when the
+## answer is large.
+## Could be optimized to call binocdf only for a subset of the x at each stage,
+## but care must be taken to handle both scalar and vector n, p.  Bookkeeping
+## may cost more than the extra computations.
+function m = bin_search_binoinv (x, n, p)
+  k = 1:length (x);
+  lower = zeros (size (x));
+  limit = 500;              # lower bound on point at which prev phase finished
+  while (any (k) && limit < 1e100)
+    cdf = binocdf (limit, n, p);
+    k = (x > cdf);
+    lower(k) = limit;
+    limit += limit;
+  end
+  upper = max (2*lower, 1);
+  k = find (lower != limit/2);       # elements for which above loop finished
+  for i = 1:ceil (log2 (max (lower)))
+    mid = (upper + lower)/2;
+    cdf = binocdf (floor(mid(:)), n, p);
+    r = (x <= cdf);
+    upper(r)  = mid(r);
+    lower(!r) = mid(!r);
+  endfor
+  m = ceil (lower);
+  m(x > binocdf (m(:), n, p)) += 1;  # fix off-by-one errors from binary search
+endfunction
+
 
 %!shared x
 %! x = [-1 0 0.5 1 2];
@@ -101,6 +173,14 @@
 %!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 accuracy, to within +/- 1 since it is a discrete distribution
+%!shared y, tol
+%! y = magic (3) + 1;
+%! tol = 1;
+%!assert (binoinv (binocdf (1:10, 11, 0.1), 11, 0.1), 1:10, tol)
+%!assert (binoinv (binocdf (1:10, 2*(1:10), 0.1), 2*(1:10), 0.1), 1:10, tol)
+%!assert (binoinv (binocdf (y, 2*y, 1./y), 2*y, 1./y), y, tol)
+
 ## Test input validation
 %!error binoinv ()
 %!error binoinv (1)
--- a/scripts/statistics/distributions/gaminv.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/distributions/gaminv.m	Thu Dec 10 12:50:06 2015 -0800
@@ -58,7 +58,7 @@
   inv(k) = Inf;
 
   k = find ((x > 0) & (x < 1) & (a > 0) & (a < Inf) & (b > 0) & (b < Inf));
-  if (any (k))
+  if (! isempty (k))
     if (! isscalar (a) || ! isscalar (b))
       a = a(k);
       b = b(k);
@@ -79,8 +79,10 @@
       y(l) = sqrt (myeps) * ones (length (l), 1);
     endif
 
-    y_old = y;
-    for i = 1 : 100
+    y_new = y;
+    loopcnt = 0;
+    do
+      y_old = y_new;
       h     = (gamcdf (y_old, a, b) - x) ./ gampdf (y_old, a, b);
       y_new = y_old - h;
       ind   = find (y_new <= myeps);
@@ -88,13 +90,14 @@
         y_new(ind) = y_old(ind) / 10;
         h = y_old - y_new;
       endif
-      if (max (abs (h)) < sqrt (myeps))
-        break;
-      endif
-      y_old = y_new;
-    endfor
+    until (max (abs (h)) < sqrt (myeps) || ++loopcnt == 40)
+
+    if (loopcnt == 40)
+      warning ("gaminv: calculation failed to converge for some values");
+    endif
 
     inv(k) = y_new;
+
   endif
 
 endfunction
--- a/scripts/statistics/distributions/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/distributions/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,99 +1,103 @@
-FCN_FILE_DIRS += statistics/distributions
+FCN_FILE_DIRS += scripts/statistics/distributions
 
-statistics_distributions_FCN_FILES = \
-  statistics/distributions/betacdf.m \
-  statistics/distributions/betainv.m \
-  statistics/distributions/betapdf.m \
-  statistics/distributions/betarnd.m \
-  statistics/distributions/binocdf.m \
-  statistics/distributions/binoinv.m \
-  statistics/distributions/binopdf.m \
-  statistics/distributions/binornd.m \
-  statistics/distributions/cauchy_cdf.m \
-  statistics/distributions/cauchy_inv.m \
-  statistics/distributions/cauchy_pdf.m \
-  statistics/distributions/cauchy_rnd.m \
-  statistics/distributions/chi2cdf.m \
-  statistics/distributions/chi2inv.m \
-  statistics/distributions/chi2pdf.m \
-  statistics/distributions/chi2rnd.m \
-  statistics/distributions/discrete_cdf.m \
-  statistics/distributions/discrete_inv.m \
-  statistics/distributions/discrete_pdf.m \
-  statistics/distributions/discrete_rnd.m \
-  statistics/distributions/empirical_cdf.m \
-  statistics/distributions/empirical_inv.m \
-  statistics/distributions/empirical_pdf.m \
-  statistics/distributions/empirical_rnd.m \
-  statistics/distributions/expcdf.m \
-  statistics/distributions/expinv.m \
-  statistics/distributions/exppdf.m \
-  statistics/distributions/exprnd.m \
-  statistics/distributions/fcdf.m \
-  statistics/distributions/finv.m \
-  statistics/distributions/fpdf.m \
-  statistics/distributions/frnd.m \
-  statistics/distributions/gamcdf.m \
-  statistics/distributions/gaminv.m \
-  statistics/distributions/gampdf.m \
-  statistics/distributions/gamrnd.m \
-  statistics/distributions/geocdf.m \
-  statistics/distributions/geoinv.m \
-  statistics/distributions/geopdf.m \
-  statistics/distributions/geornd.m \
-  statistics/distributions/hygecdf.m \
-  statistics/distributions/hygeinv.m \
-  statistics/distributions/hygepdf.m \
-  statistics/distributions/hygernd.m \
-  statistics/distributions/kolmogorov_smirnov_cdf.m \
-  statistics/distributions/laplace_cdf.m \
-  statistics/distributions/laplace_inv.m \
-  statistics/distributions/laplace_pdf.m \
-  statistics/distributions/laplace_rnd.m \
-  statistics/distributions/logistic_cdf.m \
-  statistics/distributions/logistic_inv.m \
-  statistics/distributions/logistic_pdf.m \
-  statistics/distributions/logistic_rnd.m \
-  statistics/distributions/logncdf.m \
-  statistics/distributions/logninv.m \
-  statistics/distributions/lognpdf.m \
-  statistics/distributions/lognrnd.m \
-  statistics/distributions/nbincdf.m \
-  statistics/distributions/nbininv.m \
-  statistics/distributions/nbinpdf.m \
-  statistics/distributions/nbinrnd.m \
-  statistics/distributions/normcdf.m \
-  statistics/distributions/norminv.m \
-  statistics/distributions/normpdf.m \
-  statistics/distributions/normrnd.m \
-  statistics/distributions/poisscdf.m \
-  statistics/distributions/poissinv.m \
-  statistics/distributions/poisspdf.m \
-  statistics/distributions/poissrnd.m \
-  statistics/distributions/stdnormal_cdf.m \
-  statistics/distributions/stdnormal_inv.m \
-  statistics/distributions/stdnormal_pdf.m \
-  statistics/distributions/stdnormal_rnd.m \
-  statistics/distributions/tcdf.m \
-  statistics/distributions/tinv.m \
-  statistics/distributions/tpdf.m \
-  statistics/distributions/trnd.m \
-  statistics/distributions/unidrnd.m \
-  statistics/distributions/unidcdf.m \
-  statistics/distributions/unidinv.m \
-  statistics/distributions/unidpdf.m \
-  statistics/distributions/unifrnd.m \
-  statistics/distributions/unifcdf.m \
-  statistics/distributions/unifinv.m \
-  statistics/distributions/unifpdf.m \
-  statistics/distributions/wblcdf.m \
-  statistics/distributions/wblinv.m \
-  statistics/distributions/wblpdf.m \
-  statistics/distributions/wblrnd.m \
-  statistics/distributions/wienrnd.m
+scripts_statistics_distributions_FCN_FILES = \
+  scripts/statistics/distributions/betacdf.m \
+  scripts/statistics/distributions/betainv.m \
+  scripts/statistics/distributions/betapdf.m \
+  scripts/statistics/distributions/betarnd.m \
+  scripts/statistics/distributions/binocdf.m \
+  scripts/statistics/distributions/binoinv.m \
+  scripts/statistics/distributions/binopdf.m \
+  scripts/statistics/distributions/binornd.m \
+  scripts/statistics/distributions/cauchy_cdf.m \
+  scripts/statistics/distributions/cauchy_inv.m \
+  scripts/statistics/distributions/cauchy_pdf.m \
+  scripts/statistics/distributions/cauchy_rnd.m \
+  scripts/statistics/distributions/chi2cdf.m \
+  scripts/statistics/distributions/chi2inv.m \
+  scripts/statistics/distributions/chi2pdf.m \
+  scripts/statistics/distributions/chi2rnd.m \
+  scripts/statistics/distributions/discrete_cdf.m \
+  scripts/statistics/distributions/discrete_inv.m \
+  scripts/statistics/distributions/discrete_pdf.m \
+  scripts/statistics/distributions/discrete_rnd.m \
+  scripts/statistics/distributions/empirical_cdf.m \
+  scripts/statistics/distributions/empirical_inv.m \
+  scripts/statistics/distributions/empirical_pdf.m \
+  scripts/statistics/distributions/empirical_rnd.m \
+  scripts/statistics/distributions/expcdf.m \
+  scripts/statistics/distributions/expinv.m \
+  scripts/statistics/distributions/exppdf.m \
+  scripts/statistics/distributions/exprnd.m \
+  scripts/statistics/distributions/fcdf.m \
+  scripts/statistics/distributions/finv.m \
+  scripts/statistics/distributions/fpdf.m \
+  scripts/statistics/distributions/frnd.m \
+  scripts/statistics/distributions/gamcdf.m \
+  scripts/statistics/distributions/gaminv.m \
+  scripts/statistics/distributions/gampdf.m \
+  scripts/statistics/distributions/gamrnd.m \
+  scripts/statistics/distributions/geocdf.m \
+  scripts/statistics/distributions/geoinv.m \
+  scripts/statistics/distributions/geopdf.m \
+  scripts/statistics/distributions/geornd.m \
+  scripts/statistics/distributions/hygecdf.m \
+  scripts/statistics/distributions/hygeinv.m \
+  scripts/statistics/distributions/hygepdf.m \
+  scripts/statistics/distributions/hygernd.m \
+  scripts/statistics/distributions/kolmogorov_smirnov_cdf.m \
+  scripts/statistics/distributions/laplace_cdf.m \
+  scripts/statistics/distributions/laplace_inv.m \
+  scripts/statistics/distributions/laplace_pdf.m \
+  scripts/statistics/distributions/laplace_rnd.m \
+  scripts/statistics/distributions/logistic_cdf.m \
+  scripts/statistics/distributions/logistic_inv.m \
+  scripts/statistics/distributions/logistic_pdf.m \
+  scripts/statistics/distributions/logistic_rnd.m \
+  scripts/statistics/distributions/logncdf.m \
+  scripts/statistics/distributions/logninv.m \
+  scripts/statistics/distributions/lognpdf.m \
+  scripts/statistics/distributions/lognrnd.m \
+  scripts/statistics/distributions/nbincdf.m \
+  scripts/statistics/distributions/nbininv.m \
+  scripts/statistics/distributions/nbinpdf.m \
+  scripts/statistics/distributions/nbinrnd.m \
+  scripts/statistics/distributions/normcdf.m \
+  scripts/statistics/distributions/norminv.m \
+  scripts/statistics/distributions/normpdf.m \
+  scripts/statistics/distributions/normrnd.m \
+  scripts/statistics/distributions/poisscdf.m \
+  scripts/statistics/distributions/poissinv.m \
+  scripts/statistics/distributions/poisspdf.m \
+  scripts/statistics/distributions/poissrnd.m \
+  scripts/statistics/distributions/stdnormal_cdf.m \
+  scripts/statistics/distributions/stdnormal_inv.m \
+  scripts/statistics/distributions/stdnormal_pdf.m \
+  scripts/statistics/distributions/stdnormal_rnd.m \
+  scripts/statistics/distributions/tcdf.m \
+  scripts/statistics/distributions/tinv.m \
+  scripts/statistics/distributions/tpdf.m \
+  scripts/statistics/distributions/trnd.m \
+  scripts/statistics/distributions/unidrnd.m \
+  scripts/statistics/distributions/unidcdf.m \
+  scripts/statistics/distributions/unidinv.m \
+  scripts/statistics/distributions/unidpdf.m \
+  scripts/statistics/distributions/unifrnd.m \
+  scripts/statistics/distributions/unifcdf.m \
+  scripts/statistics/distributions/unifinv.m \
+  scripts/statistics/distributions/unifpdf.m \
+  scripts/statistics/distributions/wblcdf.m \
+  scripts/statistics/distributions/wblinv.m \
+  scripts/statistics/distributions/wblpdf.m \
+  scripts/statistics/distributions/wblrnd.m \
+  scripts/statistics/distributions/wienrnd.m
 
-FCN_FILES += $(statistics_distributions_FCN_FILES)
+scripts_statistics_distributionsdir = $(fcnfiledir)/statistics/distributions
+
+scripts_statistics_distributions_DATA = $(scripts_statistics_distributions_FCN_FILES)
 
-PKG_ADD_FILES += statistics/distributions/PKG_ADD
+FCN_FILES += $(scripts_statistics_distributions_FCN_FILES)
 
-DIRSTAMP_FILES += statistics/distributions/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/statistics/distributions/PKG_ADD
+
+DIRSTAMP_FILES += scripts/statistics/distributions/$(octave_dirstamp)
--- a/scripts/statistics/distributions/nbininv.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/distributions/nbininv.m	Thu Dec 10 12:50:06 2015 -0800
@@ -1,5 +1,6 @@
-## Copyright (C) 2012 Rik Wehbring
-## Copyright (C) 1995-2015 Kurt Hornik
+## Copyright (C) 2015 Lachlan Andrew
+## Copyright (C) 2012-2015 Rik Wehbring
+## Copyright (C) 1995-2012 Kurt Hornik
 ##
 ## This file is part of Octave.
 ##
@@ -30,9 +31,6 @@
 ## @var{p} before the @var{n}-th success follows this distribution.
 ## @end deftypefn
 
-## Author: KH <Kurt.Hornik@wu-wien.ac.at>
-## Description: Quantile function of the Pascal distribution
-
 function inv = nbininv (x, n, p)
 
   if (nargin != 3)
@@ -65,34 +63,70 @@
 
   k = find ((x >= 0) & (x < 1) & (n > 0) & (n < Inf)
             & (p > 0) & (p <= 1));
-  m = zeros (size (k));
-  x = x(k);
-  if (isscalar (n) && isscalar (p))
-    s = p ^ n * ones (size (k));
-    while (1)
-      l = find (s < x);
-      if (any (l))
-        m(l) = m(l) + 1;
-        s(l) = s(l) + nbinpdf (m(l), n, p);
-      else
-        break;
-      endif
-    endwhile
-  else
-    n = n(k);
-    p = p(k);
-    s = p .^ n;
-    while (1)
-      l = find (s < x);
-      if (any (l))
-        m(l) = m(l) + 1;
-        s(l) = s(l) + nbinpdf (m(l), n(l), p(l));
-      else
-        break;
-      endif
-    endwhile
+  if (! isempty (k))
+    x = x(k);
+    m = zeros (size (k));
+    if (isscalar (n) && isscalar (p))
+      [m, unfinished] = scalar_nbininv (x(:), n, p);
+      m(unfinished) = bin_search_nbininv (x(unfinished), n, p);
+    else
+      m = bin_search_nbininv (x, n(k), p(k));
+    endif
+    inv(k) = m;
   endif
-  inv(k) = m;
+
+endfunction
+
+
+## Core algorithm to calculate the inverse negative binomial, for n and p real
+## scalars and y a column vector, and for which the output is not NaN or Inf.
+## Compute CDF in batches of doubling size until CDF > x, or answer > 500.
+## Return the locations of unfinished cases in k.
+function [m, k] = scalar_nbininv (x, n, p)
+  k = 1:length (x);
+  m = zeros (size (x));
+  prev_limit = 0;
+  limit = 10;
+  do
+    cdf = nbincdf (prev_limit:limit, n, p);
+    r = bsxfun (@le, x(k), cdf);
+    [v, m(k)] = max (r, [], 2);     # find first instance of x <= cdf
+    m(k) += prev_limit - 1;
+    k = k(v == 0);
+
+    prev_limit = limit;
+    limit += limit;
+  until (isempty (k) || limit >= 1000)
+
+endfunction
+
+## Vectorized binary search.
+## Can handle vectors n and p, and is faster than the scalar case when the
+## answer is large.
+## Could be optimized to call nbincdf only for a subset of the x at each stage,
+## but care must be taken to handle both scalar and vector n,p.  Bookkeeping
+## may cost more than the extra computations.
+function m = bin_search_nbininv (x, n, p)
+  k = 1:length (x);
+  lower = zeros (size (x));
+  limit = 1;
+  while (any (k) && limit < 1e100)
+    cdf = nbincdf (limit, n, p);
+    k = (x > cdf);
+    lower(k) = limit;
+    limit += limit;
+  end
+  upper = max (2*lower, 1);
+  k = find (lower != limit/2);    # elements for which above loop finished
+  for i = 1:ceil (log2 (max (lower)))
+    mid = (upper + lower)/2;
+    cdf = nbincdf (floor (mid), n, p);
+    r = (x <= cdf);
+    upper(r)  = mid(r);
+    lower(!r) = mid(!r);
+  endfor
+  m = ceil (lower);
+  m(x > nbincdf (m, n, p)) += 1;  # fix off-by-one errors from binary search
 
 endfunction
 
@@ -113,6 +147,14 @@
 %!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 accuracy, to within +/- 1 since it is a discrete distribution
+%!shared y, tol
+%! y = magic (3) + 1;
+%! tol = 1;
+%!assert (nbininv (nbincdf (1:10, 3, 0.1), 3, 0.1), 1:10, tol)
+%!assert (nbininv (nbincdf (1:10, 3./(1:10), 0.1), 3./(1:10), 0.1), 1:10, tol)
+%!assert (nbininv (nbincdf (y, 3./y, 1./y), 3./y, 1./y), y, tol)
+
 ## Test input validation
 %!error nbininv ()
 %!error nbininv (1)
--- a/scripts/statistics/distributions/poissinv.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/distributions/poissinv.m	Thu Dec 10 12:50:06 2015 -0800
@@ -1,5 +1,7 @@
+## Copyright (C) 1995-2015 Kurt Hornik
+## Copyright (C) 2015 Lachlan Andrew
+## Copyright (C) 2014 Mike Giles
 ## Copyright (C) 2012 Rik Wehbring
-## Copyright (C) 1995-2015 Kurt Hornik
 ##
 ## This file is part of Octave.
 ##
@@ -23,7 +25,10 @@
 ## at @var{x} of the Poisson distribution with parameter @var{lambda}.
 ## @end deftypefn
 
-## Author: KH <Kurt.Hornik@wu-wien.ac.at>
+## Author: Lachlan <lachlanbis@gmail.com>
+## based on code by
+##      KH <Kurt.Hornik@wu-wien.ac.at>
+##      Mike Giles <mike.giles@maths.ox.ac.uk>
 ## Description: Quantile function of the Poisson distribution
 
 function inv = poissinv (x, lambda)
@@ -55,26 +60,131 @@
   k = (x == 1) & (lambda > 0);
   inv(k) = Inf;
 
-  k = find ((x > 0) & (x < 1) & (lambda > 0));
-  if (isscalar (lambda))
-    cdf = exp (-lambda) * ones (size (k));
-  else
-    cdf = exp (-lambda(k));
+  k = (x > 0) & (x < 1) & (lambda > 0);
+  if (any (k(:)))
+    limit = 20;                         # After 'limit' iterations, use approx
+    if (isscalar (lambda))
+      cdf = [(cumsum (poisspdf (0:limit-1,lambda))), 2];
+      y = x(:);                         # force to column
+      r = bsxfun (@le, y(k), cdf);
+      [~, inv(k)] = max (r, [], 2);     # find first instance of x <= cdf
+      inv(k) -= 1;
+    else
+      kk = find (k);
+      cdf = exp (-lambda(kk));
+      for i = 1:limit
+        m = find (cdf < x(kk));
+        if (isempty (m))
+          break;
+        else
+          inv(kk(m)) += 1;
+          cdf(m) += poisspdf (i, lambda(kk(m)));
+        endif
+      endfor
+    endif
+
+    ## Use Mike Giles's magic when inv isn't < limit
+    k &= (inv == limit);
+    if (any (k(:)))
+      if (isscalar (lambda))
+        lam = repmat (lambda, size (x));
+      else
+        lam = lambda;
+      endif
+      inv(k) = analytic_approx (x(k), lam(k));
+    endif
   endif
 
-  while (1)
-    m = find (cdf < x(k));
-    if (any (m))
-      inv(k(m)) += 1;
-      if (isscalar (lambda))
-        cdf(m) = cdf(m) + poisspdf (inv(k(m)), lambda);
-      else
-        cdf(m) = cdf(m) + poisspdf (inv(k(m)), lambda(k(m)));
+endfunction
+
+
+## The following is based on Mike Giles's CUDA implementation,
+## [http://people.maths.ox.ac.uk/gilesm/codes/poissinv/poissinv_cuda.h]
+## which is copyright by the University of Oxford
+## and is provided under the terms of the GNU GPLv3 license:
+## http://www.gnu.org/licenses/gpl.html
+
+function inv = analytic_approx (x, lambda)
+  s = norminv (x, 0, 1) ./ sqrt (lambda);
+  k = (s > -0.6833501) & (s < 1.777993);
+  ## use polynomial approximations in central region
+  if (any (k))
+    lam = lambda(k);
+    if (isscalar (s))
+      sk = s;
+    else
+      sk = s(k);
+    endif
+
+    ## polynomial approximation to f^{-1}(s) - 1
+    rm =  2.82298751e-07;
+    rm = -2.58136133e-06 + rm.*sk;
+    rm =  1.02118025e-05 + rm.*sk;
+    rm = -2.37996199e-05 + rm.*sk;
+    rm =  4.05347462e-05 + rm.*sk;
+    rm = -6.63730967e-05 + rm.*sk;
+    rm =  0.000124762566 + rm.*sk;
+    rm = -0.000256970731 + rm.*sk;
+    rm =  0.000558953132 + rm.*sk;
+    rm =  -0.00133129194 + rm.*sk;
+    rm =   0.00370367937 + rm.*sk;
+    rm =   -0.0138888706 + rm.*sk;
+    rm =     0.166666667 + rm.*sk;
+    rm =         sk + sk.*(rm.*sk);
+
+    ## polynomial approximation to correction c0(r)
+
+    t  =   1.86386867e-05;
+    t  =  -0.000207319499 + t.*rm;
+    t  =     0.0009689451 + t.*rm;
+    t  =   -0.00247340054 + t.*rm;
+    t  =    0.00379952985 + t.*rm;
+    t  =   -0.00386717047 + t.*rm;
+    t  =    0.00346960934 + t.*rm;
+    t  =   -0.00414125511 + t.*rm;
+    t  =    0.00586752093 + t.*rm;
+    t  =   -0.00838583787 + t.*rm;
+    t  =     0.0132793933 + t.*rm;
+    t  =     -0.027775536 + t.*rm;
+    t  =      0.333333333 + t.*rm;
+
+    ##  O(1/lam) correction
+
+    y  =   -0.00014585224;
+    y  =    0.00146121529 + y.*rm;
+    y  =   -0.00610328845 + y.*rm;
+    y  =     0.0138117964 + y.*rm;
+    y  =    -0.0186988746 + y.*rm;
+    y  =     0.0168155118 + y.*rm;
+    y  =     -0.013394797 + y.*rm;
+    y  =     0.0135698573 + y.*rm;
+    y  =    -0.0155377333 + y.*rm;
+    y  =     0.0174065334 + y.*rm;
+    y  =    -0.0198011178 + y.*rm;
+    y ./= lam;
+
+    inv(k) = floor (lam + (y+t)+lam.*rm);
+  endif
+
+  k = !k & (s > -sqrt (2));
+  if (any (k))
+    ## Newton iteration
+    r = 1 + s(k);
+    r2 = r + 1;
+    while (any (abs (r - r2) > 1e-5))
+      t = log (r);
+      r2 = r;
+      s2 = sqrt (2 * ((1-r) + r.*t));
+      s2(r<1) *= -1;
+      r = r2 - (s2 - s(k)) .* s2 ./ t;
+      if (r < 0.1 * r2)
+        r = 0.1 * r2;
       endif
-    else
-      break;
-    endif
-  endwhile
+    endwhile
+    t = log (r);
+    y = lambda(k) .* r + log (sqrt (2*r.*((1-r) + r.*t)) ./ abs (r-1)) ./ t;
+    inv(k) = floor (y - 0.0218 ./ (y + 0.065 * lambda(k)));
+  endif
 
 endfunction
 
--- a/scripts/statistics/distributions/unidpdf.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/distributions/unidpdf.m	Thu Dec 10 12:50:06 2015 -0800
@@ -24,7 +24,7 @@
 ## the integer values 1--@var{n} with equal probability.
 ##
 ## Warning: The underlying implementation uses the double class and will only
-## be accurate for @var{n} @leq{} @code{bitmax} (@w{@math{2^{53} - 1}} on
+## be accurate for @var{n} < @code{flintmax} (@w{@math{2^{53}}}) on
 ## IEEE 754 compatible systems).
 ## @end deftypefn
 
--- a/scripts/statistics/models/logistic_regression.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/models/logistic_regression.m	Thu Dec 10 12:50:06 2015 -0800
@@ -128,16 +128,16 @@
   ## maximize likelihood using Levenberg modified Newton's method
   iter = 0;
   while (abs (dl' * (d2l \ dl) / length (dl)) > tol)
-    iter = iter + 1;
+    iter += 1;
     tbold = tb;
     devold = dev;
     tb = tbold - d2l \ dl;
     [g, g1, p, dev] = logistic_regression_likelihood (y, x, tb, z, z1);
     if ((dev - devold) / (dl' * (tb - tbold)) < 0)
-      epsilon = epsilon / decr;
+      epsilon /= decr;
     else
       while ((dev - devold) / (dl' * (tb - tbold)) > 0)
-        epsilon = epsilon * incr;
+        epsilon *= incr;
          if (epsilon > 1e+15)
            error ("logistic_regression: epsilon too large");
          endif
--- a/scripts/statistics/models/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/models/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,15 +1,26 @@
-FCN_FILE_DIRS += statistics/models
+FCN_FILE_DIRS += \
+  scripts/statistics/models \
+  scripts/statistics/models/private
 
-statistics_models_PRIVATE_FCN_FILES = \
-  statistics/models/private/logistic_regression_derivatives.m \
-  statistics/models/private/logistic_regression_likelihood.m
+scripts_statistics_models_PRIVATE_FCN_FILES = \
+  scripts/statistics/models/private/logistic_regression_derivatives.m \
+  scripts/statistics/models/private/logistic_regression_likelihood.m
+
+scripts_statistics_models_FCN_FILES = \
+  scripts/statistics/models/logistic_regression.m
+
+scripts_statistics_modelsdir = $(fcnfiledir)/statistics/models
 
-statistics_models_FCN_FILES = \
-  statistics/models/logistic_regression.m \
-  $(statistics_models_PRIVATE_FCN_FILES)
+scripts_statistics_models_DATA = $(scripts_statistics_models_FCN_FILES)
+
+scripts_statistics_models_privatedir = $(fcnfiledir)/statistics/models/private
+
+scripts_statistics_models_private_DATA = $(scripts_statistics_models_PRIVATE_FCN_FILES)
 
-FCN_FILES += $(statistics_models_FCN_FILES)
+FCN_FILES += \
+  $(scripts_statistics_models_FCN_FILES) \
+  $(scripts_statistics_models_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += statistics/models/PKG_ADD
+PKG_ADD_FILES += scripts/statistics/models/PKG_ADD
 
-DIRSTAMP_FILES += statistics/models/$(octave_dirstamp)
+DIRSTAMP_FILES += scripts/statistics/models/$(octave_dirstamp)
--- a/scripts/statistics/tests/cor_test.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/tests/cor_test.m	Thu Dec 10 12:50:06 2015 -0800
@@ -28,7 +28,7 @@
 ##
 ## The optional argument string @var{method} specifies which correlation
 ## coefficient to use for testing.  If @var{method} is @qcode{"pearson"}
-## (default), the (usual) Pearson's produt moment correlation coefficient is
+## (default), the (usual) Pearson's product moment correlation coefficient is
 ## used.  In this case, the data should come from a bivariate normal
 ## distribution.  Otherwise, the other two methods offer nonparametric
 ## alternatives.  If @var{method} is @qcode{"kendall"}, then Kendall's rank
--- a/scripts/statistics/tests/kolmogorov_smirnov_test_2.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/tests/kolmogorov_smirnov_test_2.m	Thu Dec 10 12:50:06 2015 -0800
@@ -76,7 +76,7 @@
   ds = diff (s);
   if (any (ds == 0))
     ## There are some ties, so keep only those changes.
-    warning ("cannot compute correct p-values with ties");
+    warning ("kolmogorov_smirnov_test_2: cannot compute correct p-values with ties");
     elems = [find(ds); n_x+n_y];
     z = z(elems);
   endif
--- a/scripts/statistics/tests/kruskal_wallis_test.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/tests/kruskal_wallis_test.m	Thu Dec 10 12:50:06 2015 -0800
@@ -73,7 +73,7 @@
   k = 0;
   j = 0;
   for i = 1 : m;
-    k = k + (sum (r ((j + 1) : (j + n(i))))) ^ 2 / n(i);
+    k += (sum (r ((j + 1) : (j + n(i))))) ^ 2 / n(i);
     j = j + n(i);
   endfor
 
@@ -82,7 +82,7 @@
 
   ## Adjust the result to takes ties into account.
   sum_ties = sum (polyval ([1, 0, -1, 0], runlength (sort (p))));
-  k = k / (1 - sum_ties / (n^3 - n));
+  k /= (1 - sum_ties / (n^3 - n));
 
   df = m - 1;
   pval = 1 - chi2cdf (k, df);
--- a/scripts/statistics/tests/manova.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/tests/manova.m	Thu Dec 10 12:50:06 2015 -0800
@@ -69,7 +69,7 @@
     group_label = s ([1, (reshape (i, 1, k - 1) + 1)]);
   endif
 
-  x = x - ones (n, 1) * mean (x);
+  x -= ones (n, 1) * mean (x);
   SST = x' * x;
 
   s = zeros (1, p);
@@ -77,7 +77,7 @@
   for i = 1 : k;
     v = x (find (g == group_label (i)), :);
     s = sum (v);
-    SSB = SSB + s' * s / rows (v);
+    SSB += s' * s / rows (v);
   endfor
   n_b = k - 1;
 
--- a/scripts/statistics/tests/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/tests/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,34 +1,38 @@
-FCN_FILE_DIRS += statistics/tests
+FCN_FILE_DIRS += scripts/statistics/tests
 
-statistics_tests_FCN_FILES = \
-  statistics/tests/anova.m \
-  statistics/tests/bartlett_test.m \
-  statistics/tests/chisquare_test_homogeneity.m \
-  statistics/tests/chisquare_test_independence.m \
-  statistics/tests/cor_test.m \
-  statistics/tests/f_test_regression.m \
-  statistics/tests/hotelling_test.m \
-  statistics/tests/hotelling_test_2.m \
-  statistics/tests/kolmogorov_smirnov_test.m \
-  statistics/tests/kolmogorov_smirnov_test_2.m \
-  statistics/tests/kruskal_wallis_test.m \
-  statistics/tests/manova.m \
-  statistics/tests/mcnemar_test.m \
-  statistics/tests/prop_test_2.m \
-  statistics/tests/run_test.m \
-  statistics/tests/sign_test.m \
-  statistics/tests/t_test.m \
-  statistics/tests/t_test_2.m \
-  statistics/tests/t_test_regression.m \
-  statistics/tests/u_test.m \
-  statistics/tests/var_test.m \
-  statistics/tests/welch_test.m \
-  statistics/tests/wilcoxon_test.m \
-  statistics/tests/z_test.m \
-  statistics/tests/z_test_2.m
+scripts_statistics_tests_FCN_FILES = \
+  scripts/statistics/tests/anova.m \
+  scripts/statistics/tests/bartlett_test.m \
+  scripts/statistics/tests/chisquare_test_homogeneity.m \
+  scripts/statistics/tests/chisquare_test_independence.m \
+  scripts/statistics/tests/cor_test.m \
+  scripts/statistics/tests/f_test_regression.m \
+  scripts/statistics/tests/hotelling_test.m \
+  scripts/statistics/tests/hotelling_test_2.m \
+  scripts/statistics/tests/kolmogorov_smirnov_test.m \
+  scripts/statistics/tests/kolmogorov_smirnov_test_2.m \
+  scripts/statistics/tests/kruskal_wallis_test.m \
+  scripts/statistics/tests/manova.m \
+  scripts/statistics/tests/mcnemar_test.m \
+  scripts/statistics/tests/prop_test_2.m \
+  scripts/statistics/tests/run_test.m \
+  scripts/statistics/tests/sign_test.m \
+  scripts/statistics/tests/t_test.m \
+  scripts/statistics/tests/t_test_2.m \
+  scripts/statistics/tests/t_test_regression.m \
+  scripts/statistics/tests/u_test.m \
+  scripts/statistics/tests/var_test.m \
+  scripts/statistics/tests/welch_test.m \
+  scripts/statistics/tests/wilcoxon_test.m \
+  scripts/statistics/tests/z_test.m \
+  scripts/statistics/tests/z_test_2.m
 
-FCN_FILES += $(statistics_tests_FCN_FILES)
+scripts_statistics_testsdir = $(fcnfiledir)/statistics/tests
+
+scripts_statistics_tests_DATA = $(scripts_statistics_tests_FCN_FILES)
 
-PKG_ADD_FILES += statistics/tests/PKG_ADD
+FCN_FILES += $(scripts_statistics_tests_FCN_FILES)
 
-DIRSTAMP_FILES += statistics/tests/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/statistics/tests/PKG_ADD
+
+DIRSTAMP_FILES += scripts/statistics/tests/$(octave_dirstamp)
--- a/scripts/statistics/tests/wilcoxon_test.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/statistics/tests/wilcoxon_test.m	Thu Dec 10 12:50:06 2015 -0800
@@ -58,11 +58,11 @@
   x = reshape (x, 1, n);
   y = reshape (y, 1, n);
   d = x - y;
-  d = d (find (d != 0));
+  d = d(find (d != 0));
   n = length (d);
   if (n > 25)
     r = ranks (abs (d));
-    z = sum (r (find (d > 0)));
+    z = sum (r(find (d > 0)));
     z = ((z - n * (n + 1) / 4) / sqrt (n * (n + 1) * (2 * n + 1) / 24));
   else
     error ("wilcoxon_test: implementation requires more than 25 different pairs");
--- a/scripts/strings/cstrcat.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/strings/cstrcat.m	Thu Dec 10 12:50:06 2015 -0800
@@ -45,14 +45,16 @@
 
 function st = cstrcat (varargin)
 
-  if (nargin < 1)
-    print_usage ();
-  elseif (! iscellstr (varargin))
-    error ("cstrcat: expecting arguments to character strings");
+  if (nargin == 0)
+    ## Special because if varargin is empty, iscellstr still returns
+    ## true but then "[varargin{:}]" would be of class double.
+    st = "";
+  elseif (iscellstr (varargin))
+    st = [varargin{:}];
+  else
+    error ("cstrcat: arguments must be character strings");
   endif
 
-  st = [varargin{:}];
-
 endfunction
 
 
@@ -65,7 +67,8 @@
 %!assert (cstrcat ("foo", "bar"), "foobar")
 %!assert (cstrcat (["a"; "bb"], ["foo"; "bar"]), ["a foo"; "bbbar"])
 
+%!assert (cstrcat (), "")
+
 ## Test input validation
-%!error cstrcat ()
 %!error cstrcat (1, 2)
 
--- a/scripts/strings/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/strings/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,39 +1,43 @@
-FCN_FILE_DIRS += strings
+FCN_FILE_DIRS += scripts/strings
 
-strings_FCN_FILES = \
-  strings/base2dec.m \
-  strings/bin2dec.m \
-  strings/blanks.m \
-  strings/cstrcat.m \
-  strings/deblank.m \
-  strings/dec2base.m \
-  strings/dec2bin.m \
-  strings/dec2hex.m \
-  strings/findstr.m \
-  strings/hex2dec.m \
-  strings/index.m \
-  strings/isletter.m \
-  strings/isstrprop.m \
-  strings/mat2str.m \
-  strings/ostrsplit.m \
-  strings/regexptranslate.m \
-  strings/rindex.m \
-  strings/str2num.m \
-  strings/strcat.m \
-  strings/strchr.m \
-  strings/strjoin.m \
-  strings/strjust.m \
-  strings/strmatch.m \
-  strings/strsplit.m \
-  strings/strtok.m \
-  strings/strtrim.m \
-  strings/strtrunc.m \
-  strings/substr.m \
-  strings/untabify.m \
-  strings/validatestring.m
+scripts_strings_FCN_FILES = \
+  scripts/strings/base2dec.m \
+  scripts/strings/bin2dec.m \
+  scripts/strings/blanks.m \
+  scripts/strings/cstrcat.m \
+  scripts/strings/deblank.m \
+  scripts/strings/dec2base.m \
+  scripts/strings/dec2bin.m \
+  scripts/strings/dec2hex.m \
+  scripts/strings/findstr.m \
+  scripts/strings/hex2dec.m \
+  scripts/strings/index.m \
+  scripts/strings/isletter.m \
+  scripts/strings/isstrprop.m \
+  scripts/strings/mat2str.m \
+  scripts/strings/ostrsplit.m \
+  scripts/strings/regexptranslate.m \
+  scripts/strings/rindex.m \
+  scripts/strings/str2num.m \
+  scripts/strings/strcat.m \
+  scripts/strings/strchr.m \
+  scripts/strings/strjoin.m \
+  scripts/strings/strjust.m \
+  scripts/strings/strmatch.m \
+  scripts/strings/strsplit.m \
+  scripts/strings/strtok.m \
+  scripts/strings/strtrim.m \
+  scripts/strings/strtrunc.m \
+  scripts/strings/substr.m \
+  scripts/strings/untabify.m \
+  scripts/strings/validatestring.m
 
-FCN_FILES += $(strings_FCN_FILES)
+scripts_stringsdir = $(fcnfiledir)/strings
+
+scripts_strings_DATA = $(scripts_strings_FCN_FILES)
 
-PKG_ADD_FILES += strings/PKG_ADD
+FCN_FILES += $(scripts_strings_FCN_FILES)
 
-DIRSTAMP_FILES += strings/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/strings/PKG_ADD
+
+DIRSTAMP_FILES += scripts/strings/$(octave_dirstamp)
--- a/scripts/strings/strcat.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/strings/strcat.m	Thu Dec 10 12:50:06 2015 -0800
@@ -82,10 +82,8 @@
 function st = strcat (varargin)
 
   if (nargin == 0)
-    print_usage ();
-  endif
-
-  if (nargin == 1)
+    st = "";
+  elseif (nargin == 1)
     st = varargin{1};
   else
     ## Convert to cells of strings
@@ -149,5 +147,5 @@
 %!assert (strcat (1, 2), strcat (char (1), char (2)))
 %!assert (strcat ("", 2), strcat ([], char (2)))
 
-%!error strcat ()
+%!assert (strcat (), "")
 
--- a/scripts/strings/validatestring.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/strings/validatestring.m	Thu Dec 10 12:50:06 2015 -0800
@@ -114,7 +114,7 @@
   matches = strncmpi (str, strarray(:), length (str));
   nmatches = sum (matches);
   if (nmatches == 0)
-    error ("%sdoes not match any of\n%s", errstr,
+    error ("validatestring: %sdoes not match any of\n%s", errstr,
            sprintf ("%s, ", strarray{:})(1:end-2));
   elseif (nmatches == 1)
     str = strarray{matches};
@@ -129,7 +129,7 @@
     if (all (submatch))
       str = short_str;
     else
-      error ("%sallows multiple unique matches:\n%s",
+      error ("validatestring: %sallows multiple unique matches:\n%s",
              errstr, sprintf ("%s, ", strarray{match_idx})(1:end-2));
     endif
   endif
--- a/scripts/testfun/__run_test_suite__.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/testfun/__run_test_suite__.m	Thu Dec 10 12:50:06 2015 -0800
@@ -21,7 +21,8 @@
 ## Undocumented internal function.
 ## @end deftypefn
 
-function __run_test_suite__ (fcndirs, fixedtestdirs)
+function [pass, fail, xfail, skip] = __run_test_suite__ (fcndirs, fixedtestdirs)
+
   testsdir = octave_config_info ("octtestsdir");
   libinterptestdir = fullfile (testsdir, "libinterp");
   liboctavetestdir = fullfile (testsdir, "liboctave");
@@ -49,7 +50,7 @@
     try
       fid = fopen (logfile, "wt");
       if (fid < 0)
-        error ("could not open %s for writing", logfile);
+        error ("__run_test_suite__: could not open %s for writing", logfile);
       endif
       test ("", "explain", fid);
       dp = dn = dxf = dsk = 0;
@@ -117,6 +118,14 @@
     warning (orig_wstate);
     page_screen_output (pso);
   end_unwind_protect
+
+  if (nargout > 0)
+    pass = np;
+    fail = nfail;
+    xfail = dxf;
+    skip = xsk;
+  endif
+
 endfunction
 
 function print_test_file_name (nm)
@@ -151,7 +160,7 @@
       retval = ! isempty (regexp (str,'^(DEFUN|DEFUN_DLD)\>',
                                       'lineanchors', 'once'));
     else
-      error ("fopen failed: %s", f);
+      error ("__run_test_suite__: fopen failed: %s", f);
     endif
   elseif (n > 2 && strcmpi (f((end-1):end), ".m"))
     retval = true;
@@ -169,7 +178,7 @@
                                 '^%!(assert|error|fail|test|xtest|warning)',
                                 'lineanchors', 'once'));
   else
-    error ("fopen failed: %s", f);
+    error ("__run_test_suite__: fopen failed: %s", f);
   endif
 endfunction
 
--- a/scripts/testfun/assert.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/testfun/assert.m	Thu Dec 10 12:50:06 2015 -0800
@@ -77,7 +77,7 @@
 
   unwind_protect
 
-    call_depth++;
+    call_depth += 1;
 
     if (call_depth == 0)
       errmsg = "";
@@ -399,7 +399,7 @@
     endif
 
   unwind_protect_cleanup
-    call_depth--;
+    call_depth -= 1;
   end_unwind_protect
 
   if (call_depth == -1)
--- a/scripts/testfun/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/testfun/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,21 +1,25 @@
-FCN_FILE_DIRS += testfun
+FCN_FILE_DIRS += scripts/testfun
 
-testfun_FCN_FILES = \
-  testfun/__have_feature__.m \
-  testfun/__printf_assert__.m \
-  testfun/__prog_output_assert__.m \
-  testfun/__run_test_suite__.m \
-  testfun/assert.m \
-  testfun/demo.m \
-  testfun/example.m \
-  testfun/fail.m \
-  testfun/rundemos.m \
-  testfun/runtests.m \
-  testfun/speed.m \
-  testfun/test.m
+scripts_testfun_FCN_FILES = \
+  scripts/testfun/__have_feature__.m \
+  scripts/testfun/__printf_assert__.m \
+  scripts/testfun/__prog_output_assert__.m \
+  scripts/testfun/__run_test_suite__.m \
+  scripts/testfun/assert.m \
+  scripts/testfun/demo.m \
+  scripts/testfun/example.m \
+  scripts/testfun/fail.m \
+  scripts/testfun/rundemos.m \
+  scripts/testfun/runtests.m \
+  scripts/testfun/speed.m \
+  scripts/testfun/test.m
 
-FCN_FILES += $(testfun_FCN_FILES)
+scripts_testfundir = $(fcnfiledir)/testfun
+
+scripts_testfun_DATA = $(scripts_testfun_FCN_FILES)
 
-PKG_ADD_FILES += testfun/PKG_ADD
+FCN_FILES += $(scripts_testfun_FCN_FILES)
 
-DIRSTAMP_FILES += testfun/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/testfun/PKG_ADD
+
+DIRSTAMP_FILES += scripts/testfun/$(octave_dirstamp)
--- a/scripts/testfun/private/html_compare_plot_demos.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/testfun/private/html_compare_plot_demos.m	Thu Dec 10 12:50:06 2015 -0800
@@ -95,16 +95,16 @@
       ## set default
       column_header = upper (toolkits{t});
       if (isfield (in, toolkits{t}))
-        column_header = strcat (column_header, in.(toolkits{t}));
+        column_header = [column_header, in.(toolkits{t})];
       endif
       fprintf (fid, '<th>%s <a href="%s/diary.log">diary</a></th>\n', ...
                     column_header, toolkits{t});
     endfor
     fprintf (fid, "</tr>\n");
 
-    for m = 1:numel(in.figfiles)
+    for m = 1:numel (in.figfiles)
       [~, file] = fileparts (in.figfiles{m});
-      fn = strcat (file, ".", in.fmt);
+      fn = [file "." in.fmt];
       fprintf (fid, "<tr>\n");
       for k = toolkits
         ffn = fullfile (k{:}, fn);
@@ -113,7 +113,7 @@
           fprintf (fid, "<img src='%s' style='width: %dpx;'>", ...
                         ffn, in.column_width);
         else
-          err_fn = regexprep(ffn, ".png", ".err");
+          err_fn = strrep (ffn, ".png", ".err");
           if (! exist (err_fn, "file"))
             warning("File %s doesn't exist...", err_fn);
           else
--- a/scripts/testfun/runtests.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/testfun/runtests.m	Thu Dec 10 12:50:06 2015 -0800
@@ -111,7 +111,7 @@
       retval = ! isempty (regexp (str,'^(?:DEFUN|DEFUN_DLD|DEFUNX)\>',
                                       'lineanchors', 'once'));
     else
-      error ("fopen failed: %s", f);
+      error ("runtests: fopen failed: %s", f);
     endif
   elseif (n > 2 && strcmpi (f((end-1):end), ".m"))
     retval = true;
--- a/scripts/testfun/test.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/testfun/test.m	Thu Dec 10 12:50:06 2015 -0800
@@ -189,7 +189,7 @@
     fprintf (__fid, "# %s test was skipped\n", __signal_skip);
     fprintf (__fid, "# %s code for the test\n\n", __signal_block);
     fprintf (__fid, "# Search for the unexpected results in the file\n");
-    fprintf (__fid, "# then page back to find the file name which caused it.\n");
+    fprintf (__fid, "# then page back to find the filename which caused it.\n");
     fprintf (__fid, "# The result may be an unexpected failure (in which\n");
     fprintf (__fid, "# case an error will be reported) or an unexpected\n");
     fprintf (__fid, "# success (in which case no error will be reported).\n");
@@ -537,7 +537,7 @@
           __istest = true;
           __code = __code(__e + 1 : end);
         else
-          __xskip++;
+          __xskip += 1;
           __istest = false;
           __code = ""; # Skip the code.
           __msg = [__signal_skip "skipped test\n"];
@@ -588,14 +588,14 @@
         catch
           if (strcmp (__type, "xtest"))
             __msg = [__signal_fail "known failure\n" lasterr()];
-            __xfail++;
+            __xfail += 1;
             __success = false;
           else
             __msg = [__signal_fail "test failed\n" lasterr()];
             __success = false;
           endif
           if (isempty (lasterr ()))
-            error ("empty error text, probably Ctrl-C --- aborting");
+            error ("test: empty error text, probably Ctrl-C --- aborting");
           endif
         end_try_catch
         clear __test__;
@@ -609,14 +609,13 @@
           fflush (__fid);
         endif
         fprintf (__fid, "%s\n", __msg);
-        fflush (__fid);
         ## Show the variable context.
         if (! strcmp (__type, "error") && ! strcmp (__type, "testif")
             && ! all (__shared == " "))
           fputs (__fid, "shared variables ");
           eval (sprintf ("fdisp(__fid,var2struct(%s));", __shared));
-          fflush (__fid);
         endif
+        fflush (__fid);
       endif
       if (! __success && ! __isxtest)
         __all_success = false;
@@ -703,7 +702,7 @@
   if (isempty (left))
     return;
   endif
-  left++;
+  left += 1;
 
   ## Return the end points of the name.
   pos = [left, right];
@@ -801,14 +800,14 @@
 ## Test 'fail' keyword
 %!fail ("test", "Invalid call to 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 ("test", "invalid")', "unknown flag")  # incorrect args
 %!fail ('garbage','garbage.*undefined')  # usage on nonexistent function should be
 
 ## Test 'error' keyword
 %!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
-%!error test ("test", "bogus");  # test without pattern
+%!error <unknown flag> test ("test", "invalid"); # incorrect args
+%!error test ("test", "invalid");  # test without pattern
 %!error <'garbage' undefined> garbage; # usage on nonexistent function is error
 
 ## Test 'warning' keyword
@@ -874,7 +873,7 @@
 %!         " a=3                  # single line demo blocks work too");
 
 ## Test 'testif' keyword
-%!testif HAVE_BOGUS_FEATURE
+%!testif HAVE_INVALID_FEATURE
 %! error ("testif executed code despite not having feature");
 
 ## Test 'xtest' keyword
@@ -899,7 +898,7 @@
 ## like to be presented with expected failures.  I use '% !' to disable.
 % !test   error("---------Failure tests.  Use test('test','verbose',1)");
 % !test   assert([a,b,c],[1,3,6]);   # variables have wrong values
-% !bogus                     # unknown block type
+% !invalid                   # unknown block type
 % !error  toeplitz([1,2,3]); # correct usage
 % !test   syntax errors)     # syntax errors fail properly
 % !shared garbage in         # variables must be comma separated
--- a/scripts/time/datevec.m	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/time/datevec.m	Thu Dec 10 12:50:06 2015 -0800
@@ -183,9 +183,9 @@
     srnd = 2 .^ floor (- log2 (tmps));
     s = round (86400 * fracd .* srnd) ./ srnd;
     h = floor (s / 3600);
-    s = s - 3600 * h;
+    s -= 3600 * h;
     mi = floor (s / 60);
-    s = s - 60 * mi;
+    s -= 60 * mi;
 
   endif
 
@@ -257,23 +257,23 @@
     ## Find location of FFF in ds.
     ## Might not match idx because of things like yyyy -> %y.
     [~, nc] = strptime (ds, f(1:idx-1));
-    
+
     msec = ds(nc:min (nc+2,end)); # pull 3-digit fractional seconds.
     msec_idx = find (! isdigit (msec), 1);
-    
+
     if (! isempty (msec_idx))  # non-digits in msec
       msec = msec(1:msec_idx-1);
       msec(end+1:3) = "0";     # pad msec with trailing zeros
       ds = [ds(1:(nc-1)), msec, ds((nc-1)+msec_idx:end)];  # zero pad ds
     elseif (numel (msec) < 3)  # less than three digits in msec
-      m_len = numel (msec); 
+      m_len = numel (msec);
       msec(end+1:3) = "0";     # pad msec with trailing zeros
       ds = [ds(1:(nc-1)), msec, ds(nc+m_len:end)];  # zero pad ds as well
     endif
-    
+
     ## replace FFF with digits to guarantee match in strptime.
     f(idx:idx+2) = msec;
-  
+
     if (nc > 0)
       [tm, nc] = strptime (ds, f);
       tm.usec = 1000 * str2double (msec);
--- a/scripts/time/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/scripts/time/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,23 +1,27 @@
-FCN_FILE_DIRS += time
+FCN_FILE_DIRS += scripts/time
 
-time_FCN_FILES = \
-  time/addtodate.m \
-  time/asctime.m \
-  time/calendar.m \
-  time/clock.m \
-  time/ctime.m \
-  time/date.m \
-  time/datenum.m \
-  time/datestr.m \
-  time/datevec.m \
-  time/eomday.m \
-  time/etime.m \
-  time/is_leap_year.m \
-  time/now.m \
-  time/weekday.m
+scripts_time_FCN_FILES = \
+  scripts/time/addtodate.m \
+  scripts/time/asctime.m \
+  scripts/time/calendar.m \
+  scripts/time/clock.m \
+  scripts/time/ctime.m \
+  scripts/time/date.m \
+  scripts/time/datenum.m \
+  scripts/time/datestr.m \
+  scripts/time/datevec.m \
+  scripts/time/eomday.m \
+  scripts/time/etime.m \
+  scripts/time/is_leap_year.m \
+  scripts/time/now.m \
+  scripts/time/weekday.m
 
-FCN_FILES += $(time_FCN_FILES)
+scripts_timedir = $(fcnfiledir)/time
+
+scripts_time_DATA = $(scripts_time_FCN_FILES)
 
-PKG_ADD_FILES += time/PKG_ADD
+FCN_FILES += $(scripts_time_FCN_FILES)
 
-DIRSTAMP_FILES += time/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/time/PKG_ADD
+
+DIRSTAMP_FILES += scripts/time/$(octave_dirstamp)
--- a/src/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,199 +0,0 @@
-# Makefile for Octave's src directory
-#
-# Copyright (C) 1993-2015 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 $(top_srcdir)/build-aux/common.mk
-
-## Search local directories before those specified by the user.
-AM_CPPFLAGS = \
-  -I$(top_srcdir)/liboctave/array \
-  -I$(top_srcdir)/liboctave/cruft/misc \
-  -I$(top_srcdir)/liboctave/numeric \
-  -I$(top_srcdir)/liboctave/system \
-  -I$(top_srcdir)/liboctave/util \
-  -I$(top_srcdir)/libinterp \
-  -I$(top_builddir)/libinterp/corefcn -I$(top_srcdir)/libinterp/corefcn \
-  -I$(top_builddir)/libgnu -I$(top_srcdir)/libgnu
-
-AM_CFLAGS += $(WARN_CFLAGS)
-
-AM_CXXFLAGS += $(WARN_CXXFLAGS)
-
-EXTRA_DIST = \
-  main.in.cc \
-  mkoctfile.in.cc \
-  octave-config.in.cc
-
-DISTCLEANFILES = \
-  main.cc \
-  mkoctfile.cc \
-  octave-config.cc
-
-bin_PROGRAMS = \
-  mkoctfile \
-  octave \
-  octave-cli \
-  octave-config
-
-noinst_HEADERS = \
-  display-available.h	\
-  shared-fcns.h
-
-OCTAVE_VERSION_LINKS = octave-cli-$(version)$(EXEEXT)
-
-archlib_PROGRAMS =
-
-if AMCOND_BUILD_GUI
-  archlib_PROGRAMS += octave-gui
-  OCTAVE_VERSION_LINKS += octave-gui-$(version)$(EXEEXT)
-endif
-
-OCTAVE_CORE_LIBS = \
-  $(top_builddir)/libinterp/liboctinterp.la \
-  $(top_builddir)/liboctave/liboctave.la
-
-include ../libgui/link-deps.mk
-
-nodist_octave_SOURCES = main.cc
-octave_SOURCES = display-available.c
-
-octave_LDADD = \
-  $(top_builddir)/libgnu/libgnu.la \
-  $(X11_LIBS) \
-  $(CARBON_LIBS) \
-  $(GNULIB_LINK_DEPS)
-
-octave_LDFLAGS = \
-  $(NO_UNDEFINED_LDFLAG) \
-  $(OCTAVE_LINK_OPTS)
-
-if AMCOND_BUILD_GUI
-  OCTAVE_CPPFLAGS = -DHAVE_OCTAVE_GUI
-endif
-
-octave_CPPFLAGS = \
-  $(AM_CPPFLAGS) \
-  $(OCTAVE_CPPFLAGS)
-
-octave_cli_SOURCES = main-cli.cc
-
-octave_cli_LDADD = \
-  $(OCTAVE_CORE_LIBS) \
-  $(OCTAVE_LINK_DEPS)
-
-octave_cli_LDFLAGS = \
-  $(NO_UNDEFINED_LDFLAG) \
-  $(OCTAVE_LINK_OPTS)
-
-if AMCOND_BUILD_GUI
-  octave_gui_SOURCES = main-gui.cc
-  OCTAVE_GUI_LIBS = $(top_builddir)/libgui/liboctgui.la
-  OCTAVE_GUI_CPPFLAGS = -I$(top_srcdir)/libgui/src
-endif
-
-octave_gui_CPPFLAGS = \
-  $(AM_CPPFLAGS) \
-  $(OCTAVE_GUI_CPPFLAGS)
-
-octave_gui_LDADD = \
-  $(OCTAVE_GUI_LIBS) \
-  $(OCTAVE_CORE_LIBS) \
-  $(OCTAVE_GUI_LINK_DEPS)
-
-octave_gui_LDFLAGS = \
-  $(NO_UNDEFINED_LDFLAG) \
-  $(OCTAVE_GUI_LINK_OPTS)
-
-mkoctfile_SOURCES =
-nodist_mkoctfile_SOURCES = mkoctfile.cc
-mkoctfile_LDADD = $(top_builddir)/libgnu/libgnu.la $(LIBS)
-
-octave_config_SOURCES =
-nodist_octave_config_SOURCES = octave-config.cc
-octave_config_LDADD = \
-  $(top_builddir)/libinterp/corefcn/libcorefcn.la \
-  $(top_builddir)/libgnu/libgnu.la \
-  $(LIBS)
-
-OCTAVE_CROSS_TOOLS=
-if AMCOND_CROSS_TOOLS
-# building cross mkoctfile
-OCTAVE_CROSS_TOOLS += $(host_triplet)-mkoctfile$(BUILD_EXEEXT)
-$(host_triplet)-mkoctfile$(BUILD_EXEEXT): $(host_triplet)-mkoctfile.cc
-	$(BUILD_CXX) -o $(host_triplet)-mkoctfile$(BUILD_EXEEXT) -Dgnulib='' -Doctave_idx_type=int $(DEFAULT_INCLUDES) $(BUILD_CXXFLAGS) $(BUILD_LDFLAGS) $(host_triplet)-mkoctfile.cc
-$(host_triplet)-mkoctfile.cc: mkoctfile.in.cc Makefile
-	$(AM_V_GEN)$(do_subst_cross_config_vals)
-
-# building cross octave-config
-OCTAVE_CROSS_TOOLS += $(host_triplet)-octave-config$(BUILD_EXEEXT)
-$(host_triplet)-octave-config$(BUILD_EXEEXT): $(host_triplet)-octave-config.cc
-	$(BUILD_CXX) -o $(host_triplet)-octave-config$(BUILD_EXEEXT) -Dgnulib='' -Doctave_idx_type=int $(DEFAULT_INCLUDES) $(BUILD_CXXFLAGS) $(BUILD_LDFLAGS) $(host_triplet)-octave-config.cc
-$(host_triplet)-octave-config.cc: octave-config.in.cc Makefile
-	$(AM_V_GEN)$(do_subst_default_vals)
-
-mostlyclean-local:
-	-rm -f $(OCTAVE_CROSS_TOOLS)
-
-endif
-
-all-local: $(OCTAVE_VERSION_LINKS) $(OCTAVE_CROSS_TOOLS)
-
-octave-config.cc: octave-config.in.cc Makefile
-	$(AM_V_GEN)$(do_subst_default_vals)
-
-mkoctfile.cc: mkoctfile.in.cc Makefile
-	$(AM_V_GEN)$(do_subst_config_vals)
-
-## main.cc 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.
-main.cc: main.in.cc Makefile
-	$(AM_V_GEN)$(do_subst_default_vals)
-
-install-exec-hook: make-version-links
-
-uninstall-local: remove-version-links
-
-make-version-links:
-	cd $(DESTDIR)$(bindir) && \
-	for f in $(basename $(bin_PROGRAMS)); do \
-	  mv $$f$(EXEEXT) $$f-$(version)$(EXEEXT) && \
-	    $(LN_S) $$f-$(version)$(EXEEXT) $$f$(EXEEXT); \
-	done
-
-remove-version-links:
-	for f in $(basename $(bin_PROGRAMS)); do \
-	  rm -f $(DESTDIR)$(bindir)/$$f-$(version)$(EXEEXT); \
-	done
-
-.PHONY: make-version-links remove-version-links
-
-## We need these file names in the build tree because the wrapper
-## program (main.cc) will try to invoke the versioned binaries.
-
-octave-cli-$(version)$(EXEEXT): octave-cli$(EXEEXT)
-	$(AM_V_GEN)rm -f $@ && \
-	$(LN_S) $< $@
-
-octave-gui-$(version)$(EXEEXT): octave-gui$(EXEEXT)
-	$(AM_V_GEN)rm -f $@ && \
-	$(LN_S) $< $@
-
-CLEANFILES = \
-  $(OCTAVE_VERSION_LINKS)
--- a/src/main.in.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/src/main.in.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -436,7 +436,7 @@
 #if defined (HAVE_OCTAVE_GUI)
   // The Octave version number is already embedded in the
   // octave_archlibdir directory name so we don't need to append it to
-  // the octave-gui file name.
+  // the octave-gui filename.
 
   std::string file = octave_archlibdir + dir_sep_char + "octave-gui";
 #else
--- a/src/mkoctfile.in.cc	Tue Dec 08 07:49:49 2015 -0800
+++ b/src/mkoctfile.in.cc	Thu Dec 10 12:50:06 2015 -0800
@@ -256,7 +256,7 @@
 "\n"
 "  -c, --compile           Compile, but do not link.\n"
 "\n"
-"  -o FILE, --output FILE  Output file name.  Default extension is .oct\n"
+"  -o FILE, --output FILE  Output filename.  Default extension is .oct\n"
 "                          (or .mex if --mex is specified) unless linking\n"
 "                          a stand-alone executable.\n"
 "\n"
@@ -503,7 +503,7 @@
               outputfile = arg;
             }
           else
-            std::cerr << "mkoctfile: output file name missing" << std::endl;
+            std::cerr << "mkoctfile: output filename missing" << std::endl;
         }
       else if (arg == "-p" || arg == "-print" || arg == "--print")
         {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,250 @@
+src_EXTRA_DIST =
+
+src_CLEANFILES =
+src_DISTCLEANFILES =
+src_MAINTAINERCLEANFILES =
+
+## Search local directories before those specified by the user.
+
+SRC_DIR_CPPFLAGS = \
+  -I$(top_srcdir)/liboctave/array \
+  -I$(top_srcdir)/liboctave/cruft/misc \
+  -I$(top_srcdir)/liboctave/numeric \
+  -I$(top_srcdir)/liboctave/system \
+  -I$(top_srcdir)/liboctave/util \
+  -I$(top_srcdir)/libinterp \
+  -I$(top_builddir)/libinterp/corefcn -I$(top_srcdir)/libinterp/corefcn \
+  -I$(top_srcdir)/src \
+  -I$(top_builddir)/libgnu -I$(top_srcdir)/libgnu
+
+EXTRA_DIST += \
+  src/main.in.cc \
+  src/mkoctfile.in.cc \
+  src/octave-config.in.cc
+
+DISTCLEANFILES += \
+  src/main.cc \
+  src/mkoctfile.cc \
+  src/octave-config.cc
+
+bin_PROGRAMS += \
+  src/mkoctfile \
+  src/octave \
+  src/octave-cli \
+  src/octave-config
+
+OCTAVE_INTERPRETER_TARGETS += \
+  $(bin_PROGRAMS) \
+  $(OCTAVE_VERSION_LINKS)
+
+noinst_HEADERS += \
+  src/display-available.h	\
+  src/shared-fcns.h
+
+OCTAVE_VERSION_LINKS += src/octave-cli-$(version)$(EXEEXT)
+
+if AMCOND_BUILD_GUI
+  archlib_PROGRAMS += src/octave-gui
+  OCTAVE_VERSION_LINKS += src/octave-gui-$(version)$(EXEEXT)
+
+  OCTAVE_INTERPRETER_TARGETS += src/octave-gui$(EXEEXT)
+endif
+
+OCTAVE_CORE_LIBS = \
+  $(top_builddir)/libinterp/liboctinterp.la \
+  $(top_builddir)/liboctave/liboctave.la
+
+nodist_src_octave_SOURCES = src/main.cc
+src_octave_SOURCES = src/display-available.c
+
+src_octave_LDADD = \
+  $(top_builddir)/libgnu/libgnu.la \
+  $(X11_LIBS) \
+  $(CARBON_LIBS) \
+  $(GNULIB_LINK_DEPS)
+
+src_octave_LDFLAGS = \
+  $(NO_UNDEFINED_LDFLAG) \
+  $(OCTAVE_LINK_OPTS) \
+  $(WARN_LDFLAGS)
+
+if AMCOND_BUILD_GUI
+  OCTAVE_CPPFLAGS = -DHAVE_OCTAVE_GUI
+endif
+
+src_octave_CPPFLAGS = \
+  $(SRC_DIR_CPPFLAGS) \
+  $(OCTAVE_CPPFLAGS)
+
+src_octave_CXXFLAGS = \
+  $(AM_CXXFLAGS) \
+  $(WARN_CXXFLAGS)
+
+src_octave_cli_SOURCES = src/main-cli.cc
+
+src_octave_cli_LDADD = \
+  $(OCTAVE_CORE_LIBS) \
+  $(OCTAVE_LINK_DEPS)
+
+src_octave_cli_LDFLAGS = \
+  $(NO_UNDEFINED_LDFLAG) \
+  $(OCTAVE_LINK_OPTS) \
+  $(WARN_LDFLAGS)
+
+src_octave_cli_CPPFLAGS = \
+  $(SRC_DIR_CPPFLAGS) \
+  $(OCTAVE_CPPFLAGS)
+
+src_octave_cli_CXXFLAGS = \
+  $(AM_CXXFLAGS) \
+  $(WARN_CXXFLAGS)
+
+if AMCOND_BUILD_GUI
+  src_octave_gui_SOURCES = src/main-gui.cc
+  OCTAVE_GUI_LIBS = $(top_builddir)/libgui/liboctgui.la
+  OCTAVE_GUI_CPPFLAGS = -I$(top_srcdir)/libgui/src
+endif
+
+src_octave_gui_CPPFLAGS = \
+  $(SRC_DIR_CPPFLAGS) \
+  $(OCTAVE_GUI_CPPFLAGS)
+
+src_octave_gui_LDADD = \
+  $(OCTAVE_GUI_LIBS) \
+  $(OCTAVE_CORE_LIBS) \
+  $(OCTAVE_GUI_LINK_DEPS)
+
+src_octave_gui_LDFLAGS = \
+  $(NO_UNDEFINED_LDFLAG) \
+  $(OCTAVE_GUI_LINK_OPTS) \
+  $(WARN_LDFLAGS)
+
+src_octave_gui_CXXFLAGS = \
+  $(AM_CXXFLAGS) \
+  $(WARN_CXXFLAGS)
+
+src_mkoctfile_SOURCES =
+
+nodist_src_mkoctfile_SOURCES = src/mkoctfile.cc
+
+src_mkoctfile_LDADD = $(top_builddir)/libgnu/libgnu.la $(LIBS)
+
+src_mkoctfile_CPPFLAGS = \
+  $(SRC_DIR_CPPFLAGS) \
+  $(OCTAVE_CPPFLAGS)
+
+src_mkoctfile_CXXFLAGS = \
+  $(AM_CXXFLAGS) \
+  $(WARN_CXXFLAGS)
+
+src_octave_config_SOURCES =
+
+nodist_src_octave_config_SOURCES = src/octave-config.cc
+
+src_octave_config_LDADD = \
+  $(top_builddir)/libinterp/corefcn/libcorefcn.la \
+  $(top_builddir)/libgnu/libgnu.la \
+  $(LIBS)
+
+src_octave_config_CPPFLAGS = \
+  $(SRC_DIR_CPPFLAGS) \
+  $(OCTAVE_CPPFLAGS)
+
+src_octave_config_CXXFLAGS = \
+  $(AM_CXXFLAGS) \
+  $(WARN_CXXFLAGS)
+
+DIRSTAMP_FILES += src/$(octave_dirstamp)
+
+mostlyclean-local: src-mostlyclean-local
+.PHONY: src-mostlyclean-local
+
+if AMCOND_CROSS_TOOLS
+
+## Building cross mkoctfile.
+
+OCTAVE_CROSS_TOOLS += src/$(host_triplet)-mkoctfile$(BUILD_EXEEXT)
+
+src/$(host_triplet)-mkoctfile$(BUILD_EXEEXT): src/$(host_triplet)-mkoctfile.cc
+	$(BUILD_CXX) -o src/$(host_triplet)-mkoctfile$(BUILD_EXEEXT) -Dgnulib='' -Doctave_idx_type=int $(DEFAULT_INCLUDES) $(BUILD_CXXFLAGS) $(BUILD_LDFLAGS) -I$(top_srcdir)/src src/$(host_triplet)-mkoctfile.cc
+
+src/$(host_triplet)-mkoctfile.cc: src/mkoctfile.in.cc Makefile | src/$(octave_dirstamp)
+	$(AM_V_GEN)$(do_subst_cross_config_vals)
+
+## Building cross octave-config.
+
+OCTAVE_CROSS_TOOLS += src/$(host_triplet)-octave-config$(BUILD_EXEEXT)
+
+src/$(host_triplet)-octave-config$(BUILD_EXEEXT): src/$(host_triplet)-octave-config.cc
+	$(BUILD_CXX) -o src/$(host_triplet)-octave-config$(BUILD_EXEEXT) -Dgnulib='' -Doctave_idx_type=int $(DEFAULT_INCLUDES) $(BUILD_CXXFLAGS) $(BUILD_LDFLAGS) -I$(top_srcdir)/src src/$(host_triplet)-octave-config.cc
+
+src/$(host_triplet)-octave-config.cc: src/octave-config.in.cc Makefile | src/$(octave_dirstamp)
+	$(AM_V_GEN)$(do_subst_default_vals)
+
+src-mostlyclean-local:
+	-rm -f $(OCTAVE_CROSS_TOOLS)
+
+else
+
+src-mostlyclean-local:
+
+endif
+
+src/octave-config.cc: src/octave-config.in.cc Makefile | src/$(octave_dirstamp)
+	$(AM_V_GEN)$(do_subst_default_vals)
+
+src/mkoctfile.cc: src/mkoctfile.in.cc Makefile | src/$(octave_dirstamp)
+	$(AM_V_GEN)$(do_subst_config_vals)
+
+## main.cc 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.
+
+src/main.cc: src/main.in.cc Makefile | src/$(octave_dirstamp)
+	$(AM_V_GEN)$(do_subst_default_vals)
+
+ALL_LOCAL_TARGETS += $(OCTAVE_VERSION_LINKS) $(OCTAVE_CROSS_TOOLS)
+
+install-exec-hook: make-version-links
+
+uninstall-local: remove-version-links
+
+make-version-links:
+	cd $(DESTDIR)$(bindir) && \
+	for f in $(notdir $(basename $(bin_PROGRAMS))); do \
+	  mv $$f$(EXEEXT) $$f-$(version)$(EXEEXT) && \
+	    $(LN_S) $$f-$(version)$(EXEEXT) $$f$(EXEEXT); \
+	done
+
+remove-version-links:
+	for f in $(notdir $(basename $(bin_PROGRAMS))); do \
+	  rm -f $(DESTDIR)$(bindir)/$$f-$(version)$(EXEEXT); \
+	done
+
+.PHONY: make-version-links remove-version-links
+
+## We need these filenames in the build tree because the wrapper
+## program (main.cc) will try to invoke the versioned binaries.
+
+src/octave-cli-$(version)$(EXEEXT): src/octave-cli$(EXEEXT)
+	$(AM_V_GEN)rm -f $@ && \
+	cd $(@D) && $(LN_S) $(<F) $(@F)
+
+src/octave-gui-$(version)$(EXEEXT): src/octave-gui$(EXEEXT)
+	$(AM_V_GEN)rm -f $@ && \
+	cd $(@D) && $(LN_S) $(<F) $(@F)
+
+src_CLEANFILES += $(OCTAVE_VERSION_LINKS)
+
+CLEANFILES += $(src_CLEANFILES)
+DISTCLEANFILES += $(src_DISTCLEANFILES)
+MAINTAINERCLEANFILES += $(src_MAINTAINERCLEANFILES)
+
+src-clean:
+	rm -f $(src_CLEANFILES)
+
+src-distclean: src-clean
+	rm -f $(src_DISTCLEANFILES)
+
+src-maintainer-clean: src-distclean
+	rm -f $(src_MAINTAINERCLEANFILES)
--- a/test/Makefile.am	Tue Dec 08 07:49:49 2015 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-# Makefile for Octave's test directory
-#
-# Copyright (C) 1994-2015 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 $(top_srcdir)/build-aux/common.mk
-
-FCN_FILES = \
-  fntests.m \
-  args.tst \
-  bug-31371.tst \
-  bug-38576.tst \
-  colormaps.tst \
-  complex.tst \
-  diag-perm.tst \
-  error.tst \
-  eval-catch.tst \
-  for.tst \
-  func.tst \
-  global.tst \
-  if.tst \
-  index.tst \
-  io.tst \
-  jit.tst \
-  line-continue.tst \
-  logical-index.tst \
-  null-assign.tst \
-  parser.tst \
-  prefer.tst \
-  range.tst \
-  recursion.tst \
-  return.tst \
-  slice.tst \
-  struct.tst \
-  switch.tst \
-  system.tst \
-  transpose.tst \
-  try.tst \
-  unwind.tst \
-  while.tst
-
-include bug-35448/module.mk
-include bug-36025/module.mk
-include bug-38236/module.mk
-include bug-38691/module.mk
-include classdef/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
-
-all-local: .gdbinit
-
-.gdbinit: ../etc/gdbinit
-	@$(gdbinit_install_rule)
-
-check: sparse.tst bc-overload-tests.stamp
-	$(top_builddir)/run-octave $(RUN_OCTAVE_OPTIONS) --norc --silent --no-history $(srcdir)/fntests.m $(srcdir)
-
-if AMCOND_HAVE_LLVM
-check-jit: sparse.tst bc-overload-tests.stamp
-	$(top_builddir)/run-octave $(RUN_OCTAVE_OPTIONS) --jit-compiler --norc --silent --no-history $(srcdir)/fntests.m $(srcdir)
-endif
-
-sparse.tst: build-sparse-tests.sh
-	$(AM_V_GEN)$(srcdir)/build-sparse-tests.sh
-
-GENERATED_BC_OVERLOADS_DIRS := \
-  $(shell $(srcdir)/build-bc-overload-tests.sh --list-dirs)
-
-GENERATED_BC_OVERLOADS_FILES := \
-  $(shell $(srcdir)/build-bc-overload-tests.sh --list-files)
-
-bc-overload-tests.stamp: build-bc-overload-tests.sh bc-overloads-expected
-	$(srcdir)/build-bc-overload-tests.sh $(srcdir)/bc-overloads-expected
-	touch $@
-
-BUILT_SOURCES = bc-overload-tests.stamp
-
-EXTRA_DIST = \
-  build-sparse-tests.sh \
-  build-bc-overload-tests.sh \
-  bc-overloads-expected \
-  build_bc_overloads_expected.m \
-  $(FCN_FILES)
-
-CLEANFILES = \
-  sparse.tst \
-  bc-overload-tests.stamp \
-  $(GENERATED_BC_OVERLOADS_FILES)
-
-DISTCLEANFILES = \
-  .gdbinit \
-  fntests.log
-
-fixedtestsdir := $(octtestsdir)/fixed
-
-nobase_fixedtests_DATA = \
-  sparse.tst \
-  $(GENERATED_BC_OVERLOADS_FILES) \
-  $(filter-out fntests.m, $(FCN_FILES))
-
-clean-local:
-	-rm -rf $(GENERATED_BC_OVERLOADS_DIRS)
--- a/test/bug-35448/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/bug-35448/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,7 +1,7 @@
-bug_35448_FCN_FILES = \
-  bug-35448/fA.m \
-  bug-35448/fB.m \
-  bug-35448/fC.m \
-  bug-35448/bug-35448.tst
+bug_35448_TEST_FILES = \
+  test/bug-35448/fA.m \
+  test/bug-35448/fB.m \
+  test/bug-35448/fC.m \
+  test/bug-35448/bug-35448.tst
 
-FCN_FILES += $(bug_35448_FCN_FILES)
+TEST_FILES += $(bug_35448_TEST_FILES)
--- a/test/bug-36025/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/bug-36025/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,7 +1,8 @@
-bug_36025_FCN_FILES = \
-  bug-36025/@testclass/one.m \
-  bug-36025/@testclass/testclass.m \
-  bug-36025/@testclass/two.m \
-  bug-36025/bug-36025.tst
 
-FCN_FILES += $(bug_36025_FCN_FILES)
+bug_36025_TEST_FILES = \
+  test/bug-36025/@testclass/one.m \
+  test/bug-36025/@testclass/testclass.m \
+  test/bug-36025/@testclass/two.m \
+  test/bug-36025/bug-36025.tst
+
+TEST_FILES += $(bug_36025_TEST_FILES)
--- a/test/bug-38236/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/bug-38236/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,6 +1,6 @@
-bug_38236_FCN_FILES = \
-  bug-38236/df_vr.m \
-  bug-38236/u_vr.m \
-  bug-38236/bug-38236.tst
+bug_38236_TEST_FILES = \
+  test/bug-38236/df_vr.m \
+  test/bug-38236/u_vr.m \
+  test/bug-38236/bug-38236.tst
 
-FCN_FILES += $(bug_38236_FCN_FILES)
+TEST_FILES += $(bug_38236_TEST_FILES)
--- a/test/bug-38691/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/bug-38691/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,8 +1,8 @@
-bug_38691_FCN_FILES = \
-  bug-38691/dir1/func1.m \
-  bug-38691/dir2/func1.m \
-  bug-38691/dir2/func2.m \
-  bug-38691/dir2/func3.m \
-  bug-38691/bug-38691.tst
+bug_38691_TEST_FILES = \
+  test/bug-38691/dir1/func1.m \
+  test/bug-38691/dir2/func1.m \
+  test/bug-38691/dir2/func2.m \
+  test/bug-38691/dir2/func3.m \
+  test/bug-38691/bug-38691.tst
 
-FCN_FILES += $(bug_38691_FCN_FILES)
+TEST_FILES += $(bug_38691_TEST_FILES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-44940/bug-44940.tst	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,11 @@
+%!test
+%! a = class_bug44940 ();
+%! b = a;
+%! c = a ();
+%! a.child = 100;
+%! assert (a.child, b.child)
+%! assert (a.child, c.child)
+%! c.child = 500;
+%! assert (a.child, b.child)
+%! assert (a.child, c.child)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-44940/class_bug44940.m	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,5 @@
+classdef class_bug44940 < handle
+  properties
+    child
+  endproperties
+endclassdef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/bug-44940/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,5 @@
+bug_44940_TEST_FILES = \
+  test/bug-44940/bug-44940.tst \
+  test/bug-44940/class_bug44940.m
+
+TEST_FILES += $(bug_44940_TEST_FILES)
--- a/test/build-bc-overload-tests.sh	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/build-bc-overload-tests.sh	Thu Dec 10 12:50:06 2015 -0800
@@ -36,19 +36,21 @@
   function_handle
 "
 
-if [ $# -eq 1 ]; then
+if [ $# -eq 2 ]; then
+  output_dir="$1"
+  shift
   case "$1" in
     --list-files)
-      echo tbcover.m
-      echo bc-overloads.tst
+      echo $output_dir/tbcover.m
+      echo $output_dir/bc-overloads.tst
       for class in $CLASSES; do
-        echo @$class/tbcover.m
+        echo $output_dir/@$class/tbcover.m
       done
       exit
     ;;
     --list-dirs)
       for class in $CLASSES; do
-        echo @$class
+        echo $output_dir/@$class
       done
       exit
     ;;
@@ -61,24 +63,24 @@
     ;;
   esac
 else
-  echo "usage: build_bc_overload_tests.sh expected-results-file" 1>&2
+  echo "usage: build-bc-overload-tests.sh output_dir option" 1>&2
   exit 1
 fi
 
 for class in $CLASSES; do
-  DIR="@$class"
+  DIR="$output_dir/@$class"
   test -d $DIR || mkdir $DIR || { echo "error: could not create $DIR"; exit; }
   cat > $DIR/tbcover.m << EOF
 % !!! DO NOT EDIT !!!
-% generated automatically by build_bc_overload_tests.sh
+% generated automatically by build-bc-overload-tests.sh
 function s = tbcover (x, y)
   s = '$class';
 EOF
 done
 
-cat > tbcover.m << EOF
+cat > $output_dir/tbcover.m << EOF
 % !!! DO NOT EDIT !!!
-% generated automatically by build_bc_overload_tests.sh
+% generated automatically by build-bc-overload-tests.sh
 function s = tbcover (x, y)
   s = 'none';
 EOF
@@ -87,10 +89,10 @@
   exit
 fi
 
-cat > bc-overloads.tst << EOF
+cat > $output_dir/bc-overloads.tst << EOF
 ## !!! DO NOT EDIT !!!
 ## THIS IS AN AUTOMATICALLY GENERATED FILE
-## modify build_bc_overload_tests.sh to generate the tests you need.
+## modify build-bc-overload-tests.sh to generate the tests you need.
 
 %!shared ex
 %! ex.double = 1;
@@ -113,7 +115,7 @@
 
 cat $expected_results_file | \
 while read cl1 cl2 clr ; do
-  cat >> bc-overloads.tst << EOF
+  cat >> $output_dir/bc-overloads.tst << EOF
 %% Name call
 %!assert (tbcover (ex.$cl1, ex.$cl2), "$clr")
 %% Handle call
@@ -122,7 +124,7 @@
 EOF
 done
 
-cat >> bc-overloads.tst << EOF
+cat >> $output_dir/bc-overloads.tst << EOF
 %%test handles through cellfun
 %!test
 %! f = fieldnames (ex);
--- a/test/build-sparse-tests.sh	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/build-sparse-tests.sh	Thu Dec 10 12:50:06 2015 -0800
@@ -1,4 +1,4 @@
-#!/bin/sh
+#! /bin/sh
 
 # Copyright (C) 2006-2015 David Bateman
 #
@@ -21,15 +21,15 @@
 # Some tests are commented out because they are known to be broken!
 # Search for "# fails"
 
-# ./build_sparse_tests.sh preset
+# ./build-sparse-tests.sh preset
 #    creates sparse.tst with preset tests.
 #    Use "test sparse.tst" from octave to run the tests.
 #
-# ./build_sparse_tests.sh random
+# ./build-sparse-tests.sh random
 #    Creates sprandom.tst with randomly generated matrices.
 #    Use "test sprandom.tst" from octave to run the tests.
 
-# build_sparse_tests.sh generates tests for real and complex sparse matrices.
+# build-sparse-tests.sh generates tests for real and complex sparse matrices.
 # Also, we want to run both fixed tests with known outputs (quick tests)
 # and longer tests with unknown outputs (thorough tests).  This requires
 # two sets of tests -- one which uses preset matrices and another which
@@ -110,20 +110,14 @@
     random) preset=false ;;
     preset) preset=true ;;
     '') preset=true ;;
-    *) echo "build_sparse_tests.sh random|preset" && exit 1 ;;
+    *) echo "build-sparse-tests.sh random|preset" && exit 1 ;;
 esac
 
-if $preset; then
-    TESTS=sparse.tst
-else
-    TESTS=sprandom.tst
-fi
-
 # create initial file
-cat >$TESTS <<EOF
+cat <<EOF
 ## !!! DO NOT EDIT !!!
 ## THIS IS AN AUTOMATICALLY GENERATED FILE
-## modify build_sparse_tests.sh to generate the tests you need.
+## modify build-sparse-tests.sh to generate the tests you need.
 EOF
 
 
@@ -134,7 +128,7 @@
 # Section separator
 
 gen_section() {
-cat >>$TESTS <<EOF
+cat <<EOF
 
 # ==============================================================
 
@@ -149,7 +143,7 @@
 # If a sparse operation yields zeros, then those elements
 # of the returned sparse matrix should be eaten.
 gen_eat_zeros() {
-cat >>$TESTS <<EOF
+cat <<EOF
 %% Make sure newly introduced zeros get eaten
 %!assert (nnz (sparse ([bf,bf,1]).^realmax), 1)
 %!assert (nnz (sparse ([1,bf,bf]).^realmax), 1)
@@ -171,7 +165,7 @@
 }
 
 gen_specific() {
-cat >>$TESTS <<EOF
+cat <<EOF
 
 %!test # segfault test from edd@debian.org
 %! n = 510;
@@ -190,7 +184,7 @@
 
 %% error handling in constructor
 %!error sparse (1,[2,3],[1,2,3])
-%!error sparse ([1,1],[1,1],[1,2],3,3,"bogus")
+%!error sparse ([1,1],[1,1],[1,2],3,3,"invalid")
 %!error sparse ([1,3],[1,-4],[3,5],2,2)
 %!error sparse ([1,3],[1,-4],[3,5i],2,2)
 %!error sparse (-1,-1,1)
@@ -202,12 +196,12 @@
     gen_section
     gen_specific
     gen_section
-    echo '%!shared bf' >> $TESTS
-    echo '%!test bf=realmin;' >> $TESTS
+    echo '%!shared bf'
+    echo '%!test bf=realmin;'
     gen_eat_zeros
-    echo '%!test bf=realmin+realmin*1i;' >> $TESTS
+    echo '%!test bf=realmin+realmin*1i;'
     gen_eat_zeros
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!assert (nnz (sparse ([-1,realmin,realmin]).^1.5), 1)
 %!assert (nnz (sparse ([-1,realmin,realmin,1]).^1.5), 2)
 
@@ -231,7 +225,7 @@
 
 gen_function() {
     if $preset; then
-        cat >>$TESTS <<EOF
+        cat <<EOF
 ##
 ## test_sparse
 ##
@@ -243,7 +237,7 @@
 
 EOF
     else
-        cat >>$TESTS <<EOF
+        cat <<EOF
 ##
 ## test_sprandom
 ##
@@ -255,7 +249,7 @@
 ##  end
 ##  The test log is appended to sprandomtest.log
 function [passes,total] = test_sprandom
-  warning ("untested --- fix the source in build_sparse_tests.sh");
+  warning ("untested --- fix the source in build-sparse-tests.sh");
   disp ("appending test output to sprandomtest.log");
   fid = fopen ("sprandomtest.log", "at");
   test ("sprandom.tst", "normal", fid);
@@ -274,7 +268,7 @@
 
 # test ordered comparisons: uses as,af,bs,bf
 gen_ordering_tests() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %% real values can be ordered (uses as,af)
 %!assert (as<=bf, sparse (af<=bf))
 %!assert (bf<=as, sparse (bf<=af))
@@ -292,7 +286,7 @@
 }
 
 gen_sparsesparse_ordering_tests() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!assert (as<=bs, sparse (af<=bf))
 %!assert (as>=bs, sparse (af>=bf))
 %!assert (as<bs, sparse (af<bf))
@@ -302,7 +296,7 @@
 
 # test element-wise binary operations: uses as,af,bs,bf,scalar
 gen_elementop_tests() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %% Elementwise binary tests (uses as,af,bs,bf,scalar)
 %!assert (as==bs, sparse (af==bf))
 %!assert (bf==as, sparse (bf==af))
@@ -332,7 +326,7 @@
 }
 
 gen_sparsesparse_elementop_tests() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!assert (as==bs, sparse (af==bf))
 %!assert (as!=bs, sparse (af!=bf))
 %!assert (as+bs, sparse (af+bf))
@@ -350,7 +344,7 @@
 
 # test matrix-matrix left and right division: uses as,af,bs,bf
 gen_divop_tests() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %% Matrix-matrix operators (uses af,as,bs,bf)
 %!assert (as/bf, af/bf, 100*eps)
 %!assert (af/bs, af/bf, 100*eps)
@@ -364,7 +358,7 @@
 
 # test matrix-matrix left and right division: uses as,af,bs,bf
 gen_square_divop_tests() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %% Matrix-matrix operators (uses af,as,bs,bf)
 %!assert (as/bf, af/bf, 100*eps)
 %!assert (af/bs, af/bf, 100*eps)
@@ -378,7 +372,7 @@
 
 # test matrix-matrix operations: uses as,af,bs,bf
 gen_matrixop_tests() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %% Matrix-matrix operators (uses af,as,bs,bf)
 %!assert (as*bf', af*bf')
 %!assert (af*bs', af*bf')
@@ -389,7 +383,7 @@
 
 # test diagonal operations
 gen_matrixdiag_tests() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %% Matrix diagonal tests (uses af,as,bf,bs)
 %!assert (diag (as), sparse (diag (af)))
 %!assert (diag (bs), sparse (diag (bf)))
@@ -414,7 +408,7 @@
 
 # test matrix reshape operations
 gen_matrixreshape_tests() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %% Matrix diagonal tests (uses af,as,bf,bs)
 %!assert (reshape (as,1,prod(size(as))), sparse (reshape (af,1,prod(size(af)))))
 %!assert (reshape (as,prod(size(as)),1), sparse (reshape (af,prod(size(af)),1)))
@@ -428,11 +422,11 @@
 
 # test mapper matrix operations: uses as,af
 print_mapper_test() {
-echo "%!assert ($1(as), sparse ($1(af)))" >>$TESTS
+echo "%!assert ($1(as), sparse ($1(af)))"
 }
 
 print_real_mapper_test() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!test
 %! wn2s = warning ("query", "Octave:num-to-str");
 %! warning ("off", "Octave:num-to-str");
@@ -449,7 +443,7 @@
 }
 
 gen_mapper_tests() {
-echo "%% Unary matrix tests (uses af,as)">>$TESTS
+echo "%% Unary matrix tests (uses af,as)"
 print_mapper_test abs
 print_mapper_test acos
 print_mapper_test acosh
@@ -483,7 +477,7 @@
 print_mapper_test tanh
 
 # Specific tests for certain mapper functions
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!assert (issparse (abs (as))  && isreal (abs (as)))
 %!assert (issparse (real (as)) && isreal (real (as)))
 %!assert (issparse (imag (as)) && isreal (imag (as)))
@@ -492,7 +486,7 @@
 }
 
 gen_real_mapper_tests() {
-echo "%% Unary matrix tests (uses af,as)">>$TESTS
+echo "%% Unary matrix tests (uses af,as)"
 print_real_mapper_test erf 1
 print_real_mapper_test erfc 1
 #print_real_mapper_test gamma 1
@@ -511,7 +505,7 @@
 #print_real_mapper_test gammaln 1
 
 # Specific tests for certain mapper functions
-    cat >>$TESTS <<EOF
+    cat <<EOF
 
 %!test
 %! wn2s = warning ("query", "Octave:num-to-str");
@@ -528,7 +522,7 @@
 
 # test matrix operations: uses as,af
 gen_unaryop_tests() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %% Unary matrix tests (uses af,as)
 %!assert (issparse (as))
 %!assert (!issparse (af))
@@ -632,7 +626,7 @@
 # The \ and / operator tests on square matrices
     gen_square_divop_tests
 
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!testif HAVE_UMFPACK
 %! assert(det(bs+speye(size(bs))), det(bf+eye(size(bf))), 100*eps*abs(det(bf+eye(size(bf)))))
 
@@ -697,7 +691,7 @@
 
 # Cholesky tests
 gen_cholesky_tests() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!testif HAVE_CHOLMOD
 %! assert (chol (bs)'*chol (bs), bs, 1e-10);
 %!testif HAVE_CHOLMOD
@@ -726,19 +720,19 @@
 
 # test scalar operations: uses af and real scalar bf; modifies as,bf,bs
 gen_scalar_tests() {
-    echo '%!test as = sparse (af);' >> $TESTS
-    echo '%!test bs = bf;' >> $TESTS
+    echo '%!test as = sparse (af);'
+    echo '%!test bs = bf;'
     gen_elementop_tests
     gen_ordering_tests
-    echo '%!test bf = bf+1i;' >>$TESTS
-    echo '%!test bs = bf;' >> $TESTS
+    echo '%!test bf = bf+1i;'
+    echo '%!test bs = bf;'
     gen_elementop_tests
 }
 
 # test matrix operations: uses af and bf; modifies as,bs
 gen_rectangular_tests() {
-    echo '%!test as = sparse(af);' >> $TESTS
-    echo '%!test bs = sparse(bf);' >>$TESTS
+    echo '%!test as = sparse(af);'
+    echo '%!test bs = sparse(bf);'
     gen_mapper_tests
     gen_real_mapper_tests
     gen_unaryop_tests
@@ -748,7 +742,7 @@
     # gen_divop_tests # Disable rectangular \ and / for now
     gen_matrixdiag_tests
     gen_matrixreshape_tests
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!testif HAVE_UMFPACK   # permuted LU
 %! [L,U] = lu (bs);
 %! assert (L*U, bs, 1e-10);
@@ -797,7 +791,7 @@
 # sparse assembly tests
 
 gen_assembly_tests() {
-cat >>$TESTS <<EOF
+cat <<EOF
 %%Assembly tests
 %!test
 %! m = max ([m;r(:)]);
@@ -838,14 +832,14 @@
 # sparse selection tests
 
 gen_scalar_select_tests () {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!assert (sparse (42)([1,1]), sparse ([42,42]))
 %!assert (sparse (42*1i)([1,1]), sparse ([42,42].*1i))
 EOF
 }
 
 gen_select_tests() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!test as = sparse (af);
 
 %% Point tests
@@ -912,7 +906,7 @@
 # sparse save and load tests
 
 gen_save_tests() {
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!test # save ascii
 %! savefile = tempname ();
 %! as_save = as;
@@ -957,14 +951,14 @@
 gen_solver_tests() {
 
 if $preset; then
-  cat >>$TESTS <<EOF
+  cat <<EOF
 %! n=8;
 %! lf=diag (1:n); lf(n-1,1)=0.5*alpha; lf(n,2)=0.25*alpha; ls=sparse (lf);
 %! uf=diag (1:n); uf(1,n-1)=2*alpha; uf(2,n)=alpha; us=sparse (uf);
 %! ts=spdiags (ones (n,3),-1:1,n,n) + diag (1:n); tf = full (ts);
 EOF
 else
-  cat >>$TESTS <<EOF
+  cat <<EOF
 %! n = floor (lognrnd (8,2)+1)';
 %! ls = tril (sprandn (8,8,0.2),-1).*alpha + n*speye (8); lf = full (ls);
 %! us = triu (sprandn (8,8,0.2),1).*alpha + n*speye (8); uf = full (us);
@@ -972,7 +966,7 @@
 EOF
 fi
 
-cat >>$TESTS <<EOF
+cat <<EOF
 %! df = diag (1:n).* alpha; ds = sparse (df);
 %! pdf = df(randperm (n), randperm (n));
 %! pds = sparse (pdf);
@@ -1020,7 +1014,7 @@
 
 EOF
 
-cat >>$TESTS <<EOF
+cat <<EOF
 %% QR solver tests
 
 %!function f (a, sz, feps)
@@ -1154,12 +1148,12 @@
 fi
 
 # scalar operations
-echo '%!shared as,af,bs,bf' >> $TESTS
+echo '%!shared as,af,bs,bf'
 if $preset; then
-    echo '%!test af=[1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4];' >> $TESTS
-    echo '%!test bf=3;' >>$TESTS
+    echo '%!test af=[1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4];'
+    echo '%!test bf=3;'
 else
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!test
 %! % generate m,n from 1 to <5000
 %! m = floor (lognrnd (8,2)+1);
@@ -1175,10 +1169,10 @@
 
 # rectangular operations
 if $preset; then
-    echo '%!test af=[1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4];' >> $TESTS
-    echo '%!test bf=[0,1-1i,0,0;2+1i,0,0,0;3-1i,2+3i,0,0];' >> $TESTS
+    echo '%!test af=[1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4];'
+    echo '%!test bf=[0,1-1i,0,0;2+1i,0,0,0;3-1i,2+3i,0,0];'
 else
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!test
 %! m = floor (lognrnd (8,2)+1);
 %! n = floor (lognrnd (8,2)+1);
@@ -1193,27 +1187,27 @@
 gen_section
 gen_save_tests
 gen_section
-echo '%!test bf = real (bf);' >> $TESTS
+echo '%!test bf = real (bf);'
 gen_rectangular_tests
 gen_section
 gen_sparsesparse_ordering_tests
 gen_section
-echo '%!test af = real (af);' >> $TESTS
+echo '%!test af = real (af);'
 gen_rectangular_tests
 gen_section
 gen_save_tests
 gen_section
-echo '%!test bf = bf+1i*(bf!=0);' >> $TESTS
+echo '%!test bf = bf+1i*(bf!=0);'
 gen_rectangular_tests
 gen_section
 
 # square operations
 if $preset; then
-    echo '%!test af = [1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4];' >> $TESTS
-    echo '%! as = sparse (af);' >> $TESTS
-    echo '%!test bf = [0,1-1i,0,0;2+1i,0,0,0;3-1i,2+3i,0,0];' >> $TESTS
+    echo '%!test af = [1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4];'
+    echo '%! as = sparse (af);'
+    echo '%!test bf = [0,1-1i,0,0;2+1i,0,0,0;3-1i,2+3i,0,0];'
 else
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!test
 %! m = floor (lognrnd (8,2)+1);
 %! n = floor (lognrnd (8,2)+1);
@@ -1224,7 +1218,7 @@
 EOF
 fi
 
-cat >>$TESTS <<EOF
+cat <<EOF
 %!test ;# invertible matrix
 %! bf = af'*bf+max (abs ([af(:);bf(:)]))*sparse (eye (columns (as)));
 %! bs = sparse (bf);
@@ -1233,48 +1227,48 @@
 
 gen_square_tests
 gen_section
-echo '%!test bf = real (bf);' >> $TESTS
-echo '%! bs = sparse (bf);' >> $TESTS
+echo '%!test bf = real (bf);'
+echo '%! bs = sparse (bf);'
 gen_square_tests
 gen_section
-echo '%!test af = real (af);' >> $TESTS
-echo '%! as = sparse (af);' >> $TESTS
+echo '%!test af = real (af);'
+echo '%! as = sparse (af);'
 gen_square_tests
 gen_section
-echo '%!test bf = bf+1i*(bf!=0);' >> $TESTS
-echo '%! bs = sparse (bf);' >> $TESTS
+echo '%!test bf = bf+1i*(bf!=0);'
+echo '%! bs = sparse (bf);'
 gen_square_tests
 gen_section
 
 # cholesky tests
 if $preset; then
-  echo '%!test bf = [5,0,1+1i,0;0,5,0,1-2i;1-1i,0,5,0;0,1+2i,0,5];' >> $TESTS
-  echo '%! bs = sparse (bf);' >> $TESTS
+  echo '%!test bf = [5,0,1+1i,0;0,5,0,1-2i;1-1i,0,5,0;0,1+2i,0,5];'
+  echo '%! bs = sparse (bf);'
 else
-  echo '# This has a small chance of failing to create a positive definite matrix' >> $TESTS
-  echo '%!test n = floor (lognrnd (8,2)+1)' >> $TESTS
-  echo '%! bs = n*speye (n,n) + sprandn (n,n,0.3);' >> $TESTS
-  echo '%! bf = full (bs);' >> $TESTS
+  echo '# This has a small chance of failing to create a positive definite matrix'
+  echo '%!test n = floor (lognrnd (8,2)+1)'
+  echo '%! bs = n*speye (n,n) + sprandn (n,n,0.3);'
+  echo '%! bf = full (bs);'
 fi
 
 gen_cholesky_tests
 gen_section
-echo '%!test bf = real (bf);' >> $TESTS
-echo '%! bs = sparse (bf);' >> $TESTS
+echo '%!test bf = real (bf);'
+echo '%! bs = sparse (bf);'
 gen_cholesky_tests
 gen_section
 
 # assembly tests
-echo '%!shared r,c,m,n,fsum,funiq' >>$TESTS
+echo '%!shared r,c,m,n,fsum,funiq'
 if $use_preset; then
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!test
 %! r = [1,1,2,1,2,3];
 %! c = [2,1,1,1,2,1];
 %! m = n = 0;
 EOF
 else
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!test
 %! % generate m,n from 1 to <5000
 %! m = floor (lognrnd (8,2)+1);
@@ -1288,16 +1282,16 @@
 gen_section
 
 # slicing tests
-echo '%!shared ridx,cidx,idx,as,af' >>$TESTS
+echo '%!shared ridx,cidx,idx,as,af'
 if $use_preset; then
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!test
 %! af = [1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4];
 %! ridx = [1,3];
 %! cidx = [2,3];
 EOF
 else
-    cat >>$TESTS <<EOF
+    cat <<EOF
 %!test
 %! % generate m,n from 1 to <5000
 %! m = floor (lognrnd (8,2)+1);
@@ -1310,16 +1304,16 @@
 fi
 gen_scalar_select_tests
 gen_select_tests
-echo '%!test af = real (af);' >> $TESTS
+echo '%!test af = real (af);'
 gen_select_tests
 gen_section
-echo '%!shared alpha,beta,df,pdf,lf,plf,uf,puf,bf,cf,bcf,tf,tcf,xf,ds,pds,ls,pls,us,pus,bs,cs,bcs,ts,tcs,xs' >>$TESTS
-echo '%!test alpha=1; beta=1;' >> $TESTS
+echo '%!shared alpha,beta,df,pdf,lf,plf,uf,puf,bf,cf,bcf,tf,tcf,xf,ds,pds,ls,pls,us,pus,bs,cs,bcs,ts,tcs,xs'
+echo '%!test alpha=1; beta=1;'
 gen_solver_tests
-echo '%!test alpha=1; beta=1i;' >> $TESTS
+echo '%!test alpha=1; beta=1i;'
 gen_solver_tests
-echo '%!test alpha=1i; beta=1;' >> $TESTS
+echo '%!test alpha=1i; beta=1;'
 gen_solver_tests
-echo '%!test alpha=1i; beta=1i;' >> $TESTS
+echo '%!test alpha=1i; beta=1i;'
 gen_solver_tests
 gen_section
--- a/test/class-concat/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/class-concat/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,5 +1,5 @@
-class_concat_FCN_FILES = \
-  class-concat/@foo/foo.m \
-  class-concat/class-concat.tst
+class_concat_TEST_FILES = \
+  test/class-concat/@foo/foo.m \
+  test/class-concat/class-concat.tst
 
-FCN_FILES += $(class_concat_FCN_FILES)
+TEST_FILES += $(class_concat_TEST_FILES)
--- a/test/classdef/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/classdef/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,7 +1,7 @@
-classdef_FCN_FILES = \
-  classdef/foo_method_changes_property_size.m \
-  classdef/foo_static_method_constant_property.m \
-  classdef/foo_value_class.m \
-  classdef/classdef.tst
+classdef_TEST_FILES = \
+  test/classdef/foo_method_changes_property_size.m \
+  test/classdef/foo_static_method_constant_property.m \
+  test/classdef/foo_value_class.m \
+  test/classdef/classdef.tst
 
-FCN_FILES += $(classdef_FCN_FILES)
+TEST_FILES += $(classdef_TEST_FILES)
--- a/test/classes/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/classes/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,124 +1,124 @@
-class_Blork_FCN_FILES = \
-  classes/@Blork/Blork.m \
-  classes/@Blork/bleek.m \
-  classes/@Blork/display.m \
-  classes/@Blork/get.m \
-  classes/@Blork/set.m
+class_Blork_TEST_FILES = \
+  test/classes/@Blork/Blork.m \
+  test/classes/@Blork/bleek.m \
+  test/classes/@Blork/display.m \
+  test/classes/@Blork/get.m \
+  test/classes/@Blork/set.m
 
-class_Cork_FCN_FILES = \
-  classes/@Cork/Cork.m \
-  classes/@Cork/click.m \
-  classes/@Cork/display.m \
-  classes/@Cork/get.m \
-  classes/@Cork/set.m
+class_Cork_TEST_FILES = \
+  test/classes/@Cork/Cork.m \
+  test/classes/@Cork/click.m \
+  test/classes/@Cork/display.m \
+  test/classes/@Cork/get.m \
+  test/classes/@Cork/set.m
 
-class_Dork_FCN_FILES = \
-  classes/@Dork/Dork.m \
-  classes/@Dork/bling.m \
-  classes/@Dork/display.m \
-  classes/@Dork/gack.m \
-  classes/@Dork/get.m \
-  classes/@Dork/getStash.m \
-  classes/@Dork/private/myStash.m \
-  classes/@Dork/set.m
+class_Dork_TEST_FILES = \
+  test/classes/@Dork/Dork.m \
+  test/classes/@Dork/bling.m \
+  test/classes/@Dork/display.m \
+  test/classes/@Dork/gack.m \
+  test/classes/@Dork/get.m \
+  test/classes/@Dork/getStash.m \
+  test/classes/@Dork/private/myStash.m \
+  test/classes/@Dork/set.m
 
-class_Gork_FCN_FILES = \
-  classes/@Gork/Gork.m \
-  classes/@Gork/cork.m \
-  classes/@Gork/display.m \
-  classes/@Gork/gark.m \
-  classes/@Gork/get.m \
-  classes/@Gork/set.m \
-  classes/@Gork/subsasgn.m \
-  classes/@Gork/subsref.m
+class_Gork_TEST_FILES = \
+  test/classes/@Gork/Gork.m \
+  test/classes/@Gork/cork.m \
+  test/classes/@Gork/display.m \
+  test/classes/@Gork/gark.m \
+  test/classes/@Gork/get.m \
+  test/classes/@Gork/set.m \
+  test/classes/@Gork/subsasgn.m \
+  test/classes/@Gork/subsref.m
 
-class_Pork_FCN_FILES = \
-  classes/@Pork/Pork.m \
-  classes/@Pork/bling.m \
-  classes/@Pork/display.m \
-  classes/@Pork/get.m \
-  classes/@Pork/gurk.m \
-  classes/@Pork/private/myStash.m \
-  classes/@Pork/set.m
+class_Pork_TEST_FILES = \
+  test/classes/@Pork/Pork.m \
+  test/classes/@Pork/bling.m \
+  test/classes/@Pork/display.m \
+  test/classes/@Pork/get.m \
+  test/classes/@Pork/gurk.m \
+  test/classes/@Pork/private/myStash.m \
+  test/classes/@Pork/set.m
 
-class_Sneetch_FCN_FILES = \
-  classes/@Sneetch/Sneetch.m \
-  classes/@Sneetch/display.m
+class_Sneetch_TEST_FILES = \
+  test/classes/@Sneetch/Sneetch.m \
+  test/classes/@Sneetch/display.m
 
-class_Snork_FCN_FILES = \
-  classes/@Snork/Snork.m \
-  classes/@Snork/cack.m \
-  classes/@Snork/display.m \
-  classes/@Snork/double.m \
-  classes/@Snork/end.m \
-  classes/@Snork/eq.m \
-  classes/@Snork/ge.m \
-  classes/@Snork/get.m \
-  classes/@Snork/getStash.m \
-  classes/@Snork/gick.m \
-  classes/@Snork/gt.m \
-  classes/@Snork/horzcat.m \
-  classes/@Snork/ldivide.m \
-  classes/@Snork/le.m \
-  classes/@Snork/loadobj.m \
-  classes/@Snork/lt.m \
-  classes/@Snork/minus.m \
-  classes/@Snork/mldivide.m \
-  classes/@Snork/mpower.m \
-  classes/@Snork/mrdivide.m \
-  classes/@Snork/mtimes.m \
-  classes/@Snork/ne.m \
-  classes/@Snork/plus.m \
-  classes/@Snork/power.m \
-  classes/@Snork/private/myStash.m \
-  classes/@Snork/rdivide.m \
-  classes/@Snork/saveobj.m \
-  classes/@Snork/set.m \
-  classes/@Snork/subsasgn.m \
-  classes/@Snork/subsindex.m \
-  classes/@Snork/subsref.m \
-  classes/@Snork/tattack.m \
-  classes/@Snork/times.m \
-  classes/@Snork/uminus.m \
-  classes/@Snork/uplus.m \
-  classes/@Snork/vertcat.m
+class_Snork_TEST_FILES = \
+  test/classes/@Snork/Snork.m \
+  test/classes/@Snork/cack.m \
+  test/classes/@Snork/display.m \
+  test/classes/@Snork/double.m \
+  test/classes/@Snork/end.m \
+  test/classes/@Snork/eq.m \
+  test/classes/@Snork/ge.m \
+  test/classes/@Snork/get.m \
+  test/classes/@Snork/getStash.m \
+  test/classes/@Snork/gick.m \
+  test/classes/@Snork/gt.m \
+  test/classes/@Snork/horzcat.m \
+  test/classes/@Snork/ldivide.m \
+  test/classes/@Snork/le.m \
+  test/classes/@Snork/loadobj.m \
+  test/classes/@Snork/lt.m \
+  test/classes/@Snork/minus.m \
+  test/classes/@Snork/mldivide.m \
+  test/classes/@Snork/mpower.m \
+  test/classes/@Snork/mrdivide.m \
+  test/classes/@Snork/mtimes.m \
+  test/classes/@Snork/ne.m \
+  test/classes/@Snork/plus.m \
+  test/classes/@Snork/power.m \
+  test/classes/@Snork/private/myStash.m \
+  test/classes/@Snork/rdivide.m \
+  test/classes/@Snork/saveobj.m \
+  test/classes/@Snork/set.m \
+  test/classes/@Snork/subsasgn.m \
+  test/classes/@Snork/subsindex.m \
+  test/classes/@Snork/subsref.m \
+  test/classes/@Snork/tattack.m \
+  test/classes/@Snork/times.m \
+  test/classes/@Snork/uminus.m \
+  test/classes/@Snork/uplus.m \
+  test/classes/@Snork/vertcat.m
 
-class_Spork_FCN_FILES = \
-  classes/@Spork/Spork.m \
-  classes/@Spork/cack.m \
-  classes/@Spork/display.m \
-  classes/@Spork/geek.m \
-  classes/@Spork/get.m \
-  classes/@Spork/getStash.m \
-  classes/@Spork/loadobj.m \
-  classes/@Spork/private/myStash.m \
-  classes/@Spork/saveobj.m \
-  classes/@Spork/set.m
+class_Spork_TEST_FILES = \
+  test/classes/@Spork/Spork.m \
+  test/classes/@Spork/cack.m \
+  test/classes/@Spork/display.m \
+  test/classes/@Spork/geek.m \
+  test/classes/@Spork/get.m \
+  test/classes/@Spork/getStash.m \
+  test/classes/@Spork/loadobj.m \
+  test/classes/@Spork/private/myStash.m \
+  test/classes/@Spork/saveobj.m \
+  test/classes/@Spork/set.m
 
-class_CPrecedenceTester1_FCN_FILES = \
-  classes/@CPrecedenceTester1/CPrecedenceTester1.m \
-  classes/@CPrecedenceTester1/tattack.m
+class_CPrecedenceTester1_TEST_FILES = \
+  test/classes/@CPrecedenceTester1/CPrecedenceTester1.m \
+  test/classes/@CPrecedenceTester1/tattack.m
 
-class_CPrecedenceTester2_FCN_FILES = \
-  classes/@CPrecedenceTester2/CPrecedenceTester2.m \
-  classes/@CPrecedenceTester2/tattack.m
+class_CPrecedenceTester2_TEST_FILES = \
+  test/classes/@CPrecedenceTester2/CPrecedenceTester2.m \
+  test/classes/@CPrecedenceTester2/tattack.m
 
-class_CPrecedenceTester3_FCN_FILES = \
-  classes/@CPrecedenceTester3/CPrecedenceTester3.m \
-  classes/@CPrecedenceTester3/tattack.m
+class_CPrecedenceTester3_TEST_FILES = \
+  test/classes/@CPrecedenceTester3/CPrecedenceTester3.m \
+  test/classes/@CPrecedenceTester3/tattack.m
 
-classes_FCN_FILES = \
-  $(class_Blork_FCN_FILES) \
-  $(class_Cork_FCN_FILES) \
-  $(class_Dork_FCN_FILES) \
-  $(class_Gork_FCN_FILES) \
-  $(class_Pork_FCN_FILES) \
-  $(class_Sneetch_FCN_FILES) \
-  $(class_Snork_FCN_FILES) \
-  $(class_Spork_FCN_FILES) \
-  $(class_CPrecedenceTester1_FCN_FILES) \
-  $(class_CPrecedenceTester2_FCN_FILES) \
-  $(class_CPrecedenceTester3_FCN_FILES) \
-  classes/classes.tst
+classes_TEST_FILES = \
+  $(class_Blork_TEST_FILES) \
+  $(class_Cork_TEST_FILES) \
+  $(class_Dork_TEST_FILES) \
+  $(class_Gork_TEST_FILES) \
+  $(class_Pork_TEST_FILES) \
+  $(class_Sneetch_TEST_FILES) \
+  $(class_Snork_TEST_FILES) \
+  $(class_Spork_TEST_FILES) \
+  $(class_CPrecedenceTester1_TEST_FILES) \
+  $(class_CPrecedenceTester2_TEST_FILES) \
+  $(class_CPrecedenceTester3_TEST_FILES) \
+  test/classes/classes.tst
 
-FCN_FILES += $(classes_FCN_FILES)
+TEST_FILES += $(classes_TEST_FILES)
--- a/test/ctor-vs-method/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/ctor-vs-method/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,11 +1,11 @@
-ctor_vs_method_FCN_FILES = \
-  ctor-vs-method/@derived/derived.m \
-  ctor-vs-method/@derived/parent.m \
-  ctor-vs-method/@other/other.m \
-  ctor-vs-method/@other/parent.m \
-  ctor-vs-method/@parent/method.m \
-  ctor-vs-method/@parent/parent.m \
-  ctor-vs-method/__trace__.m \
-  ctor-vs-method/ctor-vs-method.tst
+ctor_vs_method_TEST_FILES = \
+  test/ctor-vs-method/@derived/derived.m \
+  test/ctor-vs-method/@derived/parent.m \
+  test/ctor-vs-method/@other/other.m \
+  test/ctor-vs-method/@other/parent.m \
+  test/ctor-vs-method/@parent/method.m \
+  test/ctor-vs-method/@parent/parent.m \
+  test/ctor-vs-method/__trace__.m \
+  test/ctor-vs-method/ctor-vs-method.tst
 
-FCN_FILES += $(ctor_vs_method_FCN_FILES)
+TEST_FILES += $(ctor_vs_method_TEST_FILES)
--- a/test/diag-perm.tst	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/diag-perm.tst	Thu Dec 10 12:50:06 2015 -0800
@@ -263,3 +263,27 @@
 %! A = A * I () + A;
 %! A(6, 4) = nan ();
 %! assert (full (D - A), D - full (A));
+
+## inverse preserves diagonal structure even for singular matrices (bug #46103)
+%!test
+%! x = diag (1:3);
+%! assert (inv (x), diag ([1 1/2 1/3]));
+%! x = diag (0:2);
+%! assert (inv (x), diag ([Inf 1 1/2]));
+
+## assignment to diagonal elements preserves diagonal structure (bug #36932)
+%!test
+%! x = diag (1:3);
+%! x(1,1) = -1;
+%! assert (typeinfo (x), "diagonal matrix");
+%! x(3,3) = -1;
+%! assert (typeinfo (x), "diagonal matrix");
+
+%!test
+%! x = diag (1:3);
+%! x(1) = -1;
+%! assert (typeinfo (x), "diagonal matrix");
+%! x(9) = -1;
+%! assert (typeinfo (x), "diagonal matrix");
+
+
--- a/test/fcn-handle-derived-resolution/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/fcn-handle-derived-resolution/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,11 +1,11 @@
-fcn_handle_derived_resolution_FCN_FILES = \
-  fcn-handle-derived-resolution/@fhdr_derived/fhdr_derived.m \
-  fcn-handle-derived-resolution/@fhdr_other/getsize_arrayfun.m \
-  fcn-handle-derived-resolution/@fhdr_other/getsize_cellfun.m \
-  fcn-handle-derived-resolution/@fhdr_other/getsize_loop.m \
-  fcn-handle-derived-resolution/@fhdr_other/fhdr_other.m \
-  fcn-handle-derived-resolution/@fhdr_parent/numel.m \
-  fcn-handle-derived-resolution/@fhdr_parent/fhdr_parent.m \
-  fcn-handle-derived-resolution/fcn-handle-derived-resolution.tst
+fcn_handle_derived_resolution_TEST_FILES = \
+  test/fcn-handle-derived-resolution/@fhdr_derived/fhdr_derived.m \
+  test/fcn-handle-derived-resolution/@fhdr_other/getsize_arrayfun.m \
+  test/fcn-handle-derived-resolution/@fhdr_other/getsize_cellfun.m \
+  test/fcn-handle-derived-resolution/@fhdr_other/getsize_loop.m \
+  test/fcn-handle-derived-resolution/@fhdr_other/fhdr_other.m \
+  test/fcn-handle-derived-resolution/@fhdr_parent/numel.m \
+  test/fcn-handle-derived-resolution/@fhdr_parent/fhdr_parent.m \
+  test/fcn-handle-derived-resolution/fcn-handle-derived-resolution.tst
 
-FCN_FILES += $(fcn_handle_derived_resolution_FCN_FILES)
+TEST_FILES += $(fcn_handle_derived_resolution_TEST_FILES)
--- a/test/index.tst	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/index.tst	Thu Dec 10 12:50:06 2015 -0800
@@ -205,12 +205,6 @@
 
 %!error (a(1:2,1:2) = 1:4)
 
-%!shared x
-%! x = 1:5;
-%!error <attempted to use a complex scalar as an index> x(i)
-%!error <attempted to use a complex scalar as an index> x(j)
-%!error <attempted to use a complex scalar as an index> x(1+i)
-
 ## bug #38357
 %!shared d, dd
 %! d = diag ([1, 2, 3]);
@@ -501,3 +495,84 @@
 %! x = ones (2, 2);
 %! x([], false, :) = [];
 %! assert (x, y);
+
+
+  ##  Test indexing of unnamed constants
+%!error <index \(0\): subscripts must be>     1(0)
+%!error <index \(-1\): subscripts must be>    1(-1)
+%!error <index \(_,0.5\): subscripts>                 {}(1,0.5)
+%!error <index \(nan,_\): subscripts>                 1(NaN,1)
+%!error <index \(_,_,<cell....\[x8\]...\): subscripts> [](1,1,{},1,1,1,1,1,1,1,1)
+%!error <index \(...\[x9\]...-1,_\): subscript>      1(1,1,1,1,1,1,1,1,1,-1,1)
+%!error <index \(2\): out of bound 1>                1(2)
+%!error <index \(1\): out of bound 0>                [](1)
+%!error <index \(_,1\): but object has size 5x0>     zeros(5,0)(3,1)
+%!error <index \(3,_\): but object has size 0x5>     zeros(0,5)(3,1)
+%!error <index \(-1\): subscripts>                   1(1)(-1)(1)
+%!
+%!shared abc
+%! abc = [1, 2];
+%! ##  Test full matrices in variables
+%!error <abc\(3\): out of bound 2>      abc([false, true, true])
+%!error <abc\(-1\): subscripts>         abc(-1)(1)(1)
+%! ## xerror <index \(-1\): subscripts> abc(1)(-1)(1)   ## why no 'xerror' test?
+
+%!shared abc
+%! abc = [1 2; 3 4];
+%!error <abc\(5\): out of bound 4>         abc(5)
+%!error <abc\(_,3\): but abc has size 2x2> abc(2,3)
+%!error <abc\(_,_,0.5\): subscripts>       exp (abc(2,3,0.5))
+
+%!shared abc
+%! abc = [1 2; 3 4]; abc(1,1,2) = 1;
+%!error <abc\(_,5\): out of bound 4>                            abc(2,5)
+%!error <abc\(_,3,_\): but abc has size 2x2x2>                  abc(2,3,2)
+%!error <A\(..,I,..\) = \[\]: .* value 3 out of bound 2>        abc(3,:) = []
+%!error <A\(I\) = \[\]: .* value 50 out of bound 8>             abc(3:50) = []
+%!error <a null assignment can only have one non-colon index>   abc(3,5) = []
+%!error <=: nonconformant arguments \(op1 is 1x1, op2 is 1x5\)> abc(3,5) = 1:5
+
+%! ##  Test diagonal matrices, and access of function results
+%!error <index \(_,_,5\): but object has size 3x3> eye(3)(2,3,5)
+%!error <index \(-2,_\): subscripts>               eye(4)(-2,3)
+
+%! ##  Test cells
+%!shared abc
+%! abc = {1, 2; 3, 4};
+%!error <abc\(_,0.3,_\): subscripts>  abc(2,0.3,5)
+%!error <abc\(_,0.3,_\): subscripts>  abc{2,0.3,5}
+%!error <abc\(-2,_,_,_\): subscripts> abc{-2,1,1,1}
+%!error <abc\(0,_,_,_\): subscripts>  abc(0,1,1,1) = 1
+
+%! ##  Test permutation matrices
+%!shared abc
+%! abc = eye(3)([3 1 2],:);
+%!error <abc\(nan\): subscripts>         abc(NA)
+%!error <abc\(_,_,_,inf,_\): subscripts> abc(1,1,1,Inf,1)
+
+%! ##  Test sparse matrices
+%!shared abc
+%! abc = sparse(3,3);
+%!error <abc\(-1\): subscripts>                abc(-1)
+%!error <abc\(-1\): subscripts>                abc(-1) = 1
+%!error <abc\(-1,_\): subscripts>              abc(-1,1)
+%!error <abc\(-1,_\): subscripts>              abc(-1,1) = 1
+%!error <sparse indexing needs 1 or 2 indices> abc(0,0,0,0)
+%!error <abc\(4,_\): but abc has size 3x3>     abc(4,1)
+
+%! ##  Test ranges
+%!shared abc
+%! abc = 1:10;
+%!error <abc\(-1\): subscripts>             abc(-1)
+%!error <abc\(-1,_\): subscripts>           abc(-1,1)
+%!error <abc\(4,_\): but abc has size 1x10> abc(4,1)
+
+%! ##  Test complex
+%!shared abc, z
+%! abc = [1 2];
+%!error <abc\(0\+1i\): subscripts must be real>     abc(i)
+%! abc = [1 2; 3 4];
+%!error <abc\(1\+0i\): subscripts must be real>     abc(complex(1))
+%!error <abc\(1\+0.5i,_\): subscripts must be real> abc(1+0.5*i,3)
+%!error <abc\(_,0-2i\): subscripts must be real>   abc(2,0-2*i)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -0,0 +1,147 @@
+test_EXTRA_DIST =
+
+test_CLEANFILES =
+test_DISTCLEANFILES =
+test_MAINTAINERCLEANFILES =
+
+TEST_FILES += \
+  test/fntests.m \
+  test/args.tst \
+  test/bug-31371.tst \
+  test/bug-38576.tst \
+  test/colormaps.tst \
+  test/complex.tst \
+  test/diag-perm.tst \
+  test/error.tst \
+  test/eval-catch.tst \
+  test/for.tst \
+  test/func.tst \
+  test/global.tst \
+  test/if.tst \
+  test/index.tst \
+  test/io.tst \
+  test/jit.tst \
+  test/line-continue.tst \
+  test/logical-index.tst \
+  test/null-assign.tst \
+  test/parser.tst \
+  test/prefer.tst \
+  test/range.tst \
+  test/recursion.tst \
+  test/return.tst \
+  test/slice.tst \
+  test/struct.tst \
+  test/switch.tst \
+  test/system.tst \
+  test/transpose.tst \
+  test/try.tst \
+  test/unwind.tst \
+  test/while.tst
+
+DIRSTAMP_FILES += test/$(octave_dirstamp)
+
+include test/bug-35448/module.mk
+include test/bug-36025/module.mk
+include test/bug-38236/module.mk
+include test/bug-38691/module.mk
+include test/bug-44940/module.mk
+include test/class-concat/module.mk
+include test/classdef/module.mk
+include test/classes/module.mk
+include test/ctor-vs-method/module.mk
+include test/fcn-handle-derived-resolution/module.mk
+include test/nest/module.mk
+
+ALL_LOCAL_TARGETS += test/.gdbinit
+
+test/.gdbinit: etc/gdbinit
+	@$(gdbinit_install_rule)
+
+check-local: $(GENERATED_TEST_FILES) | $(OCTAVE_INTERPRETER_TARGETS) test/$(octave_dirstamp)
+	cd test && ../run-octave $(RUN_OCTAVE_OPTIONS) --norc --silent --no-history $(abs_top_srcdir)/test/fntests.m $(abs_top_srcdir)/test
+
+if AMCOND_HAVE_LLVM
+check-jit: $(GENERATED_TEST_FILES) | $(OCTAVE_INTERPRETER_TARGETS) test/$(octave_dirstamp)
+	cd test && ../run-octave $(RUN_OCTAVE_OPTIONS) --jit-compiler --norc --silent --no-history $(abs_top_srcdir)/test/fntests.m $(abs_top_srcdir)/test
+endif
+
+test/sparse.tst: test/build-sparse-tests.sh | test/$(octave_dirstamp)
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	$(srcdir)/test/build-sparse-tests.sh > $@-t && \
+	mv $@-t $@
+
+GENERATED_BC_OVERLOADS_DIRS := \
+  $(shell $(srcdir)/test/build-bc-overload-tests.sh test --list-dirs)
+
+GENERATED_BC_OVERLOADS_FILES := \
+  $(shell $(srcdir)/test/build-bc-overload-tests.sh test --list-files)
+
+$(GENERATED_BC_OVERLOADS_FILES): test/bc-overload-tests.stamp
+
+test/bc-overload-tests.stamp: test/build-bc-overload-tests.sh test/bc-overloads-expected | test/$(octave_dirstamp)
+	$(AM_V_GEN)rm -f $@ && \
+	$(srcdir)/test/build-bc-overload-tests.sh test $(srcdir)/test/bc-overloads-expected && \
+	touch $@
+
+GENERATED_TEST_FILES = \
+  test/sparse.tst \
+  test/bc-overload-tests.stamp
+
+fixedtestsdir := $(octtestsdir)/fixed
+
+TEST_INST_FILES = \
+  test/sparse.tst \
+  $(GENERATED_BC_OVERLOADS_FILES) \
+  $(filter-out test/fntests.m, $(TEST_FILES))
+
+install-data-local: install-test-files
+
+uninstall-local: uninstall-test-files
+
+install-test-files:
+	for f in $(TEST_INST_FILES); do \
+	  if test -f "$$f"; then d=; else d="$(srcdir)/"; fi; \
+	  base=`echo $$f | $(SED) 's,^test/,,'`; \
+	  $(MKDIR_P) $(DESTDIR)$(fixedtestsdir)/`echo $$base | $(SED) 's,/*[^/]*$$,,'`; \
+	  $(INSTALL_DATA) $$d$$f $(DESTDIR)$(fixedtestsdir)/$$base; \
+	done
+.PHONY: install-test-files
+
+uninstall-test-files:
+	for f in $(TEST_INST_FILES); do \
+	  base=`echo $$f | $(SED) 's,^test/,,'`; \
+	  rm -f $(DESTDIR)$(fixedtestsdir)/$$base; \
+	done
+.PHONY: uninstall-test-files
+
+BUILT_SOURCES += $(GENERATED_TEST_FILES)
+
+test_EXTRA_DIST += \
+  test/build-sparse-tests.sh \
+  test/build-bc-overload-tests.sh \
+  test/bc-overloads-expected \
+  test/build_bc_overloads_expected.m \
+  $(TEST_FILES)
+
+EXTRA_DIST += $(test_EXTRA_DIST)
+
+test_CLEANFILES += \
+  $(GENERATED_BC_OVERLOADS_FILES) \
+  $(GENERATED_TEST_FILES)
+
+test_DISTCLEANFILES += \
+  test/.gdbinit \
+  test/fntests.log
+
+CLEANFILES += $(test_CLEANFILES)
+DISTCLEANFILES += $(test_DISTCLEANFILES)
+MAINTAINERCLEANFILES += $(test_MAINTAINERCLEANFILES)
+
+test-clean:
+	rm -f $(test_CLEANFILES)
+
+test-distclean: test-clean
+	rm -f $(test_DISTCLEANFILES)
+
+test-maintainer-clean: test-distclean
+	rm -f $(test_MAINTAINERCLEANFILES)
--- a/test/nest/module.mk	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/nest/module.mk	Thu Dec 10 12:50:06 2015 -0800
@@ -1,21 +1,20 @@
 nest_fcn_files = \
-  nest/arg_nest.m \
-  nest/arg_ret.m \
-  nest/nest_eval.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/nest.tst \
-  nest/varg_nest.m \
-  nest/varg_nest2.m
+  test/nest/arg_nest.m \
+  test/nest/arg_ret.m \
+  test/nest/nest_eval.m \
+  test/nest/no_closure.m \
+  test/nest/persistent_nest.m \
+  test/nest/recursive_nest.m \
+  test/nest/recursive_nest2.m \
+  test/nest/recursive_nest3.m \
+  test/nest/scope0.m \
+  test/nest/scope1.m \
+  test/nest/scope2.m \
+  test/nest/scope3.m \
+  test/nest/script_nest.m \
+  test/nest/script_nest_script.m \
+  test/nest/nest.tst \
+  test/nest/varg_nest.m \
+  test/nest/varg_nest2.m
 
-FCN_FILES += $(nest_FCN_FILES)
-
+TEST_FILES += $(nest_TEST_FILES)
--- a/test/parser.tst	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/parser.tst	Thu Dec 10 12:50:06 2015 -0800
@@ -275,6 +275,18 @@
 %! assert (a += b *= c += 1, 42);
 %! assert (b == 40 && c == 8);
 
+## Test extended number format which allows '_' as NOP character
+%!assert (123_456, 123456)
+%!assert (.123_456, .123456)
+%!assert (123_456.123_456, 123456.123456)
+%!assert (0xAB_CD, 43981)
+%!assert (2e0_1, 20);
+
+## Test binary constants
+%!assert (0b101, 5)
+%!assert (0B1100_0001, 0xC1)
+%!assert (class (0b1), "double")
+
 ## Test creation of anonymous functions
 
 %!test
@@ -304,3 +316,7 @@
 %! a = {1, @sin, 2, @cos};
 %! b = {1 @sin 2 @cos};
 %! assert (a, b)
+
+## Maybe unnecessary, but check that further changes to parser don't 
+## invalidate error handling (bug #46534).
+#!error <vertical dimensions mismatch \(1x2 vs 1x1\)> z = [1, 2; 3]
--- a/test/struct.tst	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/struct.tst	Thu Dec 10 12:50:06 2015 -0800
@@ -57,21 +57,14 @@
 %! s.a = 2;
 %! assert (isfield (s, 2) == 0);
 
-%!assert (!(isstruct (1)))
-
-%!assert (!(isstruct ([1, 2])))
-
-%!assert (!(isstruct ([])))
-
-%!assert (!(isstruct ([1, 2; 3, 4])))
-
-%!assert (!(isstruct ("t")))
-
-%!assert (!(isstruct ("test")))
-
-%!assert (!(isstruct (["test"; "ing"])))
-
-%!assert (!(isstruct ({1})))
+%!assert (isstruct (1), false)
+%!assert (isstruct ([1, 2]), false)
+%!assert (isstruct ([]), false)
+%!assert (isstruct ([1, 2; 3, 4]), false)
+%!assert (isstruct ("t"), false)
+%!assert (isstruct ("test"), false)
+%!assert (isstruct (["test"; "ing"]), false)
+%!assert (isstruct ({1}), false)
 
 %!test
 %! s.a = 1;
@@ -238,6 +231,14 @@
 %! s(3).foo = 42;
 %! assert (s(3), struct ("foo", 42));
 
+## test assigning to multi-dim struct with trailing singleton dimensions,
+## Bug #35841.
+%!test
+%! a(1,1,1).b(1) = 1;
+%! a(1,1,1).b(1) = 2;
+%! a(1,1,:).b(1) = 3;
+%! assert (a(1,1,1).b(1) == 3);
+
 %!error id=Octave:index-out-of-bounds
 %! s = resize (struct (),3,2);
 %! s(3).foo = 42;
--- a/test/system.tst	Tue Dec 08 07:49:49 2015 -0800
+++ b/test/system.tst	Thu Dec 10 12:50:06 2015 -0800
@@ -202,13 +202,13 @@
 %! unlink (nm);
 %! assert (r(:), [true; false; false; false; false; false; false]);
 
-%!error <octave_base_value::double_value> S_ISREG ({})
-%!error <octave_base_value::double_value> S_ISDIR ({})
-%!error <octave_base_value::double_value> S_ISCHR ({})
-%!error <octave_base_value::double_value> S_ISBLK ({})
-%!error <octave_base_value::double_value> S_ISFIFO ({})
-%!error <octave_base_value::double_value> S_ISLNK ({})
-%!error <octave_base_value::double_value> S_ISSOCK ({})
+%!error <S_ISREG: invalid MODE value> S_ISREG ({})
+%!error <S_ISDIR: invalid MODE value> S_ISDIR ({})
+%!error <S_ISCHR: invalid MODE value> S_ISCHR ({})
+%!error <S_ISBLK: invalid MODE value> S_ISBLK ({})
+%!error <S_ISFIFO: invalid MODE value> S_ISFIFO ({})
+%!error <S_ISLNK: invalid MODE value> S_ISLNK ({})
+%!error <S_ISSOCK: invalid MODE value> S_ISSOCK ({})
 
 %!error <Invalid call to S_ISREG> S_ISREG ()
 %!error <Invalid call to S_ISDIR> S_ISDIR ()
@@ -225,7 +225,7 @@
 
 %!assert (ischar (file_in_path (path (), "date.m")))
 
-%!error <invalid option> file_in_path ("foo", "bar", 1)
+%!error <file_in_path: optional third argument must be a string> file_in_path ("foo", "bar", 1)
 %!error <Invalid call to file_in_path> file_in_path ()
 %!error <Invalid call to file_in_path> file_in_path ("foo", "bar", "baz", "ooka")