changeset 20634:1c5a86b7f838

maint: Merge stable to default to pick up fix for bug #45577.
author Rik <rik@octave.org>
date Sat, 10 Oct 2015 16:52:59 -0700
parents 69270256b879 (diff) ffc6cdcd02c5 (current diff)
children a22d8a2eb0e5
files liboctave/array/CMatrix.cc
diffstat 716 files changed, 35871 insertions(+), 27834 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sat Oct 10 16:46:00 2015 -0700
+++ b/.hgignore	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/.hgtags	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/Makefile.am	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/NEWS	Sat Oct 10 16:52:59 2015 -0700
@@ -1,3 +1,96 @@
+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 (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.
+
+ ** Other new functions added in 4.2:
+
+      psi
+      odeset
+      odeget
+      ode45
+
+ ** 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_error) 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.
+
 Summary of important user-visible changes for version 4.0:
 ---------------------------------------------------------
 
--- a/bootstrap	Sat Oct 10 16:46:00 2015 -0700
+++ b/bootstrap	Sat Oct 10 16:52:59 2015 -0700
@@ -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
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/build-aux/common.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -537,7 +537,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 +706,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}\"|" \
@@ -931,10 +929,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/build-aux/mk-opts.pl	Sat Oct 10 16:52:59 2015 -0700
@@ -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";
       }
@@ -856,13 +856,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 +872,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 +884,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);
         }
--- a/build-aux/move-if-change	Sat Oct 10 16:46:00 2015 -0700
+++ b/build-aux/move-if-change	Sat Oct 10 16:52:59 2015 -0700
@@ -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/configure.ac	Sat Oct 10 16:46:00 2015 -0700
+++ b/configure.ac	Sat Oct 10 16:52:59 2015 -0700
@@ -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,19 +2446,19 @@
 ### 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.
@@ -2865,6 +2859,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 +3002,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
 
@@ -3143,6 +3128,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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/doxyhtml/Doxyfile.in	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/arith.txi	Sat Oct 10 16:52:59 2015 -0700
@@ -315,6 +315,8 @@
 @anchor{XREFgammaln}
 @DOCSTRING(lgamma)
 
+@DOCSTRING(psi)
+
 @node Rational Approximations
 @section Rational Approximations
 
--- a/doc/interpreter/audio.txi	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/audio.txi	Sat Oct 10 16:52:59 2015 -0700
@@ -182,6 +182,3 @@
 
 @DOCSTRING(soundsc)
 
-@DOCSTRING(wavread)
-
-@DOCSTRING(wavwrite)
--- a/doc/interpreter/config-images.sh	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/config-images.sh	Sat Oct 10 16:52:59 2015 -0700
@@ -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/contributors.in	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/contributors.in	Sat Oct 10 16:52:59 2015 -0700
@@ -11,6 +11,7 @@
 Branden Archer
 Willem Atsma
 Marco Atzeri
+Ander Aurrekoetxea
 Shai Ayal
 Roger Banks
 Ben Barrowes
--- a/doc/interpreter/diffeq.txi	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/diffeq.txi	Sat Oct 10 16:52:59 2015 -0700
@@ -115,6 +115,41 @@
 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 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 Runge-Kutta methods
+  @itemize
+    @item @code{ode45} Integrates a system of non--stiff ordinary differential equations
+    (non--stiff ODEs and DAEs) using second order 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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/doccheck/aspell-octave.en.pws	Sat Oct 10 16:52:59 2015 -0700
@@ -74,7 +74,6 @@
 binornd
 Biomathematics
 bitmapped
-bitmax
 bitwise
 bivariate
 Blackman
--- a/doc/interpreter/external.txi	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/external.txi	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/genpropdoc.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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";
@@ -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.";
 
@@ -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,18 +575,52 @@
       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."; 
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/geometry.txi	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/geometryimages.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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
@@ -34,7 +35,7 @@
                            "triplot"})))
     sombreroimage (nm, 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,38 @@
   r = sqrt ((xc - x(1)).^2 + (yc - y(1)).^2);
 endfunction
 
+function sombreroimage (nm, typ, d_typ)
+  if (strcmp (typ, "txt"))
+    fid = fopen ([nm ".txt"], "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
+    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 (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 +154,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/graphics_properties.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/gui.txi	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/image.txi	Sat Oct 10 16:52:59 2015 -0700
@@ -190,6 +190,8 @@
 
 @DOCSTRING(summer)
 
+@DOCSTRING(viridis)
+
 @DOCSTRING(white)
 
 @DOCSTRING(winter)
--- a/doc/interpreter/images.awk	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/images.awk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/interpimages.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/numbers.txi	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/numbers.txi	Sat Oct 10 16:52:59 2015 -0700
@@ -619,12 +619,7 @@
 
 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 functions 'flintmax' for floating point integers, and 'intmax'.
 
 Octave also includes the basic bitwise 'and', 'or', and 'exclusive or'
 operators.
--- a/doc/interpreter/octave.texi	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/octave.texi	Sat Oct 10 16:52:59 2015 -0700
@@ -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
 
--- a/doc/interpreter/plot.txi	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/plot.txi	Sat Oct 10 16:52:59 2015 -0700
@@ -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 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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/plotimages.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/sparseimages.m	Sat Oct 10 16:52:59 2015 -0700
@@ -16,8 +16,8 @@
 ## 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 ();
   if (strcmp (typ, "png"))
     set (0, "defaulttextfontname", "*");
@@ -27,38 +27,25 @@
       && __have_feature__ ("CHOLMOD")
       && __have_feature__ ("UMFPACK"))
     if (strcmp (typ,"txt"))
-      txtimages (nm, 15, typ);
+      txtimages (d, nm, 15, typ);
     else
       if (strcmp (nm, "gplot"))
-        gplotimages ("gplot", typ);
+        gplotimages (d, "gplot", typ);
       elseif (strcmp (nm, "grid"))
-        femimages ("grid", typ);
+        femimages (d, "grid", typ);
       else
-        otherimages (nm, 200, typ);
+        otherimages (d, nm, 200, typ);
       endif
     endif
   else ## There is no sparse matrix implementation available because
        ## of missing libraries, plot sombreros instead
-    sombreroimage (nm, typ);
+    sombreroimage (d, nm, typ);
   endif
 endfunction
 
-function set_print_size ()
-  image_size = [5.0, 3.5]; # in inches, 16:9 format
-  border = 0;              # For postscript use 50/72
-  set (0, "defaultfigurepapertype", "<custom>");
-  set (0, "defaultfigurepaperorientation", "landscape");
-  set (0, "defaultfigurepapersize", image_size + 2*border);
-  set (0, "defaultfigurepaperposition", [border, border, image_size]);
-endfunction
-
-function hide_output ()
-  f = figure (1);
-  set (f, "visible", "off");
-endfunction
-
-function gplotimages (nm, typ)
+function gplotimages (d, nm, typ)
   hide_output ();
+  outfile = fullfile (d, strcat (nm, ".", typ));
   if (strcmp (typ, "eps"))
     d_typ = "-depsc2";
   else
@@ -69,50 +56,52 @@
               [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);
+  print (outfile, d_typ);
   hide_output ();
 endfunction
 
-function txtimages (nm, n, typ)
+function txtimages (d, nm, n, typ)
+  outfile = fullfile (d, strcat (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 (sprintf ("%s.txt", nm), "wt");
+    fid = fopen (fullfile (d, strcat (nm, ".txt")), "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]);
+    printsparse (a, outfile);
   else
     if (__have_feature__ ("COLAMD") && __have_feature__ ("CHOLMOD"))
       if (strcmp (nm, "spchol"))
         r1 = chol (a);
-        printsparse (r1, ["spchol." typ]);
+        printsparse (r1, outfile);
       elseif (strcmp (nm, "spcholperm"))
         [r2,p2,q2] = chol (a);
-        printsparse(r2, ["spcholperm." typ]);
+        printsparse (r2, outfile);
       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)
+function otherimages (d, nm, n, typ)
   hide_output ();
+  outfile = fullfile (d, strcat (nm, ".", typ));
   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) + ...
+  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);
+    print (outfile, d_typ);
     hide_output ();
   else
     if (__have_feature__ ("COLAMD") && __have_feature__ ("CHOLMOD"))
@@ -120,13 +109,13 @@
         r1 = chol (a);
         spy (r1);
         axis ("ij");
-        print (["spchol." typ], d_typ);
+        print (outfile, d_typ);
         hide_output ();
       elseif (strcmp (nm, "spcholperm"))
         [r2,p2,q2] = chol (a);
         spy (r2);
         axis ("ij");
-        print (["spcholperm." typ], d_typ);
+        print (outfile, d_typ);
         hide_output ();
       endif
       ## printf("Image NNZ: Matrix %d, Chol %d, PermChol %d\n",nnz(a),nnz(r1),nnz(r2));
@@ -172,8 +161,9 @@
   fclose (fid);
 endfunction
 
-function femimages (nm, typ)
+function femimages (d, nm, typ)
   hide_output ();
+  outfile = fullfile (d, strcat (nm, ".", typ));
   if (strcmp (typ, "eps"))
     d_typ = "-depsc2";
   else
@@ -253,7 +243,7 @@
 
     plot3 (xelems, yelems, velems);
     view (80, 10);
-    print ([nm "." typ], d_typ);
+    print (outfile, d_typ);
     hide_output ();
   endif
 endfunction
@@ -261,9 +251,9 @@
 ## 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)
+function sombreroimage (d, nm, typ)
   if (strcmp (typ, "txt"))
-    fid = fopen (sprintf ("%s.txt", nm), "wt");
+    fid = fopen (fullfile (d, [nm ".txt"]), "wt");
     fputs (fid, "\n");
     fputs (fid, "+---------------------------------------+\n");
     fputs (fid, "| Image unavailable because of a        |\n");
@@ -271,8 +261,7 @@
     fputs (fid, "+---------------------------------------+\n");
     fclose (fid);
     return;
-  else ## if (!strcmp (typ, "txt"))
-
+  else
     hide_output ();
     if (strcmp (typ, "eps"))
       d_typ = "-depsc2";
@@ -285,19 +274,35 @@
       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);
+      print (outfile, 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);
+## 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
+  set (0, "defaultfigurepapertype", "<custom>");
+  set (0, "defaultfigurepaperorientation", "landscape");
+  set (0, "defaultfigurepapersize", image_size + 2*border);
+  set (0, "defaultfigurepaperposition", [border, border, image_size]);
+endfunction
+
+## Use this function before plotting commands and after every call to print
+## since print() resets output to stdout (unfortunately, gnuplot can't pop
+## output as it can the terminal type).
+function hide_output ()
+  hf = figure (1, "visible", "off");
+endfunction
+
--- a/doc/interpreter/splineimages.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/splineimages.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/stats.txi	Sat Oct 10 16:52:59 2015 -0700
@@ -137,8 +137,6 @@
 
 @DOCSTRING(cloglog)
 
-@DOCSTRING(mahalanobis)
-
 @DOCSTRING(table)
 
 @node Statistical Plots
--- a/doc/interpreter/system.txi	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/interpreter/system.txi	Sat Oct 10 16:52:59 2015 -0700
@@ -80,6 +80,9 @@
 @item isdst
 Daylight Savings Time flag.
 
+@item gmtoff
+Seconds offset from UTC.
+
 @item zone
 Time zone.
 @end table
--- a/doc/liboctave/Makefile.am	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/doc/liboctave/liboctave.texi	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,595 @@
+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 $@
+	-$(PERL) $(srcdir)/doccheck/mk_undocumented_list > $@-t
+	mv $@-t $@
+.PHONY: doc/interpreter/undocumented_list
+
+SPELLCHECK_FILES = $(MUNGED_TEXI_SRC:.texi=.scheck)
+
+%.scheck: %.texi | doc/interpreter/$(octave_dirstamp)
+	$(srcdir)/doc/interpreter/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 += $(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	Sat Oct 10 16:46:00 2015 -0700
+++ /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/icons/Makefile.am	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ /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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ /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/@polynomial/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ /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/Makefile.am	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/examples/code/addtwomatrices.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/examples/code/celldemo.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/examples/code/embedded.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/examples/code/fortrandemo.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/examples/code/funcdemo.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/examples/code/globaldemo.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/examples/code/helloworld.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/examples/code/make_int.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/examples/code/paramdemo.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/examples/code/stringdemo.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/examples/code/structdemo.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/examples/code/unwinddemo.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/graphics/Backend.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/graphics/Canvas.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/graphics/Canvas.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/graphics/Figure.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/graphics/Figure.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/graphics/ListBoxControl.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/graphics/QtHandlesUtils.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/graphics/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/languages/translators	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/link-deps.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,138 @@
+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)
+
+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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/qterminal-module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/qterminal/libqterminal/unix/kpty.cpp	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/qterminal/libqterminal/unix/kpty_p.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/dialog.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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)
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/dialog.h	Sat Oct 10 16:52:59 2015 -0700
@@ -210,6 +210,8 @@
   void buttonCancel_clicked (void);
 
   void reject (void);
+
+  void item_double_clicked (const QModelIndex&);
 };
 
 
--- a/libgui/src/history-dock-widget.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/history-dock-widget.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/history-dock-widget.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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 ();
@@ -84,6 +85,8 @@
 
   QCheckBox *_filter_checkbox;
   QComboBox *_filter;
+  QWidget *_filter_widget;
+  bool _filter_shown;
   enum { MaxFilterHistory = 10 };
 };
 
--- a/libgui/src/m-editor/file-editor-tab.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -71,6 +71,7 @@
 {
   _lexer_apis = 0;
   _is_octave_file = true;
+  _lines_changed = false;
 
   _ced = directory_arg;
 
@@ -78,10 +79,15 @@
   _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&)));
 
@@ -482,12 +488,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);
@@ -1878,6 +1884,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
@@ -2063,15 +2070,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/m-editor/file-editor-tab.h	Sat Oct 10 16:52:59 2015 -0700
@@ -173,6 +173,7 @@
   void auto_margin_width ();
 
   void handle_cursor_moved (int line, int col);
+  void handle_lines_changed (void);
 
 private:
 
@@ -216,6 +217,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 ();
 
@@ -236,6 +239,7 @@
   bool _copy_available;
   bool _is_octave_file;
   bool _always_reload_changed_files;
+  bool _smart_indent;
 
   QFileSystemWatcher _file_system_watcher;
 
@@ -247,6 +251,10 @@
   QString _prep_apis_file;
 
   static bool _cancelled;
+
+  int _line;
+  int _col;
+  bool _lines_changed;
 };
 
 #endif
--- a/libgui/src/m-editor/find-dialog.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/m-editor/find-dialog.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/m-editor/find-dialog.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/m-editor/octave-qscintilla.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/m-editor/octave-qscintilla.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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/main-window.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/main-window.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/main-window.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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-qt-link.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/octave-qt-link.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/resource-manager.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -144,7 +144,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create resource_manager object!");
+      error ("unable to create resource_manager object!");
 
       retval = false;
     }
--- a/libgui/src/settings-dialog.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/settings-dialog.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -55,6 +55,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)
 {
@@ -373,30 +573,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 +632,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)
 {
@@ -802,30 +892,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
 
@@ -854,91 +944,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)
 {
--- a/libgui/src/settings-dialog.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/settings-dialog.h	Sat Oct 10 16:52:59 2015 -0700
@@ -29,10 +29,6 @@
 
 #include "color-picker.h"
 
-#ifdef HAVE_QSCINTILLA
-class QsciLexer;
-#endif
-
 namespace Ui
 {
   class settings_dialog;
@@ -66,13 +62,6 @@
 
 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/shortcut-manager.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/shortcut-manager.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -75,7 +75,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create shortcut_manager object!");
+      error ("unable to create shortcut_manager object!");
 
       retval = false;
     }
--- a/libgui/src/workspace-view.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/workspace-view.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -75,23 +75,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
@@ -129,7 +138,6 @@
 
   connect (this, SIGNAL (command_requested (const QString&)),
            p, SLOT (execute_command_in_terminal (const QString&)));
-
 }
 
 workspace_view::~workspace_view (void)
@@ -146,6 +154,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++)
@@ -263,8 +272,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 +378,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 ();
--- a/libgui/src/workspace-view.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libgui/src/workspace-view.h	Sat Oct 10 16:52:59 2015 -0700
@@ -70,6 +70,7 @@
   void handle_contextmenu_disp (void);
   void handle_contextmenu_plot (void);
   void handle_contextmenu_stem (void);
+  void handle_contextmenu_filter (void);
 
   void handle_model_changed (void);
 
@@ -92,6 +93,9 @@
   QSortFilterProxyModel _filter_model;
   QCheckBox *_filter_checkbox;
   QComboBox *_filter;
+  QWidget *_filter_widget;
+  bool _filter_shown;
+
   enum { MaxFilterHistory = 10 };
 };
 
--- a/libinterp/Makefile.am	Sat Oct 10 16:46:00 2015 -0700
+++ /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/corefcn/Cell.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/Cell.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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,57 @@
 
   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 ());
           }
-      }
-      break;
+          break;
 
-    default:
-      {
-        Array<idx_vector> iv (dim_vector (n, 1));
-
-        for (octave_idx_type i = 0; i < n; i++)
+        default:
           {
-            iv(i) = idx_arg(i).index_vector ();
+            Array<idx_vector> iv (dim_vector (n, 1));
 
-            if (error_state)
-              break;
+            for (k = 0; k < n; k++)
+              iv(k) = idx_arg(k).index_vector ();
+
+            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 +234,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 +259,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);
 }
--- a/libinterp/corefcn/__contourc__.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/__contourc__.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -316,7 +316,7 @@
         {
           contourc.resize (2, 0);
 
-          for (int i = 0; i < L.length (); i++)
+          for (int i = 0; i < L.numel (); i++)
             cntr (X, Y, Z, L (i));
 
           end_contour ();
--- a/libinterp/corefcn/__dispatch__.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/__dispatch__.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -46,42 +46,17 @@
 
   int nargin = args.length ();
 
-  std::string f, r, t;
-
   if (nargin > 0 && nargin < 4)
     {
-      if (nargin > 0)
-        {
-          f = args(0).string_value ();
+      std::string f, r, t;
 
-          if (error_state)
-            {
-              error ("__dispatch__: first argument must be a function name");
-              return retval;
-            }
-        }
+      f = args(0).string_value ("__dispatch__: first argument must be a function name");
 
       if (nargin > 1)
-        {
-          r = args(1).string_value ();
-
-          if (error_state)
-            {
-              error ("__dispatch__: second argument must be a function name");
-              return retval;
-            }
-        }
+        r = args(1).string_value ("__dispatch__: second argument must be a function name");
 
       if (nargin > 2)
-        {
-          t = args(2).string_value ();
-
-          if (error_state)
-            {
-              error ("__dispatch__: third argument must be a type name");
-              return retval;
-            }
-        }
+        t = args(2).string_value ("__dispatch__: third argument must be a type name");
 
       if (nargin == 1)
         {
--- a/libinterp/corefcn/__ichol__.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/__ichol__.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -221,8 +221,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 +231,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;
@@ -428,17 +428,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];
     }
 }
 
@@ -486,8 +485,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 +504,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/__ilu__.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -153,34 +153,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 +440,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,
@@ -515,24 +511,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 +536,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 +575,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 +604,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 +864,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 ();
     }
 }
 
@@ -1010,35 +998,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 +1050,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/__pchip_deriv__.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/__pchip_deriv__.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -68,7 +68,7 @@
           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)
             {
@@ -115,7 +115,7 @@
           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)
             {
--- a/libinterp/corefcn/__qp__.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/__qp__.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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.
 
--- a/libinterp/corefcn/balance.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/balance.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -140,9 +140,6 @@
         aa = args(0).matrix_value ();
     }
 
-  if (error_state)
-    return retval;
-
   // Treat AEP/GEP cases.
   if (AEPcase)
     {
@@ -246,13 +243,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).string_value ("balance: OPT argument must be a string");
 
       if ((nn != args(1).columns ()) || (nn != args(1).rows ()))
         {
--- a/libinterp/corefcn/besselj.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/besselj.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -178,8 +178,8 @@
               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 ());
+              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)
                 {
@@ -314,8 +314,8 @@
               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 ());
+              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)
                 {
@@ -616,54 +616,51 @@
             error ("airy: K must be an integer value");
         }
 
-      if (! error_state)
-        {
-          int idx = nargin == 1 ? 0 : 1;
+      int idx = nargin == 1 ? 0 : 1;
 
-          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;
+      if (args(idx).is_single_type ())
+        {
+          FloatComplexNDArray z = args(idx).float_complex_array_value ();
 
-                  if (kind > 1)
-                    result = biry (z, kind == 3, scale, ierr);
-                  else
-                    result = airy (z, kind == 1, scale, ierr);
+          if (! error_state)
+            {
+              Array<octave_idx_type> ierr;
+              octave_value result;
 
-                  if (nargout > 1)
-                    retval(1) = NDArray (ierr);
+              if (kind > 1)
+                result = biry (z, kind == 3, scale, ierr);
+              else
+                result = airy (z, kind == 1, scale, ierr);
 
-                  retval(0) = result;
-                }
-              else
-                error ("airy: Z must be a complex matrix");
+              if (nargout > 1)
+                retval(1) = NDArray (ierr);
+
+              retval(0) = result;
             }
           else
-            {
-              ComplexNDArray z = args(idx).complex_array_value ();
+            error ("airy: Z must be a complex matrix");
+        }
+      else
+        {
+          ComplexNDArray z = args(idx).complex_array_value ();
 
-              if (! error_state)
-                {
-                  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
+            error ("airy: Z must be a complex matrix");
         }
     }
   else
--- a/libinterp/corefcn/betainc.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/betainc.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -87,44 +87,34 @@
                 {
                   float a = a_arg.float_value ();
 
-                  if (! error_state)
+                  if (b_arg.is_scalar_type ())
                     {
-                      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 ();
+                      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 ())
                     {
-                      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 ();
+                      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);
                     }
                 }
             }
@@ -136,44 +126,34 @@
                 {
                   float a = a_arg.float_value ();
 
-                  if (! error_state)
+                  if (b_arg.is_scalar_type ())
                     {
-                      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 ();
+                      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 ())
                     {
-                      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 ();
+                      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);
                     }
                 }
             }
@@ -188,44 +168,34 @@
                 {
                   double a = a_arg.double_value ();
 
-                  if (! error_state)
+                  if (b_arg.is_scalar_type ())
                     {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          double b = b_arg.double_value ();
+                      double b = b_arg.double_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<double> b = b_arg.array_value ();
+                      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 ())
                     {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          double b = b_arg.double_value ();
+                      double b = b_arg.double_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<double> b = b_arg.array_value ();
+                      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);
                     }
                 }
             }
@@ -237,44 +207,34 @@
                 {
                   double a = a_arg.double_value ();
 
-                  if (! error_state)
+                  if (b_arg.is_scalar_type ())
                     {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          double b = b_arg.double_value ();
+                      double b = b_arg.double_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<double> b = b_arg.array_value ();
+                      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 ())
                     {
-                      if (b_arg.is_scalar_type ())
-                        {
-                          double b = b_arg.double_value ();
+                      double b = b_arg.double_value ();
 
-                          if (! error_state)
-                            retval = betainc (x, a, b);
-                        }
-                      else
-                        {
-                          Array<double> b = b_arg.array_value ();
+                      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);
                     }
                 }
             }
@@ -360,44 +320,34 @@
             {
               double a = a_arg.double_value ();
 
-              if (! error_state)
+              if (b_arg.is_scalar_type ())
                 {
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+                  double b = b_arg.double_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> 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 ();
 
-              if (! error_state)
+              if (b_arg.is_scalar_type ())
                 {
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+                  double b = b_arg.double_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> b = b_arg.array_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
+                  retval = betaincinv (x, a, b);
                 }
             }
         }
@@ -409,44 +359,34 @@
             {
               double a = a_arg.double_value ();
 
-              if (! error_state)
+              if (b_arg.is_scalar_type ())
                 {
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+                  double b = b_arg.double_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> 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 ();
 
-              if (! error_state)
+              if (b_arg.is_scalar_type ())
                 {
-                  if (b_arg.is_scalar_type ())
-                    {
-                      double b = b_arg.double_value ();
+                  double b = b_arg.double_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> b = b_arg.array_value ();
 
-                      if (! error_state)
-                        retval = betaincinv (x, a, b);
-                    }
+                  retval = betaincinv (x, a, b);
                 }
             }
         }
--- a/libinterp/corefcn/bitfcns.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/bitfcns.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -182,22 +182,22 @@
                 {
                   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 ();
+
+                  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 ();
+
+                  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 ();
+
+                  retval = bitopx (fname, x, y).array_value ();
                 }
               else
                 {
@@ -206,8 +206,8 @@
 
                   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).float_array_value ();
                 }
             }
           else
@@ -222,64 +222,64 @@
                 {
                   uint64NDArray x (dx);
                   uint64NDArray y = args(q).uint64_array_value ();
-                  if (! error_state)
-                    retval = bitopx (fname, x, y);
+
+                  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);
+
+                  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);
+
+                  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);
+
+                  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);
+
+                  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);
+
+                  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);
+
+                  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);
+
+                  retval = bitopx (fname, x, y);
                 }
               else
                 error ("%s: invalid operand type", fname.c_str ());
@@ -292,64 +292,64 @@
             {
               uint64NDArray x = args(0).uint64_array_value ();
               uint64NDArray y = args(1).uint64_array_value ();
-              if (! error_state)
-                retval = bitopx (fname, x, y);
+
+              retval = bitopx (fname, x, y);
             }
           else if (args(0).type_id () == octave_uint32_matrix::static_type_id ()
                    || args(0).type_id () == octave_uint32_scalar::static_type_id ())
             {
               uint32NDArray x = args(0).uint32_array_value ();
               uint32NDArray y = args(1).uint32_array_value ();
-              if (! error_state)
-                retval = bitopx (fname, x, y);
+
+              retval = bitopx (fname, x, y);
             }
           else if (args(0).type_id () == octave_uint16_matrix::static_type_id ()
                    || args(0).type_id () == octave_uint16_scalar::static_type_id ())
             {
               uint16NDArray x = args(0).uint16_array_value ();
               uint16NDArray y = args(1).uint16_array_value ();
-              if (! error_state)
-                retval = bitopx (fname, x, y);
+
+              retval = bitopx (fname, x, y);
             }
           else if (args(0).type_id () == octave_uint8_matrix::static_type_id ()
                    || args(0).type_id () == octave_uint8_scalar::static_type_id ())
             {
               uint8NDArray x = args(0).uint8_array_value ();
               uint8NDArray y = args(1).uint8_array_value ();
-              if (! error_state)
-                retval = bitopx (fname, x, y);
+
+              retval = bitopx (fname, x, y);
             }
           else if (args(0).type_id () == octave_int64_matrix::static_type_id ()
                    || args(0).type_id () == octave_int64_scalar::static_type_id ())
             {
               int64NDArray x = args(0).int64_array_value ();
               int64NDArray y = args(1).int64_array_value ();
-              if (! error_state)
-                retval = bitopx (fname, x, y);
+
+              retval = bitopx (fname, x, y);
             }
           else if (args(0).type_id () == octave_int32_matrix::static_type_id ()
                    || args(0).type_id () == octave_int32_scalar::static_type_id ())
             {
               int32NDArray x = args(0).int32_array_value ();
               int32NDArray y = args(1).int32_array_value ();
-              if (! error_state)
-                retval = bitopx (fname, x, y);
+
+              retval = bitopx (fname, x, y);
             }
           else if (args(0).type_id () == octave_int16_matrix::static_type_id ()
                    || args(0).type_id () == octave_int16_scalar::static_type_id ())
             {
               int16NDArray x = args(0).int16_array_value ();
               int16NDArray y = args(1).int16_array_value ();
-              if (! error_state)
-                retval = bitopx (fname, x, y);
+
+              retval = bitopx (fname, x, y);
             }
           else if (args(0).type_id () == octave_int8_matrix::static_type_id ()
                    || args(0).type_id () == octave_int8_scalar::static_type_id ())
             {
               int8NDArray x = args(0).int8_array_value ();
               int8NDArray y = args(1).int8_array_value ();
-              if (! error_state)
-                retval = bitopx (fname, x, y);
+
+              retval = bitopx (fname, x, y);
             }
           else
             error ("%s: invalid operand type", fname.c_str ());
@@ -368,8 +368,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 +378,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 +389,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 +460,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: expecting integer as second argument"); \
 
 #define DO_UBITSHIFT(T, N) \
   do \
@@ -546,8 +541,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,7 +563,7 @@
 @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;
@@ -603,9 +598,6 @@
             }
         }
 
-      if (error_state)
-        return retval;
-
       octave_value m_arg = args(0);
       std::string cname = m_arg.class_name ();
 
@@ -678,43 +670,6 @@
 %!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,7 +681,7 @@
 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;
@@ -785,7 +740,7 @@
 @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;
@@ -856,7 +811,7 @@
 @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;
--- a/libinterp/corefcn/bsxfun.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/bsxfun.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -237,12 +237,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 +256,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 +294,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 +309,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);
     }
 }
 
@@ -374,7 +374,7 @@
             }
         }
 
-      if (! error_state && retval.empty ())
+      if (retval.empty ())
         {
           dim_vector dva = A.dims ();
           octave_idx_type nda = dva.length ();
@@ -391,277 +391,268 @@
             }
 
           for (octave_idx_type i = 0; i < nd; i++)
-            if (dva (i) != dvb (i) && dva (i) != 1 && dvb (i) != 1)
+            if (dva(i) != dvb(i) && dva(i) != 1 && dvb(i) != 1)
               {
                 error ("bsxfun: dimensions of A and B must match");
                 break;
               }
 
-          if (!error_state)
-            {
-              // Find the size of the output
-              dim_vector dvc;
-              dvc.resize (nd);
+          // 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))));
+          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 (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);
+          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);
 
 #define BSXDEF(T) \
-                  T result_ ## T; \
-                  bool have_ ## T = false;
+              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);
+              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);
+              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 (maybe_update_column (Ac, A, dva, dvc, i, idxA))
-                        inputs (0) = Ac;
+              for (octave_idx_type i = 0; i < ncount; i++)
+                {
+                  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;
+                  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;
+                  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); \
-                        }
+  (result_type == CLS) \
+    { \
+      have_ ## T = true; \
+      result_ ## T = tmp (0). EXTRACTOR ## _array_value (); \
+      result_ ## T .resize (dvc); \
+    }
 
-                      if (i == 0)
+                  if (i == 0)
+                    {
+                      if (! tmp(0).is_sparse_type ())
                         {
-                          if (! tmp(0).is_sparse_type ())
+                          std::string result_type = tmp(0).class_name ();
+                          if (result_type == "double")
                             {
-                              std::string result_type = tmp(0).class_name ();
-                              if (result_type == "double")
+                              if (tmp(0).is_real_type ())
                                 {
-                                  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);
-                                    }
+                                  have_NDArray = true;
+                                  result_NDArray = tmp(0).array_value ();
+                                  result_NDArray.resize (dvc);
                                 }
-                              else if (result_type == "single")
+                              else
                                 {
-                                  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);
-                                    }
+                                  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 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
                                 {
-                                  C = tmp (0);
-                                  C = C.resize (dvc);
+                                  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
+                    }
+                  else
+                    {
+                      update_index (ra_idx, dvc, i);
+
+                      if (have_FloatNDArray
+                          || have_FloatComplexNDArray)
                         {
-                          update_index (ra_idx, dvc, i);
-
-                          if (have_FloatNDArray
-                              || have_FloatComplexNDArray)
+                          if (! tmp(0).is_float_type ())
                             {
-                              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 (have_FloatNDArray)
                                 {
-                                  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;
-                                    }
+                                  have_FloatNDArray = false;
+                                  C = result_FloatNDArray;
                                 }
-                              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_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_FloatComplexNDArray = true;
+                                  have_NDArray = true;
                                 }
                             }
-                          else if (have_NDArray)
+                          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 ())
                             {
-                              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;
-                                }
+                              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); \
-                          }
+  (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);
-                        }
+                      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);
                     }
+                }
 
 #define BSXEND(T) \
-                  (have_ ## T) \
-                    retval(0) = result_ ## 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;
-                }
+              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/cellfun.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/cellfun.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -70,17 +70,22 @@
                  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&)
     {
       if (error_handler.is_defined ())
-        error_state = 1;
+        execution_error = true;
+      else
+        octave_throw_execution_exception ();
     }
 
-  if (error_state)
+  if (execution_error)
     {
       if (error_handler.is_defined ())
         {
@@ -96,14 +101,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 +183,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\"");
@@ -433,7 +430,7 @@
     {
       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 +446,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 +457,7 @@
             error ("cellfun: invalid function NAME: %s", name.c_str ());
         }
 
-      if (error_state || ! retval.empty ())
+      if (! retval.empty ())
         return retval;
     }
 
@@ -509,7 +506,7 @@
                   retval =
                     try_cellfun_internal_ops<Cell, Cell> (tmp_args, nargin);
 
-                if (error_state || ! retval.empty ())
+                if (! retval.empty ())
                   return retval;
               }
 
@@ -519,11 +516,9 @@
             func = f;
           }
       }
+
     nevermind:
 
-      if (error_state)
-        return octave_value_list ();
-
       // Extract cell arguments.
 
       octave_value_list inputlist (nargin, octave_value ());
@@ -601,9 +596,6 @@
                 = 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");
@@ -652,9 +644,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
                                     {
@@ -666,9 +655,6 @@
                         }
                     }
                 }
-
-              if (error_state)
-                break;
             }
 
           retval.resize (nargout1);
@@ -702,9 +688,6 @@
                 = 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");
@@ -1204,7 +1187,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 +1201,6 @@
 
           symbol_table_lookup = true;
         }
-
-      if (error_state)
-        return retval;
     }
 
   if (func.is_function_handle () || func.is_inline_function ()
@@ -1258,9 +1238,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 +1304,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 +1360,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 +1372,6 @@
                         }
                     }
                 }
-
-              if (error_state)
-                break;
             }
 
           retval.resize (nargout1);
@@ -1440,18 +1405,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 +1673,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++)
@@ -1783,8 +1742,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,23 +1793,17 @@
     {
       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
@@ -1911,9 +1862,7 @@
       if (nargin > 1)
         dimv = args(1).int_vector_value (true);
 
-      if (error_state)
-        ;
-      else if (array.is_bool_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);
@@ -1959,8 +1908,6 @@
         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);
     }
@@ -1981,7 +1928,7 @@
   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;
@@ -2031,8 +1978,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 +2039,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 +2103,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 +2133,6 @@
 
       retval(j) = a.do_index_op (ra_idx);
 
-      if (error_state)
-        break;
-
       rdv.increment_index (ridx);
     }
 
@@ -2251,11 +2195,7 @@
       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);
-          if (error_state)
-            return retval;
-        }
+        d[i-1] = args(i).octave_idx_type_vector_value (true);
 
       octave_value a = args(0);
       bool sparse = a.is_sparse_type ();
@@ -2339,13 +2279,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 +2298,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);
@@ -2407,88 +2347,85 @@
             error ("cellslices: DIM must be a valid dimension");
         }
 
-      if (! error_state)
+      if (lb.numel () != ub.numel ())
+        error ("cellslices: the lengths of LB and UB must match");
+      else
         {
-          if (lb.length () != ub.length ())
-            error ("cellslices: the lengths of LB and UB must match");
-          else
+          Cell retcell;
+          if (! x.is_sparse_type () && x.is_matrix_type ())
             {
-              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 ())
                 {
-                  // specialize for some dense arrays.
-                  if (x.is_bool_type ())
-                    retcell = do_cellslices_nda (x.bool_array_value (),
+                  if (x.is_int8_type ())
+                    retcell = do_cellslices_nda (x.int8_array_value (),
                                                  lb, ub, dim);
-                  else if (x.is_char_matrix ())
-                    retcell = do_cellslices_nda (x.char_array_value (),
+                  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_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_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
-                    {
-                      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);
-                    }
+                    retcell = do_cellslices_nda (x.complex_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 (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);
                 }
-              if (! error_state)
-                retval = retcell;
             }
+          else
+            {
+              // 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);
+                }
+            }
+
+          retval = retcell;
         }
     }
   else
@@ -2523,28 +2460,24 @@
 @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);
+      const Cell x = args(0).cell_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);
-              if (error_state)
-                break;
-            }
+      for (octave_idx_type i = 0; i < nel; i++)
+        {
+          octave_quit ();
 
-          retval = y;
+          octave_value tmp = x(i);
+
+          y(i) = tmp.do_index_op (idx);
         }
-      else
-        error ("cellindexmat: X must be a cell");
+
+      retval = y;
     }
   else
     print_usage ();
--- a/libinterp/corefcn/colloc.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/colloc.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -61,9 +61,6 @@
 
   double tmp = args(0).double_value ();
 
-  if (error_state)
-    return retval;
-
   if (xisnan (tmp))
     {
       error ("colloc: N cannot be NaN");
@@ -83,35 +80,21 @@
 
   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).string_value ("colloc: expecting string argument \"left\" or \"right\"");
 
-          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");
+          error ("colloc: unrecognized argument");
           return retval;
         }
     }
--- a/libinterp/corefcn/conv2.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/conv2.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -329,15 +329,7 @@
       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;
-        }
-    }
+    shape = args(2).string_value ("convn: SHAPE must be a string");
 
   if (shape == "full")
     ct = convn_full;
--- a/libinterp/corefcn/daspk.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/daspk.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -63,7 +63,7 @@
 {
   ColumnVector retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -95,7 +95,7 @@
           if (tlen > 1)
             ires = tmp(1).int_value ();
 
-          if (error_state || retval.length () == 0)
+          if (error_state || retval.numel () == 0)
             gripe_user_supplied_eval ("daspk");
         }
       else
@@ -111,7 +111,7 @@
 {
   Matrix retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -141,7 +141,7 @@
 
           retval = tmp(0).matrix_value ();
 
-          if (error_state || retval.length () == 0)
+          if (error_state || retval.numel () == 0)
             gripe_user_supplied_eval ("daspk");
         }
       else
@@ -157,7 +157,7 @@
 #define DASPK_ABORT1(msg) \
   do \
     { \
-      ::error ("daspk: " msg); \
+      error ("daspk: " msg); \
       DASPK_ABORT (); \
     } \
   while (0)
@@ -165,7 +165,7 @@
 #define DASPK_ABORT2(fmt, arg) \
   do \
     { \
-      ::error ("daspk: " fmt, arg); \
+      error ("daspk: " fmt, arg); \
       DASPK_ABORT (); \
     } \
   while (0)
@@ -297,9 +297,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 ())
                 daspk_fcn = c(0).function_value ();
@@ -364,31 +364,28 @@
                   {
                     string_vector tmp = f_arg.all_strings ();
 
-                    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)
                       {
-                        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");
+                        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)
+                        if (!daspk_jac)
                           {
-                            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 (fcn_name.length ())
+                              clear_function (fcn_name);
+                            daspk_fcn = 0;
                           }
                       }
                   }
@@ -426,7 +423,7 @@
           crit_times_set = 1;
         }
 
-      if (state.capacity () != deriv.capacity ())
+      if (state.numel () != deriv.numel ())
         DASPK_ABORT1 ("x and xdot must have the same size");
 
       double tzero = out_times (0);
@@ -451,26 +448,23 @@
       if (jac_name.length ())
         clear_function (jac_name);
 
-      if (! error_state)
-        {
-          std::string msg = dae.error_message ();
+      std::string msg = dae.error_message ();
 
-          retval(3) = msg;
-          retval(2) = static_cast<double> (dae.integration_state ());
+      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 (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 (nargout < 3)
+            error ("daspk: %s", msg.c_str ());
         }
     }
   else
--- a/libinterp/corefcn/dasrt.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/dasrt.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -63,7 +63,7 @@
 {
   ColumnVector retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -91,7 +91,7 @@
 
           retval = ColumnVector (tmp(0).vector_value ());
 
-          if (error_state || retval.length () == 0)
+          if (error_state || retval.numel () == 0)
             gripe_user_supplied_eval ("dasrt");
         }
       else
@@ -131,7 +131,7 @@
 
           retval = ColumnVector (tmp(0).vector_value ());
 
-          if (error_state || retval.length () == 0)
+          if (error_state || retval.numel () == 0)
             gripe_user_supplied_eval ("dasrt");
         }
       else
@@ -147,7 +147,7 @@
 {
   Matrix retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -177,7 +177,7 @@
 
           retval = tmp(0).matrix_value ();
 
-          if (error_state || retval.length () == 0)
+          if (error_state || retval.numel () == 0)
             gripe_user_supplied_eval ("dasrt");
         }
       else
@@ -193,7 +193,7 @@
 #define DASRT_ABORT1(msg) \
   do \
     { \
-      ::error ("dasrt: " msg); \
+      error ("dasrt: " msg); \
       DASRT_ABORT; \
     } \
   while (0)
@@ -201,7 +201,7 @@
 #define DASRT_ABORT2(fmt, arg) \
   do \
     { \
-      ::error ("dasrt: " fmt, arg); \
+      error ("dasrt: " fmt, arg); \
       DASRT_ABORT; \
     } \
   while (0)
@@ -385,9 +385,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 +448,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;
@@ -560,28 +557,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/dassl.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -63,7 +63,7 @@
 {
   ColumnVector retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -95,7 +95,7 @@
           if (tlen > 1)
             ires = tmp(1).int_value ();
 
-          if (error_state || retval.length () == 0)
+          if (error_state || retval.numel () == 0)
             gripe_user_supplied_eval ("dassl");
         }
       else
@@ -111,7 +111,7 @@
 {
   Matrix retval;
 
-  assert (x.capacity () == xdot.capacity ());
+  assert (x.numel () == xdot.numel ());
 
   octave_value_list args;
 
@@ -141,7 +141,7 @@
 
           retval = tmp(0).matrix_value ();
 
-          if (error_state || retval.length () == 0)
+          if (error_state || retval.numel () == 0)
             gripe_user_supplied_eval ("dassl");
         }
       else
@@ -157,7 +157,7 @@
 #define DASSL_ABORT1(msg) \
   do \
     { \
-      ::error ("dassl: " msg); \
+      error ("dassl: " msg); \
       DASSL_ABORT (); \
     } \
   while (0)
@@ -165,7 +165,7 @@
 #define DASSL_ABORT2(fmt, arg) \
   do \
     { \
-      ::error ("dassl: " fmt, arg); \
+      error ("dassl: " fmt, arg); \
       DASSL_ABORT (); \
     } \
   while (0)
@@ -298,9 +298,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 ())
                 dassl_fcn = c(0).function_value ();
@@ -365,31 +365,28 @@
                   {
                     string_vector tmp = f_arg.all_strings ();
 
-                    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)
                       {
-                        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");
+                        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)
+                        if (!dassl_jac)
                           {
-                            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 (fcn_name.length ())
+                              clear_function (fcn_name);
+                            dassl_fcn = 0;
                           }
                       }
                   }
@@ -427,7 +424,7 @@
           crit_times_set = 1;
         }
 
-      if (state.capacity () != deriv.capacity ())
+      if (state.numel () != deriv.numel ())
         DASSL_ABORT1 ("x and xdot must have the same size");
 
       double tzero = out_times (0);
@@ -453,26 +450,23 @@
       if (jac_name.length ())
         clear_function (jac_name);
 
-      if (! error_state)
-        {
-          std::string msg = dae.error_message ();
+      std::string msg = dae.error_message ();
 
-          retval(3) = msg;
-          retval(2) = static_cast<double> (dae.integration_state ());
+      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 (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 (nargout < 3)
+            error ("dassl: %s", msg.c_str ());
         }
     }
   else
--- a/libinterp/corefcn/data.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/data.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -413,7 +413,7 @@
   else if (nargin >= 3)
     {
       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
@@ -590,7 +590,26 @@
 @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")
 {
@@ -689,20 +708,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 +738,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 +754,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,11 +770,27 @@
 @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")
 {
@@ -881,8 +922,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 +936,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 +948,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,132 +961,80 @@
         error ("sum: unrecognized string argument"); \
       nargin --; \
     } \
-  \
+ \
   if (nargin == 1 || nargin == 2) \
     { \
       octave_value arg = args(0); \
  \
       int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
  \
-      if (! error_state) \
+      if (dim >= -1) \
         { \
-          if (dim >= -1) \
+          if (arg.is_sparse_type ()) \
             { \
-              if (arg.is_sparse_type ()) \
+              if (arg.is_real_type ()) \
                 { \
-                  if (arg.is_real_type ()) \
-                    { \
-                      SparseMatrix tmp = arg.sparse_matrix_value (); \
-                      \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
-                  else \
-                    { \
-                      SparseComplexMatrix tmp \
-                        = arg.sparse_complex_matrix_value (); \
-                      \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
+                  SparseMatrix tmp = arg.sparse_matrix_value (); \
+ \
+                  retval = tmp.FCN (dim); \
                 } \
               else \
                 { \
-                  if (isnative) \
+                  SparseComplexMatrix tmp \
+                    = arg.sparse_complex_matrix_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 ()) \
                     { \
-                      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 ()) \
+                      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 ()) \
                         { \
-                          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); \
+                          FloatComplexNDArray tmp = \
+                            arg.float_complex_array_value (); \
+ \
+                          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; \
+                          FloatNDArray tmp = arg.float_array_value (); \
+ \
+                          retval = tmp.FCN (dim); \
                         } \
                     } \
-                  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 ()) \
+                  else if (arg.is_complex_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); \
-                        } \
+                      ComplexNDArray tmp = arg.complex_array_value (); \
+ \
+                      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); \
+ \
+                      retval = tmp.FCN (dim); \
                     } \
                   else \
                     { \
@@ -1052,11 +1042,50 @@
                       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 \
+                { \
+                  gripe_wrong_type_arg (#FCN, arg); \
+                  return retval; \
+                } \
             } \
           else \
             error (#FCN ": invalid dimension argument = %d", dim + 1); \
         } \
-      \
+ \
     } \
   else \
     print_usage (); \
@@ -1075,68 +1104,59 @@
  \
       int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
  \
-      if (! error_state) \
+      if (dim >= -1) \
         { \
-          if (dim >= -1) \
+          if (arg.is_real_type ()) \
             { \
-              if (arg.is_real_type ()) \
+              if (arg.is_sparse_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 ()) \
-                    { \
-                      FloatNDArray tmp = arg.float_array_value (); \
- \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
-                  else \
-                    { \
-                      NDArray tmp = arg.array_value (); \
- \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
+                  SparseMatrix tmp = arg.sparse_matrix_value (); \
+\
+                  retval = tmp.FCN (dim); \
                 } \
-              else if (arg.is_complex_type ()) \
+              else if (arg.is_single_type ()) \
                 { \
-                  if (arg.is_sparse_type ()) \
-                    { \
-                      SparseComplexMatrix tmp = arg.sparse_complex_matrix_value (); \
- \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
-                  else if (arg.is_single_type ()) \
-                    { \
-                      FloatComplexNDArray tmp \
-                        = arg.float_complex_array_value (); \
- \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
-                  else \
-                    { \
-                      ComplexNDArray tmp = arg.complex_array_value (); \
- \
-                      if (! error_state) \
-                        retval = tmp.FCN (dim); \
-                    } \
+                  FloatNDArray tmp = arg.float_array_value (); \
+\
+                  retval = tmp.FCN (dim); \
                 } \
               else \
                 { \
-                  gripe_wrong_type_arg (#FCN, arg); \
-                  return retval; \
+                  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 \
-            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 (); \
@@ -1212,9 +1232,6 @@
       nargin --;
     }
 
-  if (error_state)
-    return retval;
-
   if (nargin == 1 || nargin == 2)
     {
       octave_value arg = args(0);
@@ -1227,74 +1244,71 @@
             error ("cumsum: invalid dimension argument = %d", dim + 1);
         }
 
-      if (! error_state)
+      switch (arg.builtin_type ())
         {
-          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;
-                }
+        case btyp_bool:
+          if (arg.is_sparse_type ())
+            {
+              SparseMatrix cs = arg.sparse_matrix_value ().cumsum (dim);
+              if (isnative)
+                retval = cs != 0.0;
               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);
+                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
@@ -1511,9 +1525,6 @@
       nargin --;
     }
 
-  if (error_state)
-    return retval;
-
   if (nargin == 1 || nargin == 2)
     {
       octave_value arg = args(0);
@@ -1526,73 +1537,70 @@
             error ("prod: invalid dimension DIM = %d", dim + 1);
         }
 
-      if (! error_state)
+      switch (arg.builtin_type ())
         {
-          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);
+          // 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 = NDArray (arg.bool_array_value ().all (dim));
-              break;
-
-            default:
-              gripe_wrong_type_arg ("prod", arg);
+                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
@@ -1701,7 +1709,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 +1720,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 +1740,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 +1771,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
@@ -1856,19 +1861,14 @@
 
       octave_value_list tmp2 = fcn.do_multi_index_op (1, ovl);
 
-      if (! error_state)
+      if (tmp2.length () > 0)
+        retval = tmp2(0);
+      else
         {
-          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;
-            }
+          error ("%s/%s method did not return a value",
+                 dtype.c_str (), cattype.c_str ());
+          goto done;
         }
-      else
-        goto done;
     }
   else
     {
@@ -1888,12 +1888,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);
@@ -2051,7 +2046,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 +2085,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 +2095,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 +2104,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;
         }
@@ -2584,15 +2572,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 ();
@@ -3019,9 +3006,6 @@
       nargin --;
     }
 
-  if (error_state)
-    return retval;
-
   if (nargin == 1 || nargin == 2)
     {
       octave_value arg = args(0);
@@ -3034,88 +3018,85 @@
             error ("sum: invalid dimension DIM = %d", dim + 1);
         }
 
-      if (! error_state)
+      switch (arg.builtin_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 ())
             {
-            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_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);
+          // 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.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);
+                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
@@ -3362,8 +3343,7 @@
             {
               SparseComplexMatrix val = arg.sparse_complex_matrix_value ();
 
-              if (! error_state)
-                retval = octave_value (new octave_sparse_complex_matrix (val));
+              retval = octave_value (new octave_sparse_complex_matrix (val));
             }
           else if (arg.is_single_type ())
             {
@@ -3371,15 +3351,13 @@
                 {
                   FloatComplex val = arg.float_complex_value ();
 
-                  if (! error_state)
-                    retval = octave_value (new octave_float_complex (val));
+                  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));
+                  retval = octave_value (new octave_float_complex_matrix (val));
                 }
             }
           else
@@ -3388,15 +3366,13 @@
                 {
                   Complex val = arg.complex_value ();
 
-                  if (! error_state)
-                    retval = octave_value (new octave_complex (val));
+                  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));
+                  retval = octave_value (new octave_complex_matrix (val));
                 }
             }
 
@@ -3414,66 +3390,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 +3459,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 +3484,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 +3522,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,35 +3545,29 @@
             {
               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");
             }
         }
 
@@ -3991,9 +3943,6 @@
       nargin--;
 
       dt = oct_data_conv::string_to_data_type (nm);
-
-      if (error_state)
-        return retval;
     }
 
   switch (nargin)
@@ -4023,77 +3972,71 @@
       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 +4060,6 @@
       nargin--;
 
       dt = oct_data_conv::string_to_data_type (nm);
-
-      if (error_state)
-        return retval;
     }
 
   switch (nargin)
@@ -4149,32 +4089,26 @@
       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 +4131,6 @@
       nargin--;
 
       dt = oct_data_conv::string_to_data_type (nm);
-
-      if (error_state)
-        return retval;
     }
 
   switch (nargin)
@@ -4229,32 +4160,26 @@
       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 +4203,6 @@
       nargin--;
 
       dt = oct_data_conv::string_to_data_type (nm);
-
-      if (error_state)
-        return retval;
     }
 
   switch (nargin)
@@ -4310,33 +4232,27 @@
       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;
@@ -4378,18 +4294,14 @@
       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,7 +4600,7 @@
 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 ();
@@ -4700,52 +4612,48 @@
         {
           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 +4769,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 +4988,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,9 +5108,6 @@
       nargin--;
 
       dt = oct_data_conv::string_to_data_type (nm);
-
-      if (error_state)
-        return retval;
     }
 
   switch (nargin)
@@ -5219,8 +5121,7 @@
         octave_idx_type nr, nc;
         get_dimensions (args(0), "eye", nr, nc);
 
-        if (! error_state)
-          retval = identity_matrix (nr, nc, dt);
+        retval = identity_matrix (nr, nc, dt);
       }
       break;
 
@@ -5229,8 +5130,7 @@
         octave_idx_type nr, nc;
         get_dimensions (args(0), args(1), "eye", nr, nc);
 
-        if (! error_state)
-          retval = identity_matrix (nr, nc, dt);
+        retval = identity_matrix (nr, nc, dt);
       }
       break;
 
@@ -5276,7 +5176,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 +5186,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 +5211,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\
@@ -5322,7 +5224,7 @@
 {
   octave_value retval;
 
-  int nargin = args.length ();
+  octave_idx_type nargin = args.length ();
 
   octave_idx_type npoints = 100;
 
@@ -5341,33 +5243,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,12 +5289,48 @@
 %! 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
@@ -5446,7 +5389,7 @@
   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));
@@ -5469,15 +5412,13 @@
       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;
 }
 
@@ -5527,15 +5468,15 @@
     {
       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)
             {
@@ -5570,9 +5511,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 +5519,7 @@
             }
         }
 
-      if (! error_state && (empty_dim > 0))
+      if (empty_dim > 0)
         {
           octave_idx_type nel = new_dims.numel ();
 
@@ -5605,8 +5544,7 @@
       return retval;
     }
 
-  if (! error_state)
-    retval = args(0).reshape (new_dims);
+  retval = args(0).reshape (new_dims);
 
   return retval;
 }
@@ -5658,7 +5596,7 @@
   if (nargin < 1 || nargin > 2)
     print_usage () ;
 
-  if (! error_state && nargin == 2)
+  if (nargin == 2)
     {
       dim = args(1).idx_type_value ();
 
@@ -5666,24 +5604,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;
@@ -5832,53 +5767,47 @@
               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 ())
             {
-              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 = 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 ());
-                    }
+                  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: invalid combination of options");
+                    error ("norm: unrecognized option: %s", str.c_str ());
                 }
-              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 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
@@ -6516,21 +6445,18 @@
             error ("toc: invalid ID");
         }
 
-      if (! error_state)
+      if (start_time < 0)
+        error ("toc called before timer set");
+      else
         {
-          if (start_time < 0)
-            error ("toc called before timer set");
+          octave_time now;
+
+          double tmp = now.double_value () - start_time;
+
+          if (nargout > 0)
+            retval = tmp;
           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_stdout << "Elapsed time is " << tmp << " seconds.\n";
         }
     }
 
@@ -6729,12 +6655,8 @@
           return retval;
         }
 
-      if (! args(2).is_string ())
-        {
-          error ("sort: MODE must be a string");
-          return retval;
-        }
-      std::string mode = args(2).string_value ();
+      std::string mode = args(2).string_value ("sort: MODE must be a string");
+
       if (mode == "ascend")
         smode = ASCENDING;
       else if (mode == "descend")
@@ -7012,20 +6934,16 @@
   // 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.string_value ("issorted: expecting %s argument to be a string", argn);
+
+  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;
 }
@@ -7071,19 +6989,11 @@
       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");
-        }
+      std::string tmp = args(1).string_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), "second");
     }
 
   octave_value arg = args(0);
@@ -7183,44 +7093,48 @@
       if (dim < 0)
         dim = argx.dims ().first_non_singleton ();
 
-      idx_vector n = args(1).index_vector ();
-
-      if (error_state)
-        return retval;
-
-      switch (argx.builtin_type ())
+      try
         {
-        case btyp_double:
-          retval = argx.array_value ().nth_element (n, dim);
-          break;
-        case btyp_float:
-          retval = argx.float_array_value ().nth_element (n, dim);
-          break;
-        case btyp_complex:
-          retval = argx.complex_array_value ().nth_element (n, dim);
-          break;
-        case btyp_float_complex:
-          retval = argx.float_complex_array_value ().nth_element (n, dim);
-          break;
+          idx_vector n = args(1).index_vector ();
+
+          switch (argx.builtin_type ())
+            {
+            case btyp_double:
+              retval = argx.array_value ().nth_element (n, dim);
+              break;
+            case btyp_float:
+              retval = argx.float_array_value ().nth_element (n, dim);
+              break;
+            case btyp_complex:
+              retval = argx.complex_array_value ().nth_element (n, dim);
+              break;
+            case btyp_float_complex:
+              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 ())
-            retval = argx.cellstr_value ().nth_element (n, dim);
-          else
-            gripe_wrong_type_arg ("nth_element", argx);
+            default:
+              if (argx.is_cellstr ())
+                retval = argx.cellstr_value ().nth_element (n, dim);
+              else
+                gripe_wrong_type_arg ("nth_element", argx);
+            }
+        }
+      catch (index_exception& e)
+        {
+          error ("nth_element: invalid N value %s. %s", e.idx (), e.explain ());
         }
     }
   else
@@ -7262,14 +7176,15 @@
   int nargin = args.length ();
   if (nargin >= 2 && nargin <= 3 && args(0).is_numeric_type ())
     {
-      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)
+      try
         {
+          idx_vector idx = args(0).index_vector ();
+          octave_idx_type n = -1;
+          if (nargin == 3)
+            n = args(2).idx_type_value (true);
+
           octave_value vals = args(1);
+
           if (vals.is_range ())
             {
               Range r = vals.range_value ();
@@ -7298,6 +7213,11 @@
           else
             gripe_wrong_type_arg ("accumarray", vals);
         }
+      catch (index_exception& e)
+        {
+          error ("__accumarray_sum__: invalid IDX %s. %s",
+                 e.idx(), e.explain ());
+        }
     }
   else
     print_usage ();
@@ -7342,13 +7262,13 @@
   int nargin = args.length ();
   if (nargin >= 3 && nargin <= 4 && args(0).is_numeric_type ())
     {
-      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)
+      try
         {
+          idx_vector idx = args(0).index_vector ();
+          octave_idx_type n = -1;
+          if (nargin == 4)
+            n = args(3).idx_type_value (true);
+
           octave_value vals = args(1);
           octave_value zero = args(2);
 
@@ -7373,20 +7293,20 @@
                                              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,
@@ -7396,6 +7316,12 @@
               gripe_wrong_type_arg ("accumarray", vals);
             }
         }
+      catch (index_exception& e)
+        {
+          error ("do_accumarray_minmax_fun: invalid index %s. %s",
+                                        e.idx (), e.explain ());
+        }
+
     }
   else
     print_usage ();
@@ -7462,17 +7388,17 @@
   int nargin = args.length ();
   if (nargin >= 2 && nargin <= 4 && args(0).is_numeric_type ())
     {
-      idx_vector idx = args(0).index_vector ();
-      int dim = -1;
-      if (nargin >= 3)
-        dim = args(2).int_value () - 1;
-
-      octave_idx_type n = -1;
-      if (nargin == 4)
-        n = args(3).idx_type_value (true);
-
-      if (! error_state)
+      try
         {
+          idx_vector idx = args(0).index_vector ();
+          int dim = -1;
+          if (nargin >= 3)
+            dim = args(2).int_value () - 1;
+
+          octave_idx_type n = -1;
+          if (nargin == 4)
+            n = args(3).idx_type_value (true);
+
           octave_value vals = args(1);
 
           if (vals.is_single_type ())
@@ -7496,6 +7422,10 @@
           else
             gripe_wrong_type_arg ("accumdim", vals);
         }
+      catch (index_exception& e)
+        {
+          error ("__accumdim_sum__: invalid IDX %s. %s", e.idx(), e.explain ());
+        }
     }
   else
     print_usage ();
@@ -7839,33 +7769,29 @@
   else 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 ("order K must be a scalar or []");
+      if (order < 0)
+        error ("order K must be non-negative");
     }
 
+  if (nargin > 2)
+    {
+      dim = args(2).int_value (true, false);
+      if (dim < 1 || dim > args(0).ndims ())
+        error ("DIM must be a valid dimension");
+      else
+        dim -= 1;
+    }
+
+  retval = do_diff (args(0), order, dim);
+
   return retval;
 }
 
@@ -7949,9 +7875,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;
@@ -8033,21 +7958,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 +7995,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 +8009,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 +8061,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/debug.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/debug.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -210,15 +210,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
@@ -250,8 +246,7 @@
       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 +255,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;
         }
     }
 }
@@ -292,7 +280,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create breakpoint table!");
+      error ("unable to create breakpoint table!");
       retval = false;
     }
 
@@ -677,8 +665,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);
 }
@@ -731,10 +718,7 @@
   if (nargin == 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;
 }
@@ -973,134 +957,131 @@
   int nargin = args.length ();
   string_vector argv = args.make_argv ("dbtype");
 
-  if (! error_state)
+  switch (nargin)
     {
-      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);
+
+                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 (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");
+                if (std::min (start, end) <= 0)
+                  {
+                    error ("dbtype: start and end lines must be >= 1\n");
+                    break;
+                  }
 
-          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 ());
 
-        case 1: // (dbtype start:end) || (dbtype func) || (dbtype lineno)
-          {
-            std::string arg = argv[1];
+            if (line == 0)  // (dbtype func)
+              {
+                dbg_fcn = get_user_code (arg);
 
-            size_t ind = arg.find (':');
+                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;
+                  }
 
-            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);
-
-                    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");
+              break;
+            }
 
-        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;
@@ -1200,7 +1181,7 @@
     {
       int n = 0;
 
-      for (octave_idx_type i = 0; i < len && ! error_state; i++)
+      for (octave_idx_type i = 0; i < len; i++)
         {
           octave_value arg = args(i);
 
@@ -1218,7 +1199,7 @@
           else
             n = arg.int_value ();
 
-          if (! error_state && n <= 0)
+          if (n <= 0)
             error ("dbstack: N must be a non-negative integer");
         }
 
@@ -1228,63 +1209,60 @@
   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;
@@ -1367,14 +1345,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, ,
@@ -1442,38 +1417,33 @@
         print_usage ();
       else if (nargin == 1)
         {
-          if (args(0).is_string ())
+          std::string arg = args(0).string_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
         {
--- a/libinterp/corefcn/defun-int.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/defun-int.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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/det.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/det.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -151,15 +151,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 +167,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 +188,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 +216,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/dirfns.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -128,9 +128,6 @@
 
   string_vector argv = args.make_argv ("cd");
 
-  if (error_state)
-    return retval;
-
   if (nargout > 0)
     retval = octave_value (octave_env::get_current_directory ());
 
@@ -187,24 +184,19 @@
 
   if (args.length () == 1)
     {
-      std::string dirname = args(0).string_value ();
+      std::string dirname = args(0).string_value ("readdir: DIR must be a string");
+
+      dir_entry dir (dirname);
 
-      if (error_state)
-        gripe_wrong_type_arg ("readdir", args(0));
+      if (dir)
+        {
+          string_vector dirlist = dir.read ();
+          retval(1) = 0.0;
+          retval(0) = Cell (dirlist.sort ());
+        }
       else
         {
-          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 ();
-            }
+          retval(2) = dir.error ();
         }
     }
   else
@@ -248,27 +240,13 @@
 
   if (nargin == 2)
     {
-      std::string parent = args(0).string_value ();
-      std::string dir = args(1).string_value ();
+      std::string parent = args(0).string_value ("mkdir: PARENT must be a string");
+      std::string dir = args(1).string_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 ();
-
-      if (error_state)
-        {
-          gripe_wrong_type_arg ("mkdir", args(0));
-          return retval;
-        }
-    }
+    dirname = args(0).string_value ("mkdir: DIR must be a string");
 
   if (nargin == 1 || nargin == 2)
     {
@@ -334,48 +312,43 @@
 
   if (nargin == 1 || nargin == 2)
     {
-      std::string dirname = args(0).string_value ();
+      std::string dirname = args(0).string_value ("rmdir: DIR must be a string");
 
-      if (error_state)
-        gripe_wrong_type_arg ("rmdir", args(0));
-      else
+      std::string fulldir = file_ops::tilde_expand (dirname);
+      int status = -1;
+      std::string msg;
+
+      if (nargin == 2)
         {
-          std::string fulldir = file_ops::tilde_expand (dirname);
-          int status = -1;
-          std::string msg;
+          if (args(1).string_value () == "s")
+            {
+              bool doit = true;
 
-          if (nargin == 2)
-            {
-              if (args(1).string_value () == "s")
+              if (interactive && ! forced_interactive
+                  && Vconfirm_recursive_rmdir)
                 {
-                  bool doit = true;
-
-                  if (interactive && ! forced_interactive
-                      && Vconfirm_recursive_rmdir)
-                    {
-                      std::string prompt
-                        = "remove entire contents of " + fulldir + "? ";
+                  std::string prompt
+                    = "remove entire contents of " + fulldir + "? ";
 
-                      doit = octave_yes_or_no (prompt);
-                    }
+                  doit = octave_yes_or_no (prompt);
+                }
 
-                  if (doit)
-                    status = octave_recursive_rmdir (fulldir, msg);
-                }
-              else
-                error ("rmdir: expecting second argument to be \"s\"");
+              if (doit)
+                status = octave_recursive_rmdir (fulldir, msg);
             }
           else
-            status = octave_rmdir (fulldir, msg);
+            error ("rmdir: expecting second argument to be \"s\"");
+        }
+      else
+        status = octave_rmdir (fulldir, msg);
 
-          if (status < 0)
-            {
-              retval(2) = "rmdir";
-              retval(1) = msg;
-            }
-          else
-            retval(0) = true;
+      if (status < 0)
+        {
+          retval(2) = "rmdir";
+          retval(1) = msg;
         }
+      else
+        retval(0) = true;
     }
   else
     print_usage ();
@@ -402,27 +375,17 @@
 
   if (args.length () == 2)
     {
-      std::string from = args(0).string_value ();
+      std::string from = args(0).string_value ("link: OLD must be a string");
+      std::string to = args(1).string_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;
 
-              if (status < 0)
-                retval(1) = msg;
-              retval(0) = status;
-            }
-        }
+      retval(0) = status;
     }
   else
     print_usage ();
@@ -449,27 +412,17 @@
 
   if (args.length () == 2)
     {
-      std::string from = args(0).string_value ();
+      std::string from = args(0).string_value ("symlink: OLD must be a string");
+      std::string to = args(1).string_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;
 
-              if (status < 0)
-                retval(1) = msg;
-              retval(0) = status;
-            }
-        }
+      retval(0) = status;
     }
   else
     print_usage ();
@@ -498,22 +451,18 @@
 
   if (args.length () == 1)
     {
-      std::string symlink = args(0).string_value ();
+      std::string symlink = args(0).string_value ("readlink: SYMLINK must be a string");
+
+      std::string result;
+      std::string msg;
 
-      if (error_state)
-        gripe_wrong_type_arg ("readlink", args(0));
-      else
-        {
-          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;
 
-          if (status < 0)
-            retval(2) = msg;
-          retval(1) = status;
-          retval(0) = result;
-        }
+      retval(1) = status;
+      retval(0) = result;
     }
   else
     print_usage ();
@@ -540,27 +489,17 @@
 
   if (args.length () == 2)
     {
-      std::string from = args(0).string_value ();
+      std::string from = args(0).string_value ("rename: OLD must be a string");
+      std::string to = args(1).string_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;
 
-              if (status < 0)
-                retval(1) = msg;
-              retval(0) = status;
-            }
-        }
+      retval(0) = status;
     }
   else
     print_usage ();
@@ -623,16 +562,11 @@
 
   if (args.length () == 1)
     {
-      string_vector pat = args(0).all_strings ();
+      string_vector pat = args(0).all_strings ("glob: PATTERN must be a string");
 
-      if (error_state)
-        gripe_wrong_type_arg ("glob", args(0));
-      else
-        {
-          glob_match pattern (file_ops::tilde_expand (pat));
+      glob_match pattern (file_ops::tilde_expand (pat));
 
-          retval = Cell (pattern.glob ());
-        }
+      retval = Cell (pattern.glob ());
     }
   else
     print_usage ();
@@ -730,17 +664,11 @@
     retval = file_ops::dir_sep_str ();
   else if (args.length () == 1)
     {
-      std::string s = args(0).string_value ();
-
-      if (! error_state)
-        {
-          if (s == "all")
-            retval = file_ops::dir_sep_chars ();
-          else
-            gripe_wrong_type_arg ("filesep", args(0));
-        }
+      std::string s = args(0).string_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 ();
@@ -765,27 +693,22 @@
 
   if (nargin == 1)
     {
-      std::string sval = args(0).string_value ();
+      std::string sval = args(0).string_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 ();
--- a/libinterp/corefcn/display.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/display.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/dlmread.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/dlmread.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -198,8 +198,7 @@
       && args(nargin-2).string_value () == "emptyvalue")
     {
       empty_value = args(nargin-1).double_value ();
-      if (error_state)
-        return retval;
+
       nargin -= 2;
     }
 
@@ -233,9 +232,6 @@
     {
       octave_stream is = octave_stream_list::lookup (args(0), "dlmread");
 
-      if (error_state)
-        return retval;
-
       input = is.input_stream ();
 
       if (! input)
@@ -258,9 +254,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 +272,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 +367,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/dot.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -147,7 +147,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 +158,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 +171,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 +183,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 +198,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 +209,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 +222,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);
                 }
             }
         }
@@ -340,22 +336,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 +361,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/dynamic-ld.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -160,7 +160,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create shared library list object!");
+      error ("unable to create shared library list object!");
 
       retval = false;
     }
@@ -216,7 +216,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create dynamic loader object!");
+      error ("unable to create dynamic loader object!");
 
       retval = false;
     }
@@ -269,40 +269,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 +325,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/eig.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/eig.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -127,19 +127,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 +143,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 +178,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 +194,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 +294,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/error.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/error.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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,26 @@
   return octave_call_stack::empty_backtrace ();
 }
 
+static void
+debug_or_throw_exception (void)
+{
+  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 ();
+
+      do_keyboard (octave_value_list ());
+    }
+  else
+    octave_throw_execution_exception ();
+}
+
 // Warning messages are never buffered.
 
 static void
@@ -204,7 +211,7 @@
 
   std::string base_msg = output_buf.str ();
 
-  bool to_beep_or_not_to_beep_p = Vbeep_on_error && ! error_state;
+  bool to_beep_or_not_to_beep_p = Vbeep_on_error;
 
   std::string msg_string;
 
@@ -238,7 +245,7 @@
 
   msg_string += base_msg + "\n";
 
-  if (! error_state && save_last_error)
+  if (save_last_error)
     {
       // This is the first error in a possible series.
 
@@ -314,6 +321,10 @@
   if (nframes > 0)
     pr_where_1 ("%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++)
     {
@@ -328,48 +339,6 @@
     }
 }
 
-// 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)
 {
@@ -405,7 +374,8 @@
 usage_1 (const char *id, const char *fmt, va_list args)
 {
   verror (true, std::cerr, "usage", id, fmt, args);
-  error_state = -1;
+
+  debug_or_throw_exception ();
 }
 
 void
@@ -439,37 +409,49 @@
 }
 
 static void
-error_2 (const char *id, const char *fmt, va_list args, bool with_cfn = false)
+error_1 (std::ostream& os, const char *name, 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);
-
-  bool in_user_code = octave_call_stack::caller_user_code () != 0;
-
-  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;
-
-      error_state = 0;
+      if (*fmt)
+        {
+          size_t len = strlen (fmt);
 
-      tree_evaluator::debug_mode = true;
+          if (len > 0)
+            {
+              if (fmt[len - 1] == '\n')
+                {
+                  if (len > 1)
+                    {
+                      char *tmp_fmt = strsave (fmt);
+                      tmp_fmt[len - 1] = '\0';
+                      verror (true, os, name, id, tmp_fmt, args, with_cfn);
+                      delete [] tmp_fmt;
+                    }
+                }
+              else
+                {
+                  verror (true, os, name, id, fmt, args, with_cfn);
 
-      tree_evaluator::current_frame = octave_call_stack::current_frame ();
+                  bool in_user_code = octave_call_stack::caller_user_code () != 0;
 
-      do_keyboard (octave_value_list ());
+                  if (in_user_code && ! discard_error_messages)
+                    pr_where ("error");
+                }
+            }
+        }
     }
+  else
+    panic ("error_1: invalid format");
+
+  debug_or_throw_exception ();
 }
 
 void
 verror (const char *fmt, va_list args)
 {
-  error_2 ("", fmt, args);
+  error_1 (std::cerr, "error", "", fmt, args);
 }
 
 void
@@ -484,7 +466,7 @@
 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 +481,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 +496,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 +610,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,14 +629,11 @@
 
       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;
-
       if ((interactive || forced_interactive)
           && Vdebug_on_warning && in_user_code)
         {
@@ -856,120 +835,117 @@
     {
       const octave_scalar_map err = args(0).scalar_map_value ();
 
-      if (! error_state)
+      if (err.contains ("message") && err.contains ("identifier"))
         {
-          if (err.contains ("message") && err.contains ("identifier"))
-            {
-              std::string msg = err.contents ("message").string_value ();
-              std::string id = err.contents ("identifier").string_value ();
-              int len = msg.length ();
-
-              std::string file;
-              std::string nm;
-              int l = -1;
-              int c = -1;
-
-              octave_map err_stack = initialize_last_error_stack ();
-
-              if (err.contains ("stack"))
-                {
-                  err_stack = err.contents ("stack").map_value ();
+          std::string msg = err.contents ("message").string_value ();
+          std::string id = err.contents ("identifier").string_value ();
+          int len = msg.length ();
 
-                  if (err_stack.numel () > 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 ();
+          std::string file;
+          std::string nm;
+          int l = -1;
+          int c = -1;
 
-                      if (err_stack.contains ("line"))
-                        l = err_stack.contents ("line")(0).nint_value ();
+          octave_map err_stack = initialize_last_error_stack ();
 
-                      if (err_stack.contains ("column"))
-                        c = err_stack.contents ("column")(0).nint_value ();
-                    }
-                }
+          if (err.contains ("stack"))
+            {
+              err_stack = err.contents ("stack").map_value ();
 
-              // Ugh.
-              char *tmp_msg = strsave (msg.c_str ());
-              if (tmp_msg[len-1] == '\n')
+              if (err_stack.numel () > 0)
                 {
-                  if (len > 1)
-                    {
-                      tmp_msg[len - 1] = '\0';
-                      rethrow_error (id.c_str (), "%s\n", tmp_msg);
-                    }
+                  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 ();
                 }
-              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;
+          // 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);
+                }
+            }
+          else
+            rethrow_error (id.c_str (), "%s", tmp_msg);
+          delete [] tmp_msg;
 
-              if (err.contains ("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 (file.empty ())
                 {
-                  if (file.empty ())
+                  if (nm.empty ())
                     {
-                      if (nm.empty ())
+                      if (l > 0)
                         {
-                          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);
-                            }
-                        }
-                      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);
-                            }
+                          if (c > 0)
+                            pr_where_1 ("error: near line %d, column %d",
+                                        l, c);
+                          else
+                            pr_where_1 ("error: near line %d", l);
                         }
                     }
                   else
                     {
-                      if (nm.empty ())
+                      if (l > 0)
                         {
-                          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);
-                            }
+                          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
+                    }
+                }
+              else
+                {
+                  if (nm.empty ())
+                    {
+                      if (l > 0)
                         {
-                          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);
-                            }
+                          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);
                         }
                     }
                 }
             }
-          else
-            error ("rethrow: ERR structure must contain the fields 'message and 'identifier'");
         }
+      else
+        error ("rethrow: ERR structure must contain the fields 'message and 'identifier'");
     }
   return retval;
 }
@@ -994,31 +970,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";
         }
     }
 
@@ -1163,12 +1136,7 @@
           //        handle_message, error_with_id, etc.
         }
       else
-        {
-          have_fmt = maybe_extract_message_id ("error", args, nargs, id);
-
-          if (error_state)
-            return retval;
-        }
+        have_fmt = maybe_extract_message_id ("error", args, nargs, id);
 
       handle_message (error_with_id, id.c_str (), "unspecified error",
                       nargs, have_fmt);
@@ -1192,6 +1160,8 @@
 
   octave_idx_type nel = ident.numel ();
 
+  assert (nel != 0);
+
   bool found = false;
 
   std::string val;
@@ -1219,13 +1189,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;
 }
@@ -1810,11 +1781,6 @@
   octave_value retval;
   int nargin = args.length ();
 
-  unwind_protect frame;
-
-  frame.protect_var (error_state);
-  error_state = 0;
-
   if (nargin < 2)
     {
       octave_scalar_map err;
@@ -1849,47 +1815,47 @@
               int new_error_line = -1;
               int new_error_column = -1;
 
-              if (! error_state && new_err.contains ("message"))
+              if (new_err.contains ("message"))
                 {
                   const std::string tmp =
                     new_err.getfield ("message").string_value ();
                   new_error_message = tmp;
                 }
 
-              if (! error_state && new_err.contains ("identifier"))
+              if (new_err.contains ("identifier"))
                 {
                   const std::string tmp =
                     new_err.getfield ("identifier").string_value ();
                   new_error_id = tmp;
                 }
 
-              if (! error_state && new_err.contains ("stack"))
+              if (new_err.contains ("stack"))
                 {
                   new_err_stack =
                     new_err.getfield ("stack").scalar_map_value ();
 
-                  if (! error_state && new_err_stack.contains ("file"))
+                  if (new_err_stack.contains ("file"))
                     {
                       const std::string tmp =
                         new_err_stack.getfield ("file").string_value ();
                       new_error_file = tmp;
                     }
 
-                  if (! error_state && new_err_stack.contains ("name"))
+                  if (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"))
+                  if (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"))
+                  if (new_err_stack.contains ("column"))
                     {
                       const int tmp =
                         new_err_stack.getfield ("column").nint_value ();
@@ -1897,35 +1863,31 @@
                     }
                 }
 
-              if (! error_state)
-                {
-                  Vlast_error_message = new_error_message;
-                  Vlast_error_id = new_error_id;
+              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;
+              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);
-                    }
+                  Vlast_error_stack
+                    = octave_call_stack::backtrace (0, curr_frame);
                 }
             }
           else
             error ("lasterror: argument must be a structure or a string");
         }
 
-      if (! error_state)
-        retval = err;
+      retval = err;
     }
   else
     print_usage ();
@@ -1951,36 +1913,26 @@
 {
   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");
 
-      if (! error_state)
-        {
-          std::string prev_error_id = Vlast_error_id;
-          std::string prev_error_message = Vlast_error_message;
+      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 > 2)
+        Vlast_error_id = argv(2);
 
-          if (argc > 1)
-            Vlast_error_message = argv(1);
+      if (argc > 1)
+        Vlast_error_message = argv(1);
 
-          if (argc == 1 || nargout > 0)
-            {
-              retval(1) = prev_error_id;
-              retval(0) = prev_error_message;
-            }
+      if (argc == 1 || nargout > 0)
+        {
+          retval(1) = prev_error_id;
+          retval(0) = prev_error_message;
         }
-      else
-        error ("lasterr: all arguments must be strings");
     }
   else
     print_usage ();
@@ -2012,26 +1964,20 @@
     {
       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;
+      std::string prev_warning_id = Vlast_warning_id;
+      std::string prev_warning_message = Vlast_warning_message;
 
-          if (argc > 2)
-            Vlast_warning_id = argv(2);
+      if (argc > 2)
+        Vlast_warning_id = argv(2);
 
-          if (argc > 1)
-            Vlast_warning_message = argv(1);
+      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;
-            }
+      if (argc == 1 || nargout > 0)
+        {
+          retval(1) = prev_warning_id;
+          retval(0) = prev_warning_message;
         }
-      else
-        error ("lastwarn: all arguments must be strings");
     }
   else
     print_usage ();
@@ -2160,7 +2106,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/event-queue.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/event-queue.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/fft.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -74,9 +74,6 @@
         }
     }
 
-  if (error_state)
-    return retval;
-
   if (nargin > 2)
     {
       double dval = args(2).double_value ();
@@ -90,9 +87,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 +106,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 +124,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 +141,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/fft2.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -71,9 +71,6 @@
         }
     }
 
-  if (error_state)
-    return retval;
-
   octave_idx_type n_cols = -1;
   if (nargin > 2)
     {
@@ -88,22 +85,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 +113,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 +130,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/fftn.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -85,9 +85,6 @@
         }
     }
 
-  if (error_state)
-    return retval;
-
   if (dims.all_zero ())
     {
       if (arg.is_single_type ())
@@ -102,21 +99,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 +116,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/file-io.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
 }
@@ -283,8 +277,7 @@
 
       octave_stream os = octave_stream_list::lookup (fid, "fclear");
 
-      if (! error_state)
-        os.clearerr ();
+      os.clearerr ();
     }
   else
     print_usage ();
@@ -327,8 +320,7 @@
         {
           octave_stream os = octave_stream_list::lookup (fid, "fflush");
 
-          if (! error_state)
-            retval = os.flush ();
+          retval = os.flush ();
         }
     }
   else
@@ -368,19 +360,16 @@
     {
       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
@@ -420,19 +409,16 @@
     {
       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
@@ -470,17 +456,14 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), who);
 
-      if (! error_state)
-        {
-          octave_value count_arg = (nargin == 2) ? args(1) : octave_value ();
+      octave_value count_arg = (nargin == 2) ? args(1) : octave_value ();
 
-          bool err = false;
+      bool err = false;
 
-          off_t tmp = os.skipl (count_arg, err, who);
+      off_t tmp = os.skipl (count_arg, err, who);
 
-          if (! (error_state || err))
-            retval = tmp;
-        }
+      if (! err)
+        retval = tmp;
     }
   else
     print_usage ();
@@ -503,51 +486,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 +538,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.string_value ("%s: file name must be a string", fcn);
+  std::string mode = tc_mode.string_value ("%s: file mode must be a string", fcn);
+  std::string arch = tc_arch.string_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 +670,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 +690,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);
@@ -809,8 +766,7 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), "frewind");
 
-      if (! error_state)
-        result = os.rewind ();
+      result = os.rewind ();
     }
   else
     print_usage ();
@@ -848,13 +804,10 @@
     {
       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);
-        }
+      retval = os.seek (args(1), origin_arg);
     }
   else
     print_usage ();
@@ -878,8 +831,7 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), "ftell");
 
-      if (! error_state)
-        retval = os.tell ();
+      retval = os.tell ();
     }
   else
     print_usage ();
@@ -929,25 +881,22 @@
           os = octave_stream_list::lookup (args(0), who);
         }
 
-      if (! error_state)
+      if (args(fmt_n).is_string ())
         {
-          if (args(fmt_n).is_string ())
+          octave_value_list tmp_args;
+
+          if (nargin > 1 + fmt_n)
             {
-              octave_value_list tmp_args;
-
-              if (nargin > 1 + fmt_n)
-                {
-                  tmp_args.resize (nargin-fmt_n-1, octave_value ());
+              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);
-                }
+              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
+        error ("%s: format TEMPLATE must be a string", who.c_str ());
     }
   else
     print_usage ();
@@ -1001,7 +950,7 @@
           result = stdout_stream.printf (args(0), tmp_args, who);
         }
       else
-        ::error ("%s: format TEMPLATE must be a string", who.c_str ());
+        error ("%s: format TEMPLATE must be a string", who.c_str ());
     }
   else
     print_usage ();
@@ -1036,8 +985,7 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), who);
 
-      if (! error_state)
-        retval = os.puts (args(1), who);
+      retval = os.puts (args(1), who);
     }
   else
     print_usage ();
@@ -1129,10 +1077,10 @@
                            : octave_value (result, type));
             }
           else
-            ::error ("%s: format TEMPLATE must be a string", who.c_str ());
+            error ("%s: format TEMPLATE must be a string", who.c_str ());
         }
       else
-        ::error ("%s: unable to create output buffer", who.c_str ());
+        error ("%s: unable to create output buffer", who.c_str ());
     }
   else
     print_usage ();
@@ -1200,13 +1148,10 @@
     {
       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
     {
@@ -1218,32 +1163,23 @@
         {
           octave_stream os = octave_stream_list::lookup (args(0), who);
 
-          if (! error_state)
+          if (args(1).is_string ())
             {
-              if (args(1).is_string ())
-                {
-                  octave_idx_type count = 0;
+              octave_idx_type count = 0;
 
-                  Array<double> size = (nargin == 3)
-                                       ? args(2).vector_value ()
-                                       : Array<double> (dim_vector (1, 1),
-                                                        lo_ieee_inf_value ());
+              Array<double> size = (nargin == 3)
+                ? args(2).vector_value ()
+                : Array<double> (dim_vector (1, 1),
+                                 lo_ieee_inf_value ());
 
-                  if (! error_state)
-                    {
-                      octave_value tmp = os.scanf (args(1), size, count, who);
+              octave_value tmp = os.scanf (args(1), size, count, who);
 
-                      if (! error_state)
-                        {
-                          retval(2) = os.error ();
-                          retval(1) = count;
-                          retval(0) = tmp;
-                        }
-                    }
-                }
-              else
-                ::error ("%s: format must be a string", who.c_str ());
+              retval(2) = os.error ();
+              retval(1) = count;
+              retval(0) = tmp;
             }
+          else
+            error ("%s: format must be a string", who.c_str ());
         }
       else
         print_usage ();
@@ -1264,7 +1200,7 @@
       retval = tmp.string_value ();
     }
   else
-    ::error ("sscanf: argument STRING must be a string");
+    error ("sscanf: argument STRING must be a string");
 
   return retval;
 }
@@ -1301,14 +1237,13 @@
               if (args(1).is_string ())
                 retval = os.oscanf (args(1), who);
               else
-                ::error ("%s: format TEMPLATE must be a string", who.c_str ());
+                error ("%s: format TEMPLATE must be a string", who.c_str ());
             }
           else
-            ::error ("%s: unable to create temporary input buffer",
-                     who.c_str ());
+            error ("%s: unable to create temporary input buffer", who.c_str ());
         }
       else
-        ::error ("%s: argument STRING must be a string", who.c_str ());
+        error ("%s: argument STRING must be a string", who.c_str ());
     }
   else
     {
@@ -1321,45 +1256,38 @@
 
           std::string data = get_sscanf_data (args(0));
 
-          if (! error_state)
+          octave_stream os = octave_istrstream::create (data);
+
+          if (os.is_valid ())
             {
-              octave_stream os = octave_istrstream::create (data);
-
-              if (os.is_valid ())
+              if (args(1).is_string ())
                 {
-                  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_value tmp = os.scanf (args(1), size, count, who);
+                  octave_idx_type count = 0;
 
-                      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 ();
+                  Array<double> size = (nargin == 3)
+                    ? args(2).vector_value ()
+                    : Array<double> (dim_vector (1, 1),
+                                     lo_ieee_inf_value ());
+
+                  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 ());
+                  // 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: unable to create temporary input buffer",
-                         who.c_str  ());
+                error ("%s: format TEMPLATE must be a string",
+                       who.c_str ());
             }
+          else
+            error ("%s: unable to create temporary input buffer",
+                   who.c_str  ());
         }
       else
         print_usage ();
@@ -1402,48 +1330,37 @@
 
   if (! error_state)
     {
-      if (prec_arg.is_string ())
-        {
-          std::string prec = prec_arg.string_value ();
+      std::string prec = prec_arg.string_value ("fread: PRECISION must be a string");
+
+      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);
 
-          oct_data_conv::string_to_data_type (prec, block_size,
-                                              input_type, output_type);
+      if (! error_state)
+        {
+          int skip = skip_arg.int_value (true);
 
           if (! error_state)
             {
-              int skip = skip_arg.int_value (true);
-
-              if (! error_state)
-                {
-                  if (arch_arg.is_string ())
-                    {
-                      std::string arch = arch_arg.string_value ();
+              std::string arch = arch_arg.string_value ("fread: ARCH architecture type must be a string");
 
-                      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)
-                        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");
+              retval = os.read (size, block_size, input_type,
+                                output_type, skip, flt_fmt, count);
             }
           else
-            ::error ("fread: invalid PRECISION specified");
+            error ("fread: SKIP must be an integer");
         }
       else
-        ::error ("fread: PRECISION must be a string");
+        error ("fread: invalid PRECISION specified");
     }
   else
-    ::error ("fread: invalid SIZE specified");
+    error ("fread: invalid SIZE specified");
 
   return retval;
 }
@@ -1630,39 +1547,36 @@
 
       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 && ! args(idx).is_string ())
+        size = args(idx++);
 
-          if (nargin > idx)
-            prec = args(idx++);
+      if (nargin > idx)
+        prec = args(idx++);
 
-          if (nargin > idx)
-            skip = args(idx++);
+      if (nargin > idx)
+        skip = args(idx++);
 
-          if (nargin > idx)
-            arch = args(idx++);
-          else if (skip.is_string ())
-            {
-              arch = skip;
-              skip = 0;
-            }
+      if (nargin > idx)
+        arch = args(idx++);
+      else if (skip.is_string ())
+        {
+          arch = skip;
+          skip = 0;
+        }
 
-          octave_idx_type count = -1;
-
-          octave_value tmp = do_fread (os, size, prec, skip, arch, count);
+      octave_idx_type count = -1;
 
-          retval(1) = count;
-          retval(0) = tmp;
-        }
+      octave_value tmp = do_fread (os, size, prec, skip, arch, count);
+
+      retval(1) = count;
+      retval(0) = tmp;
     }
   else
     print_usage ();
@@ -1677,43 +1591,32 @@
 {
   int retval = -1;
 
-  if (prec_arg.is_string ())
-    {
-      std::string prec = prec_arg.string_value ();
+  std::string prec = prec_arg.string_value ("fwrite: PRECISION must be a string");
+
+  int block_size = 1;
+  oct_data_conv::data_type output_type;
 
-      int block_size = 1;
-      oct_data_conv::data_type output_type;
+  oct_data_conv::string_to_data_type (prec, block_size, output_type);
 
-      oct_data_conv::string_to_data_type (prec, block_size, output_type);
+  if (! error_state)
+    {
+      int skip = skip_arg.int_value (true);
 
       if (! error_state)
         {
-          int skip = skip_arg.int_value (true);
-
-          if (! error_state)
-            {
-              if (arch_arg.is_string ())
-                {
-                  std::string arch = arch_arg.string_value ();
+          std::string arch = arch_arg.string_value ("fwrite: ARCH architecture type must be a string");
 
-                  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)
-                    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");
+          retval = os.write (data, block_size, output_type,
+                             skip, flt_fmt);
         }
       else
-        ::error ("fwrite: invalid PRECISION specified");
+        error ("fwrite: SKIP must be an integer");
     }
   else
-    ::error ("fwrite: PRECISION must be a string");
+    error ("fwrite: invalid PRECISION specified");
 
   return retval;
 }
@@ -1748,34 +1651,31 @@
     {
       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";
+      octave_value prec = "uchar";
+      octave_value skip = 0;
+      octave_value arch = "unknown";
 
-          int idx = 1;
+      int idx = 1;
 
-          octave_value data = args(idx++);
+      octave_value data = args(idx++);
 
-          if (nargin > idx)
-            prec = args(idx++);
+      if (nargin > idx)
+        prec = args(idx++);
 
-          if (nargin > idx)
-            skip = args(idx++);
+      if (nargin > idx)
+        skip = args(idx++);
 
-          if (nargin > idx)
-            arch = args(idx++);
-          else if (skip.is_string ())
-            {
-              arch = skip;
-              skip = 0;
-            }
+      if (nargin > idx)
+        arch = args(idx++);
+      else if (skip.is_string ())
+        {
+          arch = skip;
+          skip = 0;
+        }
 
-          double status = do_fwrite (os, data, prec, skip, arch);
+      double status = do_fwrite (os, data, prec, skip, arch);
 
-          retval = status;
-        }
+      retval = status;
     }
   else
     print_usage ();
@@ -1803,8 +1703,7 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), "feof");
 
-      if (! error_state)
-        retval = os.eof () ? 1.0 : 0.0;
+      retval = os.eof () ? 1.0 : 0.0;
     }
   else
     print_usage ();
@@ -1841,27 +1740,21 @@
     {
       octave_stream os = octave_stream_list::lookup (args(0), "ferror");
 
-      if (! error_state)
-        {
-          bool clear = false;
+      bool clear = false;
 
-          if (nargin == 2)
-            {
-              std::string opt = args(1).string_value ();
+      if (nargin == 2)
+        {
+          std::string opt = args(1).string_value ();
 
-              if (! error_state)
-                clear = (opt == "clear");
-              else
-                return retval;
-            }
+          clear = (opt == "clear");
+        }
+
+      int error_number = 0;
 
-          int error_number = 0;
-
-          std::string error_message = os.error (clear, error_number);
+      std::string error_message = os.error (clear, error_number);
 
-          retval(1) = error_number;
-          retval(0) = error_message;
-        }
+      retval(1) = error_number;
+      retval(0) = error_message;
     }
   else
     print_usage ();
@@ -1913,34 +1806,23 @@
 
   if (nargin == 2)
     {
-      if (args(0).is_string ())
-        {
-          std::string name = args(0).string_value ();
+      std::string name = args(0).string_value ("popen: COMMAND must be a string");
+      std::string mode = args(1).string_value ("popen: MODE must be a string");
 
-          if (args(1).is_string ())
-            {
-              std::string mode = args(1).string_value ();
-
-              if (mode == "r")
-                {
-                  octave_stream ips = octave_iprocstream::create (name);
+      if (mode == "r")
+        {
+          octave_stream ips = octave_iprocstream::create (name);
 
-                  retval = octave_stream_list::insert (ips);
-                }
-              else if (mode == "w")
-                {
-                  octave_stream ops = octave_oprocstream::create (name);
+          retval = octave_stream_list::insert (ips);
+        }
+      else if (mode == "w")
+        {
+          octave_stream ops = octave_oprocstream::create (name);
 
-                  retval = octave_stream_list::insert (ops);
-                }
-              else
-                ::error ("popen: invalid MODE specified");
-            }
-          else
-            ::error ("popen: MODE must be a string");
+          retval = octave_stream_list::insert (ops);
         }
       else
-        ::error ("popen: COMMAND must be a string");
+        error ("popen: invalid MODE specified");
     }
   else
     print_usage ();
@@ -1996,22 +1878,14 @@
   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");
-        }
+        dir = args(0).string_value ("tempname: DIR must be a string");
 
       std::string pfx ("oct-");
+
       if (len > 1)
-        {
-          if (args(1).is_string ())
-            pfx = args(1).string_value ();
-          else
-            ::error ("PREFIX must be a string");
-        }
+        pfx = args(1).string_value ("tempname: PREFIX must be a string");
 
       retval = octave_tempnam (dir, pfx);
     }
@@ -2154,54 +2028,49 @@
 
   if (nargin == 1 || nargin == 2)
     {
-      if (args(0).is_string ())
+      std::string tmpl8 = args(0).string_value ("mkstemp: TEMPLATE argument must be a string");
+
+      OCTAVE_LOCAL_BUFFER (char, tmp, tmpl8.size () + 1);
+      strcpy (tmp, tmpl8.c_str ());
+
+      int fd = gnulib::mkostemp (tmp, O_BINARY);
+
+      if (fd < 0)
         {
-          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);
+
+              octave_stream s = octave_stdiostream::create (nm, fid, md);
 
-          if (fd < 0)
-            {
-              retval(2) = gnulib::strerror (errno);
-              retval(0) = fd;
+              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
             {
-              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;
-                }
+              retval(2) = gnulib::strerror (errno);
+              retval(0) = -1;
             }
         }
-      else
-        error ("mkstemp: TEMPLATE argument must be a string");
     }
   else
     print_usage ();
@@ -2209,6 +2078,8 @@
   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 +2088,7 @@
   int tmp = x % obase;
 
   if (tmp > ibase - 1)
-    ::error ("umask: invalid digit");
+    error ("umask: invalid digit");
   else
     {
       retval = tmp;
@@ -2227,7 +2098,7 @@
           tmp = x % obase;
           if (tmp > ibase - 1)
             {
-              ::error ("umask: invalid digit");
+              error ("umask: invalid digit");
               break;
             }
           retval += mult * tmp;
@@ -2269,20 +2140,19 @@
           if (mask < 0)
             {
               status = -1;
-              ::error ("umask: MASK must be a positive integer value");
+              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);
+              status = convert (octave_umask (oct_mask), 10, 8);
             }
         }
       else
         {
           status = -1;
-          ::error ("umask: MASK must be an integer");
+          error ("umask: MASK must be an integer");
         }
     }
   else
--- a/libinterp/corefcn/filter.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/filter.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
 
@@ -127,8 +127,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)
@@ -275,8 +275,8 @@
       return MArray<T> ();
     }
 
-  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 ();
@@ -451,8 +451,8 @@
 
               if (nargin == 3 || args(3).is_empty ())
                 {
-                  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;
 
@@ -499,8 +499,8 @@
 
               if (nargin == 3 || args(3).is_empty ())
                 {
-                  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;
 
@@ -550,8 +550,8 @@
 
               if (nargin == 3 || args(3).is_empty ())
                 {
-                  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;
 
@@ -598,8 +598,8 @@
 
               if (nargin == 3 || args(3).is_empty ())
                 {
-                  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;
 
--- a/libinterp/corefcn/find.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/find.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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++)
           {
@@ -424,13 +424,10 @@
 
       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)
         {
@@ -447,23 +444,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 ())
@@ -472,10 +470,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)
@@ -497,17 +493,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);
@@ -516,15 +508,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 ())
     {
@@ -532,32 +522,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/gammainc.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -85,127 +85,97 @@
 
   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).string_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);
+  if (nargin < 2 || nargin > 3)
+    print_usage ();
 
-      // 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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/gcd.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -420,7 +420,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 ();
@@ -495,9 +495,6 @@
                                            x, retval(j+1));
               for (int i = 0; i < j; i++)
                 retval(i+1).assign (octave_value::op_el_mul_eq, x);
-
-              if (error_state)
-                break;
             }
         }
       else
@@ -505,12 +502,7 @@
           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));
-
-              if (error_state)
-                break;
-            }
+            retval(0) = do_simple_gcd (retval(0), args(j));
         }
     }
   else
--- a/libinterp/corefcn/getgrent.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/getgrent.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -112,20 +112,17 @@
     {
       double dval = args(0).double_value ();
 
-      if (! error_state)
+      if (D_NINT (dval) == dval)
         {
-          if (D_NINT (dval) == dval)
-            {
-              gid_t gid = static_cast<gid_t> (dval);
+          gid_t gid = static_cast<gid_t> (dval);
+
+          std::string msg;
 
-              std::string 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) = mk_gr_map (octave_group::getgrgid (gid, msg));
         }
+      else
+        error ("getgrgid: GID must be an integer");
     }
   else
     print_usage ();
@@ -154,13 +151,10 @@
     {
       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));
-        }
+      retval(1) = msg;
+      retval(0) = mk_gr_map (octave_group::getgrnam (s.c_str (), msg));
     }
   else
     print_usage ();
--- a/libinterp/corefcn/getpwent.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/getpwent.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -116,20 +116,17 @@
     {
       double dval = args(0).double_value ();
 
-      if (! error_state)
+      if (D_NINT (dval) == dval)
         {
-          if (D_NINT (dval) == dval)
-            {
-              uid_t uid = static_cast<uid_t> (dval);
+          uid_t uid = static_cast<uid_t> (dval);
+
+          std::string msg;
 
-              std::string 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) = mk_pw_map (octave_passwd::getpwuid (uid, msg));
         }
+      else
+        error ("getpwuid: UID must be an integer");
     }
   else
     print_usage ();
@@ -158,13 +155,10 @@
     {
       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));
-        }
+      retval(1) = msg;
+      retval(0) = mk_pw_map (octave_passwd::getpwnam (s, msg));
     }
   else
     print_usage ();
--- a/libinterp/corefcn/givens.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/givens.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -92,25 +92,19 @@
               FloatComplex cx = args(0).float_complex_value ();
               FloatComplex cy = args(1).float_complex_value ();
 
-              if (! error_state)
-                {
-                  FloatComplexMatrix result = Givens (cx, cy);
+              FloatComplexMatrix result = Givens (cx, cy);
 
-                  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
@@ -118,25 +112,19 @@
               float x = args(0).float_value ();
               float y = args(1).float_value ();
 
-              if (! error_state)
-                {
-                  FloatMatrix result = Givens (x, y);
+              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;
                 }
             }
         }
@@ -147,25 +135,19 @@
               Complex cx = args(0).complex_value ();
               Complex cy = args(1).complex_value ();
 
-              if (! error_state)
-                {
-                  ComplexMatrix result = Givens (cx, cy);
+              ComplexMatrix result = Givens (cx, cy);
 
-                  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
@@ -173,25 +155,19 @@
               double x = args(0).double_value ();
               double y = args(1).double_value ();
 
-              if (! error_state)
-                {
-                  Matrix result = Givens (x, y);
+              Matrix 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;
                 }
             }
         }
--- a/libinterp/corefcn/gl-render.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/gl-render.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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);
@@ -3229,7 +3230,7 @@
 {
 #if HAVE_FREETYPE
   text_renderer.text_to_pixels (txt, pixels, bbox,
-                                halign, valign, rotation, "none");
+                                halign, valign, rotation, interpreter);
 #endif
 }
 
--- a/libinterp/corefcn/gl-render.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/gl-render.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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);
@@ -207,6 +211,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/graphics.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/graphics.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -144,12 +144,10 @@
 
   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.
+      // 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;
 
@@ -187,8 +185,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 +231,7 @@
 static Matrix
 default_lim (bool logscale = false)
 {
-  Matrix m (1, 2, 0);
+  Matrix m (1, 2);
 
   if (logscale)
     {
@@ -239,7 +239,10 @@
       m(1) = 1.0;
     }
   else
-    m(1) = 1;
+    {
+      m(0) = 0.0;
+      m(1) = 1.0;
+    }
 
   return m;
 }
@@ -258,7 +261,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 +277,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 +289,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 +302,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 +318,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 +343,9 @@
 default_patch_xdata (void)
 {
   Matrix m (3, 1, 0.0);
+
   m(1) = 1.0;
+
   return m;
 }
 
@@ -338,94 +353,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 +475,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 +486,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 +585,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 +862,7 @@
     {
       Matrix _cmap = fig.get (caseless_str ("colormap")).matrix_value ();
 
-      if (! error_state)
-        cmap = _cmap;
+      cmap = _cmap;
     }
 
   if (is_scaled)
@@ -837,8 +873,7 @@
         {
           Matrix _clim = ax.get (caseless_str ("clim")).matrix_value ();
 
-          if (! error_state)
-            clim = _clim;
+          clim = _clim;
         }
     }
 
@@ -1047,7 +1082,6 @@
 {
   if (do_set (v))
     {
-
       // Notify graphics toolkit.
       if (id >= 0 && do_notify_toolkit)
         {
@@ -1057,7 +1091,7 @@
         }
 
       // run listeners
-      if (do_run && ! error_state)
+      if (do_run)
         run_listeners (POSTSET);
 
       return true;
@@ -1073,12 +1107,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)
@@ -1225,6 +1254,7 @@
           else
             {
               color_values col (s);
+
               if (! error_state)
                 {
                   if (current_type != color_t || col != color_val)
@@ -1250,14 +1280,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
@@ -1559,7 +1587,6 @@
 
       if (go.valid_object ())
         gh_manager::free (*p);
-
     }
 
   if (clear)
@@ -1569,30 +1596,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 +1644,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 +1656,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).string_value ("addproperty: invalid argument for radio property, expected a string value");
+
+          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 +1709,6 @@
       if (args.length () > 0)
         {
           retval.set (args(0));
-
           // FIXME: additional argument could define constraints,
           //        but is this really useful?
         }
@@ -1707,18 +1721,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 +1758,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 +1829,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 +1965,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 +1975,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 +1997,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 +2019,7 @@
         }
     }
 
-  if (! error_state && offset == 0)
+  if (offset == 0)
     error ("invalid default property specification");
 }
 
@@ -2143,27 +2145,24 @@
 
   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 ();
+          caseless_str pname = args(i).string_value ();
 
           if (! error_state)
             {
               octave_value val = args(i+1);
 
-              set_value_or_default (name, val);
-
-              if (error_state)
-                break;
+              set_value_or_default (pname, val);
             }
           else
             error ("set: expecting argument %d to be a property name", i);
         }
     }
-  else
-    error ("set: invalid number of arguments");
 }
 
 /*
@@ -2181,26 +2180,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 +2252,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 +2346,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 +2415,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 +2428,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 +2473,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 +2531,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 +2543,53 @@
 {
   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 ();
+  double hv = ov.double_value ();
 
   if (! error_state)
     {
-      h = gh_manager::lookup (val);
+      h = gh_manager::lookup (hv);
 
       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);
+          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)
-            obj.set ("parent", new_parent.value ());
+            go.set ("parent", new_parent.value ());
           else
-            obj.reparent (new_parent);
+            go.reparent (new_parent);
         }
       else
         error ("%s: invalid graphics handle (= %g) for %s",
-               who.c_str (), val, property.c_str ());
+               who.c_str (), hv, pname.c_str ());
     }
   else
     error ("%s: expecting %s to be a graphics handle",
-           who.c_str (), property.c_str ());
+           who.c_str (), pname.c_str ());
 
   return h;
 }
@@ -2629,27 +2617,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 +2655,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 +2718,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 +2749,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 +2763,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 +2811,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 +2827,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 +2834,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 +2842,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,7 +2872,7 @@
         {
           std::string pname = q->first;
 
-          obj.set (pname, q->second);
+          bgo.set (pname, q->second);
 
           if (error_state)
             {
@@ -2919,17 +2900,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 +2957,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,38 +2980,36 @@
 void
 base_properties::set_parent (const octave_value& val)
 {
-  double hnp = val.double_value ();
+  double hp = val.double_value ();
 
   graphics_handle new_parent = octave_NaN;
 
   if (! error_state)
     {
-      if (hnp == __myhandle__)
+      if (hp == __myhandle__)
         error ("set: can not set object parent to be object itself");
       else
         {
-          new_parent = gh_manager::lookup (hnp);
+          new_parent = gh_manager::lookup (hp);
 
           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__);
+              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
-                // Do nothing more
-                return;
+                return;  // Do nothing more
 
               // 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__)
+              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_obj.get_properties ().set_parent (get_parent ().as_octave_value ());
+                  new_parent_go.get_properties ().set_parent (get_parent ().as_octave_value ());
                 }
 
               // Set parent property to new_parent and do adoption
@@ -3041,7 +3017,7 @@
               ::adopt (parent.handle_value (), __myhandle__);
             }
           else
-            error ("set: invalid graphics handle (= %g) for parent", hnp);
+            error ("set: invalid graphics handle (= %g) for parent", hp);
         }
     }
   else
@@ -3063,38 +3039,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 +3081,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 +3125,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 +3160,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 +3173,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 +3197,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);
@@ -3228,7 +3207,7 @@
 
       property p = get_properties ().get_property (pa->first);
 
-      if (! error_state && p.ok ())
+      if (p.ok ())
         p.delete_listener ();
     }
 }
@@ -3252,11 +3231,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 +3255,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 +3280,6 @@
       if (! retval.empty ())
         retval += "\n";
     }
-  else
-    error ("base_graphics_object::values_as_string: invalid graphics object");
 
   return retval;
 }
@@ -3312,11 +3289,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 +3309,6 @@
       if (! retval.empty ())
         retval += "\n";
     }
-  else
-    error ("base_graphics_object::value_as_string: invalid graphics object");
 
   return retval;
 }
@@ -3341,16 +3318,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 +3343,6 @@
             }
         }
     }
-  else
-    error ("base_graphics_object::values_as_struct: invalid graphics object");
 
   return retval;
 }
@@ -3415,9 +3392,6 @@
 {
   graphics_handle val (v);
 
-  if (error_state)
-    return;
-
   if (xisnan (val.value ()))
     {
       if (! cbo_stack.empty ())
@@ -3445,9 +3419,6 @@
 {
   graphics_handle val (v);
 
-  if (error_state)
-    return;
-
   if (xisnan (val.value ()) || is_handle (val))
     {
       currentfigure = val;
@@ -3459,264 +3430,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 +3548,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 +3575,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 +3648,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 +3695,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 +3712,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 +3729,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 +3826,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 +4085,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 +4113,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 +4137,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 +4159,7 @@
     {
       paperorientation.set ("portrait");
     }
+
   std::string punits = get_paperunits ();
   if (punits == "centimeters")
     {
@@ -4391,93 +4173,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 +4363,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 +4424,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 +4462,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 +4548,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 +4571,7 @@
     }
   if (ext(1)+ext(3) > pos(1)+pos(3))
     pos(3) = ext(1)+ext(3)-pos(1);
+
   return pos;
 }
 
@@ -4904,18 +4687,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 +4755,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 +4766,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 +4803,7 @@
   yticklabelmode = "auto";
   zticklabelmode = "auto";
 
-  interpreter = "none";
+  ticklabelinterpreter = "tex";
 
   color = color_values ("white");
   xcolor = color_values ("black");
@@ -5169,7 +4948,7 @@
 
   update_transform ();
   sync_positions ();
-  override_defaults (obj);
+  override_defaults (bgo);
 }
 
 void
@@ -5234,8 +5013,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 +5024,9 @@
 xform_vector (void)
 {
   ColumnVector v (4, 0.0);
+
   v(3) = 1;
+
   return v;
 }
 
@@ -5251,7 +5034,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 +5052,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 +5065,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 +5089,7 @@
 inline void
 xform (ColumnVector& v, const Matrix& m)
 {
-  v = m*v;
+  v = m * v;
 }
 
 inline void
@@ -5334,9 +5131,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 +5154,9 @@
     1,1,1,1
   };
   Matrix m (4, 8);
+
   memcpy (m.fortran_vec (), data, sizeof (double)*32);
+
   return m;
 }
 
@@ -5363,7 +5164,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 +5206,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 +5220,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 +5289,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 +5309,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 +5387,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 +5425,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 +5449,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 +5477,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 +5505,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 +5571,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 +5643,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 +5662,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 +5688,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 +5744,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 +5763,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 +5798,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 +5854,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 +5901,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 +5978,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 +5998,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 +6039,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 +6065,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 +6085,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 +6140,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 +6209,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 +6235,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 +6254,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 +6309,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 +6322,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 +6367,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 +6453,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 +6496,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 +6512,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 +6544,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 +6573,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 +6620,7 @@
     {
       Matrix m = data.matrix_value ();
 
-      if (! error_state && m.numel () == 4)
+      if (m.numel () == 4)
         {
           double val;
 
@@ -6863,8 +6643,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 +6670,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 +6694,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 +6720,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 +6777,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 +6805,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 +6838,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 +6865,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 +6896,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 +6930,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,14 +6941,14 @@
 
       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.)
+          if (exponent < 0.0)
             {
               os << "e-";
               exponent = -exponent;
@@ -7186,7 +6985,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++)
     {
@@ -7226,11 +7025,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 +7039,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 +7053,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 +7067,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 +7081,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 +7300,6 @@
     }
 
   xproperties.update_transform ();
-
 }
 
 void
@@ -7944,11 +7742,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 +7753,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 +7924,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 +7940,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 +7950,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 +8037,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 +8061,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 +8072,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 +8080,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 +8112,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 +8257,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 +8399,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 +8490,7 @@
     }
   else
     {
-      limits.resize (4,1);
+      limits.resize (4, 1);
       limits(0) = min_val;
       limits(1) = max_val;
       limits(2) = min_pos;
@@ -8881,7 +8672,7 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect;
- */
+*/
 
 // ---------------------------------------------------------------------
 
@@ -8890,10 +8681,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 +8710,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 +8728,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 +8754,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 +8775,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 +8791,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 +8819,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 +8855,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 +8882,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 +8898,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 +8923,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 +8966,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 +9020,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 +9041,7 @@
           // constructed.
 
           axes::properties& props =
-            dynamic_cast<axes::properties&> (obj.get_properties ());
+            dynamic_cast<axes::properties&> (go.get_properties ());
 
           graphics_object tgo;
 
@@ -9276,11 +9059,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 +9077,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 +9279,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
@@ -9564,11 +9346,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,7 +9357,7 @@
                  nm.c_str ());
         }
 
-      if (fcn && ! error_state)
+      if (fcn)
         feval (fcn, args);
 
       END_INTERRUPT_WITH_EXCEPTIONS;
@@ -9808,15 +9588,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;
@@ -9862,15 +9639,11 @@
       // 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 ();
-        }
+      // 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 ();
@@ -10080,44 +9853,44 @@
           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)
+          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 (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);
+                          go.set (args(1).cellstr_value (),
+                                  args(2).cell_value (), 0);
                         }
-                      else if (hcv.length () == args(2).cell_value ().rows ())
+                      else if (hcv.numel () == args(2).cell_value ().rows ())
                         {
-                          obj.set (args(1).cellstr_value (),
-                                   args(2).cell_value (), n);
+                          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.length (), args(2).cell_value ().rows ());
+                                 hcv.numel (), args(2).cell_value ().rows ());
                           break;
 
                         }
                     }
                   else if (nargin == 2 && args(1).is_map ())
                     {
-                      obj.set (args(1).map_value ());
+                      go.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))
+                      octave_map pmap = go.values_as_struct ();
+
+                      if (go.has_readonly_property (property))
                         if (nargout != 0)
                           retval = Matrix ();
                         else
@@ -10129,9 +9902,9 @@
                             retval = pmap.getfield (property)(0);
                           else
                             {
-                              std::string s = obj.value_as_string (property);
-                              if (! error_state)
-                                octave_stdout << s;
+                              std::string s = go.value_as_string (property);
+
+                              octave_stdout << s;
                             }
                         }
                       else
@@ -10143,17 +9916,17 @@
                   else if (nargin == 1)
                     {
                       if (nargout != 0)
-                        retval = obj.values_as_struct ();
+                        retval = go.values_as_struct ();
                       else
                         {
-                          std::string s = obj.values_as_string ();
-                          if (! error_state)
-                            octave_stdout << s;
+                          std::string s = go.values_as_string ();
+
+                          octave_stdout << s;
                         }
                     }
                   else
                     {
-                      obj.set (args.splice (0, 1));
+                      go.set (args.splice (0, 1));
                       request_drawnow = true;
                     }
                 }
@@ -10163,13 +9936,10 @@
                   break;
                 }
 
-              if (error_state)
-                break;
-
               request_drawnow = true;
             }
 
-          if (! error_state && request_drawnow)
+          if (request_drawnow)
             Vdrawnow_requested = true;
         }
       else
@@ -10186,10 +9956,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);
 
@@ -10232,103 +10002,88 @@
 
       if (! error_state)
         {
-          octave_idx_type len = hcv.length ();
+          octave_idx_type len = hcv.numel ();
 
           if (nargin == 1 && len > 1)
             {
-              std::string t0 = get_graphics_object_type (hcv(0));
+              std::string typ0 = get_graphics_object_type (hcv(0));
+
+              for (octave_idx_type n = 1; n < len; n++)
+                {
+                  std::string typ = get_graphics_object_type (hcv(n));
+
+                  if (typ != typ0)
+                    {
+                      error ("get: vector of handles must all have same type");
+                      break;
+                    }
+                }
+            }
+
+          if (nargin > 1 && args(1).is_cellstr ())
+            {
+              Array<std::string> plist = args(1).cellstr_value ();
 
               if (! error_state)
                 {
-                  for (octave_idx_type n = 1; n < len; n++)
+                  octave_idx_type plen = plist.numel ();
+
+                  use_cell_format = true;
+
+                  vals.resize (dim_vector (len, plen));
+
+                  for (octave_idx_type n = 0; n < len; n++)
                     {
-                      std::string t = get_graphics_object_type (hcv(n));
-
-                      if (error_state)
-                        break;
-
-                      if (t != t0)
+                      graphics_object go = gh_manager::get_object (hcv(n));
+
+                      if (go)
                         {
-                          error ("get: vector of handles must all have same type");
+                          for (octave_idx_type m = 0; m < plen; m++)
+                            {
+                              caseless_str property = plist(m);
+
+                              vals(n, m) = go.get (property);
+                            }
+                        }
+                      else
+                        {
+                          error ("get: invalid handle (= %g)", hcv(n));
                           break;
                         }
                     }
-
                 }
-            }
-
-          if (! error_state)
-            {
-              if (nargin > 1 && args(1).is_cellstr ())
+              else
+                error ("get: expecting property name or cell array of property names as second argument");
+            }
+          else
+            {
+              caseless_str property;
+
+              if (nargin > 1)
                 {
-                  Array<std::string> plist = args(1).cellstr_value ();
-
-                  if (! error_state)
+                  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));
+
+              for (octave_idx_type n = 0; n < len; n++)
+                {
+                  graphics_object go = gh_manager::get_object (hcv(n));
+
+                  if (go)
                     {
-                      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;
-                            }
-                        }
+                      if (nargin == 1)
+                        vals(n) = go.get ();
+                      else
+                        vals(n) = go.get (property);
                     }
                   else
-                    error ("get: expecting property name or cell array of property names as second argument");
-                }
-              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;
-                            }
-                        }
+                      error ("get: invalid handle (= %g)", hcv(n));
+                      break;
                     }
                 }
             }
@@ -10339,30 +10094,27 @@
   else
     print_usage ();
 
-  if (! error_state)
-    {
-      if (use_cell_format)
-        retval = vals;
+  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
-        {
-          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;
-        }
+        retval = vals;
     }
 
   return retval;
@@ -10396,16 +10148,16 @@
 
       if (! error_state)
         {
-          octave_idx_type len = hcv.length ();
+          octave_idx_type len = hcv.numel ();
 
           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);
+              graphics_object go = gh_manager::get_object (hcv(n));
+
+              if (go)
+                vals(n) = go.get (true);
               else
                 {
                   error ("get: invalid handle (= %g)", hcv(n));
@@ -10419,15 +10171,12 @@
   else
     print_usage ();
 
-  if (! error_state)
-    {
-      octave_idx_type len = vals.numel ();
-
-      if (len > 1)
-        retval = vals;
-      else if (len == 1)
-        retval = vals(0);
-    }
+  octave_idx_type len = vals.numel ();
+
+  if (len > 1)
+    retval = vals;
+  else if (len == 1)
+    retval = vals(0);
 
   return retval;
 }
@@ -10446,25 +10195,21 @@
   caseless_str p ("parent");
 
   for (int i = 0; i < xargs.length (); i++)
-    if (xargs(i).is_string ()
-        && p.compare (xargs(i).string_value ()))
+    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;
-              }
+            xargs = xargs.splice (i, 2);
+            break;
           }
         else
           error ("__go_%s__: missing value for parent property",
                  go_name.c_str ());
       }
 
-  if (! error_state && xisnan (val))
+  if (xisnan (val))
     val = args(0).double_value ();
 
   if (! error_state)
@@ -10488,8 +10233,7 @@
 
               retval = h.value ();
 
-              if (! error_state)
-                Vdrawnow_requested = true;
+              Vdrawnow_requested = true;
             }
           else
             error ("__go%s__: unable to create graphics handle",
@@ -10538,24 +10282,22 @@
 
               if (xisnan (val))
                 {
-                  caseless_str p ("integerhandle");
+                  caseless_str pname ("integerhandle");
 
                   for (int i = 0; i < xargs.length (); i++)
                     {
                       if (xargs(i).is_string ()
-                          && p.compare (xargs(i).string_value ()))
+                          && pname.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;
-                                }
+                              caseless_str on ("on");
+                              int_fig_handle = on.compare (pval);
+                              xargs = xargs.splice (i, 2);
+
+                              break;
                             }
                         }
                     }
@@ -10566,10 +10308,9 @@
 
                   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...
+                      // 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");
@@ -10618,7 +10359,6 @@
 int
 calc_dimensions (const graphics_object& go)
 {
-
   int nd = 2;
 
   if (go.isa ("surface"))
@@ -10630,13 +10370,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);
@@ -10822,23 +10562,20 @@
 
       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
+          // 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.elem (i));
+              h = gh_manager::lookup (vals(i));
 
               if (! h.ok ())
                 {
-                  error ("delete: invalid graphics object (= %g)",
-                         vals.elem (i));
+                  error ("delete: invalid graphics object (= %g)", vals(i));
                   break;
                 }
             }
 
-          if (! error_state)
-            delete_graphics_objects (vals);
+          delete_graphics_objects (vals);
         }
       else
         error ("delete: invalid graphics object");
@@ -10864,12 +10601,7 @@
   std::string mode = "";
 
   if (nargin == 2)
-    {
-      mode = args(1).string_value ();
-
-      if (error_state)
-        return retval;
-    }
+    mode = args(1).string_value ();
 
   if (nargin == 1 || nargin == 2)
     {
@@ -10883,9 +10615,9 @@
 
           if (h.ok ())
             {
-              graphics_object obj = gh_manager::get_object (h);
-
-              obj.set_defaults (mode);
+              graphics_object go = gh_manager::get_object (h);
+
+              go.set_defaults (mode);
 
               h = gh_manager::lookup (val);
               if (! h.ok ())
@@ -10957,17 +10689,12 @@
 
           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));
-                }
+              std::string name = args(1).string_value ("__go_execute_callback__: invalid callback name");
+
+              if (nargin == 2)
+                gh_manager::execute_callback (h, name);
               else
-                error ("__go_execute_callback__: invalid callback name");
+                gh_manager::execute_callback (h, name, args(2));
             }
           else
             error ("__go_execute_callback__: invalid graphics object (= %g)",
@@ -10998,15 +10725,15 @@
 
       if (! error_state)
         {
-          graphics_object fobj = gh_manager::get_object (h);
-          if (fobj &&  fobj.isa ("image"))
+          graphics_object go = gh_manager::get_object (h);
+          if (go && go.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 ();
+                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
@@ -11051,8 +10778,7 @@
               args(0) = dtk;
               feval ("graphics_toolkit", args);
 
-              if (! error_state)
-                pl = loaded_toolkits.find (dtk);
+              pl = loaded_toolkits.find (dtk);
 
               if (error_state || pl == loaded_toolkits.end ())
                 error ("failed to load %s graphics toolkit", dtk.c_str ());
@@ -11137,13 +10863,9 @@
 
   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");
+      std::string name = args(0).string_value ("register_graphics_toolkit: TOOLKIT must be a string");
+
+      gtk_manager::register_toolkit (name);
     }
   else
     print_usage ();
@@ -11197,7 +10919,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));
 
@@ -11255,97 +10977,86 @@
           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).string_value ("drawnow: invalid terminal TERM, expected a string value");
+
+          file = args(1).string_value ("drawnow: invalid FILE, expected a string value");
+
+          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)
+                }
+            }
+
+          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 ())
                     {
-                      // Strip leading pipe character
-                      file = file.substr (pos_c);
+                      graphics_object go = gh_manager::get_object (h);
+
+                      gh_manager::unlock ();
+
+                      go.get_toolkit ().print_figure (go, term, file,
+                                                      mono, debug_file);
+
+                      gh_manager::lock ();
                     }
                   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);
-
-                              gh_manager::unlock ();
-
-                              go.get_toolkit ().print_figure (go, term, file,
-                                                              mono, debug_file);
-
-                              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");
+                    error ("drawnow: nothing to draw");
                 }
               else
-                error ("drawnow: invalid FILE, expected a string value");
+                error ("drawnow: invalid DEBUG_FILE, expected a string value");
             }
           else
-            error ("drawnow: invalid terminal TERM, expected a string value");
+            error ("drawnow: invalid colormode MONO, expected a boolean value");
         }
       else
         print_usage ();
@@ -11401,31 +11112,25 @@
 
       if (! error_state)
         {
-          std::string pname = args(1).string_value ();
-
-          if (! error_state)
-            {
-              graphics_handle gh = gh_manager::lookup (h);
-
-              if (gh.ok ())
+          std::string pname = args(1).string_value ("addlistener: invalid property name, expected a string value");
+
+          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)
                 {
-                  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);
-                    }
+                  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");
+            error ("addlistener: invalid graphics object (= %g)", h);
         }
       else
         error ("addlistener: invalid handle");
@@ -11474,39 +11179,32 @@
 
       if (! error_state)
         {
-          std::string pname = args(1).string_value ();
-
-          if (! error_state)
-            {
-              graphics_handle gh = gh_manager::lookup (h);
-
-              if (gh.ok ())
+          std::string pname = args(1).string_value ("dellistener: invalid property name, expected a string value");
+
+          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
                 {
-                  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")
                     {
-                      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);
+                      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);
             }
           else
-            error ("dellistener: invalid property name, expected a string value");
+            error ("dellistener: invalid graphics object (= %g)", h);
         }
       else
         error ("dellistener: invalid handle");
@@ -11595,47 +11293,36 @@
 
   if (args.length () >= 3)
     {
-      std::string name = args(0).string_value ();
+      std::string name = args(0).string_value ("addproperty: invalid property NAME, expected a string value");
+
+      double h = args(1).double_value ();
 
       if (! error_state)
         {
-          double h = args(1).double_value ();
-
-          if (! error_state)
-            {
-              graphics_handle gh = gh_manager::lookup (h);
-
-              if (gh.ok ())
+          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 ("addproperty: invalid property TYPE, expected a string value");
+
+              if (! go.get_properties ().has_property (name))
                 {
-                  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");
+                  property p = property::create (name, gh, type,
+                                                 args.splice (0, 3));
+
+                  go.get_properties ().insert_property (name, p);
                 }
               else
-                error ("addproperty: invalid graphics object (= %g)", h);
+                error ("addproperty: a '%s' property already exists in the graphics object",
+                       name.c_str ());
             }
           else
-            error ("addproperty: invalid handle value");
+            error ("addproperty: invalid graphics object (= %g)", h);
         }
       else
-        error ("addproperty: invalid property NAME, expected a string value");
+        error ("addproperty: invalid handle value");
     }
   else
     print_usage ();
@@ -11649,11 +11336,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);
 
@@ -11666,15 +11353,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);
@@ -11683,16 +11369,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;
@@ -11716,29 +11402,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);
             }
         }
     }
@@ -11759,36 +11439,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 ();
@@ -11801,8 +11472,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 ();
@@ -11871,9 +11541,9 @@
           if (args.length () > 1)
             {
               pname = args(1).string_value ();
+
               if (! error_state
-                  && ! pname.empty ()
-                  && ! pname.compare ("timeout"))
+                  && ! pname.empty () && ! pname.compare ("timeout"))
                 {
                   if (pname.compare ("\\timeout"))
                     pname = "timeout";
@@ -11919,11 +11589,11 @@
 
                   gh_manager::auto_lock guard;
 
-                  graphics_handle handle = gh_manager::lookup (h);
-
-                  if (handle.ok ())
+                  graphics_handle gh = gh_manager::lookup (h);
+
+                  if (gh.ok ())
                     {
-                      graphics_object go = gh_manager::get_object (handle);
+                      graphics_object go = gh_manager::get_object (gh);
 
                       if (max_arg_index >= 2
                           && compare_property_values (go.get (pname),
@@ -11971,9 +11641,7 @@
                 error ("waitfor: invalid property name, expected a non-empty string value");
             }
 
-          if (! error_state
-              && timeout_index < 0
-              && args.length () > (max_arg_index + 1))
+          if (timeout_index < 0 && args.length () > (max_arg_index + 1))
             {
               caseless_str s = args(max_arg_index + 1).string_value ();
 
@@ -11988,7 +11656,7 @@
                 error ("waitfor: invalid parameter, expected 'timeout'");
             }
 
-          if (! error_state && timeout_index >= 0)
+          if (timeout_index >= 0)
             {
               if (args.length () > (timeout_index + 1))
                 {
@@ -12012,10 +11680,10 @@
 
           // 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
+          //        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
+          //        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
@@ -12036,9 +11704,9 @@
                 {
                   gh_manager::auto_lock guard;
 
-                  graphics_handle handle = gh_manager::lookup (h);
-
-                  if (handle.ok ())
+                  graphics_handle gh = gh_manager::lookup (h);
+
+                  if (gh.ok ())
                     {
                       if (! pname.empty () && waitfor_results[id])
                         break;
@@ -12089,9 +11757,6 @@
 
   double h = args(0).double_value ();
 
-  if (error_state)
-    return retval;
-
   gh_manager::auto_lock guard;
 
   graphics_handle handle = gh_manager::lookup (h);
@@ -12111,9 +11776,6 @@
     {
       std::string opt = args(1).string_value ();
 
-      if (error_state)
-        return retval;
-
       if (opt == "out" || opt == "reset")
         {
           if (opt == "out")
@@ -12123,7 +11785,6 @@
             }
           else
             ax_props.clear_zoom_stack (false);
-
         }
     }
   else
@@ -12131,12 +11792,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/graphics.in.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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
           {
-            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;
+            nda = val.array_value ();
           }
-        else
+        catch (const octave_execution_exception&)
           {
             error ("set: invalid string property value for \"%s\"",
                    get_name ().c_str ());
-
-            return false;
           }
+
+        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;
       }
 
     return true;
@@ -1488,23 +1478,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 +1697,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 (const octave_execution_exception&)
+      {
+        error ("set: expecting children to be array of graphics handles");
+      }
 
     octave_idx_type nel = new_kids.numel ();
 
@@ -1721,33 +1715,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 +2351,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create gh_manager!");
+        error ("unable to create gh_manager!");
 
         retval = false;
       }
@@ -3218,29 +3204,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 +3381,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 +3424,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)
@@ -3464,6 +3445,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 +3453,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 +3473,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 +3491,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 +3854,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 +3868,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 +3944,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 +3960,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 +3975,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"
@@ -4478,27 +4494,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 +5321,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 +5387,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 +5449,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 +5547,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 +5615,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 +5715,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 +5771,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 +5926,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create gh_manager!");
+        error ("unable to create gh_manager!");
 
         retval = false;
       }
@@ -6059,8 +6072,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/gripes.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -205,15 +205,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/gripes.h	Sat Oct 10 16:52:59 2015 -0700
@@ -114,9 +114,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/help.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
@@ -1092,20 +1092,15 @@
 
   if (args.length () == 1)
     {
-      const std::string name = args(0).string_value ();
+      const std::string name = args(0).string_value ("get_help_text: NAME must be a string");
 
-      if (! error_state)
-        {
-          std::string text;
-          std::string format;
+      std::string text;
+      std::string format;
 
-          do_get_help_text (name, text, format);
+      do_get_help_text (name, text, format);
 
-          retval(1) = format;
-          retval(0) = text;
-        }
-      else
-        error ("get_help_text: invalid input");
+      retval(1) = format;
+      retval(0) = text;
     }
   else
     print_usage ();
@@ -1162,20 +1157,15 @@
 
   if (args.length () == 1)
     {
-      const std::string fname = args(0).string_value ();
+      const std::string fname = args(0).string_value ("get_help_text_from_file: NAME must be a string");
 
-      if (! error_state)
-        {
-          std::string text;
-          std::string format;
+      std::string text;
+      std::string format;
 
-          do_get_help_text_from_file (fname, text, format);
+      do_get_help_text_from_file (fname, text, format);
 
-          retval(1) = format;
-          retval(0) = text;
-        }
-      else
-        error ("get_help_text_from_file: invalid input");
+      retval(1) = format;
+      retval(0) = text;
     }
   else
     print_usage ();
@@ -1303,7 +1293,7 @@
 
   if (! error_state)
     {
-      int argc = argv.length ();
+      int argc = argv.numel ();
 
       if (argc > 1)
         {
@@ -1380,24 +1370,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).string_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/hess.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/hess.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -98,34 +98,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 +129,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/hex2num.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -242,7 +242,7 @@
       if (! error_state)
         {
           octave_idx_type nchars = 8;
-          octave_idx_type nr = v.length ();
+          octave_idx_type nr = v.numel ();
           charMatrix m (nr, nchars);
           const float *pv = v.fortran_vec ();
 
@@ -279,7 +279,7 @@
       if (! error_state)
         {
           octave_idx_type nchars = 16;
-          octave_idx_type nr = v.length ();
+          octave_idx_type nr = v.numel ();
           charMatrix m (nr, nchars);
           const double *pv = v.fortran_vec ();
 
--- a/libinterp/corefcn/input.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/input.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -408,13 +408,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 ();
 
@@ -688,13 +688,7 @@
   if (nargin == 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).string_value ("input: unrecognized argument");
 
   flush_octave_stdout ();
 
@@ -707,7 +701,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 ();
 
@@ -837,15 +831,7 @@
       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;
-            }
-        }
+        prompt = args(0).string_value ("yes_or_no: PROMPT must be a string");
 
       retval = octave_yes_or_no (prompt);
     }
@@ -888,8 +874,7 @@
   if (nargin > 0)
     prompt = args(0).string_value ();
 
-  if (! error_state)
-    get_debug_input (prompt);
+  get_debug_input (prompt);
 
   return retval;
 }
@@ -976,9 +961,6 @@
 
   string_vector argv = args.make_argv ("echo");
 
-  if (error_state)
-    return retval;
-
   switch (argc)
     {
     case 1:
@@ -1028,6 +1010,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\
@@ -1056,56 +1085,53 @@
     {
       std::string hint = args(0).string_value ();
 
-      if (! error_state)
-        {
-          int n = 32;
+      int n = 32;
 
-          string_vector list (n);
+      string_vector list (n);
+
+      int k = 0;
 
-          int k = 0;
+      for (;;)
+        {
+          std::string cmd = generate_completion (hint, k);
 
-          for (;;)
+          if (! cmd.empty ())
             {
-              std::string cmd = generate_completion (hint, k);
-
-              if (! cmd.empty ())
+              if (k == n)
                 {
-                  if (k == n)
-                    {
-                      n *= 2;
-                      list.resize (n);
-                    }
-
-                  list[k++] = cmd;
+                  n *= 2;
+                  list.resize (n);
                 }
-              else
-                {
-                  list.resize (k);
-                  break;
-                }
-            }
 
-          if (nargout > 0)
-            {
-              if (! list.empty ())
-                retval = list;
-              else
-                retval = "";
+              list[k++] = cmd;
             }
           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 ();
+              list.resize (k);
+              break;
+            }
+        }
 
-              for (int i = 0; i < len; i++)
-                octave_stdout << list[i] << "\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.
 
-          octave_completion_matches_called = true;
+          int len = list.numel ();
+
+          for (int i = 0; i < len; i++)
+            octave_stdout << list[i] << "\n";
         }
+
+      octave_completion_matches_called = true;
     }
   else
     print_usage ();
@@ -1113,6 +1139,21 @@
   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\
@@ -1136,8 +1177,7 @@
     {
       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 ();
@@ -1487,7 +1527,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/jit-typeinfo.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/jit-typeinfo.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -215,41 +215,20 @@
 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 ();
-    }
+  gripe_invalid_index ();
 }
 
 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 +236,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 +260,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 +274,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/jit-typeinfo.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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/load-path.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/load-path.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -91,12 +91,10 @@
                   initialize ();
                 }
             }
-          catch (octave_execution_exception)
+          catch (const octave_execution_exception&)
             {
               // Skip updating if we don't know where we are, but
               // don't treat it as an error.
-
-              error_state = 0;
             }
         }
       else if (fs.mtime () + fs.time_resolution () > dir_time_last_checked)
@@ -159,7 +157,7 @@
 
           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.
         }
@@ -180,7 +178,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 +248,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++)
         {
@@ -333,7 +331,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create load path object!");
+      error ("unable to create load path object!");
 
       retval = false;
     }
@@ -408,7 +406,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 +766,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 +798,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++)
     {
@@ -1373,7 +1368,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 +1483,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 +1529,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 +1562,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 +1607,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 +1665,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 +1711,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];
@@ -1893,7 +1888,7 @@
 
   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++)
     {
@@ -2150,7 +2145,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 +2156,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)
@@ -2244,31 +2239,20 @@
 
   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).string_value ("genpath: DIR must be a string");
+
+      retval = genpath (dirname);
     }
   else if (nargin > 1)
     {
-      std::string dirname = args(0).string_value ();
+      std::string dirname = args(0).string_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).string_value ("genpath: all arguments must be strings");
+
+      retval = genpath (dirname, skip);
     }
   else
     print_usage ();
@@ -2364,33 +2348,30 @@
 
   string_vector argv = args.make_argv ("path");
 
-  if (! error_state)
+  if (argc > 1)
     {
-      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 < 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";
     }
 
   return retval;
@@ -2474,34 +2455,29 @@
 
       for (int i = 0; i < nargin; i++)
         {
-          if (args(i).is_string ())
+          std::string arg = args(i).string_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 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;
-                }
+              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)
@@ -2543,28 +2519,23 @@
 
       for (int i = 0; i < nargin; i++)
         {
-          if (args(i).is_string ())
+          std::string arg = args(i).string_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++)
             {
-              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
+                need_to_update = true;
             }
-          else
-            error ("addpath: all arguments must be strings");
         }
 
       if (need_to_update)
--- a/libinterp/corefcn/load-save.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/load-save.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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.
@@ -269,7 +270,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 +363,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:
@@ -399,7 +400,7 @@
 
       if (error_state || stream.eof () || name.empty ())
         break;
-      else if (! error_state && ! name.empty ())
+      else
         {
           if (tc.is_defined ())
             {
@@ -454,14 +455,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)
@@ -716,7 +709,7 @@
         }
       else if (argv[i] == "-text" || argv[i] == "-t")
         {
-          format = LS_ASCII;
+          format = LS_TEXT;
         }
       else
         break;
@@ -935,8 +928,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:
@@ -1052,7 +1045,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 +1070,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 +1196,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 +1229,7 @@
 #ifdef HAVE_HDF5
     case LS_HDF5:
 #endif /* HAVE_HDF5 */
-    case LS_ASCII:
+    case LS_TEXT:
       {
         octave_localtime now;
 
@@ -1621,7 +1615,7 @@
 
   bool save_as_floats = false;
 
-  load_save_format format = LS_ASCII;
+  load_save_format format = LS_TEXT;
 
   bool append = false;
 
@@ -1634,7 +1628,7 @@
   // 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)
@@ -1646,9 +1640,9 @@
       return retval;
     }
 
-  if (save_as_floats && format == LS_ASCII)
+  if (save_as_floats && format == LS_TEXT)
     {
-      error ("save: cannot specify both -ascii and -float-binary");
+      error ("save: cannot specify both -text and -float-binary");
       return retval;
     }
 
--- a/libinterp/corefcn/load-save.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/load-save.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/lookup.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -283,9 +283,6 @@
   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)
     {
 
--- a/libinterp/corefcn/ls-hdf5.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/ls-hdf5.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/ls-hdf5.h	Sat Oct 10 16:52:59 2015 -0700
@@ -25,7 +25,7 @@
 
 #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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/ls-mat-ascii.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -119,7 +119,7 @@
   nr = 0;
   nc = 0;
 
-  while (is && ! error_state)
+  while (is)
     {
       octave_quit ();
 
@@ -270,7 +270,7 @@
 
       octave_quit ();
 
-      if (! error_state && nr > 0 && nc > 0)
+      if (nr > 0 && nc > 0)
         {
           Matrix tmp (nr, nc);
 
@@ -369,15 +369,18 @@
   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&)
     {
       success = false;
+    }
 
-      error_state = 0;
-    }
-  else
+  if (success)
     {
       long old_precision = os.precision ();
 
--- a/libinterp/corefcn/ls-mat4.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/ls-mat4.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -373,7 +373,7 @@
 
         read_mat_binary_data (is, re.fortran_vec (), prec, dlen, swap, flt_fmt);
 
-        if (! is || error_state)
+        if (! is)
           {
             error ("load: reading matrix data for '%s'", name);
             goto data_read_error;
@@ -386,7 +386,7 @@
             read_mat_binary_data (is, im.fortran_vec (), prec, dlen, swap,
                                   flt_fmt);
 
-            if (! is || error_state)
+            if (! is)
               {
                 error ("load: reading imaginary matrix data for '%s'", name);
                 goto data_read_error;
@@ -498,7 +498,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-oct-ascii.cc	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/corefcn/ls-oct-text.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,432 @@
+/*
+
+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: 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_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");
+      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 ());
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/corefcn/ls-oct-text.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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/lsode.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/lsode.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -88,7 +88,7 @@
 
           retval = ColumnVector (tmp(0).vector_value ());
 
-          if (error_state || retval.length () == 0)
+          if (error_state || retval.numel () == 0)
             gripe_user_supplied_eval ("lsode");
         }
       else
@@ -127,7 +127,7 @@
 
           retval = tmp(0).matrix_value ();
 
-          if (error_state || retval.length () == 0)
+          if (error_state || retval.numel () == 0)
             gripe_user_supplied_eval ("lsode");
         }
       else
@@ -143,7 +143,7 @@
 #define LSODE_ABORT1(msg) \
   do \
     { \
-      ::error ("lsode: " msg); \
+      error ("lsode: " msg); \
       LSODE_ABORT (); \
     } \
   while (0)
@@ -151,7 +151,7 @@
 #define LSODE_ABORT2(fmt, arg) \
   do \
     { \
-      ::error ("lsode: " fmt, arg); \
+      error ("lsode: " fmt, arg); \
       LSODE_ABORT (); \
     } \
   while (0)
@@ -300,9 +300,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 ())
                 lsode_fcn = c(0).function_value ();
@@ -367,31 +367,28 @@
                   {
                     string_vector tmp = f_arg.all_strings ();
 
-                    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)
                       {
-                        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");
+                        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)
+                        if (!lsode_jac)
                           {
-                            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 (fcn_name.length ())
+                              clear_function (fcn_name);
+                            lsode_fcn = 0;
                           }
                       }
                   }
@@ -451,22 +448,19 @@
       if (jac_name.length ())
         clear_function (jac_name);
 
-      if (! error_state)
-        {
-          std::string msg = ode.error_message ();
+      std::string msg = ode.error_message ();
 
-          retval(2) = msg;
-          retval(1) = static_cast<double> (ode.integration_state ());
+      retval(2) = msg;
+      retval(1) = static_cast<double> (ode.integration_state ());
 
-          if (ode.integration_ok ())
-            retval(0) = output;
-          else
-            {
-              retval(0) = Matrix ();
+      if (ode.integration_ok ())
+        retval(0) = output;
+      else
+        {
+          retval(0) = Matrix ();
 
-              if (nargout < 2)
-                error ("lsode: %s", msg.c_str ());
-            }
+          if (nargout < 2)
+            error ("lsode: %s", msg.c_str ());
         }
     }
   else
--- a/libinterp/corefcn/lu.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/lu.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -158,7 +158,7 @@
   Matrix thres;
 
   int n = 1;
-  while (n < nargin && ! error_state)
+  while (n < nargin)
     {
       if (args(n).is_string ())
         {
@@ -173,21 +173,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: expecting 2-element vector for THRES");
         }
     }
 
@@ -360,76 +357,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 +430,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;
                 }
             }
         }
--- a/libinterp/corefcn/luinc.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/luinc.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -154,12 +154,12 @@
                 {
                   thresh = tmp.matrix_value ();
 
-                  if (thresh.nelem () == 1)
+                  if (thresh.numel () == 1)
                     {
                       thresh.resize (1,2);
                       thresh(1) = thresh(0);
                     }
-                  else if (thresh.nelem () != 2)
+                  else if (thresh.numel () != 2)
                     {
                       error ("luinc: expecting 2-element vector for thresh");
                       return retval;
@@ -179,200 +179,170 @@
         {
           std::string tmp = args(2).string_value ();
 
-          if (! error_state)
-            {
-              if (tmp.compare ("vector") == 0)
-                vecout = true;
-              else
-                error ("luinc: unrecognized string argument");
-            }
+          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)
+      if (args(0).type_name () == "sparse matrix")
         {
-          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;
+
+          switch (nargout)
             {
-              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);
+            case 0:
+            case 1:
+            case 2:
+              {
+                SparseLU fact (sm, Qinit, thresh, false, true, droptol,
+                               milu, udiag);
 
-              for (octave_idx_type i = 0; i < sm_nc; i++)
-                Qinit (i) = i;
+                SparseMatrix P = fact.Pr ();
+                SparseMatrix L = P.transpose () * fact.L ();
 
-              if (! error_state)
-                {
-                  switch (nargout)
-                    {
-                    case 0:
-                    case 1:
-                    case 2:
-                      {
-                        SparseLU fact (sm, Qinit, thresh, false, true, droptol,
-                                       milu, udiag);
+                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)
-                          {
-                            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;
+            case 3:
+              {
+                SparseLU fact (sm, Qinit, thresh, false, true, droptol,
+                               milu, udiag);
 
-                    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 ();
+
+                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:
+              {
+                SparseLU fact (sm, Qinit, thresh, false, false, droptol,
+                               milu, udiag);
 
-                    case 4:
-                    default:
-                      {
-                        SparseLU fact (sm, Qinit, thresh, false, false, droptol,
-                                       milu, udiag);
+                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));
 
-                        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;
-                    }
-                }
+                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);
-
-              for (octave_idx_type i = 0; i < sm_nc; i++)
-                Qinit (i) = i;
+        }
+      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;
-                    }
-                }
+                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");
         }
+      else
+        error ("luinc: matrix A must be sparse");
     }
 
   return retval;
--- a/libinterp/corefcn/matrix_type.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/matrix_type.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -157,11 +157,9 @@
                     {
                       SparseComplexMatrix m =
                         args(0).sparse_complex_matrix_value ();
-                      if (!error_state)
-                        {
-                          mattyp = MatrixType (m);
-                          args(0).matrix_type (mattyp);
-                        }
+
+                      mattyp = MatrixType (m);
+                      args(0).matrix_type (mattyp);
                     }
                 }
               else
@@ -171,11 +169,9 @@
                   if (mattyp.is_unknown () && autocomp)
                     {
                       SparseMatrix m = args(0).sparse_matrix_value ();
-                      if (!error_state)
-                        {
-                          mattyp = MatrixType (m);
-                          args(0).matrix_type (mattyp);
-                        }
+
+                      mattyp = MatrixType (m);
+                      args(0).matrix_type (mattyp);
                     }
                 }
 
@@ -218,120 +214,103 @@
           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 ();
+
+              std::string str_typ = args(1).string_value ("matrix_type: TYPE must be a string");
+
+              // FIXME: why do I have to explicitly call the constructor?
+              MatrixType mattyp = MatrixType ();
 
-                  // FIXME: why do I have to explicitly call the constructor?
-                  MatrixType mattyp = MatrixType ();
+              octave_idx_type nl = 0;
+              octave_idx_type nu = 0;
 
-                  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);
 
-                  // 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 (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");
+                      if (error_state)
+                        error ("matrix_type: band size NL, NU must be integers");
                       else
                         {
-                          nl = args(2).nint_value ();
-                          nu = args(3).nint_value ();
-
-                          if (error_state)
-                            error ("matrix_type: band size NL, NU must be integers");
+                          if (nl == 1 && nu == 1)
+                            mattyp.mark_as_tridiagonal ();
                           else
-                            {
-                              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 (! error_state)
-                    {
-                      if (nargin == 3
-                          && (str_typ == "upper" || str_typ == "lower"))
-                        {
-                          const ColumnVector perm =
-                            ColumnVector (args(2).vector_value ());
+                            mattyp.mark_as_banded (nu, nl);
 
-                          if (error_state)
-                            error ("matrix_type: Invalid permutation vector PERM");
-                          else
-                            {
-                              octave_idx_type len = perm.length ();
-                              dim_vector dv = args(0).dims ();
-
-                              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);
+                          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 =
+                    ColumnVector (args(2).vector_value ());
+
+                  if (error_state)
+                    error ("matrix_type: Invalid permutation vector PERM");
+                  else
+                    {
+                      octave_idx_type len = perm.numel ();
+                      dim_vector dv = args(0).dims ();
+
+                      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
@@ -350,20 +329,16 @@
                         {
                           FloatComplexMatrix m;
                           m = args(0).float_complex_matrix_value ();
-                          if (!error_state)
-                            {
-                              mattyp = MatrixType (m);
-                              args(0).matrix_type (mattyp);
-                            }
+
+                          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);
-                            }
+
+                          mattyp = MatrixType (m);
+                          args(0).matrix_type (mattyp);
                         }
                     }
                 }
@@ -376,20 +351,16 @@
                       if (args(0).is_single_type ())
                         {
                           FloatMatrix m = args(0).float_matrix_value ();
-                          if (!error_state)
-                            {
-                              mattyp = MatrixType (m);
-                              args(0).matrix_type (mattyp);
-                            }
+
+                          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);
-                            }
+
+                          mattyp = MatrixType (m);
+                          args(0).matrix_type (mattyp);
                         }
                     }
                 }
@@ -421,101 +392,79 @@
           else
             {
               // Ok, we're changing the matrix type
-              if (! args(1).is_string ())
-                error ("matrix_type: TYPE must be a string");
+
+              std::string str_typ = args(1).string_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 =
+                    ColumnVector (args(2).vector_value ());
+
+                  if (error_state)
+                    error ("matrix_type: Invalid permutation vector PERM");
+                  else
+                    {
+                      octave_idx_type len = perm.numel ();
+                      dim_vector dv = args(0).dims ();
+
+                      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)
+                error ("matrix_type: Invalid number of arguments");
+
+              // 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
                 {
-                  std::string str_typ = args(1).string_value ();
-
-                  // 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 ();
+                  if (args(0).is_complex_type ())
+                    retval = octave_value (args(0).complex_matrix_value (),
+                                           mattyp);
                   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 (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);
-                            }
-                        }
-                    }
+                    retval = octave_value (args(0).matrix_value (), mattyp);
                 }
             }
         }
--- a/libinterp/corefcn/max.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/max.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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));
@@ -271,7 +257,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 +268,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 ())
@@ -876,9 +862,6 @@
   octave_value_list retval;
   ArrayType array = octave_value_extract<ArrayType> (arg);
 
-  if (error_state)
-    return retval;
-
   if (nargout == 2)
     {
       retval.resize (2);
--- a/libinterp/corefcn/md5sum.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/md5sum.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -59,18 +59,15 @@
       if (nargin == 2)
         have_str = args(1).bool_value ();
 
-      if (!error_state)
+      if (have_str)
+        retval = oct_md5 (str);
+      else
         {
-          if (have_str)
-            retval = oct_md5 (str);
-          else
-            {
-              std::string fname = file_ops::tilde_expand (str);
+          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);
         }
     }
 
--- a/libinterp/corefcn/mex.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/mex.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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];
@@ -2713,12 +2718,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;
 }
 
@@ -3054,20 +3060,17 @@
 
   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;
     }
 
+  retval.resize (nargout);
+
+  for (int i = 0; i < nargout; i++)
+    retval(i) = mxArray::as_octave_value (argout[i]);
+
   // Clean up mex resources.
   frame.run ();
 
@@ -3099,9 +3102,20 @@
   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&)
+    {
+      execution_error = true;
+    }
+
+  if (execution_error && mex_context->trap_feval_error == 0)
     {
       // FIXME: is this the correct way to clean up?  abort() is
       // going to trigger a long jump, so the normal class destructors
@@ -3132,13 +3146,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,14 +3165,19 @@
 
   octave_value_list ret;
 
-  ret = eval_string (s, false, parse_status, 0);
-
-  if (parse_status || error_state)
+  bool execution_error = false;
+
+  try
     {
-      error_state = 0;
-
-      retval = 1;
+      ret = eval_string (s, false, parse_status, 0);
     }
+  catch (const octave_execution_exception&)
+    {
+      execution_error = true;
+    }
+
+  if (parse_status || execution_error)
+    retval = 1;
 
   return retval;
 }
@@ -3271,9 +3284,6 @@
             {
               octave_call_stack::goto_base_frame ();
 
-              if (error_state)
-                return retval;
-
               frame.add_fcn (octave_call_stack::pop);
             }
 
@@ -3334,9 +3344,6 @@
             {
               octave_call_stack::goto_base_frame ();
 
-              if (error_state)
-                return 1;
-
               frame.add_fcn (octave_call_stack::pop);
             }
 
@@ -3380,10 +3387,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/mex.h	Sat Oct 10 16:52:59 2015 -0700
@@ -52,7 +52,7 @@
 
 typedef void mxArray;
 
-#if ! defined (__cplusplus)
+#if ! defined (__cplusplus) && ! defined (bool)
 typedef int bool;
 #endif
 
--- a/libinterp/corefcn/mgorth.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/mgorth.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -45,7 +45,7 @@
 
   h(Vc) = xnorm (x);
   if (real (h(Vc)) > 0)
-    x = x / h(Vc);
+    x /= h(Vc);
 }
 
 DEFUN (mgorth, args, nargout,
--- a/libinterp/corefcn/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/oct-errno.in.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/oct-errno.in.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -303,7 +303,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create errno object!");
+      error ("unable to create errno object!");
 
       retval = false;
     }
--- a/libinterp/corefcn/oct-handle.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/oct-handle.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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 (const octave_execution_exception&)
+          {
+            error ("invalid handle");
+          }
       }
   }
 
--- a/libinterp/corefcn/oct-hdf5-id.cc	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/oct-hdf5.h	Sat Oct 10 16:52:59 2015 -0700
@@ -27,6 +27,14 @@
 
 #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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/oct-hist.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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).string_value ("history: expecting file name 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
--- a/libinterp/corefcn/oct-lvalue.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/oct-lvalue.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/oct-lvalue.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/oct-map.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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 ());
@@ -900,46 +900,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;
@@ -1094,46 +1100,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 +1162,7 @@
 
   ref.assign (idx, rhs);
 
-  if (! error_state && ref.dims () != dimensions)
+  if (ref.dims () != dimensions)
     {
       dimensions = ref.dims ();
 
@@ -1164,7 +1176,7 @@
       optimize_dimensions ();
     }
 
-  if (! error_state && &ref == &tmp)
+  if (&ref == &tmp)
     setfield (k, tmp);
 }
 
@@ -1244,14 +1256,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);
 }
 
 /*
--- a/libinterp/corefcn/oct-map.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/oct-map.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/oct-obj.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
   }
--- a/libinterp/corefcn/oct-stream.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/oct-stream.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -123,7 +123,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 +145,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 +232,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 +256,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 +339,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 +486,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 +514,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 +544,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 +661,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 +685,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 +868,7 @@
 void
 printf_format_list::printme (void) const
 {
-  int n = list.length ();
+  int n = list.numel ();
 
   for (int i = 0; i < n; i++)
     {
@@ -1603,11 +1600,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 +1864,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 +1916,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
@@ -2344,17 +2357,14 @@
 
   octave_value val = get_next_value ();
 
+  double dval = val.double_value (true);
+
   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;
-        }
+      if (D_NINT (dval) == dval)
+        retval = NINT (dval);
+      else
+        curr_state = conversion_error;
     }
 
   return retval;
@@ -2570,9 +2580,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 +2603,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,8 +2613,7 @@
           {
             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;
 
@@ -2640,9 +2647,6 @@
 
       printf_value_cache val_cache (args, who);
 
-      if (error_state)
-        return retval;
-
       for (;;)
         {
           octave_quit ();
@@ -2900,8 +2904,7 @@
         }
     }
 
-  if (! error_state)
-    retval = getl (max_len, err, who);
+  retval = getl (max_len, err, who);
 
   return retval;
 }
@@ -2940,8 +2943,7 @@
         }
     }
 
-  if (! error_state)
-    retval = gets (max_len, err, who);
+  retval = gets (max_len, err, who);
 
   return retval;
 }
@@ -2985,8 +2987,7 @@
         }
     }
 
-  if (! error_state)
-    retval = skipl (count, err, who);
+  retval = skipl (count, err, who);
 
   return retval;
 }
@@ -3189,7 +3190,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]);
 
@@ -3381,7 +3382,6 @@
 
       if (! error_state)
         {
-
           octave_idx_type elts_to_read;
 
           if (one_elt_size_spec)
@@ -4296,8 +4296,7 @@
 
   int i = get_file_number (fid);
 
-  if (! error_state)
-    retval = do_lookup (i, who);
+  retval = do_lookup (i, who);
 
   return retval;
 }
@@ -4353,8 +4352,7 @@
     {
       int i = get_file_number (fid);
 
-      if (! error_state)
-        retval = do_remove (i, who);
+      retval = do_remove (i, who);
     }
 
   return retval;
--- a/libinterp/corefcn/oct-stream.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/oct-stream.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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-tex-lexer.in.ll	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/oct-tex-lexer.in.ll	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/oct-tex-parser.in.yy	Sat Oct 10 16:52:59 2015 -0700
@@ -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/octave-link.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/octave-link.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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).string_value ("expecting file name as argument");
 
-      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).string_value ("expecting file name as first argument");
 
-      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).string_value ("invalid arguments");
+      std::string msg = args(1).string_value ("invalid arguments");
+      std::string title = args(2).string_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).string_value ("invalid arguments");
+      std::string title = args(1).string_value ("invalid arguments");
+      std::string btn1 = args(2).string_value ("invalid arguments");
+      std::string btn2 = args(3).string_value ("invalid arguments");
+      std::string btn3 = args(4).string_value ("invalid arguments");
+      std::string btndef = args(5).string_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;
@@ -327,30 +307,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 +367,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/pager.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/pager.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
     }
@@ -545,9 +545,6 @@
 
   string_vector argv = args.make_argv ("diary");
 
-  if (error_state)
-    return retval;
-
   if (diary_file.empty ())
     diary_file = "diary";
 
@@ -626,9 +623,6 @@
 
   string_vector argv = args.make_argv ("more");
 
-  if (error_state)
-    return retval;
-
   if (argc == 2)
     {
       std::string arg = argv[1];
--- a/libinterp/corefcn/pinv.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/pinv.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -83,9 +83,6 @@
           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");
@@ -103,9 +100,6 @@
           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");
@@ -128,9 +122,6 @@
       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");
@@ -141,20 +132,16 @@
         {
           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,9 +149,6 @@
       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");
@@ -175,20 +159,16 @@
         {
           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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/pr-output.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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)
     {
@@ -3442,46 +3442,43 @@
       if (nargin == 2)
         rat_string_len = args(1).nint_value ();
 
-      if (! error_state)
+      octave_value arg = args(0);
+
+      if (arg.is_numeric_type ())
         {
-          octave_value arg = args(0);
-
-          if (arg.is_numeric_type ())
+          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)
             {
-              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
                 {
-                  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;
-                    }
+                  lst.push_back (s.substr (n, m - n));
+                  n = m + 1;
                 }
-
-              retval = string_vector (lst);
             }
-          else
-            error ("rats: X must be numeric");
+
+          retval = string_vector (lst);
         }
+      else
+        error ("rats: X must be numeric");
     }
 
   return retval;
@@ -3565,17 +3562,14 @@
 
       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");
-        }
+      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");
     }
   else
     print_usage ();
@@ -4069,9 +4063,6 @@
 
   string_vector argv = args.make_argv ("format");
 
-  if (error_state)
-    return retval;
-
   set_format_style (argc, argv);
 
   return retval;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/corefcn/psi.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,240 @@
+/*
+
+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 ();
+      return retval;
+    }
+
+  const octave_value oct_z = (nargin == 1) ? args(0) : args(1);
+  const octave_idx_type k = (nargin == 1) ? 0 : args(0).idx_type_value ();
+  if (error_state || k < 0)
+    {
+      error ("psi: K must be a non-negative integer");
+      return retval;
+    }
+  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)");
+          return retval;
+        }
+
+#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)"); \
+                  return retval; \
+                } \
+              *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 <K must be a non-negative integer> 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/quad.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/quad.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -159,7 +159,7 @@
 #define QUAD_ABORT1(msg) \
   do \
     { \
-      ::error ("quad: " msg); \
+      error ("quad: " msg); \
       QUAD_ABORT (); \
     } \
   while (0)
@@ -167,7 +167,7 @@
 #define QUAD_ABORT2(fmt, arg) \
   do \
     { \
-      ::error ("quad: " fmt, arg); \
+      error ("quad: " fmt, arg); \
       QUAD_ABORT (); \
     } \
   while (0)
@@ -312,7 +312,7 @@
               if (error_state)
                 QUAD_ABORT1 ("expecting vector of tolerances as fifth argument");
 
-              switch (tol.capacity ())
+              switch (tol.numel ())
                 {
                 case 2:
                   quad_opts.set_single_precision_relative_tolerance (tol (1));
@@ -421,7 +421,7 @@
               if (error_state)
                 QUAD_ABORT1 ("expecting vector of tolerances as fifth argument");
 
-              switch (tol.capacity ())
+              switch (tol.numel ())
                 {
                 case 2:
                   quad_opts.set_relative_tolerance (tol (1));
--- a/libinterp/corefcn/quadcc.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/quadcc.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -1713,7 +1713,7 @@
           return retval;
         }
       Matrix effex = fvals(0).matrix_value ();
-      if (effex.length () != ex.length ())
+      if (effex.numel () != ex.numel ())
         {
           error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input");
           return retval;
@@ -1832,12 +1832,12 @@
                 return retval;
               }
             Matrix effex = fvals(0).matrix_value ();
-            if (effex.length () != ex.length ())
+            if (effex.numel () != ex.numel ())
               {
                 error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input");
                 return retval;
               }
-            neval += effex.length ();
+            neval += effex.numel ();
             for (i = 0; i < n[d] / 2; i++)
               {
                 j = (2 * i + 1) * skip[d];
@@ -1980,12 +1980,12 @@
                 return retval;
               }
             Matrix effex = fvals(0).matrix_value ();
-            if (effex.length () != ex.length ())
+            if (effex.numel () != ex.numel ())
               {
                 error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input");
                 return retval;
               }
-            neval += effex.length ();
+            neval += effex.numel ();
             for (i = 0; i < n[0] - 1; i++)
               {
                 j = (i + 1) * skip[0];
@@ -2076,12 +2076,12 @@
                 return retval;
               }
             Matrix effex = fvals(0).matrix_value ();
-            if (effex.length () != ex.length ())
+            if (effex.numel () != ex.numel ())
               {
                 error ("quadcc: integrand F must return a single, real-valued vector of the same size as the input");
                 return retval;
               }
-            neval += effex.length ();
+            neval += effex.numel ();
             for (i = 0; i < n[0] - 1; i++)
               {
                 j = (i + 1) * skip[0];
--- a/libinterp/corefcn/qz.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/qz.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -403,14 +403,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).string_value ("qz: OPT must be a string");
 
       if (! tmp.empty ())
         ord_job = tmp[0];
@@ -495,9 +490,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 +509,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.
--- a/libinterp/corefcn/rand.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/rand.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -190,7 +190,7 @@
 
             if (r.all_elements_are_ints ())
               {
-                octave_idx_type n = r.nelem ();
+                octave_idx_type n = r.numel ();
 
                 dims.resize (n);
 
@@ -218,7 +218,7 @@
 
             if (! error_state)
               {
-                octave_idx_type len = iv.length ();
+                octave_idx_type len = iv.numel ();
 
                 dims.resize (len);
 
@@ -317,7 +317,7 @@
     {
       if (additional_arg)
         {
-          if (a.length () == 1)
+          if (a.numel () == 1)
             return octave_rand::float_nd_array (dims, a(0));
           else
             {
@@ -326,7 +326,7 @@
                   error ("%s: mismatch in argument size", fcn);
                   return retval;
                 }
-              octave_idx_type len = a.length ();
+              octave_idx_type len = a.numel ();
               FloatNDArray m (dims);
               float *v = m.fortran_vec ();
               for (octave_idx_type i = 0; i < len; i++)
@@ -341,7 +341,7 @@
     {
       if (additional_arg)
         {
-          if (a.length () == 1)
+          if (a.numel () == 1)
             return octave_rand::nd_array (dims, a(0));
           else
             {
@@ -350,7 +350,7 @@
                   error ("%s: mismatch in argument size", fcn);
                   return retval;
                 }
-              octave_idx_type len = a.length ();
+              octave_idx_type len = a.numel ();
               NDArray m (dims);
               double *v = m.fortran_vec ();
               for (octave_idx_type i = 0; i < len; i++)
@@ -1181,7 +1181,7 @@
             {
               idx = Array<octave_idx_type> (dim_vector (1, idx_len));
             }
-          catch (std::bad_alloc)
+          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.
--- a/libinterp/corefcn/regexp.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/regexp.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
             }
         }
@@ -191,13 +288,7 @@
     {
       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).string_value ("%s: optional arguments must be strings", who.c_str ());
 
       std::transform (str.begin (), str.end (), str.begin (), tolower);
 
@@ -246,12 +337,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 +348,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 +355,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 +554,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 +571,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 +593,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 +612,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 +635,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);
@@ -1065,6 +1129,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,
@@ -1237,19 +1307,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 +1340,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);
 }
@@ -1362,41 +1426,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/schur.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -143,15 +143,7 @@
   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).string_value ("schur: second argument must be a string");
 
   bool force_complex = false;
 
@@ -194,39 +186,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 +221,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 ();
             }
         }
     }
@@ -334,25 +312,21 @@
             {
               FloatMatrix u = args(0).float_matrix_value ();
               FloatMatrix t = args(1).float_matrix_value ();
-              if (! error_state)
-                {
-                  FloatComplexSCHUR cs (FloatSCHUR (t, u));
+
+              FloatComplexSCHUR cs (FloatSCHUR (t, u));
 
-                  retval(1) = cs.schur_matrix ();
-                  retval(0) = cs.unitary_matrix ();
-                }
+              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 ();
             }
         }
     }
--- a/libinterp/corefcn/sighandlers.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/sighandlers.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -199,7 +199,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create w32_interrupt_manager");
+        error ("unable to create w32_interrupt_manager");
 
         retval = false;
       }
@@ -929,7 +929,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create child list object!");
+      error ("unable to create child list object!");
 
       retval = false;
     }
--- a/libinterp/corefcn/sparse.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/sparse.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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,48 @@
           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 (! error_state && (m < 0 || n < 0))
+            error ("sparse: dimensions must be non-negative");
+        }
+      else if (nargin != 3)
+        print_usage ();
 
-              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;
         }
     }
 
@@ -266,11 +267,11 @@
       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)
+
+      if (m >= 0 && n >= 0 && nz >= 0)
         retval = SparseMatrix (dim_vector (m, n), nz);
       else
         error ("spalloc: M,N,NZ must be non-negative");
--- a/libinterp/corefcn/spparms.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/spparms.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -167,21 +167,16 @@
     }
   else if (nargin == 2)
     {
-      if (args(0).is_string ())
-        {
-          std::string str = args(0).string_value ();
+      std::string str = args(0).string_value ("spparms: first argument must be a string");
 
-          double val = args(1).double_value ();
+      double val = args(1).double_value ();
 
-          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 (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: too many input arguments");
--- a/libinterp/corefcn/sqrtm.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/sqrtm.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -248,7 +248,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/str2double.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -358,24 +358,21 @@
       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);
--- a/libinterp/corefcn/strfns.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/strfns.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -103,8 +103,8 @@
               return retval;
             }
 
-          if (s.length () > 0)
-            n_elts += s.length ();
+          if (s.numel () > 0)
+            n_elts += s.numel ();
           else
             n_elts += 1;
 
@@ -125,7 +125,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 +210,70 @@
   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).all_strings ();
 
-          size_t n = s.length ();
+      if (error_state)
+        {
+          error ("strvcat: unable to convert some args to strings");
+          return retval;
+        }
 
-          // do not count empty strings in calculation of number of elements
-          if (n > 0)
+      size_t n = s.numel ();
+
+      // 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 +290,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 (), "")
 */
 
 
@@ -374,7 +365,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 +378,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 +395,7 @@
         }
       else if (r > 1)
         {
-          if (cell.length () == 1)
+          if (cell.numel () == 1)
             {
               // Broadcast the cell.
 
@@ -427,13 +418,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 +484,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
@@ -704,16 +695,13 @@
     {
       octave_idx_type n = args(2).idx_type_value ();
 
-      if (! error_state)
+      if (n > 0)
         {
-          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");
+          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");
     }
   else
     print_usage ();
@@ -847,16 +835,13 @@
     {
       octave_idx_type n = args(2).idx_type_value ();
 
-      if (! error_state)
+      if (n > 0)
         {
-          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");
+          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");
     }
   else
     print_usage ();
@@ -938,15 +923,7 @@
   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).string_value ("list_in_columns: PREFIX must be a string");
 
   std::ostringstream buf;
 
--- a/libinterp/corefcn/sub2ind.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/sub2ind.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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);
@@ -92,32 +92,31 @@
       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++)
         {
-          dv = dv.redim (nargin - 1);
-          for (int j = 0; j < nargin - 1; j++)
+          if (args(j+1).is_numeric_type ())
             {
-              if (args(j+1).is_numeric_type ())
+              try
                 {
                   idxa(j) = args(j+1).index_vector ();
-                  if (error_state)
-                    break;
-                  else if (j > 0 && args(j+1).dims () != args(1).dims ())
+
+                  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");
-
-              if (error_state)
-                break;
+              catch (index_exception& e)
+                {
+                  e.set_pos_if_unset (nargin-1, j+1);
+                  e.set_var ("");     // no particular variable
+                  (*current_liboctave_error_with_id_handler)
+                    (e.id(), e.err());
+                }
             }
+          else
+            error ("sub2ind: subscripts must be numeric");
         }
 
-      if (! error_state)
-        {
-          idx_vector idx = sub2ind (dv, idxa);
-          retval = idx;
-        }
+      retval = sub2ind (dv, idxa);
     }
 
   return retval;
@@ -134,23 +133,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 +163,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,
@@ -195,14 +194,19 @@
   else
     {
       dim_vector dv = get_dim_vector (args(0), "ind2sub");
-      idx_vector idx = args(1).index_vector ();
-      if (! error_state)
+
+      try
         {
+          idx_vector idx = args(1).index_vector ();
+
           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 (index_exception& e)
+        {
+          error ("ind2sub: Invalid index %s. %s", e.idx (), e.explain ());
         }
     }
 
--- a/libinterp/corefcn/svd.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/svd.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/sylvester.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -126,20 +126,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 +136,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 +151,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 +161,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/symtab.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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"
@@ -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 ())
                 {
@@ -1687,20 +1688,16 @@
 
   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).string_value ("ignore_function_time_stamp: expecting argument to 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 \"all\", \"system\", or \"none\"");
     }
   else if (nargin > 1)
     print_usage ();
@@ -1728,8 +1725,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,6 +1745,7 @@
 @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;
@@ -1810,6 +1809,39 @@
   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)
+    {
+      std::string name = args(0).string_value ("__get_cmd_line_function_text__: expecting 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 ();
+        }
+    }
+  else
+    print_usage ();
+
+  return retval;
+}
+
 #if 0
 
 // FIXME: should we have functions like this in Octave?
@@ -1820,12 +1852,9 @@
 
   if (args.length () == 2)
     {
-      std::string name = args(0).string_value ();
+      std::string name = args(0).string_value ("set_variable: expecting variable name as first argument");
 
-      if (! error_state)
-        symbol_table::assign (name, args(1));
-      else
-        error ("set_variable: expecting variable name as first argument");
+      symbol_table::assign (name, args(1));
     }
   else
     print_usage ();
@@ -1839,18 +1868,13 @@
 
   if (args.length () == 1)
     {
-      std::string name = args(0).string_value ();
+      std::string name = args(0).string_value ("variable_value: expecting variable name as first argument");
 
-      if (! error_state)
-        {
-          retval = symbol_table::varval (name);
+      retval = symbol_table::varval (name);
 
-          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");
+      if (retval.is_undefined ())
+        error ("variable_value: '%s' is not a variable in the current scope",
+               name.c_str ());
     }
   else
     print_usage ();
--- a/libinterp/corefcn/symtab.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/symtab.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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++)
       {
--- a/libinterp/corefcn/syscalls.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/syscalls.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -137,20 +137,17 @@
           octave_stream new_stream
             = octave_stream_list::lookup (args(1), "dup2");
 
-          if (! error_state)
-            {
-              int i_old = old_stream.file_number ();
-              int i_new = new_stream.file_number ();
+          int i_old = old_stream.file_number ();
+          int i_new = new_stream.file_number ();
 
-              if (i_old >= 0 && i_new >= 0)
-                {
-                  std::string msg;
+          if (i_old >= 0 && i_new >= 0)
+            {
+              std::string msg;
 
-                  int status = octave_syscalls::dup2 (i_old, i_new, msg);
+              int status = octave_syscalls::dup2 (i_old, i_new, msg);
 
-                  retval(1) = msg;
-                  retval(0) = status;
-                }
+              retval(1) = msg;
+              retval(0) = status;
             }
         }
       else
@@ -192,54 +189,46 @@
 
   if (nargin == 1 || nargin == 2)
     {
-      if (args(0).is_string ())
-        {
-          std::string exec_file = args(0).string_value ();
-
-          string_vector exec_args;
+      std::string exec_file = args(0).string_value ("exec: FILE must be a string");
 
-          if (nargin == 2)
-            {
-              string_vector tmp = args(1).all_strings ();
-
-              if (! error_state)
-                {
-                  int len = tmp.length ();
+      string_vector exec_args;
 
-                  exec_args.resize (len + 1);
-
-                  exec_args[0] = exec_file;
-
-                  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);
-
-              exec_args[0] = exec_file;
-            }
+      if (nargin == 2)
+        {
+          string_vector tmp = args(1).all_strings ();
 
           if (! error_state)
             {
-              octave_history_write_timestamp ();
+              int len = tmp.numel ();
 
-              if (! command_history::ignoring_entries ())
-                command_history::clean_up_and_save ();
+              exec_args.resize (len + 1);
+
+              exec_args[0] = exec_file;
 
-              std::string msg;
-
-              int status = octave_syscalls::execvp (exec_file, exec_args, msg);
-
-              retval(1) = msg;
-              retval(0) = status;
+              for (int i = 0; i < len; i++)
+                exec_args[i+1] = tmp[i];
             }
+          else
+            error ("exec: all arguments must be strings");
         }
       else
-        error ("exec: FILE must be a string");
+        {
+          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;
     }
   else
     print_usage ();
@@ -304,77 +293,69 @@
 
   if (nargin >= 1 && nargin <= 3)
     {
-      if (args(0).is_string ())
-        {
-          std::string exec_file = args(0).string_value ();
-
-          string_vector arg_list;
+      std::string exec_file = args(0).string_value ("popen2: COMMAND argument must be a string");
 
-          if (nargin >= 2)
-            {
-              string_vector tmp = args(1).all_strings ();
-
-              if (! error_state)
-                {
-                  int len = tmp.length ();
+      string_vector arg_list;
 
-                  arg_list.resize (len + 1);
-
-                  arg_list[0] = exec_file;
-
-                  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 (nargin >= 2)
+        {
+          string_vector tmp = args(1).all_strings ();
 
           if (! error_state)
             {
-              bool sync_mode = (nargin == 3 ? args(2).bool_value () : false);
+              int len = tmp.numel ();
 
-              if (! error_state)
-                {
-                  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");
+              arg_list.resize (len + 1);
 
-                      std::string nm;
-
-                      octave_stream is = octave_stdiostream::create (nm, ifile,
-                                                                  std::ios::in);
-
-                      octave_stream os = octave_stdiostream::create (nm, ofile,
-                                                                 std::ios::out);
+              arg_list[0] = exec_file;
 
-                      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 ());
-                }
+              for (int i = 0; i < len; i++)
+                arg_list[i+1] = tmp[i];
             }
           else
             error ("popen2: all arguments must be strings");
         }
       else
-        error ("popen2: COMMAND argument must be a string");
+        {
+          arg_list.resize (1);
+
+          arg_list[0] = exec_file;
+        }
+
+      if (! error_state)
+        {
+          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 (nm, ifile,
+                                                             std::ios::in);
+
+              octave_stream os = octave_stdiostream::create (nm, 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 ());
+        }
+      else
+        error ("popen2: all arguments must be strings");
     }
   else
     print_usage ();
@@ -527,20 +508,17 @@
           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
             {
-              // FIXME: Need better checking here?
-              if (fid < 0)
-                error ("fcntl: invalid file id");
-              else
-                {
-                  std::string msg;
+              std::string msg;
 
-                  int status = octave_fcntl (fid, req, arg, msg);
+              int status = octave_fcntl (fid, req, arg, msg);
 
-                  retval(1) = msg;
-                  retval(0) = status;
-                }
+              retval(1) = msg;
+              retval(0) = status;
             }
         }
       else
@@ -768,20 +746,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 +776,11 @@
 
   if (args.length () == 1)
     {
-      std::string fname = args(0).string_value ();
+      std::string fname = args(0).string_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 +788,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 +834,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 +843,30 @@
 
   if (nargin == 2)
     {
-      if (args(0).is_string ())
-        {
-          std::string name = args(0).string_value ();
+      std::string name = args(0).string_value ("mkfifo: FILE must be a string");
 
-          if (args(1).is_scalar_type ())
-            {
-              long mode = args(1).long_value ();
-
-              if (! error_state)
-                {
-                  std::string msg;
+      int octal_mode = args(1).int_value ();
 
-                  int status = octave_mkfifo (name, mode, msg);
-
-                  retval(0) = status;
+      if (! error_state)
+        {
+          if (octal_mode < 0)
+            error ("mkfifo: MODE must be a positive integer value");
+          else
+            {
+              int mode = convert (octal_mode, 8, 10);
 
-                  if (status < 0)
-                    retval(1) = msg;
-                }
-              else
-                error ("mkfifo: invalid MODE");
+              std::string msg;
+
+              int status = octave_mkfifo (name, mode, msg);
+
+              retval(0) = status;
+
+              if (status < 0)
+                retval(1) = msg;
             }
-          else
-            error ("mkfifo: MODE must be an integer");
         }
       else
-        error ("mkfifo: FILE must be a string");
+        error ("mkfifo: MODE must be an integer");
     }
   else
     print_usage ();
@@ -878,6 +874,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\
@@ -1037,23 +1046,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).string_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
@@ -1329,19 +1332,14 @@
 
   if (nargin == 1)
     {
-      if (args(0).is_string ())
-        {
-          std::string name = args(0).string_value ();
+      std::string name = args(0).string_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 ();
@@ -1650,19 +1648,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).string_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 ();
--- a/libinterp/corefcn/sysdep.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/sysdep.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -195,27 +195,22 @@
 
   if (args.length () == 1)
     {
-      std::string file = args(0).string_value ();
+      std::string file = args(0).string_value ("__open_with_system_app__: argument must be a file name");
 
-      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 ();
@@ -620,8 +615,7 @@
     {
       std::string name = args(0).string_value ();
 
-      if (! error_state)
-        retval = octave_env::getenv (name);
+      retval = octave_env::getenv (name);
     }
   else
     print_usage ();
@@ -651,20 +645,13 @@
 
   if (nargin == 2 || nargin == 1)
     {
-      if (args(0).is_string ())
-        {
-          std::string var = args(0).string_value ();
-
-          std::string val = (nargin == 2
-                             ? args(1).string_value () : std::string ());
+      std::string var = args(0).string_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");
+      std::string val = (nargin == 2
+                         ? args(1).string_value ("setenv: VALUE must be a string")
+                         : std::string ());
+
+      octave_env::putenv (var, val);
     }
   else
     print_usage ();
@@ -700,11 +687,7 @@
     {
       std::string tmp = args(0).string_value ();
 
-      if (! error_state)
-        {
-          int status = gnulib::unsetenv (tmp.c_str ());
-          retval = status;
-        }
+      retval = gnulib::unsetenv (tmp.c_str ());
     }
   else
     print_usage ();
@@ -805,23 +788,20 @@
     {
       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
     {
@@ -853,15 +833,12 @@
     {
       double dval = args(0).double_value ();
 
-      if (! error_state)
+      if (xisnan (dval))
+        warning ("sleep: NaN is an invalid delay");
+      else
         {
-          if (xisnan (dval))
-            warning ("sleep: NaN is an invalid delay");
-          else
-            {
-              Fdrawnow ();
-              octave_sleep (dval);
-            }
+          Fdrawnow ();
+          octave_sleep (dval);
         }
     }
   else
@@ -896,19 +873,16 @@
     {
       double dval = args(0).double_value ();
 
-      if (! error_state)
+      if (xisnan (dval))
+        warning ("usleep: NaN is an invalid delay");
+      else
         {
-          if (xisnan (dval))
-            warning ("usleep: NaN is an invalid delay");
-          else
-            {
-              Fdrawnow ();
+          Fdrawnow ();
 
-              int delay = NINT (dval);
+          int delay = NINT (dval);
 
-              if (delay > 0)
-                octave_usleep (delay);
-            }
+          if (delay > 0)
+            octave_usleep (delay);
         }
     }
   else
--- a/libinterp/corefcn/time.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/time.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -50,6 +50,7 @@
   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;
@@ -96,6 +97,7 @@
   tm.wday (intfield (m, "wday"));
   tm.yday (intfield (m, "yday"));
   tm.isdst (intfield (m, "isdst"));
+  tm.gmtoff (intfield (m, "gmtoff"));
   tm.zone (stringfield (m, "zone"));
 
   return tm;
@@ -150,7 +152,8 @@
            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\
@@ -163,8 +166,7 @@
     {
       double tmp = args(0).double_value ();
 
-      if (! error_state)
-        retval = octave_value (mk_tm_map (octave_gmtime (tmp)));
+      retval = octave_value (mk_tm_map (octave_gmtime (tmp)));
     }
   else
     print_usage ();
@@ -211,6 +213,7 @@
            wday = 1\n\
            yday = 47\n\
            isdst = 0\n\
+           gmtoff = -21600\n\
            zone = CST\n\
         @}\n\
 @end group\n\
@@ -224,8 +227,7 @@
     {
       double tmp = args(0).double_value ();
 
-      if (! error_state)
-        retval = octave_value (mk_tm_map (octave_localtime (tmp)));
+      retval = octave_value (mk_tm_map (octave_localtime (tmp)));
     }
   else
     print_usage ();
@@ -399,6 +401,9 @@
 @item %X\n\
 Locale's time representation (%H:%M:%S).\n\
 \n\
+@item %z\n\
+Offset from UTC (±hhmm), or nothing if no time zone is determinable.\n\
+\n\
 @item %Z\n\
 Time zone (EDT), or nothing if no time zone is determinable.\n\
 @end table\n\
@@ -468,26 +473,21 @@
 
   if (args.length () == 2)
     {
-      if (args(0).is_string ())
+      std::string fmt = args(0).string_value ("strftime: FMT must be a string");
+
+      octave_scalar_map map = args(1).scalar_map_value ();
+
+      if (! error_state)
         {
-          std::string fmt = args(0).string_value ();
-
-          octave_scalar_map map = args(1).scalar_map_value ();
+          octave_base_tm tm = extract_tm (map);
 
           if (! error_state)
-            {
-              octave_base_tm tm = extract_tm (map);
-
-              if (! error_state)
-                retval = tm.strftime (fmt);
-              else
-                error ("strftime: invalid TM_STRUCT argument");
-            }
+            retval = tm.strftime (fmt);
           else
-            error ("strftime: TM_STRUCT must be a structure");
+            error ("strftime: invalid TM_STRUCT argument");
         }
       else
-        error ("strftime: FMT must be a string");
+        error ("strftime: TM_STRUCT must be a structure");
     }
   else
     print_usage ();
@@ -524,24 +524,14 @@
 
   if (args.length () == 2)
     {
-      if (args(0).is_string ())
-        {
-          std::string str = args(0).string_value ();
+      std::string str = args(0).string_value ("strptime: argument STR must be a string");
 
-          if (args(1).is_string ())
-            {
-              std::string fmt = args(1).string_value ();
+      std::string fmt = args(1).string_value ("strptime: FMT must be a string");
 
-              octave_strptime t (str, fmt);
+      octave_strptime t (str, fmt);
 
-              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");
+      retval(1) = t.characters_converted ();
+      retval(0) = octave_value (mk_tm_map (t));
     }
   else
     print_usage ();
--- a/libinterp/corefcn/toplev.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/toplev.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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)
 {
@@ -636,20 +651,25 @@
                 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 (index_exception& e)
         {
           recover_from_exception ();
-          std::cerr << "error: unhandled execution exception -- trying to return to prompt"
+          std::cerr << "error: unhandled index exception: "
+                    << e.err () << " -- trying to return to prompt"
                     << std::endl;
         }
-      catch (std::bad_alloc)
+      catch (const octave_execution_exception&)
+        {
+          recover_from_exception ();
+        }
+      catch (const std::bad_alloc&)
         {
           recover_from_exception ();
           std::cerr << "error: out of memory -- trying to return to prompt"
@@ -1017,23 +1037,15 @@
 
       if (nargin == 3)
         {
-          if (args(2).is_string ())
-            {
-              std::string type_str = args(2).string_value ();
+          std::string type_str = args(2).string_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;
-                }
-            }
+          if (type_str == "sync")
+            type = et_sync;
+          else if (type_str == "async")
+            type = et_async;
           else
             {
-              error ("system: TYPE must be a string");
+              error ("system: TYPE must be \"sync\" or \"async\"");
               return retval;
             }
         }
@@ -1055,75 +1067,70 @@
           return retval;
         }
 
-      std::string cmd_str = args(0).string_value ();
+      std::string cmd_str = args(0).string_value ("system: expecting string as first argument");
 
-      if (! error_state)
-        {
 #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 ();
+          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.
+          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));
+              execl (SHELL_PATH, "sh", "-c", cmd_str.c_str (),
+                     static_cast<void *> (0));
 
-                  panic_impossible ();
-                }
-              else
-                retval(0) = pid;
+              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 ());
+          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 ("asynchronous system calls are not supported");
-#endif
-            }
-          else if (return_output)
-            retval = run_command_and_return_output (cmd_str);
+          if (! CreateProcess (0, xcmd_str, 0, 0, FALSE, 0, 0, 0, &si, &pi))
+            error ("system: CreateProcess failed -- can't create child process");
           else
             {
-              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.
+              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 (octave_wait::ifexited (status))
-                status = octave_wait::exitstatus (status);
+          // 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.
 
-              retval(0) = status;
-            }
+          if (octave_wait::ifexited (status))
+            status = octave_wait::exitstatus (status);
+
+          retval(0) = status;
         }
-      else
-        error ("system: expecting string as first argument");
     }
   else
     print_usage ();
@@ -1215,35 +1222,27 @@
 
   if (nargin == 1 || nargin == 2)
     {
-      if (args(0).is_string ())
-        {
-          std::string arg = args(0).string_value ();
+      std::string arg = args(0).string_value ("atexit: FCN argument must be a string");
 
-          bool add_mode = true;
+      bool add_mode = true;
 
-          if (nargin == 2)
-            {
-              add_mode = args(1).bool_value ();
-
-              if (error_state)
-                error ("atexit: FLAG argument must be a logical value");
-            }
+      if (nargin == 2)
+        {
+          add_mode = args(1).bool_value ();
 
-          if (! error_state)
-            {
-              if (add_mode)
-                octave_add_atexit_function (arg);
-              else
-                {
-                  bool found = octave_remove_atexit_function (arg);
+          if (error_state)
+            error ("atexit: FLAG argument must be a logical value");
+        }
 
-                  if (nargout > 0)
-                    retval(0) = found;
-                }
-            }
+      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");
     }
   else
     print_usage ();
@@ -1530,20 +1529,17 @@
     {
       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)
     retval = m;
--- a/libinterp/corefcn/toplev.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/toplev.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/tril.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -202,12 +202,7 @@
     }
 
   if (nargin == 2)
-    {
-      k = args(1).int_value (true);
-
-      if (error_state)
-        return retval;
-    }
+    k = args(1).int_value (true);
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
@@ -218,7 +213,7 @@
       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))
+      else if (k < -dims(0) || k > dims(1))
         error ("%s: requested diagonal out of range", name.c_str ());
       else
         {
@@ -312,9 +307,6 @@
                         idx.push_back (ov_idx);
 
                         tmp = tmp.subsasgn ("(", idx, arg.do_index_op (ov_idx));
-
-                        if (error_state)
-                          return retval;
                       }
                   }
                 else
@@ -330,9 +322,6 @@
                         idx.push_back (ov_idx);
 
                         tmp = tmp.subsasgn ("(", idx, arg.do_index_op (ov_idx));
-
-                        if (error_state)
-                          return retval;
                       }
                   }
 
--- a/libinterp/corefcn/tsearch.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/tsearch.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -86,9 +86,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 +100,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/txt-eng-ft.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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
@@ -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 ()
--- a/libinterp/corefcn/typecast.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/typecast.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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);
@@ -212,7 +212,7 @@
 
       std::string numclass = args(1).string_value ();
 
-      if (error_state || numclass.size () == 0)
+      if (numclass.size () == 0)
         ;
       else if (numclass == "char")
         retval = octave_value (reinterpret_copy<charNDArray>
@@ -253,7 +253,7 @@
       else if (numclass == "double complex")
         retval = reinterpret_copy<ComplexNDArray> (data, byte_size, old_dims);
 
-      if (! error_state && retval.is_undefined ())
+      if (retval.is_undefined ())
         error ("typecast: cannot convert to %s class", numclass.c_str ());
     }
   else
@@ -347,7 +347,7 @@
 
       std::string numclass = args(1).string_value ();
 
-      if (error_state || numclass.size () == 0)
+      if (numclass.size () == 0)
         ;
       else if (numclass == "char")
         retval = octave_value (do_bitpack<charNDArray> (bitp), '\'');
@@ -382,7 +382,7 @@
       else if (numclass == "double complex")
         retval = do_bitpack<ComplexNDArray> (bitp);
 
-      if (! error_state && retval.is_undefined ())
+      if (retval.is_undefined ())
         error ("bitpack: cannot pack to %s class", numclass.c_str ());
     }
 
--- a/libinterp/corefcn/urlwrite.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/urlwrite.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -81,7 +81,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create ch_manager!");
+        error ("unable to create ch_manager!");
 
         retval = false;
       }
@@ -350,35 +350,17 @@
       return retval;
     }
 
-  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).string_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).string_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).string_value ("urlwrite: METHOD must be a string");
 
       if (method != "get" && method != "post")
         {
@@ -511,26 +493,14 @@
       return retval;
     }
 
-  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).string_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).string_value ("urlread: METHOD must be a string");
 
       if (method != "get" && method != "post")
         {
@@ -599,22 +569,18 @@
     }
   else
     {
-      host = args(0).string_value ();
+      host = args(0).string_value ("__ftp__: HOST must be a string");
 
       if (nargin > 1)
-        user = args(1).string_value ();
+        user = args(1).string_value ("__ftp__: USER must be a string");
 
       if (nargin > 2)
-        passwd = args(2).string_value ();
+        passwd = args(2).string_value ("__ftp__: PASSWD must be a 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 ();
-        }
+      retval = ch.value ();
     }
 
   return retval;
@@ -636,9 +602,6 @@
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         retval = curl.pwd ();
       else
@@ -664,15 +627,12 @@
     {
       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).string_value ("__ftp_cwd__: PATH must be a string");
 
           if (! error_state)
             curl.cwd (path);
@@ -702,9 +662,6 @@
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         {
           if (nargout == 0)
@@ -712,7 +669,7 @@
           else
             {
               string_vector sv = curl.list ();
-              octave_idx_type n = sv.length ();
+              octave_idx_type n = sv.numel ();
 
               if (n == 0)
                 {
@@ -783,9 +740,6 @@
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         curl.ascii ();
       else
@@ -811,9 +765,6 @@
     {
       url_transfer curl = ch_manager::get_object (args(0));
 
-      if (error_state)
-        return retval;
-
       if (curl.is_valid ())
         curl.binary ();
       else
@@ -839,9 +790,6 @@
     {
       curl_handle h = ch_manager::lookup (args(0));
 
-      if (error_state)
-        return retval;
-
       if (h.ok ())
         ch_manager::free (h);
       else
@@ -867,9 +815,6 @@
     {
       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
@@ -895,12 +840,9 @@
     {
       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).string_value ("__ftp_delete__: FILE must be a string");
 
           if (! error_state)
             curl.del (file);
@@ -930,12 +872,9 @@
     {
       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).string_value ("__ftp_rmdir__: DIR must be a string");
 
           if (! error_state)
             curl.rmdir (dir);
@@ -965,12 +904,9 @@
     {
       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).string_value ("__ftp_mkdir__: DIR must be a string");
 
           if (! error_state)
             curl.mkdir (dir);
@@ -1000,13 +936,10 @@
     {
       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).string_value ("__ftp_rename__: OLDNAME must be a string");
+          std::string newname = args(2).string_value ("__ftp_rename__: NEWNAME must be a string");
 
           if (! error_state)
             curl.rename (oldname, newname);
@@ -1036,12 +969,9 @@
     {
       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).string_value ("__ftp_mput__: PATTERN must be a string");
 
           if (! error_state)
             {
@@ -1050,7 +980,7 @@
               glob_match pattern (file_ops::tilde_expand (pat));
               string_vector files = pattern.glob ();
 
-              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);
 
@@ -1113,7 +1043,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,16 +1058,13 @@
     {
       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).string_value ("__ftp_mget__: PATTERN must be a string");
           std::string target;
 
           if (nargin == 3)
-            target = args(2).string_value () + file_ops::dir_sep_str ();
+            target = args(2).string_value ("__ftp_mget__: TARGET must be a string") + file_ops::dir_sep_str ();
 
           if (! error_state)
             {
@@ -1145,7 +1073,7 @@
               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)))
                     {
--- a/libinterp/corefcn/utils.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/utils.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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);
 
@@ -316,7 +316,7 @@
     {
       string_vector names = args(0).all_strings ();
 
-      if (! error_state && names.length () > 0)
+      if (! error_state && names.numel () > 0)
         {
           if (nargin == 1)
             retval =
@@ -393,32 +393,27 @@
 
   if (nargin == 2 || nargin == 3)
     {
-      if (args(0).is_string ())
-        {
-          std::string path = args(0).string_value ();
+      std::string path = args(0).string_value ("file_in_path: PATH must be a string");
+
+      string_vector names = args(1).all_strings ();
 
-          string_vector names = args(1).all_strings ();
-
-          if (! error_state && names.length () > 0)
+      if (! error_state && names.numel () > 0)
+        {
+          if (nargin == 2)
+            retval = search_path_for_file (path, names);
+          else if (nargin == 3)
             {
-              if (nargin == 2)
-                retval = search_path_for_file (path, names);
-              else if (nargin == 3)
-                {
-                  std::string opt = args(2).string_value ();
+              std::string opt = args(2).string_value ();
 
-                  if (! error_state && opt == "all")
-                    retval = Cell (make_absolute
-                                   (search_path_for_all_files (path, names)));
-                  else
-                    error ("file_in_path: invalid option");
-                }
+              if (! error_state && opt == "all")
+                retval = Cell (make_absolute
+                               (search_path_for_all_files (path, names)));
+              else
+                error ("file_in_path: invalid option");
             }
-          else
-            error ("file_in_path: all arguments must be strings");
         }
       else
-        error ("file_in_path: PATH must be a string");
+        error ("file_in_path: all arguments must be strings");
     }
   else
     print_usage ();
@@ -631,11 +626,7 @@
         {
           switch (s[++j])
             {
-            case '0':
-              retval[i] = '\0';
-              break;
-
-            case 'a':
+            case 'a': // alarm
               retval[i] = '\a';
               break;
 
@@ -675,6 +666,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]);
@@ -713,10 +756,9 @@
 
   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");
+      std::string str = args(0).string_value ("do_string_escapes: STRING argument must be of type string");
+
+      retval = do_string_escapes (str);
     }
   else
     print_usage ();
@@ -745,9 +787,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 *
@@ -846,10 +899,9 @@
 
   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");
+      std::string str = args(0).string_value ("undo_string_escapes: S argument must be a string");
+
+      retval = undo_string_escapes (str);
     }
   else
     print_usage ();
@@ -943,12 +995,9 @@
 
   if (args.length () == 1)
     {
-      std::string nm = args(0).string_value ();
+      std::string nm = args(0).string_value ("make_absolute_filename: FILE argument must be a file name");
 
-      if (! error_state)
-        retval = octave_env::make_absolute (nm);
-      else
-        error ("make_absolute_filename: FILE argument must be a file name");
+      retval = octave_env::make_absolute (nm);
     }
   else
     print_usage ();
@@ -988,17 +1037,12 @@
 
   if (nargin == 1 || nargin == 2)
     {
-      dir = args(0).string_value ();
+      dir = args(0).string_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");
+      if (nargin == 1)
+        retval = load_path::find_dir (dir);
+      else if (nargin == 2)
+        retval = Cell (load_path::find_matching_dirs (dir));
     }
   else
     print_usage ();
@@ -1156,10 +1200,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 +1209,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 +1230,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,8 +1238,7 @@
         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
@@ -1214,7 +1251,7 @@
   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
@@ -1239,10 +1276,17 @@
             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 (index_exception& e)
+                {
+                  error ("dims_to_numel: Invalid IDX %s. %s",
+                                                        e.idx (), e.explain ());
+                }
             }
         }
     }
@@ -1391,33 +1435,23 @@
   else if (nargin != 1)
     print_usage ();
 
-  if (! error_state)
-    {
-      unwind_protect frame;
-
-      frame.protect_var (error_state);
+  unwind_protect frame;
 
-      frame.protect_var (discard_error_messages);
-      discard_error_messages = true;
+  frame.protect_var (discard_error_messages);
+  discard_error_messages = true;
 
-      try
-        {
-          idx_vector idx = args(0).index_vector (true);
+  try
+    {
+      idx_vector idx = args(0).index_vector (true);
 
-          if (! error_state)
-            {
-              if (nargin == 2)
-                retval = idx.extent (n) <= n;
-              else
-                retval = true;
-            }
-          else
-            retval = false;
-        }
-      catch (octave_execution_exception)
-        {
-          retval = false;
-        }
+      if (nargin == 2)
+        retval = idx.extent (n) <= n;
+      else
+        retval = true;
+    }
+  catch (const octave_execution_exception&)
+    {
+      retval = false;
     }
 
   return retval;
@@ -1475,40 +1509,35 @@
         }
     }
 
-  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);
+  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 ();
+      octave_quit ();
 
-          const octave_value_list tmp = fun (new_args, nargout);
+      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);
+          break;
+        }
+      else
+        {
+          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/variables.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/variables.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -147,39 +147,34 @@
 
   if (! retval)
     {
-      if (arg.is_string ())
+      std::string s = arg.string_value ("%s: expecting first argument to 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)
             {
-              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 ());
+              error ("%s: '%s' is not valid as a function",
+                     warn_for.c_str (), fname.c_str ());
+              return retval;
             }
-          else
-            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,9 +262,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);
 
@@ -310,7 +302,6 @@
       unwind_protect frame;
 
       frame.protect_var (discard_error_messages);
-      frame.protect_var (error_state);
 
       discard_error_messages = true;
 
@@ -377,9 +368,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&)
+    {
+      // Ignore errors.
+    }
 
   return retval;
 }
@@ -395,6 +391,14 @@
   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 ());
+      return 0;
+    }
 
   if (search_any || search_var)
     {
@@ -586,29 +590,19 @@
 
   if (nargin == 1 || nargin == 2)
     {
-      if (args(0).is_string ())
+      std::string name = args(0).string_value ("exist: NAME must be a string");
+
+      if (nargin == 2)
         {
-          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);
+          std::string type = args(1).string_value ("exist: TYPE must be a string");
+
+          if (type == "class")
+            warning ("exist: \"class\" type argument is not implemented");
+
+          retval = symbol_exist (name, type);
         }
       else
-        error ("exist: NAME must be a string");
+        retval = symbol_exist (name);
     }
   else
     print_usage ();
@@ -682,6 +676,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")
 
 */
 
@@ -816,27 +811,22 @@
 
   if (nargin == 1)
     {
-      std::string sval = args(0).string_value ();
-
-      if (! error_state)
+      std::string sval = args(0).string_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 ();
@@ -944,17 +934,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).string_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 ();
@@ -985,24 +970,19 @@
 
   if (nargin == 1)
     {
-      if (args(0).is_string ())
+      std::string sval = args(0).string_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 +1227,7 @@
                   break;
 
                 case 'e':
-                  os << varval.capacity ();
+                  os << varval.numel ();
                   break;
 
                 case 'n':
@@ -1395,7 +1375,7 @@
 
             octave_value val = p->varval;
 
-            elements += val.capacity ();
+            elements += val.numel ();
             bytes += val.byte_size ();
           }
 
@@ -1467,7 +1447,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 ()
@@ -1683,13 +1663,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 +1750,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);
                         }
                     }
                 }
@@ -1884,8 +1858,7 @@
 
       string_vector argv = args.make_argv ("who");
 
-      if (! error_state)
-        retval = do_who (argc, argv, nargout == 1);
+      retval = do_who (argc, argv, nargout == 1);
     }
   else
     print_usage ();
@@ -1965,8 +1938,7 @@
 
       string_vector argv = args.make_argv ("whos");
 
-      if (! error_state)
-        retval = do_who (argc, argv, nargout == 1, true);
+      retval = do_who (argc, argv, nargout == 1, true);
     }
   else
     print_usage ();
@@ -2091,13 +2063,9 @@
 
   if (args.length () == 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).string_value ("munlock: FCN must be a string");
+
+      munlock (name);
     }
   else if (args.length () == 0)
     {
@@ -2129,13 +2097,9 @@
 
   if (args.length () == 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).string_value ("mislocked: FCN must be a string");
+
+      retval = mislocked (name);
     }
   else if (args.length () == 0)
     {
@@ -2208,7 +2172,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 +2198,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 +2209,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 +2239,7 @@
         {
           string_vector lvars = symbol_table::variable_names ();
 
-          int lcount = lvars.length ();
+          int lcount = lvars.numel ();
 
           for (int i = 0; i < lcount; i++)
             {
@@ -2455,129 +2419,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 ();
         }
     }
 
@@ -2713,12 +2674,9 @@
 
   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");
+      std::string name = args(0).string_value ("__varval__: expecting argument to be variable name");
+
+      retval = symbol_table::varval (args(0).string_value ());
     }
   else
     print_usage ();
--- a/libinterp/corefcn/xdiv.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/xdiv.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/xpow.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/corefcn/xpow.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -705,10 +705,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 +940,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 +1121,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 +1132,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 +1150,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 +1171,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 +1185,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 +1201,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 +1257,7 @@
         }
     }
 
-  int len = a.length ();
+  int len = a.numel ();
 
   bool convert_to_complex = false;
 
@@ -1310,7 +1310,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 +1341,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 +1356,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 +1375,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 +1394,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 +1408,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 +1440,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 +1459,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 +1490,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));
@@ -2471,7 +2471,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 +2482,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 +2500,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 +2521,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 +2535,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 +2551,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 +2607,7 @@
         }
     }
 
-  int len = a.length ();
+  int len = a.numel ();
 
   bool convert_to_complex = false;
 
@@ -2660,7 +2660,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 +2691,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 +2706,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 +2725,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 +2744,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 +2758,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 +2790,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 +2809,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 +2840,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/dldfcn/__eigs__.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/__eigs__.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -270,7 +270,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 +288,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 ())
         {
@@ -319,7 +319,7 @@
   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 ())
         {
@@ -423,48 +423,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 +552,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,108 +602,13 @@
               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);
--- a/libinterp/dldfcn/__glpk__.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/__glpk__.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -470,7 +470,7 @@
   //--            bound on each of the variables.
   Matrix LB (args(3).matrix_value ());
 
-  if (error_state || LB.length () < mrowsc)
+  if (error_state || LB.numel () < mrowsc)
     {
       error ("__glpk__: invalid value of LB");
       return retval;
@@ -495,7 +495,7 @@
   //--            bound on each of the variables.
   Matrix UB (args(4).matrix_value ());
 
-  if (error_state || UB.length () < mrowsc)
+  if (error_state || UB.numel () < mrowsc)
     {
       error ("__glpk__: invalid value of UB");
       return retval;
--- a/libinterp/dldfcn/__init_fltk__.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/__init_fltk__.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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++)
       {
@@ -1777,7 +1777,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create figure_manager object!");
+        error ("unable to create figure_manager object!");
 
         retval = false;
       }
--- a/libinterp/dldfcn/__init_gnuplot__.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/__init_gnuplot__.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/__magick_read__.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
@@ -686,7 +691,6 @@
   catch (Magick::Exception& e)
     {
       error ("Magick++ exception: %s", e.what ());
-      error_state = 1;
     }
 }
 
@@ -711,7 +715,7 @@
 
       if (QuantumDepth < 32)
         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;
@@ -753,8 +757,6 @@
 
   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 ();
@@ -776,7 +778,7 @@
         }
       // 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)--;
@@ -798,7 +800,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 ()
@@ -1377,7 +1379,6 @@
   catch (Magick::Exception& e)
     {
       error ("Magick++ exception: %s", e.what ());
-      error_state = 1;
     }
 }
 
@@ -1511,8 +1512,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 +1546,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;
@@ -1811,8 +1826,7 @@
 
   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 ();
 
--- a/libinterp/dldfcn/__osmesa_print__.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/__osmesa_print__.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -182,41 +182,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/__voronoi__.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -87,7 +87,7 @@
 {
   octave_value_list retval;
 
-  std::string caller = args(0).string_value ();
+  std::string caller = args(0).string_value ("__voronoi__: CALLER must be a string");
 
 #if defined (HAVE_QHULL)
 
--- a/libinterp/dldfcn/amd.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/amd.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -133,67 +133,66 @@
       if (!error_state && n_row != n_col)
         error ("amd: matrix S must be square");
 
-      if (!error_state)
+      OCTAVE_LOCAL_BUFFER (double, Control, AMD_CONTROL);
+      AMD_NAME (_defaults) (Control) ;
+      if (nargin > 1)
         {
-          OCTAVE_LOCAL_BUFFER (double, Control, AMD_CONTROL);
-          AMD_NAME (_defaults) (Control) ;
-          if (nargin > 1)
-            {
-              octave_scalar_map arg1 = args(1).scalar_map_value ();
-
-              if (!error_state)
-                {
-                  octave_value tmp;
-
-                  tmp = arg1.getfield ("dense");
-                  if (tmp.is_defined ())
-                    Control[AMD_DENSE] = tmp.double_value ();
-
-                  tmp = arg1.getfield ("aggressive");
-                  if (tmp.is_defined ())
-                    Control[AMD_AGGRESSIVE] = tmp.double_value ();
-                }
-              else
-                error ("amd: OPTS argument must be a scalar structure");
-            }
+          octave_scalar_map arg1 = args(1).scalar_map_value ();
 
           if (!error_state)
             {
-              OCTAVE_LOCAL_BUFFER (octave_idx_type, P, n_col);
-              Matrix xinfo (AMD_INFO, 1);
-              double *Info = xinfo.fortran_vec ();
+              octave_value tmp;
+
+              tmp = arg1.getfield ("dense");
+              if (tmp.is_defined ())
+                Control[AMD_DENSE] = 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);
+              tmp = arg1.getfield ("aggressive");
+              if (tmp.is_defined ())
+                Control[AMD_AGGRESSIVE] = tmp.double_value ();
+            }
+          else
+            error ("amd: OPTS argument must be a scalar structure");
+        }
 
-              octave_idx_type result = AMD_NAME (_order) (n_col, cidx, ridx, P,
-                                                          Control, Info);
+      if (!error_state)
+        {
+          OCTAVE_LOCAL_BUFFER (octave_idx_type, P, n_col);
+          Matrix xinfo (AMD_INFO, 1);
+          double *Info = xinfo.fortran_vec ();
 
-              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;
+          // 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);
 
-                    Matrix Pout (1, n_col);
-                    for (octave_idx_type i = 0; i < n_col; i++)
-                      Pout.xelem (i) = P[i] + 1;
+          switch (result)
+            {
+            case AMD_OUT_OF_MEMORY:
+              error ("amd: out of memory");
+              break;
+
+            case AMD_INVALID:
+              error ("amd: matrix S is corrupted");
+              break;
 
-                    retval(0) = Pout;
-                  }
-                }
+            default:
+              {
+                if (nargout > 1)
+                  retval(1) = xinfo;
+
+                Matrix Pout (1, n_col);
+                for (octave_idx_type i = 0; i < n_col; i++)
+                  Pout.xelem (i) = P[i] + 1;
+
+                retval(0) = Pout;
+              }
             }
         }
     }
--- a/libinterp/dldfcn/audiodevinfo.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/audiodevinfo.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -570,7 +570,7 @@
   octave_value_list retval = feval (player->octave_callback_function,
                                     ovl (static_cast<double> (frames)), 1);
 
-  if (error_state || retval.length () < 2)
+  if (retval.length () < 2)
     {
       error ("audio player callback function failed");
       return paAbort;
@@ -579,8 +579,8 @@
   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)
+  if (frames - sound.rows () != 0 || sound.columns () < 1
+      || sound.columns () > 2)
     {
       error ("audio player callback function failed");
       return paAbort;
@@ -1086,7 +1086,7 @@
 unsigned int
 audioplayer::get_total_samples (void)
 {
-  return left.length ();
+  return left.numel ();
 }
 
 void
@@ -1104,7 +1104,7 @@
 void
 audioplayer::reset_end_sample (void)
 {
-  set_end_sample (left.length ());
+  set_end_sample (left.numel ());
 }
 
 void
--- a/libinterp/dldfcn/audioread.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/audioread.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -84,9 +84,6 @@
 
   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);
@@ -112,10 +109,7 @@
     {
       RowVector range = args(1).row_vector_value ();
 
-      if (error_state)
-        return retval;
-
-      if (range.nelem () != 2)
+      if (range.numel () != 2)
         {
           error ("audioread: invalid specification for range of frames");
           return retval;
@@ -159,9 +153,6 @@
       else
         type = args(1).string_value ();
 
-      if (error_state)
-        return retval;
-
       if (type == "native")
         {
           switch (info.format & SF_FORMAT_SUBMASK)
@@ -301,14 +292,8 @@
 
   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 +311,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)
@@ -498,9 +480,6 @@
 
   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);
--- a/libinterp/dldfcn/ccolamd.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/ccolamd.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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
@@ -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);
@@ -511,7 +511,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
--- a/libinterp/dldfcn/chol.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/chol.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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 (),
@@ -153,222 +160,174 @@
     }
 
   int n = 1;
-  while (n < nargin && ! error_state)
+  while (n < nargin)
     {
-      std::string tmp = args(n++).string_value ();
+      std::string tmp = args(n++).string_value ("chol: expecting trailing string arguments");
 
-      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.compare ("vector") == 0)
+        vecout = true;
+      else if (tmp.compare ("lower") == 0)
+        LLt = true;
+      else if (tmp.compare ("upper") == 0)
+        LLt = false;
       else
-        error ("chol: expecting trailing string arguments");
+        error ("chol: unexpected second or third input");
     }
 
-  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 ();
-
-              if (! error_state)
-                {
-                  octave_idx_type info;
-
-                  FloatCHOL fact;
-                  if (LLt)
-                    fact = FloatCHOL (m.transpose (), info);
-                  else
-                    fact = FloatCHOL (m, info);
+          FloatMatrix m = arg.float_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 ())
-            {
-              FloatComplexMatrix m = arg.float_complex_matrix_value ();
+          octave_idx_type info;
+
+          FloatCHOL fact;
+          fact = FloatCHOL (m, info, LLt != true);
 
-              if (! error_state)
-                {
-                  octave_idx_type info;
-
-                  FloatComplexCHOL fact;
-                  if (LLt)
-                    fact = FloatComplexCHOL (m.transpose (), info);
-                  else
-                    fact = FloatComplexCHOL (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 ())
+        {
+          FloatComplexMatrix m = arg.float_complex_matrix_value ();
+
+          octave_idx_type info;
+
+          FloatComplexCHOL fact;
+          if (LLt)
+            fact = FloatComplexCHOL (m.transpose (), info);
+          else
+            fact = FloatComplexCHOL (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");
         }
       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 +345,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 <expecting trailing string arguments> chol (1, 2)
+%!error <unexpected second or third input> chol (1, "foobar")
 */
 
 DEFUN_DLD (cholinv, args, ,
@@ -420,29 +380,23 @@
                 {
                   SparseMatrix m = arg.sparse_matrix_value ();
 
-                  if (! error_state)
-                    {
-                      SparseCHOL chol (m, info);
+                  SparseCHOL chol (m, info);
 
-                      if (info == 0)
-                        retval = chol.inverse ();
-                      else
-                        error ("cholinv: A must be positive definite");
-                    }
+                  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);
+                  SparseComplexCHOL chol (m, info);
 
-                      if (info == 0)
-                        retval = chol.inverse ();
-                      else
-                        error ("cholinv: A must be positive definite");
-                    }
+                  if (info == 0)
+                    retval = chol.inverse ();
+                  else
+                    error ("cholinv: A must be positive definite");
                 }
               else
                 gripe_wrong_type_arg ("cholinv", arg);
@@ -453,29 +407,23 @@
                 {
                   FloatMatrix m = arg.float_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");
-                    }
+                  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;
+                  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);
@@ -486,29 +434,23 @@
                 {
                   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");
-                    }
+                  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");
-                    }
+                  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);
@@ -569,15 +511,13 @@
                 {
                   SparseMatrix r = arg.sparse_matrix_value ();
 
-                  if (! error_state)
-                    retval = chol2inv (r);
+                  retval = chol2inv (r);
                 }
               else if (arg.is_complex_type ())
                 {
                   SparseComplexMatrix r = arg.sparse_complex_matrix_value ();
 
-                  if (! error_state)
-                    retval = chol2inv (r);
+                  retval = chol2inv (r);
                 }
               else
                 gripe_wrong_type_arg ("chol2inv", arg);
@@ -588,15 +528,13 @@
                 {
                   FloatMatrix r = arg.float_matrix_value ();
 
-                  if (! error_state)
-                    retval = chol2inv (r);
+                  retval = chol2inv (r);
                 }
               else if (arg.is_complex_type ())
                 {
                   FloatComplexMatrix r = arg.float_complex_matrix_value ();
 
-                  if (! error_state)
-                    retval = chol2inv (r);
+                  retval = chol2inv (r);
                 }
               else
                 gripe_wrong_type_arg ("chol2inv", arg);
@@ -608,15 +546,13 @@
                 {
                   Matrix r = arg.matrix_value ();
 
-                  if (! error_state)
-                    retval = chol2inv (r);
+                  retval = chol2inv (r);
                 }
               else if (arg.is_complex_type ())
                 {
                   ComplexMatrix r = arg.complex_matrix_value ();
 
-                  if (! error_state)
-                    retval = chol2inv (r);
+                  retval = chol2inv (r);
                 }
               else
                 gripe_wrong_type_arg ("chol2inv", arg);
--- a/libinterp/dldfcn/colamd.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/colamd.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -297,7 +297,7 @@
       if (nargin == 2)
         {
           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[COLAMD_DENSE_ROW] = User_knobs(0);
@@ -534,7 +534,7 @@
       if (nargin == 2)
         {
           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[COLAMD_DENSE_ROW] = User_knobs(COLAMD_DENSE_ROW);
@@ -705,17 +705,9 @@
 
       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;
-            }
+          std::string str = args(1).string_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)
--- a/libinterp/dldfcn/config-module.awk	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/config-module.awk	Sat Oct 10 16:52:59 2015 -0700
@@ -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)\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/dmperm.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/dmperm.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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);
+      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
-        {
+        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);
+      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);
+      //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(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
--- a/libinterp/dldfcn/fftw.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/fftw.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -143,197 +143,183 @@
     }
 
 #if defined (HAVE_FFTW)
-  if (args(0).is_string ())
+  std::string arg0 = args(0).string_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).string_value ("fftw: planner expects a string value as METHOD");
 
-      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).string_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).string_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/symrcm.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/dldfcn/symrcm.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -469,9 +469,6 @@
       ridx = Ac.xridx ();
     }
 
-  if (error_state)
-    return retval;
-
   octave_idx_type nr = arg.rows ();
   octave_idx_type nc = arg.columns ();
 
--- a/libinterp/link-deps.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/link-deps.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -1,5 +1,3 @@
-include $(top_srcdir)/liboctave/link-deps.mk
-
 if AMCOND_ENABLE_DYNAMIC_LINKING
   LIBOCTINTERP_LINK_DEPS =
 else
--- a/libinterp/mkdefs	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/mkdefs	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/mkops	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,402 @@
+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)
+
+## 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/octave-value/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-base-diag.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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
@@ -153,21 +165,32 @@
                 && jdx(0).is_scalar_type () && jdx(1).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
                   {
-                    matrix.dgelem (i0(0)) = val;
-                    retval = this;
-                    this->count++;
-                    // invalidate cache
-                    dense_cache = octave_value ();
+                    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-int.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-base-int.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-mat.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-base-mat.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -36,7 +36,7 @@
 #include "ov-base-mat.h"
 #include "ov-base-scalar.h"
 #include "pr-output.h"
-
+ 
 template <class MT>
 octave_value
 octave_base_matrix<MT>::subsref (const std::string& type,
@@ -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 (index_exception& e)
+    {
+      gripe_invalid_index (e.idx(), n_idx, k+1);
     }
 
   // Clear cache.
@@ -288,86 +292,85 @@
 
   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.
   clear_cached_info ();
--- a/libinterp/octave-value/ov-base-sparse.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-base-sparse.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-base-sparse.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-base.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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 ();
 }
 
@@ -537,6 +537,33 @@
   return retval;
 }
 
+Cell
+octave_base_value::cell_value (const char *fmt, va_list args) const
+{
+  // Note that this method does not need to be particularly efficient
+  // since it is already an error to end up here.
+
+  // FIXME: do we want both the wrong-type-argument error and any custom
+  // error message, or just the custom error message, or should that
+  // behavior be optional in some way?
+
+  try
+    {
+      std::string tn = type_name ();
+
+      error ("wrong type argument '%s'\n", tn.c_str ());
+    }
+  catch (const octave_execution_exception&)
+    {
+      if (fmt)
+        verror (fmt, args);
+
+      throw;
+    }
+
+  return Cell ();
+}
+
 Matrix
 octave_base_value::matrix_value (bool) const
 {
@@ -658,8 +685,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 +920,7 @@
 
   octave_value tmp = convert_to_str (pad, true);
 
-  if (! error_state)
-    retval = tmp.all_strings ();
+  retval = tmp.all_strings ();
 
   return retval;
 }
@@ -907,12 +932,38 @@
 
   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::string_value (const char *fmt, va_list args) const
+{
+  // Note that this method does not need to be particularly efficient
+  // since it is already an error to end up here.
+
+  // FIXME: do we want both the wrong-type-argument error and any custom
+  // error message, or just the custom error message, or should that
+  // behavior be optional in some way?
+
+  try
+    {
+      std::string tn = type_name ();
+
+      error ("wrong type argument '%s'\n", tn.c_str ());
+    }
+  catch (const octave_execution_exception&)
+    {
+      if (fmt)
+        verror (fmt, args);
+
+      throw;
+    }
+
+  return std::string ();
+}
+
 Array<std::string>
 octave_base_value::cellstr_value (void) const
 {
@@ -1350,7 +1401,7 @@
     {
       f (*this, idx.front (), rhs.get_rep ());
 
-      done = (! error_state);
+      done = true;
     }
 
   if (done)
@@ -1378,7 +1429,7 @@
 
                   retval = val.subsasgn (type, idx, rhs);
 
-                  done = (! error_state);
+                  done = true;
                 }
               else
                 gripe_assign_conversion_failed (type_name (),
@@ -1388,7 +1439,7 @@
             gripe_indexed_assignment (type_name (), rhs.type_name ());
         }
 
-      if (! (done || error_state))
+      if (! done)
         {
           octave_value tmp_rhs;
 
@@ -1450,7 +1501,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-base.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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; }
 
@@ -480,6 +481,8 @@
 
   virtual Cell cell_value (void) const;
 
+  virtual Cell cell_value (const char *fmt, va_list args) const;
+
   virtual Matrix matrix_value (bool = false) const;
 
   virtual FloatMatrix float_matrix_value (bool = false) const;
@@ -563,6 +566,8 @@
 
   virtual std::string string_value (bool force = false) const;
 
+  virtual std::string string_value (const char *fmt, va_list args) const;
+
   virtual Array<std::string> cellstr_value (void) const;
 
   virtual Range range_value (void) const;
--- a/libinterp/octave-value/ov-bool-mat.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-bool-mat.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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);
 
--- a/libinterp/octave-value/ov-bool-sparse.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-bool-sparse.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-bool.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-builtin.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-builtin.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-cell.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-cell.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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"
@@ -152,15 +152,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 +201,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 +274,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 +290,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 +336,90 @@
         }
     }
 
-  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;
-
-        case '{':
+        if (! error_state)
           {
-            octave_value_list idxf = idx.front ();
+            count++;
+            retval = octave_value (this);
+          }
+        else
+          gripe_failed_assignment ();
+      }
+      break;
 
-            if (t_rhs.is_cs_list ())
-              {
-                Cell tmp_cell = Cell (t_rhs.list_value ());
+    case '{':
+      {
+        octave_value_list idxf = idx.front ();
 
-                // Inquire the proper shape of the RHS.
+        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 ();
+            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;
-
-        case '.':
+        if (! error_state)
           {
-            if (is_empty ())
-              {
-                // 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);
+            count++;
+            retval = octave_value (this);
+          }
+        else
+          gripe_failed_assignment ();
+      }
+      break;
 
-                return tmp.subsasgn (type, idx, rhs);
-              }
-            else
-              {
-                std::string nm = type_name ();
-                error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
-              }
+    case '.':
+      {
+        if (is_empty ())
+          {
+            // 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);
+
+            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;
@@ -614,10 +598,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 +619,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 +748,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 +758,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 +767,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 +780,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 +830,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 +879,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)
@@ -1341,15 +1322,11 @@
       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;
 }
@@ -1470,7 +1447,7 @@
           // except if the struct is a column vector.
 
           dim_vector result_dv;
-          if (m_dv (m_dv.length () - 1) == 1)
+          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.
--- a/libinterp/octave-value/ov-cell.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-cell.h	Sat Oct 10 16:52:59 2015 -0700
@@ -135,6 +135,8 @@
 
   Cell cell_value (void) const { return matrix; }
 
+  Cell cell_value (const char *, va_list) const { return matrix; }
+
   octave_value_list list_value (void) const;
 
   octave_value convert_to_str_internal (bool pad, bool, char type) const
--- a/libinterp/octave-value/ov-class.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-class.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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 *
@@ -402,18 +401,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 +423,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 +453,6 @@
 
           args(1) = make_idx_args (type, idx, "subsref");
 
-          if (error_state)
-            return octave_value_list ();
-
           count++;
           args(0) = octave_value (this);
 
@@ -508,7 +501,7 @@
 {
   octave_value retval;
 
-  if (val.length () == 1)
+  if (val.numel () == 1)
     {
       retval = val(0);
 
@@ -569,10 +562,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:
@@ -628,6 +617,7 @@
       if (obvp)
         {
           obvp->subsasgn (type, idx, rhs);
+
           if (! error_state)
             {
               count++;
@@ -682,20 +672,17 @@
                         u = numeric_conv (map_elt, type.substr (2));
                       }
 
-                    if (! error_state)
-                      {
-                        std::list<octave_value_list> next_idx (idx);
+                    std::list<octave_value_list> next_idx (idx);
 
-                        // We handled two index elements, so subsasgn to
-                        // needs to skip both of them.
+                    // We handled two index elements, so subsasgn to
+                    // needs to skip both of them.
 
-                        next_idx.erase (next_idx.begin ());
-                        next_idx.erase (next_idx.begin ());
+                    next_idx.erase (next_idx.begin ());
+                    next_idx.erase (next_idx.begin ());
 
-                        u.make_unique ();
+                    u.make_unique ();
 
-                        t_rhs = u.subsasgn (type.substr (2), next_idx, rhs);
-                      }
+                    t_rhs = u.subsasgn (type.substr (2), next_idx, rhs);
                   }
                 else
                   gripe_invalid_index_for_assignment ();
@@ -728,27 +715,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;
 
@@ -899,18 +882,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 +1038,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 +1152,21 @@
 
           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&)
+            {
+              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 +1250,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 +1263,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 +1296,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.cell_value ("load: internal error loading class elements") : Cell (t2);
 
                   m.assign (nm, tcell);
                 }
@@ -1342,10 +1322,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 +1367,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 +1438,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.cell_value ("load: internal error loading class elements") : Cell (t2);
 
           m.assign (nm, tcell);
         }
@@ -1486,10 +1455,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 +1527,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 +1672,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.cell_value ("load: internal error loading class elements") : Cell (t2);
 
       m.assign (dsub.name, tcell);
 
@@ -1732,13 +1690,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;
         }
     }
 
@@ -1885,55 +1838,47 @@
       // 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).string_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).map_value ();
 
-                          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 (! 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 (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 ());
-                        }
+                      retval
+                        = octave_value (new octave_class (m, id, parents));
                     }
-                  else
-                    error ("class: expecting structure S as first argument");
+
+                  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: '%s' is invalid as a class name in this context",
-                       id.c_str ());
+                error ("class: expecting structure S as first argument");
             }
           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;
@@ -1985,23 +1930,24 @@
       return retval;
     }
 
-  octave_value obj = args(0); // not const because of find_parent_class ()
-  const Array<std::string> cls = args(1).cellstr_value ();
+  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).cellstr_value ();
   if (error_state)
     {
       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++)
+  boolNDArray matches (clsnames.dims (), false);
+  for (octave_idx_type idx = 0; idx < clsnames.numel (); 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);
@@ -2128,18 +2074,12 @@
       else
         error ("ismethod: expecting object or class name as first argument");
 
-      if (! error_state)
-        {
-          std::string method = args(1).string_value ();
+      std::string method = args(1).string_value ();
 
-          if (! error_state)
-            {
-              if (load_path::find_method (class_name, method) != std::string ())
-                retval = true;
-              else
-                retval = false;
-            }
-        }
+      if (load_path::find_method (class_name, method) != std::string ())
+        retval = true;
+      else
+        retval = false;
     }
   else
     print_usage ();
@@ -2169,11 +2109,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 +2164,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).string_value ("superiorto: expecting argument to be class name");
 
       // User defined classes always have higher precedence
       // than built-in classes
@@ -2273,12 +2205,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).string_value ("inferiorto: expecting argument to be class name");
 
       if (is_built_in_class (sup_class))
         {
--- a/libinterp/octave-value/ov-class.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-class.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-classdef.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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 ();
@@ -235,13 +231,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 +282,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 +325,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 +383,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 +528,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).string_value ("fromName: invalid class name, expected a string value");
+
+      retval(0) = to_ov (lookup_class (name));
     }
   else
     error ("fromName: invalid number of parameters");
@@ -562,29 +549,24 @@
 
       if (! error_state)
         {
-          std::string meth_name = args(1).string_value ();
-
-          if (! error_state)
+          std::string meth_name = args(1).string_value ("fevalStatic: invalid method name, expected a string value");
+
+          cdef_method meth = cls.find_method (meth_name);
+
+          if (meth.ok ())
             {
-              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 ());
-                }
+              if (meth.is_static ())
+                retval = meth.execute (args.splice (0, 2), nargout,
+                                       true, "fevalStatic");
               else
-                error ("fevalStatic: method not found: %s",
+                error ("fevalStatic: method `%s' is not static",
                        meth_name.c_str ());
             }
           else
-            error ("fevalStatic: invalid method name, expected a string value");
+            error ("fevalStatic: method not found: %s", meth_name.c_str ());
         }
-      error ("fevalStatic: invalid object, expected a meta.class object");
+      else
+        error ("fevalStatic: invalid object, expected a meta.class object");
     }
   else
     error ("fevalStatic: invalid arguments");
@@ -604,26 +586,21 @@
 
       if (! error_state)
         {
-          std::string prop_name = args(1).string_value ();
-
-          if (! error_state)
+          std::string prop_name = args(1).string_value ("getConstant: invalid property name, expected a string value");
+
+          cdef_property prop = cls.find_property (prop_name);
+
+          if (prop.ok ())
             {
-              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 ());
-                }
+              if (prop.is_constant ())
+                retval(0) = prop.get_value (true, "getConstant");
               else
-                error ("getConstant: property not found: %s",
+                error ("getConstant: property `%s' is not constant",
                        prop_name.c_str ());
             }
           else
-            error ("getConstant: invalid property name, expected a string value");
+            error ("getConstant: property not found: %s",
+                   prop_name.c_str ());
         }
       else
         error ("getConstant: invalid object, expected a meta.class object");
@@ -740,8 +717,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 +727,6 @@
         }
     }
 
-  if (error_state)
-    return cdef_class ();
-
   if (! name.empty ())
     cdef_manager::register_class (cls);
 
@@ -910,13 +884,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 +897,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 +918,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 +943,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 +973,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 +1160,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;
   }
@@ -1241,66 +1196,63 @@
 
         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");
+      error ("superclass calls can only occur in methods or constructors");
 
     return retval;
   }
@@ -1363,27 +1315,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 +1393,7 @@
               }
           }
 
-        if (skip == 0 && ! error_state)
+        if (skip == 0)
           {
             cdef_property prop = cls.find_property (name);
 
@@ -1476,17 +1418,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 +1464,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 +1522,7 @@
 
         octave_value tmp = new_obj.subsasgn (type, idx, rhs);
 
-        if (! error_state)
-          retval = tmp;
+        retval = tmp;
       }
       break;
 
@@ -1602,13 +1541,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 +1561,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 +1626,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 +1659,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 +1713,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 +1810,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 +1856,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 +1916,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 +1935,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 +2069,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 +2107,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 +2157,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 +2182,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 +2206,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 +2234,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 +2257,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 +2275,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 +2295,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 +2315,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 +2330,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 +2366,7 @@
     {
       cdef_class cls = lookup_class (super_classes(i));
 
-      if (!error_state)
-        cls.delete_object (obj);
+      cls.delete_object (obj);
     }
 }
 
@@ -2509,65 +2400,56 @@
 
       if (idx.front ().length () == 1)
         {
-          std::string nm = idx.front ()(0).string_value ();
-
-          if (! error_state)
+          std::string nm = idx.front ()(0).string_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 +2468,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 +2497,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 +2517,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 +2535,7 @@
 {
   cdef_object obj = construct_object (args);
 
-  if (! error_state && obj.ok ())
+  if (obj.ok ())
     return to_ov (obj);
 
   return octave_value ();
@@ -2740,13 +2606,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 +2675,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 +2685,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 +2996,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 +3016,7 @@
 
       args = execute_ov (get_fcn, args, 1);
 
-      if (! error_state)
-        retval = args(0);
+      retval = args(0);
     }
 
   return retval;
@@ -3209,8 +3062,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 +3081,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 +3101,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 +3112,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 +3161,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 +3184,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 +3213,7 @@
     {
       check_method ();
 
-      if (! error_state && function.is_defined ())
+      if (function.is_defined ())
         {
           octave_value_list new_args;
 
@@ -3402,10 +3247,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 +3268,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 +3287,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).string_value ("fromName: invalid package name, expected a string value");
+
+      retval(0) = to_ov (lookup_package (name));
     }
   else
     error ("fromName: invalid number of parameters");
@@ -3608,57 +3444,49 @@
     case '.':
       if (idx.front ().length () == 1)
         {
-          std::string nm = idx.front ()(0).string_value ();
-
-          if (! error_state)
-            {
+          std::string nm = idx.front ()(0).string_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");
+          else if (! error_state)
+            error ("member `%s' in package `%s' does not exist",
+                   nm.c_str (), get_name ().c_str ());
         }
       else
         error ("invalid meta.package indexing");
@@ -4001,12 +3829,9 @@
 
   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");
+      std::string cname = args(0).string_value ("invalid package name, expected a string value");
+
+      retval = to_ov (lookup_package (cname));
     }
   else
     print_usage ();
@@ -4039,12 +3864,9 @@
 
   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");
+      std::string cls = args(0).string_value ("invalid class name, expected a string value");
+
+      retval = to_ov (lookup_class (cls));
     }
   else
     print_usage ();
--- a/libinterp/octave-value/ov-classdef.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-classdef.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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-complex.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-complex.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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<Complex>;
@@ -301,7 +301,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;
@@ -480,3 +481,39 @@
       return octave_base_value::map (umap);
     }
 }
+
+class complex_index_exception : public index_exception
+{
+public:
+
+  complex_index_exception (const char *value) : index_exception (value) { }
+
+  ~complex_index_exception (void) { }
+
+  const char* explain (void) const
+  {
+    return "subscripts must be real (forgot to initialize i or j?)";
+  }
+
+  // ID of error to throw.
+  const char* id (void) const
+  {
+    return error_id_invalid_index;
+  }
+};
+
+// Complain if a complex value is used as a subscript
+
+void
+gripe_complex_index (Complex idx)
+{
+  // FIXME: don't use a fixed size buffer!
+
+  char buf [100];
+
+  sprintf (buf, "%g%+gi", std::real(idx), std::imag(idx));
+
+  complex_index_exception e (buf);
+
+  throw e;
+}
--- a/libinterp/octave-value/ov-complex.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-complex.h	Sat Oct 10 16:52:59 2015 -0700
@@ -43,6 +43,9 @@
 
 class tree_walker;
 
+extern void OCTAVE_API
+gripe_complex_index (Complex idx);
+
 // Complex scalar values.
 
 class
@@ -81,8 +84,7 @@
   // 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?)");
+    gripe_complex_index (scalar);
     return idx_vector ();
   }
 
--- a/libinterp/octave-value/ov-cx-diag.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-cx-diag.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-mat.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-cx-mat.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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"
 
@@ -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-sparse.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-cx-sparse.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-fcn-handle.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-fcn-handle.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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);
             }
         }
 
@@ -1854,10 +1851,6 @@
 \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")
 {
@@ -1866,13 +1859,19 @@
 
   if (nargin == 1 || nargin == 2)
     {
-      if (args(0).is_string ())
+      std::string nm = args(0).string_value ("str2func: FCN_NAME must be a string");
+
+      if (nm[0] == '@')
         {
-          std::string nm = args(0).string_value ();
-          retval = make_fcn_handle (nm, nargin != 2);
+          int parse_status;
+          octave_value anon_fcn_handle =
+            eval_string (nm, true, parse_status);
+
+          if (parse_status == 0)
+            retval = anon_fcn_handle;
         }
       else
-        error ("str2func: FCN_NAME must be a string");
+        retval = make_fcn_handle (nm, nargin != 2);
     }
   else
     print_usage ();
@@ -1881,6 +1880,22 @@
 }
 
 /*
+%!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;
@@ -2061,8 +2076,18 @@
                           unwind_protect frame;
                           interpreter_try (frame);
 
-                          root_val = make_fcn_handle (head_name);
-                          if (error_state)
+                          bool execution_error = false;
+
+                          try
+                            {
+                              root_val = make_fcn_handle (head_name);
+                            }
+                          catch (const octave_execution_exception&)
+                            {
+                              execution_error = true;
+                            }
+
+                          if (execution_error)
                             bad = true;
                         }
                     }
--- a/libinterp/octave-value/ov-fcn-inline.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-fcn-inline.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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 << ", ";
@@ -681,162 +681,150 @@
 
   if (nargin > 0)
     {
-      if (args(0).is_string ())
+      std::string fun = args(0).string_value ("inline: STR argument must be a string");
+
+      string_vector fargs;
+
+      if (nargin == 1)
         {
-          std::string fun = args(0).string_value ();
-          string_vector fargs;
+          bool is_arg = false;
+          bool in_string = false;
+          std::string tmp_arg;
+          size_t i = 0;
+          size_t fun_length = fun.length ();
 
-          if (nargin == 1)
+          while (i < fun_length)
             {
-              bool is_arg = false;
-              bool in_string = false;
-              std::string tmp_arg;
-              size_t i = 0;
-              size_t fun_length = fun.length ();
+              bool terminate_arg = false;
+              char c = fun[i++];
 
-              while (i < fun_length)
+              if (in_string)
                 {
-                  bool terminate_arg = false;
-                  char c = fun[i++];
+                  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 (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);
+                    // Do we have a variable or a function?
+                    if (c != '(')
+                      terminate_arg = true;
                     else
                       {
-                        // Before we do anything remove trailing whitespaces.
-                        while (i < fun_length && isspace (c))
-                          c = fun[i++];
-
-                        // Do we have a variable or a function?
-                        if (c != '(')
-                          terminate_arg = true;
-                        else
-                          {
-                            tmp_arg = std::string ();
-                            is_arg = false;
-                          }
+                        tmp_arg = std::string ();
+                        is_arg = false;
                       }
-                  else if (! is_arg)
+                  }
+              else if (! is_arg)
+                {
+                  if (c == 'e' || c == 'E')
                     {
-                      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);
+                      // possible number in exponent form, not arg
+                      if (isdigit (fun[i])
+                          || fun[i] == '-' || fun[i] == '+')
+                        continue;
                     }
-                  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);
-
-                      tmp_arg = std::string ();
-                      is_arg = false;
-                    }
+                  is_arg = true;
+                  tmp_arg.append (1, c);
+                }
+              else
+                {
+                  tmp_arg.append (1, c);
                 }
 
-              // Sort the arguments into ascii order.
-              fargs.sort ();
+              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 (fargs.length () == 0)
-                fargs.append (std::string ("x"));
+                  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;
+                }
             }
-          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 ();
+          // Sort the arguments into ascii order.
+          fargs.sort ();
 
-              if (! error_state)
-                {
-                  if (n >= 0)
-                    {
-                      fargs.resize (n+1);
+          if (fargs.numel () == 0)
+            fargs.append (std::string ("x"));
 
-                      fargs(0) = "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 ();
 
-                      for (int i = 1; i < n+1; i++)
-                        {
-                          std::ostringstream buf;
-                          buf << "P" << i;
-                          fargs(i) = buf.str ();
-                        }
-                    }
-                  else
+          if (! error_state)
+            {
+              if (n >= 0)
+                {
+                  fargs.resize (n+1);
+
+                  fargs(0) = "x";
+
+                  for (int i = 1; i < n+1; i++)
                     {
-                      error ("inline: N must be a positive integer or zero");
-                      return retval;
+                      std::ostringstream buf;
+                      buf << "P" << i;
+                      fargs(i) = buf.str ();
                     }
                 }
               else
                 {
-                  error ("inline: N must be an integer");
+                  error ("inline: N must be a positive integer or zero");
                   return retval;
                 }
             }
           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;
-                    }
-                }
+              error ("inline: N must be an integer");
+              return retval;
             }
-
-          retval = octave_value (new octave_fcn_inline (fun, fargs));
         }
       else
-        error ("inline: STR argument must be a string");
+        {
+          fargs.resize (nargin - 1);
+
+          for (int i = 1; i < nargin; i++)
+            {
+              std::string s = args(i).string_value ("inline: expecting string arguments");
+              fargs(i-1) = s;
+            }
+        }
+
+      retval = octave_value (new octave_fcn_inline (fun, fargs));
     }
   else
     print_usage ();
@@ -920,9 +908,9 @@
         {
           string_vector t1 = fn->fcn_arg_names ();
 
-          Cell t2 (dim_vector (t1.length (), 1));
+          Cell t2 (dim_vector (t1.numel (), 1));
 
-          for (int i = 0; i < t1.length (); i++)
+          for (int i = 0; i < t1.numel (); i++)
             t2(i) = t1(i);
 
           retval = t2;
@@ -990,38 +978,35 @@
             error ("vectorize: FUN must be a string or inline function");
         }
 
-      if (! error_state)
+      std::string new_func;
+      size_t i = 0;
+
+      while (i < old_func.length ())
         {
-          std::string new_func;
-          size_t i = 0;
+          std::string t1 = old_func.substr (i, 1);
 
-          while (i < old_func.length ())
+          if (t1 == "*" || t1 == "/" || t1 == "\\" || t1 == "^")
             {
-              std::string t1 = old_func.substr (i, 1);
-
-              if (t1 == "*" || t1 == "/" || t1 == "\\" || t1 == "^")
-                {
-                  if (i && old_func.substr (i-1, 1) != ".")
-                    new_func.append (".");
+              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++;
-                    }
+              // 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++;
             }
+          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
+        retval = octave_value (new octave_fcn_inline
+                               (new_func, old->fcn_arg_names ()));
     }
   else
     print_usage ();
--- a/libinterp/octave-value/ov-float.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-float.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-flt-complex.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-flt-complex.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-cx-diag.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-flt-cx-diag.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-mat.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-flt-cx-mat.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-re-diag.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-flt-re-diag.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-mat.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-flt-re-mat.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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:
--- a/libinterp/octave-value/ov-int16.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-int16.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-int32.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-int64.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-int8.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-java.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-java.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -350,6 +350,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 +375,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 +827,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 +860,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 +885,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 +974,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 +1060,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 +1097,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 +1108,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 +1117,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 +1129,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 +1138,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 +1217,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 +1338,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 +1363,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 +1384,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 +1395,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 +1405,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 +1415,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 +1552,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 +1580,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 +1728,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 +1739,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 +1767,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 +1816,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 +2085,7 @@
 
   initialize_java ();
 
-  if (! error_state)
-    retval = 1;
+  retval = 1;
 
   return retval;
 #else
@@ -2109,27 +2137,24 @@
 
   initialize_java ();
 
-  if (! error_state)
+  JNIEnv *current_env = octave_java::thread_jni_env ();
+
+  if (args.length () > 0)
     {
-      JNIEnv *current_env = octave_java::thread_jni_env ();
-
-      if (args.length () > 0)
+      if (args(0).is_string ())
         {
-          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");
+          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
-        print_usage ();
+        error ("javaObject: CLASSNAME must be a string");
     }
+  else
+    print_usage ();
 
   return retval;
 #else
@@ -2177,39 +2202,36 @@
 
   initialize_java ();
 
-  if (! error_state)
+  JNIEnv *current_env = octave_java::thread_jni_env ();
+
+  if (args.length () > 1)
     {
-      JNIEnv *current_env = octave_java::thread_jni_env ();
-
-      if (args.length () > 1)
+      if (args(0).is_string ())
         {
-          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 ())
             {
-              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");
+              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: METHODNAME must be a string");
+            error ("javaMethod: OBJ must be a Java object or a string");
         }
       else
-        print_usage ();
+        error ("javaMethod: METHODNAME must be a string");
     }
+  else
+    print_usage ();
 
   return retval;
 #else
@@ -2252,35 +2274,32 @@
 
   initialize_java ();
 
-  if (! error_state)
+  JNIEnv *current_env = octave_java::thread_jni_env ();
+
+  if (args.length () == 2)
     {
-      JNIEnv *current_env = octave_java::thread_jni_env ();
-
-      if (args.length () == 2)
+      if (args(1).is_string ())
         {
-          if (args(1).is_string ())
+          std::string name = args(1).string_value ();
+
+          if (args(0).is_java ())
             {
-              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");
+              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__: NAME must be a string");
+            error ("__java_get__: OBJ must be a Java object or a string");
         }
       else
-        print_usage ();
+        error ("__java_get__: NAME must be a string");
     }
+  else
+    print_usage ();
 
   return retval;
 #else
@@ -2317,35 +2336,32 @@
 
   initialize_java ();
 
-  if (! error_state)
+  JNIEnv *current_env = octave_java::thread_jni_env ();
+
+  if (args.length () == 3)
     {
-      JNIEnv *current_env = octave_java::thread_jni_env ();
-
-      if (args.length () == 3)
+      if (args(1).is_string ())
         {
-          if (args(1).is_string ())
+          std::string name = args(1).string_value ();
+
+          if (args(0).is_java ())
             {
-              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");
+              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__: NAME must be a string");
+            error ("__java_set__: OBJ must be a Java object or a string");
         }
       else
-        print_usage ();
+        error ("__java_set__: NAME must be a string");
     }
+  else
+    print_usage ();
 
   return retval;
 #else
@@ -2365,23 +2381,20 @@
 
   initialize_java ();
 
-  if (! error_state)
+  JNIEnv *current_env = octave_java::thread_jni_env ();
+
+  if (args.length () == 1)
     {
-      JNIEnv *current_env = octave_java::thread_jni_env ();
-
-      if (args.length () == 1)
+      if (args(0).is_java ())
         {
-          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);
+          octave_java *jobj = TO_JAVA (args(0));
+          retval(0) = box_more (current_env, jobj->to_java (), 0);
         }
       else
-        print_usage ();
+        retval(0) = args(0);
     }
+  else
+    print_usage ();
 
   return retval;
 #else
--- a/libinterp/octave-value/ov-java.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-java.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-lazy-idx.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-mex-fcn.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-mex-fcn.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-oncleanup.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-oncleanup.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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.
       warning ("onCleanup: interrupt occured in cleanup action");
     }
+  catch (const octave_execution_exception&)
+    {
+      // Propagate the error.
+      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;
 }
 
--- a/libinterp/octave-value/ov-oncleanup.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-oncleanup.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-perm.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-range.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-range.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-range.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-re-diag.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-mat.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-re-mat.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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:
--- a/libinterp/octave-value/ov-re-sparse.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-re-sparse.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-scalar.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-scalar.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-str-mat.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-str-mat.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
@@ -242,6 +252,38 @@
   return retval;
 }
 
+std::string
+octave_char_matrix_str::string_value (const char *fmt, va_list args) const
+{
+  std::string retval;
+
+  if (! fmt)
+    return string_value ();
+
+  bool conversion_error = false;
+
+  if (matrix.ndims () == 2)
+    {
+      charMatrix chm (matrix);
+
+      try
+        {
+          retval = chm.row_as_string (0);  // FIXME?
+        }
+      catch (const octave_execution_exception&)
+        {
+          conversion_error = true;
+        }
+    }
+  else
+    conversion_error = true;
+
+  if (conversion_error)
+    verror (fmt, args);
+
+  return retval;
+}
+
 Array<std::string>
 octave_char_matrix_str::cellstr_value (void) const
 {
@@ -292,7 +334,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 +342,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 +469,7 @@
                     }
                 }
 
-              if (! error_state)
-                matrix = chm;
+              matrix = chm;
             }
           else
             {
@@ -442,7 +483,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 +580,9 @@
       char *tmp = m.fortran_vec ();
       is.read (tmp, dv.numel ());
 
-      if (error_state || ! is)
+      if (! is)
         return false;
+
       matrix = m;
     }
   else
@@ -592,7 +634,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 +739,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-str-mat.h	Sat Oct 10 16:52:59 2015 -0700
@@ -129,6 +129,8 @@
 
   std::string string_value (bool force = false) const;
 
+  std::string string_value (const char *fmt, va_list args) const;
+
   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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-struct.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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"
@@ -153,17 +153,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 +173,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 +216,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 +236,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 +318,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
@@ -347,33 +338,28 @@
 
                 // 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 +376,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 +391,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;
 
@@ -464,9 +444,6 @@
 
                 maybe_warn_invalid_field_name (key, "subsasgn");
 
-                if (error_state)
-                  return retval;
-
                 if (! error_state)
                   {
                     if (t_rhs.is_cs_list ())
@@ -572,9 +549,6 @@
 
             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 ());
@@ -679,7 +653,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 +709,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 +725,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 +740,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 +794,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.cell_value ("load: internal error loading struct elements") : Cell (t2);
 
               m.setfield (nm, tcell);
             }
@@ -953,13 +921,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.cell_value ("load: internal error loading struct elements") : Cell (t2);
 
           m.setfield (nm, tcell);
         }
@@ -1056,13 +1018,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.cell_value ("load: internal error loading struct elements") : Cell (t2);
 
       m.setfield (dsub.name, tcell);
 
@@ -1156,9 +1112,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 +1236,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,24 +1252,20 @@
               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)
@@ -1400,7 +1346,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 +1407,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 +1422,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,7 +1450,7 @@
 
               // 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;
@@ -1925,14 +1871,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 +1883,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 +1890,6 @@
         }
       else
         map.setfield (key, Cell (dims, args(i+1)));
-
-      if (error_state)
-        return retval;
     }
 
   return octave_value (map);
@@ -2017,7 +1951,7 @@
 
   string_vector keys = m.fieldnames ();
 
-  if (keys.length () == 0)
+  if (keys.numel () == 0)
     retval = Cell (0, 1);
   else
     retval = Cell (keys);
@@ -2175,12 +2109,7 @@
       if (nargin == 3)
         {
           if (args(2).is_real_scalar ())
-            {
-              dim = nargin == 2 ? 0 : args(2).int_value () - 1;
-
-              if (error_state)
-                return retval;
-            }
+            dim = nargin == 2 ? 0 : args(2).int_value () - 1;
           else
             {
               error ("cell2struct: DIM must be a real scalar");
@@ -2279,28 +2208,24 @@
 
       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++)
         {
-          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
             {
-              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;
-                }
+              error ("rmfield: structure does not contain field %s",
+                     key.c_str ());
+
+              break;
             }
-
-          if (! error_state)
-            retval = m;
         }
+
+      retval = m;
     }
   else
     print_usage ();
--- a/libinterp/octave-value/ov-typeinfo.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-typeinfo.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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)
     {
--- a/libinterp/octave-value/ov-uint16.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-uint16.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-uint32.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-uint64.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-uint8.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-usr-fcn.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov-usr-fcn.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
 
@@ -514,7 +508,7 @@
 
   if (call_depth >= Vmax_recursion_depth)
     {
-      ::error ("max_recursion_depth exceeded");
+      error ("max_recursion_depth exceeded");
       return retval;
     }
 
@@ -536,11 +530,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 +538,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;
         }
     }
@@ -636,9 +622,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 +635,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.cell_value ("expecting varargout to 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 +780,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 ();
@@ -1123,22 +1097,20 @@
           if (args(0).is_scalar_type ())
             {
               double k = args(0).double_value ();
-              if (! error_state)
-                retval = isargout1 (nargout1, ignored, k);
+
+              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));
 
-                  retval = r;
-                }
+              boolNDArray r (ka.dims ());
+              for (octave_idx_type i = 0;
+                   i < ka.numel () && ! error_state;
+                   i++)
+                r(i) = isargout1 (nargout1, ignored, ka(i));
+
+              retval = r;
             }
           else
             gripe_wrong_type_arg ("isargout", args(0));
--- a/libinterp/octave-value/ov.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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++)
@@ -1443,28 +1443,21 @@
         {
           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;
-    }
+  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;
 
   return *this;
 }
@@ -1490,29 +1483,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,7 +1537,7 @@
       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 ();
     }
 
@@ -1568,6 +1550,15 @@
   return rep->cell_value ();
 }
 
+Cell
+octave_value::cell_value (const char *fmt, ...) const
+{
+  va_list args;
+  va_start (args,fmt);
+  return rep->cell_value (fmt, args);
+  va_end (args);
+}
+
 // Define the idx_type_value function here instead of in ov.h to avoid
 // needing definitions for the SIZEOF_X macros in ov.h.
 
@@ -1692,12 +1683,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>
@@ -1743,36 +1731,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 +1801,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 +1833,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 +1877,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,12 +1888,9 @@
 {
   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"));
 }
 
 octave_value
@@ -1993,14 +1960,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 +1975,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 +2094,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 +2193,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 +2203,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 +2240,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;
@@ -2521,16 +2436,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 +2450,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 +2512,7 @@
         {
           make_unique ();
 
-          try
-            {
-              f (*rep);
-            }
-          catch (octave_execution_exception)
-            {
-              gripe_library_execution_error ();
-            }
+          f (*rep);
         }
       else
         {
@@ -2643,14 +2533,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 +2573,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);
     }
@@ -2969,24 +2843,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).string_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 +2865,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 () == ":")
@@ -3066,15 +2933,12 @@
 
       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);
-        }
+      octave_value arg0 = args(0);
+
+      if (type.empty ())
+        retval = arg0;
+      else
+        retval = arg0.subsref (type, idx, nargout);
     }
   else
     print_usage ();
@@ -3124,23 +2988,19 @@
 
       decode_subscripts ("subsasgn", args(1), type, idx);
 
-      if (! error_state)
+      if (type.empty ())
         {
-          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
+        {
+          octave_value arg0 = args(0);
+
+          arg0.make_unique ();
+
+          retval= arg0.subsasgn (type, idx, args(2));
         }
     }
   else
--- a/libinterp/octave-value/ov.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave-value/ov.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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 (); }
@@ -770,6 +770,8 @@
 
   Cell cell_value (void) const;
 
+  Cell cell_value (const char *fmt, ...) const;
+
   Matrix matrix_value (bool frc_str_conv = false) const
   { return rep->matrix_value (frc_str_conv); }
 
@@ -897,6 +899,14 @@
   std::string string_value (bool force = false) const
   { return rep->string_value (force); }
 
+  std::string string_value (const char *fmt, ...) const
+  {
+    va_list args;
+    va_start (args,fmt);
+    return rep->string_value (fmt, args);
+    va_end (args);
+  }
+
   Array<std::string> cellstr_value (void) const
   { return rep->cellstr_value (); }
 
--- a/libinterp/octave.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/octave.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -279,14 +279,14 @@
     {
       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,14 +394,14 @@
     {
       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"
--- a/libinterp/operators/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/operators/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/operators/op-bm-b.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/operators/op-bm-bm.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -120,8 +120,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-int.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/operators/op-int.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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-sbm-b.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/operators/op-sbm-b.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/operators/op-sbm-bm.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/operators/op-str-m.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/operators/op-str-s.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/parse-tree/lex.ll	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/lex.ll	Sat Oct 10 16:52:59 2015 -0700
@@ -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})
@@ -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 ())
@@ -1911,9 +1916,6 @@
 
   string_vector argv = args.make_argv ("iskeyword");
 
-  if (error_state)
-    return retval;
-
   if (argc == 1)
     {
       // Neither set and get are keywords.  See the note in the
@@ -2658,6 +2660,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'));
@@ -2671,28 +2679,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/oct-parse.in.yy	Sat Oct 10 16:52:59 2015 -0700
@@ -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);
 
@@ -2268,23 +2265,20 @@
             {
               octave_value tmp = e->rvalue1 ();
 
-              if (! (error_state || warning_state))
-                {
-                  tree_constant *tc_retval
-                    = new tree_constant (tmp, base->line (), base->column ());
-
-                  std::ostringstream buf;
-
-                  tree_print_code tpc (buf);
-
-                  e->accept (tpc);
-
-                  tc_retval->stash_original_text (buf.str ());
-
-                  delete e;
-
-                  retval = tc_retval;
-                }
+              tree_constant *tc_retval
+                = new tree_constant (tmp, base->line (), base->column ());
+
+              std::ostringstream buf;
+
+              tree_print_code tpc (buf);
+
+              e->accept (tpc);
+
+              tc_retval->stash_original_text (buf.str ());
+
+              delete e;
+
+              retval = tc_retval;
             }
         }
       else
@@ -3799,9 +3793,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);
 
@@ -3812,24 +3803,21 @@
     {
       octave_value tmp = array_list->rvalue1 ();
 
-      if (! (error_state || warning_state))
-        {
-          tree_constant *tc_retval
-            = new tree_constant (tmp, array_list->line (),
-                                 array_list->column ());
-
-          std::ostringstream buf;
-
-          tree_print_code tpc (buf);
-
-          array_list->accept (tpc);
-
-          tc_retval->stash_original_text (buf.str ());
-
-          delete array_list;
-
-          retval = tc_retval;
-        }
+      tree_constant *tc_retval
+        = new tree_constant (tmp, array_list->line (),
+                             array_list->column ());
+
+      std::ostringstream buf;
+
+      tree_print_code tpc (buf);
+
+      array_list->accept (tpc);
+
+      tc_retval->stash_original_text (buf.str ());
+
+      delete array_list;
+
+      retval = tc_retval;
     }
 
   return retval;
@@ -4379,51 +4367,48 @@
     {
       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 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]);
         }
     }
   else
@@ -4499,40 +4484,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 (const octave_execution_exception&)
+    {
+      error ("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;
     }
 }
 
@@ -4565,15 +4548,7 @@
   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).string_value ("mfilename: expecting argument to be a character string");
 
   std::string fname;
 
@@ -4624,22 +4599,14 @@
 
   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");
+      std::string file_name = args(0).string_value ("source: expecting file name as argument");
+
+      std::string context;
+
+      if (nargin == 2)
+        context = args(1).string_value ("source: expecting context to be character string");
+
+      source_file (file_name, context);
     }
   else
     print_usage ();
@@ -4663,9 +4630,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 (const octave_execution_exception&)
+        {
+          error ("feval: function '%s' not found", name.c_str ());
+        }
     }
 
   return retval;
@@ -4710,12 +4682,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 ()
@@ -4816,20 +4785,14 @@
 
   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 ());
-        }
+      const std::string name (args(0).string_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
-        error ("builtin: function name (F) must be a string");
+        error ("builtin: lookup for symbol '%s' failed", name.c_str ());
     }
   else
     print_usage ();
@@ -4880,7 +4843,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 +4854,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 +4885,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.string_value ("eval: expecting std::string argument");
 
   return eval_string (s, silent, parse_status, nargout);
 }
@@ -4999,13 +4955,21 @@
 
       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))
+      bool execution_error = false;
+
+      octave_value_list tmp;
+
+      try
         {
-          error_state = 0;
-
+          tmp = eval_string (args(0), nargout > 0, parse_status, nargout);
+        }
+      catch (const octave_execution_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().
 
@@ -5016,8 +4980,16 @@
           if (nargout > 0)
             retval = tmp;
         }
-      else if (nargout > 0)
-        retval = tmp;
+      else
+        {
+          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 ();
+        }
     }
   else
     print_usage ();
@@ -5077,38 +5049,25 @@
 
   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");
-            }
-        }
+      std::string context = args(0).string_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
-        error ("assignin: CONTEXT must be a string");
+        error ("assignin: CONTEXT must be \"caller\" or \"base\"");
+
+      frame.add_fcn (octave_call_stack::pop);
+
+      std::string nm = args(1).string_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");
     }
   else
     print_usage ();
@@ -5131,55 +5090,64 @@
 
   if (nargin > 1)
     {
-      std::string context = args(0).string_value ();
-
-      if (! error_state)
+      std::string context = args(0).string_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)
         {
-          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 ();
-                }
-            }
+          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&)
+        {
+          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
-        error ("evalin: CONTEXT must be a string");
+        {
+          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 ();
+        }
     }
   else
     print_usage ();
@@ -5220,7 +5188,7 @@
 
   if (nargin == 1 || nargin == 2)
     {
-      std::string file = args(0).string_value ();
+      std::string file = args(0).string_value ("__parse_file__: expecting file name as argument");
 
       std::string full_file = octave_env::make_absolute (file);
 
@@ -5238,20 +5206,15 @@
             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");
+      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
     print_usage ();
--- a/libinterp/parse-tree/pt-arg-list.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-arg-list.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-assign.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-assign.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -77,71 +77,66 @@
 {
   octave_value retval;
 
-  if (error_state)
-    return retval;
-
   if (rhs)
     {
       octave_value rhs_val = rhs->rvalue1 ();
 
-      if (! error_state)
+      if (rhs_val.is_undefined ())
         {
-          if (rhs_val.is_undefined ())
+          error ("value on right hand side of assignment is undefined");
+          return retval;
+        }
+      else
+        {
+          if (rhs_val.is_cs_list ())
             {
-              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 ();
+
+              if (! lst.empty ())
+                rhs_val = lst(0);
+              else
                 {
-                  const octave_value_list lst = rhs_val.list_value ();
+                  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");
-                      return retval;
-                    }
-                }
-
+          try
+            {
               octave_lvalue ult = lhs->lvalue ();
 
               if (ult.numel () != 1)
                 gripe_nonbraced_cs_list_assignment ();
 
-              if (! error_state)
-                {
-                  ult.assign (etype, rhs_val);
+              ult.assign (etype, rhs_val);
 
-                  if (! error_state)
-                    {
-                      if (etype == octave_value::op_asn_eq)
-                        retval = rhs_val;
-                      else
-                        retval = ult.value ();
+              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 ();
 
-                          ult.clear_index ();
-
-                          octave_value lhs_val = ult.value ();
+                  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)
+            {       // problems with range, invalid index type etc.
+              e.set_var (lhs->name ());
+              (*current_liboctave_error_with_id_handler) (e.id(), e.err());
+            }
         }
     }
 
@@ -211,16 +206,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 +224,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 +246,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 +281,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 +299,7 @@
                       k++;
                       continue;
                     }
-                  else if (! error_state)
+                  else
                     {
                       retval_list.push_back (rhs_val(k));
 
@@ -323,10 +333,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 +345,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-binop.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-binop.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-cbinop.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-cbinop.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-cell.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-cell.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -71,7 +71,7 @@
                 continue;  // blank line
               else
                 {
-                  ::error ("number of columns must match");
+                  error ("number of columns must match");
                   return retval;
                 }
             }
--- a/libinterp/parse-tree/pt-colon.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-colon.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -44,7 +44,7 @@
       if (op_limit)
         {
           if (op_increment)
-            ::error ("invalid colon expression");
+            error ("invalid colon expression");
           else
             {
               // Stupid syntax:
@@ -62,7 +62,7 @@
       retval = this;
     }
   else
-    ::error ("invalid colon expression");
+    error ("invalid colon expression");
 
   return retval;
 }
@@ -85,73 +85,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 +138,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-decl.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-decl.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-eval.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-eval.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -59,6 +59,8 @@
 
 bool tree_evaluator::quiet_breakpoint_flag = false;
 
+bool tree_evaluator::unwind_protect_exception = false;
+
 tree_evaluator::stmt_list_type tree_evaluator::statement_context
   = tree_evaluator::other;
 
@@ -95,15 +97,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 +114,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 +146,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 +203,6 @@
           tree_decl_elt *elt = *p;
 
           fcn (*elt);
-
-          if (error_state)
-            break;
         }
     }
 }
@@ -253,12 +243,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 +269,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 +282,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,7 +303,7 @@
     return;
 #endif
 
-  if (error_state || rhs.is_undefined ())
+  if (rhs.is_undefined ())
     return;
 
   {
@@ -328,16 +311,13 @@
 
     octave_lvalue ult = lhs->lvalue ();
 
-    if (error_state)
-      return;
-
     tree_statement_list *loop_body = cmd.body ();
 
     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++)
           {
@@ -345,7 +325,7 @@
 
             ult.assign (octave_value::op_asn_eq, val);
 
-            if (! error_state && loop_body)
+            if (loop_body)
               loop_body->accept (*this);
 
             if (quit_loop_now ())
@@ -356,7 +336,7 @@
       {
         ult.assign (octave_value::op_asn_eq, rhs);
 
-        if (! error_state && loop_body)
+        if (loop_body)
           loop_body->accept (*this);
 
         // Maybe decrement break and continue states.
@@ -402,7 +382,7 @@
 
                 ult.assign (octave_value::op_asn_eq, val);
 
-                if (! error_state && loop_body)
+                if (loop_body)
                   loop_body->accept (*this);
 
                 if (quit_loop_now ())
@@ -412,8 +392,8 @@
       }
     else
       {
-        ::error ("invalid type in for loop expression near line %d, column %d",
-                 cmd.line (), cmd.column ());
+        error ("invalid type in for loop expression near line %d, column %d",
+               cmd.line (), cmd.column ());
       }
   }
 }
@@ -421,9 +401,6 @@
 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 +414,7 @@
 
   octave_value rhs = expr->rvalue1 ();
 
-  if (error_state || rhs.is_undefined ())
+  if (rhs.is_undefined ())
     return;
 
   if (rhs.is_map ())
@@ -479,7 +456,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 +549,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 +629,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 +714,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 +722,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 +740,6 @@
 {
   static octave_value_list empty_list;
 
-  if (error_state)
-    return;
-
   tree_statement_list::iterator p = lst.begin ();
 
   if (p != lst.end ())
@@ -793,9 +754,6 @@
 
               elt->accept (*this);
 
-              if (error_state)
-                break;
-
               if (tree_break_command::breaking
                   || tree_continue_command::continuing)
                 break;
@@ -855,7 +813,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 +822,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 +833,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 +857,22 @@
 
   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&)
+        {
+          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 +885,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 +910,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 +928,17 @@
   frame.protect_var (tree_break_command::breaking);
   tree_break_command::breaking = 0;
 
-  if (list)
-    list->accept (*this);
+  bool execution_error_in_cleanup = false;
+
+  try
+    {
+      if (list)
+        list->accept (*this);
+    }
+  catch (const octave_execution_exception&)
+    {
+      execution_error_in_cleanup = true;
+    }
 
   // The unwind_protects are popped off the stack in the reverse of
   // the order they are pushed on.
@@ -1011,24 +968,30 @@
   // whatever they were when the cleanup block was entered.
 
   if (tree_break_command::breaking || tree_return_command::returning)
-    {
-      frame.discard (2);
-    }
+    frame.discard (2);
   else
-    {
-      frame.run (2);
-    }
+    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.
+  // We don't want to ignore errors that occur in the cleanup code,
+  // so if an error is encountered there, rethrow the exception.
+  // Otherwise, rethrow any exception that might have occurred in the
+  // unwind_protect block.
 
-  if (error_state)
+  if (execution_error_in_cleanup)
     frame.discard (2);
   else
     frame.run (2);
 
   frame.run ();
+
+  // FIXME: we should really be rethrowing whatever exception occurred,
+  // not just throwing an execution exception.
+  if (unwind_protect_exception || execution_error_in_cleanup)
+    {
+      unwind_protect_exception = false;
+
+      octave_throw_execution_exception ();
+    }
 }
 
 void
@@ -1040,18 +1003,21 @@
 
   if (unwind_protect_code)
     {
+      unwind_protect_exception = false;
+
       try
         {
           unwind_protect_code->accept (*this);
         }
-      catch (...)
+      catch (const octave_execution_exception&)
         {
+          unwind_protect_exception = true;
+
           // 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.
+
+          // We want to rethrow the exception so that interrupts continue.
           throw;
         }
 
@@ -1062,9 +1028,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 +1054,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 +1067,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 +1088,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-eval.h	Sat Oct 10 16:52:59 2015 -0700
@@ -153,6 +153,8 @@
 
   static bool quiet_breakpoint_flag;
 
+  static bool unwind_protect_exception;
+
   // Possible types of evaluation contexts.
   enum stmt_list_type
   {
--- a/libinterp/parse-tree/pt-exp.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-exp.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-id.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-id.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-id.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-idx.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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.string_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,26 @@
   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 ());
+
+  (*current_liboctave_error_with_id_handler) (e.id (), e.err ());
+}
+
 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 +312,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 +368,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 +382,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 +481,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-mat.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-mat.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -276,7 +276,7 @@
 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 +360,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 +388,32 @@
 
   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);
+              break;
             }
         }
     }
 
-  ok = ! error_state;
+  ok = true;
 }
 
 void
@@ -606,60 +603,57 @@
         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);
+          return;
+        }
+    }
+
+  ok = true;
 }
 
 octave_value_list
@@ -707,20 +701,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 +739,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 +749,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 +757,7 @@
           i++;
         }
 
-      if (! error_state)
-        result = Array<T>::cat (-2, ncols, array_list);
+      result = Array<T>::cat (-2, ncols, array_list);
     }
   else
     {
@@ -808,9 +791,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 +829,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 +900,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 +1071,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-misc.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-misc.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -92,30 +92,27 @@
         }
     }
 
-  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);
         }
     }
 
@@ -200,7 +197,7 @@
             {
               if (! elt->eval ())
                 {
-                  ::error ("no default value for argument %d\n", i+1);
+                  error ("no default value for argument %d", i+1);
                   return;
                 }
             }
--- a/libinterp/parse-tree/pt-pr-code.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-pr-code.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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 ())
+    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-select.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-select.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-unop.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/parse-tree/pt-unop.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/template-inst/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/libinterp/template-inst/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/liboctave/Makefile.am	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/Array-util.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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++;
     }
 
@@ -126,7 +126,7 @@
     {
       for (int i = 0; i < n; i ++)
         {
-          if (dim (i) != 1)
+          if (dim(i) != 1)
             {
               retval = false;
 
@@ -148,7 +148,7 @@
   else
     {
       for (int i = 0; i < n; i ++)
-        if (dim (i) > 1)
+        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,29 @@
 
       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 ("");           // no particular variable
+              (*current_liboctave_error_with_id_handler) (e.id(), e.err());
+            }
+        }
+      // 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 +577,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 +589,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.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/Array.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/Array.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/CColVector.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/CDiagMatrix.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/CDiagMatrix.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/CMatrix.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/CMatrix.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
@@ -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 ());
@@ -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;
 }
 
@@ -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/CNDArray.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/CNDArray.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/CRowVector.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/CRowVector.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/CSparse.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/CSparse.h	Sat Oct 10 16:52:59 2015 -0700
@@ -34,7 +34,6 @@
 
 #include "DET.h"
 #include "MSparse.h"
-#include "MSparse-defs.h"
 
 #include "Sparse-op-decls.h"
 
--- a/liboctave/array/DiagArray2.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/DiagArray2.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/DiagArray2.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/MArray.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/MSparse-C.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/MSparse-C.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/MSparse-d.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -26,7 +26,6 @@
 #endif
 
 #include "MSparse.h"
-#include "MSparse.cc"
 
 template class OCTAVE_API MSparse<double>;
 
--- a/liboctave/array/MSparse-defs.h	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/MSparse.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/MSparse.h	Sat Oct 10 16:52:59 2015 -0700
@@ -24,18 +24,20 @@
 #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/PermMatrix.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/PermMatrix.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/PermMatrix.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/Range.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/Range.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/Sparse.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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.
 
@@ -2214,7 +2214,7 @@
         assign (idx_i, idx_j, Sparse<T> (n, m));
     }
   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 +2244,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 +2310,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;
--- a/liboctave/array/Sparse.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/Sparse.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/boolMatrix.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/boolSparse.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/boolSparse.h	Sat Oct 10 16:52:59 2015 -0700
@@ -25,7 +25,7 @@
 #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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/chMatrix.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/chNDArray.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/chNDArray.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/dColVector.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/dColVector.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/dDiagMatrix.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/dDiagMatrix.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/dMatrix.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/dMatrix.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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 ();
@@ -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/dNDArray.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/dNDArray.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/dRowVector.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/dRowVector.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/dSparse.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/dSparse.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/dim-vector.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/fCColVector.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/fCDiagMatrix.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/fCDiagMatrix.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/fCMatrix.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/fCMatrix.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
@@ -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;
 }
 
@@ -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/fCNDArray.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/fCNDArray.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/fCRowVector.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/fCRowVector.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/fColVector.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/fColVector.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/fDiagMatrix.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/fDiagMatrix.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/fMatrix.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/fMatrix.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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 ();
@@ -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/fNDArray.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/fNDArray.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/fRowVector.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/fRowVector.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/idx-vector.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/idx-vector.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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 != 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/intNDArray.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/intNDArray.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/array/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/cruft/Faddeeva/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/Faddeeva/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/amos/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/blas-xtra/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/daspk/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/dasrt/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/dassl/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/fftpack/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/lapack-xtra/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/misc/f77-fcn.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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 \
--- a/liboctave/cruft/misc/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/misc/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/misc/quit.h	Sat Oct 10 16:52:59 2015 -0700
@@ -195,18 +195,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/odepack/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/ordered-qz/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/quadpack/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/ranlib/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/slatec-err/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/cruft/slatec-fn/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,123 @@
+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)
+
+## 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/CmplxCHOL.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/CmplxCHOL.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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,13 +101,28 @@
   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++)
+  if (is_upper)
     {
-      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;
+      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 ();
 
@@ -116,8 +131,18 @@
   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 +168,7 @@
 }
 
 static ComplexMatrix
-chol2inv_internal (const ComplexMatrix& r)
+chol2inv_internal (const ComplexMatrix& r, bool is_upper = true)
 {
   ComplexMatrix retval;
 
@@ -157,17 +182,37 @@
 
       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 +226,7 @@
 ComplexMatrix
 ComplexCHOL::inverse (void) const
 {
-  return chol2inv_internal (chol_mat);
+  return chol2inv_internal (chol_mat, is_upper);
 }
 
 void
@@ -200,7 +245,7 @@
 {
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       ComplexColumnVector utmp = u;
 
@@ -220,7 +265,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       ComplexColumnVector utmp = u;
 
@@ -242,7 +287,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,7 +350,7 @@
 
   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);
@@ -331,7 +376,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       if (singular (chol_mat))
         info = 2;
@@ -358,7 +403,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");
--- a/liboctave/numeric/CmplxCHOL.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/CmplxCHOL.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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/CmplxLU.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/CmplxLU.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/CmplxQR.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/CmplxQR.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/CollocWt.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/CollocWt.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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++)
--- a/liboctave/numeric/DASPK.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/DASPK.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/DASRT.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/DASRT.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/DASSL.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/DASSL.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/EIG.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/EIG.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/LSODE.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/LSODE.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/ODES.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/ODES.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/ODES.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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/Quad.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/Quad.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/SparseCmplxLU.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/SparseCmplxLU.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/SparsedbleLU.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/SparsedbleLU.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/base-dae.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/base-dae.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/base-de.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/base-lu.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-min.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/base-min.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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/dbleCHOL.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/dbleCHOL.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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,13 +101,28 @@
   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++)
+  if (is_upper)
     {
-      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;
+      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 ();
 
@@ -116,9 +131,18 @@
   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 +156,18 @@
       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 +177,7 @@
 }
 
 static Matrix
-chol2inv_internal (const Matrix& r)
+chol2inv_internal (const Matrix& r, bool is_upper = true)
 {
   Matrix retval;
 
@@ -161,17 +194,37 @@
 
       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 +239,7 @@
 Matrix
 CHOL::inverse (void) const
 {
-  return chol2inv_internal (chol_mat);
+  return chol2inv_internal (chol_mat, is_upper);
 }
 
 void
@@ -205,7 +258,7 @@
 {
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       ColumnVector utmp = u;
 
@@ -225,7 +278,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       ColumnVector utmp = u;
 
@@ -247,7 +300,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,7 +362,7 @@
 
   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);
@@ -335,7 +388,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       if (singular (chol_mat))
         info = 2;
@@ -361,7 +414,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");
--- a/liboctave/numeric/dbleCHOL.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/dbleCHOL.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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/dbleLU.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/dbleLU.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/dbleQR.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/dbleQR.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/eigs-base.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/eigs-base.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
--- a/liboctave/numeric/fCmplxCHOL.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/fCmplxCHOL.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -200,7 +200,7 @@
 {
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       FloatComplexColumnVector utmp = u;
 
@@ -220,7 +220,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       FloatComplexColumnVector utmp = u;
 
@@ -243,7 +243,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");
--- a/liboctave/numeric/fCmplxLU.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/fCmplxLU.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/fCmplxQR.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/fCmplxQR.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/fEIG.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/fEIG.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/floatCHOL.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/floatCHOL.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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,30 @@
   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++)
+  if (is_upper)
     {
-      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;
+      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+1; 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 +132,18 @@
   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 +157,19 @@
       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 +179,7 @@
 }
 
 static FloatMatrix
-chol2inv_internal (const FloatMatrix& r)
+chol2inv_internal (const FloatMatrix& r, bool is_upper = true)
 {
   FloatMatrix retval;
 
@@ -161,17 +196,37 @@
 
       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 +241,7 @@
 FloatMatrix
 FloatCHOL::inverse (void) const
 {
-  return chol2inv_internal (chol_mat);
+  return chol2inv_internal (chol_mat, is_upper);
 }
 
 void
@@ -205,7 +260,7 @@
 {
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       FloatColumnVector utmp = u;
 
@@ -225,7 +280,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       FloatColumnVector utmp = u;
 
@@ -247,7 +302,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,7 +364,7 @@
 
   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);
@@ -335,7 +390,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       if (singular (chol_mat))
         info = 2;
@@ -361,7 +416,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");
--- a/liboctave/numeric/floatCHOL.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/floatCHOL.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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/floatLU.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/floatLU.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/floatQR.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/floatQR.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/lo-mappers.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/lo-mappers.h	Sat Oct 10 16:52:59 2015 -0700
@@ -28,6 +28,7 @@
 
 #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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/lo-specfun.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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,6 +186,16 @@
 
   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)
@@ -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)
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/lo-specfun.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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-rand.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/oct-rand.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-spparms.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/oct-spparms.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/sparse-base-chol.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/numeric/sparse-base-chol.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/operators/mk-ops.awk	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/operators/mk-ops.awk	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
             }
 
--- a/liboctave/operators/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/operators/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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-inlines.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/operators/mx-inlines.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/sparse-mk-ops.awk	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/operators/sparse-mk-ops.awk	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
             }
 
--- a/liboctave/system/file-ops.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/system/file-ops.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/system/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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-time.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/system/oct-time.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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
 
@@ -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/util/cmd-edit.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/cmd-edit.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -1668,7 +1668,7 @@
                   {
                     temp = octave_env::get_current_directory ();
                   }
-                catch (octave_execution_exception)
+                catch (const octave_execution_exception&)
                   {
                     temp = "";
                   }
--- a/liboctave/util/f2c-main.c	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/f2c-main.c	Sat Oct 10 16:52:59 2015 -0700
@@ -20,6 +20,10 @@
 
 */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <assert.h>
 
 
--- a/liboctave/util/glob-match.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/glob-match.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/kpse.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/lo-array-gripes.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -25,6 +25,7 @@
 #include <config.h>
 #endif
 
+#include <string.h>
 #include "lo-array-gripes.h"
 #include "lo-error.h"
 
@@ -90,34 +91,6 @@
 }
 
 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)
 {
@@ -128,25 +101,234 @@
      is1d ? "I" : "..,I,..", idx, ext);
 }
 
-void
-gripe_invalid_index (void)
+
+
+// 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.
+
+const char *
+index_exception::err (void) throw ()
 {
-  const char *err_id = error_id_invalid_index;
+  msg = access () + "; " + explain ();
+  return msg.c_str ();
+}
+
+// Show what was illegally accessed, 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:: access (void) const
+{
+  // FIXME: don't use a fixed size buffer!
+
+  int buf_len = 300;
+
+  char output [buf_len];
+  char pre [buf_len];
+  char post [buf_len];
+
+  // dim == 0 if position not yet given, or
+  // <static_cast unsigned int>(-1) if explicitly shown to be unknown
+  // both are caught by this condition
 
-  (*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
+  if (static_cast <unsigned int> (dim-1) > 100000)
+    {
+      // No parentheses are given if the dimension is not known.
+      pre[0] = post[0] = '\0';
+    }
+  else
+    {
+      if (dim < 5)
+        {
+          pre[0] = '(';
+          octave_idx_type i;
+
+          for (i = 1; i < dim; i++)
+            {
+              pre[2*i-1] = '_';
+              pre[2*i]   = ',';
+            }
+
+          pre[2*i-1] = '\0';    // i == min (1, dim)
+        }
+      else
+        {
+          sprintf (pre, "(...[x%d]...", dim-1);
+        }
+
+      if (static_cast <unsigned int> (nd-dim) < 5)
+        {
+          for (octave_idx_type i = 0; i < nd-dim; i++)
+            {
+              post[2*i]   = ',';
+              post[2*i+1] = '_';
+            }
+
+          if (nd >= dim)
+            {
+              post[2*(nd-dim)] = ')';
+              post[2*(nd-dim)+1] = '\0';
+            }
+        }
+      else
+        sprintf (post, "...[x%d]...)", nd-dim);
+    }
+
+  const char *v;
+
+  if (var[0] == '\0' || var == "<unknown>")
+    v = "index ";
+  else
+    v = var.c_str ();
+
+  snprintf (output, buf_len, "%s%s%s%s", v, pre, idx(), post);
+
+  return output;
 }
 
-// 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
+class invalid_index : public index_exception
+{
+public:
+
+  invalid_index (const char *value, octave_idx_type ndim,
+                 octave_idx_type dimen)
+    : index_exception (value, ndim, dimen)
+  { }
+
+  const char* explain (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* id (void) const
+  {
+    return error_id_invalid_index;
+  }
+};
+
+// Complain of an index that is: negative, fractional, or too big.
+
+void
+gripe_invalid_index (const char *idx, octave_idx_type nd,
+                     octave_idx_type dim, const char * /* var */)
+{
+    invalid_index e (idx, nd, dim);
+
+    throw e;
+}
+
+void
+gripe_invalid_index (octave_idx_type n, octave_idx_type nd,
+                     octave_idx_type dim, const char *var)
+{
+  // FIXME: don't use a fixed size buffer!
+  char buf [100];
+
+  sprintf (buf, "%d", n+1);
+
+  gripe_invalid_index (buf, nd, dim, var);
+}
+
+void
+gripe_invalid_index (double n, octave_idx_type nd, octave_idx_type dim,
+                     const char *var)
+{
+  // FIXME: don't use a fixed size buffer!
+  char buf [100];
+
+  sprintf (buf, "%g", n+1);
+
+  gripe_invalid_index (buf, nd, dim, var);
+}
+
+
+// Gripe and exception for read access beyond the bounds of an array.
+
+class out_of_range : public index_exception
+{
+public:
+
+  out_of_range (const char *value, octave_idx_type nd_in,octave_idx_type dim_in)
+        : index_exception (value, nd_in, dim_in), extent(0)
+    { }
+
+  const char* explain (void) const
+  {
+    static std::string expl;    // should probably be member variable, but
+                                // then explain() can't be const.
+
+    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
+      {
+        // FIXME: don't use a fixed size buffer!
+        char buf [100];
+        sprintf (buf, "%d", extent);
+        expl = "out of bound " + std::string (buf);
+      }
+
+    return expl.c_str ();
+  }
+
+  // ID of error to throw.
+  const char* 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:
+
+  dim_vector  size;         // dimension of object being accessed
+
+  octave_idx_type extent;   // length of dimension being accessed
+};
+
+// 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)
+{
+    char buf [100];
+    sprintf (buf, "%d", idx);
+    out_of_range e (buf, nd, dim);
+
+    e.set_extent (ext);
+    dim_vector d (1,1,1,1,1,1,1);   // make  explain()  give extent not size
+    e.set_size (d);
+    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)
+{
+    char buf [100];
+    sprintf (buf, "%d", idx);
+    out_of_range e (buf, nd, dim);
+
+    e.set_extent (ext);
+    e.set_size (d);
+    throw e;
+}
 
 void
 gripe_invalid_resize (void)
@@ -157,20 +339,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 +354,5 @@
          "matrix singular to machine precision, rcond = %g", rcond);
     }
 }
+
+/* Tests in test/index.tst */
--- a/liboctave/util/lo-array-gripes.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/lo-array-gripes.h	Sat Oct 10 16:52:59 2015 -0700
@@ -24,6 +24,80 @@
 #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 char *index_in, octave_idx_type nd_in = 0,
+                   octave_idx_type dim_in = 0, const char *var_in = "")
+    : index (index_in), nd (nd_in), dim (dim_in), var (var_in)
+  { }
+
+  ~index_exception (void) throw () { }
+
+  // Erroneous index value.  Called in what, and by external code
+  // (e.g., nth_element) to make a custom error message.
+  const char *idx (void) const { return index.c_str (); }
+
+  // details set by subclass.
+  virtual const char* explain (void) const = 0;
+
+  // ID of error to throw.
+  virtual const char* id (void) const = 0;
+
+  virtual const char* err (void) throw ();
+
+  // Position of error: dimension in error, and number of dimensions.
+  void set_pos (octave_idx_type nd_in, octave_idx_type dim_in)
+  {
+    nd = nd_in;
+    dim = dim_in;
+  }
+
+  void set_pos_if_unset (octave_idx_type nd_in, octave_idx_type dim_in)
+  {
+    if (nd == 0)
+      {
+        nd  = nd_in;
+        dim = dim_in;
+      }
+  }
+
+  // Name of variable being indexed.  eye(2)(1,1) gives "<unknown>".
+  void set_var (std::string var_in) { var = var_in; }
+
+private:
+
+  // Value of invalid index.
+  std::string index;
+
+  // Formatted message returned by what(), (not on stack).
+  std::string msg;      
+
+protected:
+
+  // Show what's wrong, e.g.,  A(-1,_), A(0+1i).
+  std::string access (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,21 @@
                               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 char *var = NULL);
+
+extern void OCTAVE_API
+gripe_invalid_index (octave_idx_type n, octave_idx_type nd=0,
+                     octave_idx_type dim=0, const char *var = NULL);
+
+extern void OCTAVE_API
+gripe_invalid_index (const char *idx, octave_idx_type nd=0,
+                     octave_idx_type dim=0, const char *var = NULL);
 
 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-regexp.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/lo-regexp.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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-glob.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/oct-glob.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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-shlib.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/oct-shlib.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/pathsearch.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/pathsearch.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -79,7 +79,7 @@
 
   if (initialized)
     {
-      int len = pv.length ();
+      int len = pv.numel ();
 
       int nmax = len > 32 ? len : 32;
 
--- a/liboctave/util/sparse-util.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/sparse-util.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/sparse-util.h	Sat Oct 10 16:52:59 2015 -0700
@@ -24,16 +24,18 @@
 #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/str-vec.cc	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/str-vec.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/str-vec.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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/unwind-prot.h	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/unwind-prot.h	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/liboctave/util/url-transfer.cc	Sat Oct 10 16:52:59 2015 -0700
@@ -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/m4/acinclude.m4	Sat Oct 10 16:46:00 2015 -0700
+++ b/m4/acinclude.m4	Sat Oct 10 16:52:59 2015 -0700
@@ -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
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/run-octave.in	Sat Oct 10 16:52:59 2015 -0700
@@ -20,9 +20,9 @@
 ## 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%}
 
 # FIXME -- is there a better way to handle the possibility of spaces
 # in these names?
@@ -89,14 +89,16 @@
 ## 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
+
+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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/@ftp/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/audio/@audioplayer/set.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/audio/@audiorecorder/set.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/audio/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/audio/mu2lin.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/deprecated/luinc.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/deprecated/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/re_read_readline_init_file.m	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/elfun/cosd.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/elfun/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/general/bitcmp.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/general/bitget.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/general/bitset.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/cplxpair.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/general/cplxpair.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/del2.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/general/del2.m	Sat Oct 10 16:52:59 2015 -0700
@@ -156,7 +156,7 @@
     endif
   endfor
 
-  D = D ./ nd;
+  D ./= nd;
 endfunction
 
 
--- a/scripts/general/inputParser.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/general/inputParser.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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
@@ -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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/general/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -1,87 +1,98 @@
-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/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/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/num2str.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/general/num2str.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/profexplore.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/general/profexplore.m	Sat Oct 10 16:52:59 2015 -0700
@@ -105,7 +105,7 @@
         if (rv == 0)
           return;
         elseif (rv > 1)
-          rv = rv - 1;
+          rv -= 1;
           return;
         else
           assert (rv == 1);
--- a/scripts/general/quadl.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/general/quadl.m	Sat Oct 10 16:52:59 2015 -0700
@@ -133,7 +133,7 @@
     R = 1;
   endif
   if (R > 0 && R < 1)
-    tol = tol/R;
+    tol /= R;
   endif
   is = s * abs (is) * tol/myeps;
   if (is == 0)
--- a/scripts/general/randi.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/general/randi.m	Sat Oct 10 16:52:59 2015 -0700
@@ -46,8 +46,7 @@
 ## Implementation Note: @code{randi} relies internally on @code{rand} which
 ## uses class @qcode{"double"} to represent numbers.  This limits the maximum
 ## integer (@var{imax}) and range (@var{imax} - @var{imin}) to the value
-## returned by the @code{bitmax} function.  For IEEE floating point numbers
-## this value is @w{@math{2^{53} - 1}}.
+## returned by the @code{flintmax} function.
 ##
 ## @seealso{rand}
 ## @end deftypefn
@@ -59,22 +58,24 @@
   if (nargin < 1)
     print_usage ();
   endif
+  nargoutchk (0, 1);
 
-  if (! (isnumeric (bounds) && isreal (bounds)))
-    error ("randi: IMIN and IMAX must be real numeric bounds");
+  if (! (isnumeric (bounds) && all (bounds == fix (bounds))))
+    error ("randi: IMIN and IMAX must be integer bounds.");
   endif
 
+  bounds = real (double (bounds));
   if (isscalar (bounds))
     imin = 1;
-    imax = fix (bounds);
+    imax = bounds;
     if (imax < 1)
-      error ("randi: require IMAX >= 1");
+      error ("randi: require IMAX >= 1.");
     endif
   else
-    imin = fix (bounds(1));
-    imax = fix (bounds(2));
+    imin = bounds(1);
+    imax = bounds(2);
     if (imax < imin)
-      error ("randi: require IMIN <= IMAX");
+      error ("randi: require IMIN <= IMAX.");
     endif
   endif
 
@@ -85,27 +86,33 @@
     rclass = "double";
   endif
 
-  if (strfind (rclass, "int"))
-    if (imax > intmax (rclass))
-      error ("randi: require IMAX < intmax (CLASS)");
-    endif
-  elseif (strcmp (rclass, "single"))
-    if (imax > bitmax (rclass))
-      error ("randi: require IMAX < bitmax (CLASS)");
-    endif
+  ## Limit set by use of class double in rand()
+  if (imax >= flintmax ())
+    error ("randi: maximum integer IMAX must be smaller than flintmax ().");
   endif
-  ## Limit set by use of class double in rand()
-  if (imax > bitmax)
-    error ("randi: maximum integer IMAX must be smaller than bitmax ()");
-  endif
-  if ((imax - imin) > bitmax)
-    error ("randi: maximum integer range must be smaller than bitmax ()");
+  if ((imax - imin) >= flintmax ())
+    error ("randi: maximum integer range must be smaller than flintmax ().");
   endif
 
 
   ri = imin + floor ( (imax-imin+1)*rand (varargin{:}) );
 
   if (! strcmp (rclass, "double"))
+    if (strfind (rclass, "int"))
+      maxval = intmax (rclass);
+      minval = intmin (rclass);
+    elseif (strcmp (rclass, "single"))
+      maxval = flintmax (rclass);
+      minval = -maxval;
+    endif
+    if ((imax >= maxval) || ((imax - imin) >= maxval))
+      warning (["randi: maximum integer IMAX or range exceeds requested ", ...
+        "type.  Values might be truncated to requested type."]);
+    endif
+    if (imin < minval)
+      warning (["randi: minimum integer IMIN exceeds requested type.  ", ...
+        "Values might be truncated to requested type."]);
+    endif
     ri = cast (ri, rclass);
   endif
 
@@ -121,22 +128,56 @@
 %! assert (columns (ri), 1);
 %! assert (class (ri), "double");
 %!test
+%! ri = randi (int64 (100), 1, 1000);
+%! assert (ri, fix (ri));
+%! assert (min (ri), 1);
+%! assert (max (ri), 100);
+%! assert (rows (ri), 1);
+%! assert (columns (ri), 1000);
+%! assert (class (ri), "double");
+%!test
 %! ri = randi ([-5, 10], 1000, 1, "int8");
 %! assert (ri, fix (ri));
 %! assert (min (ri), int8 (-5));
 %! assert (max (ri), int8 (10));
 %! assert (class (ri), "int8");
+%!test
+%! ri = randi ([-5; 10], 1000, 1, "single");
+%! assert (ri, fix (ri));
+%! assert (min (ri), single (-5));
+%! assert (max (ri), single (10));
+%! assert (class (ri), "single");
 %!
 %!assert (size (randi (10, 3,1,2)), [3, 1, 2])
 
+## Test range exceedings
+%!warning <exceeds requested type>
+%! ri = randi ([-5, 10], 1000, 1, "uint8");
+%! assert (ri, fix (ri));
+%! assert (min (ri), uint8 (-5));
+%! assert (max (ri), uint8 (10));
+%! assert (class (ri), "uint8");
+%!warning <exceeds requested type> randi (intmax("int8"), 10, 1, "int8");
+%!warning <exceeds requested type> randi (flintmax("single"), 10, 1, "single");
+%!warning <exceeds requested type>
+%! randi ([-1, intmax("int8") - 1], 10, 1, "int8");
+%!warning <exceeds requested type>
+%! randi ([-1, flintmax("single") - 1], 10, 1, "single");
+%!warning <exceeds requested type>
+%! randi ([-flintmax("single"), 0], 10, 1, "single");
+%!warning <exceeds requested type>
+%! randi ([-flintmax("single") + 1, 1], 10, 1, "single");
+
 ## Test input validation
 %!error (randi ())
 %!error (randi ("test"))
-%!error (randi (10+2i))
+%!error (randi (struct ("a", 1)))
 %!error (randi (0))
+%!error (randi (1.5))
+%!error (randi ([1.5, 2.5]))
+%!error (randi ([1, 2.5]))
+%!error (randi ([1.5, 2]))
 %!error (randi ([10, 1]))
-%!error (randi (256, "uint8"))
-%!error (randi (2^25, "single"))
-%!error (randi (bitmax () + 1))
-%!error (randi ([-1, bitmax()]))
-
+%!error (randi (flintmax ()))
+%!error (randi ([-1, flintmax() - 1]))
+%!error ([r1, r2] = randi ())
--- a/scripts/general/rat.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/general/rat.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/general/rotdim.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/geometry/griddata.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/geometry/griddata.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/geometry/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/gui/listdlg.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/gui/listdlg.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/gui/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/__fltk_file_filter__.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/gui/private/__fltk_file_filter__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/waitbar.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/gui/waitbar.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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
+## "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%');
@@ -192,6 +246,51 @@
 %! pause (0.5);
 %! 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)
--- a/scripts/help/__unimplemented__.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/help/__unimplemented__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/}."];
 
@@ -750,9 +749,6 @@
   "ode23s",
   "ode23t",
   "ode23tb",
-  "ode45",
-  "odeget",
-  "odeset",
   "odextend",
   "openfig",
   "opengl",
--- a/scripts/help/get_first_help_sentence.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/help/get_first_help_sentence.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/help/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/private/__strip_html_tags__.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/help/private/__strip_html_tags__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -77,6 +77,6 @@
   endfor
 
   ## Actually remove the elements
-  text = text (keep);
+  text = text(keep);
 endfunction
 
--- a/scripts/help/type.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/help/type.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/cmpermute.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/cmpermute.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/cmunique.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/colormap.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/cubehelix.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/cubehelix.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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);
 
--- a/scripts/image/hsv2rgb.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/hsv2rgb.m	Sat Oct 10 16:52:59 2015 -0700
@@ -1,4 +1,5 @@
 ## Copyright (C) 1999-2015 Kai Habel
+## Copyright (C) 2015 Carnë Draug
 ##
 ## This file is part of Octave.
 ##
@@ -19,22 +20,39 @@
 ## -*- 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
+## >> 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 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 +63,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, cls, sz, is_im, is_nd, is_int] ...
+    = 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, cls, sz, is_im, is_nd, is_int);
 
 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 +124,22 @@
 %! 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)
--- a/scripts/image/imformats.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/imformats.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/imread.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/imshow.m	Sat Oct 10 16:52:59 2015 -0700
@@ -77,6 +77,7 @@
   truecolor = false;
   indexed = false;
   xdata = ydata = [];
+  prop_val_args = {};
 
   ## Get the image.
   if (ischar (im))
@@ -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++;
         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++;
         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++;
         case "xdata"
           xdata = varargin{narg++};
           if (! isvector (xdata))
@@ -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)
@@ -262,9 +262,10 @@
 %!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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/imwrite.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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 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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/iscolormap.m	Sat Oct 10 16:52:59 2015 -0700
@@ -22,7 +22,12 @@
 ##
 ## 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.
+## 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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -1,64 +1,78 @@
-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/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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/ntsc2rgb.m	Sat Oct 10 16:52:59 2015 -0700
@@ -45,22 +45,8 @@
     print_usage ();
   endif
 
-  if (! isa (yiq, "double"))
-    error ("ntsc2rgb: YIQ must be of type double");
-  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, cls, sz, is_im, is_nd, is_int] ...
+    = 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,17 +56,11 @@
   trans = [ 1.0,      1.0,      1.0;
             0.95617, -0.27269, -1.10374;
             0.62143, -0.64681,  1.70062 ];
-
   rgb = yiq * trans;
 
-  ## If input was an image, convert it back into one.
-  if (is_image)
-    rgb = reshape (rgb, sz);
-  endif
-
+  rgb = colorspace_conversion_revert (rgb, cls, sz, is_im, is_nd, is_int);
 endfunction
 
-
 ## Test pure R, G, B colors
 %!assert (ntsc2rgb ([.299  .596  .211]), [1 0 0], 1e-5)
 %!assert (ntsc2rgb ([.587 -.274 -.523]), [0 1 0], 1e-5)
@@ -97,6 +77,14 @@
 ## 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 a colormap or YIQ image> ntsc2rgb (uint8 (1))
+%!error <YIQ must be a colormap or YIQ image> ntsc2rgb (ones (2,2))
 
+## 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)
--- a/scripts/image/private/__imwrite__.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/private/__imwrite__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/image/private/colorspace_conversion_input_check.m	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,71 @@
+## 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, cls, sz, is_im, is_nd, is_int] ...
+            = 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", "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))
+    in_arg = double (in_arg) / double (intmin (cls));
+    is_int = true;
+  else
+    is_int = false;
+  endif
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/image/private/colorspace_conversion_revert.m	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,37 @@
+## 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, cls, sz, is_im, is_nd, is_int)
+  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
+  if (is_int)
+    rv *= intmax (cls);
+  endif
+endfunction
--- a/scripts/image/rgb2hsv.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/rgb2hsv.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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, cls, sz, is_im, is_nd, is_int] ...
+    = 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, cls, sz, is_im, is_nd, is_int);
 
 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,22 @@
 %! 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)
--- a/scripts/image/rgb2ntsc.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/image/rgb2ntsc.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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, cls, sz, is_im, is_nd, is_int] ...
+    = 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,11 @@
   trans = [ 0.299,  0.596,  0.211;
             0.587, -0.274, -0.523;
             0.114, -0.322,  0.312 ];
-
-  ## Convert data.
   yiq = rgb * trans;
 
-  ## If input was an image, convert it back into one.
-  if (is_image)
-    yiq = reshape (yiq, sz);
-  endif
-
+  yiq = colorspace_conversion_revert (yiq, cls, sz, is_im, is_nd, is_int);
 endfunction
 
-
 ## Test pure RED, GREEN, BLUE colors
 %!assert (rgb2ntsc ([1 0 0]), [.299  .596  .211])
 %!assert (rgb2ntsc ([0 1 0]), [.587 -.274 -.523])
@@ -114,5 +82,13 @@
 %!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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/image/viridis.m	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,316 @@
+## 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
+
+%!demo
+%! ## Show the 'viridis' colormap as an image
+%! image (1:256, linspace (0, 1, 256), repmat ((1:256)', 1, 256));
+%! axis ([1, 256, 0, 1], "ticy", "xy");
+%! colormap (viridis (256));
--- a/scripts/io/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/io/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/io/strread.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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
@@ -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))) = ...
@@ -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/java/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/java/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/linear-algebra/duplication_matrix.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/linear-algebra/duplication_matrix.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/linear-algebra/housh.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/krylov.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/linear-algebra/krylov.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/linear-algebra/logm.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/linear-algebra/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/linear-algebra/normest.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/linear-algebra/onenormest.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/miscellaneous/dos.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/miscellaneous/dos.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/miscellaneous/edit.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/fullfile.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/miscellaneous/fullfile.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/inputname.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/miscellaneous/inputname.m	Sat Oct 10 16:52:59 2015 -0700
@@ -61,11 +61,11 @@
 %!assert (inputname (1), "hello")
 %!assert (inputname (2), "worldly")
 
-%!function r = foo (x, y)
+%!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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/miscellaneous/ls.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/miscellaneous/menu.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/miscellaneous/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/unix.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/miscellaneous/unix.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,37 @@
+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/odepkg_event_handle.m \
+  scripts/ode/private/odepkg_structure_check.m \
+  scripts/ode/private/ode_rk_interpolate.m \
+  scripts/ode/private/ode_struct_value_check.m \
+  scripts/ode/private/runge_kutta_45_dorpri.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	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,673 @@
+## 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{opt})
+## @deftypefnx {Function File} {[@var{t}, @var{y}] =} ode45 (@dots{}, @var{par1}, @var{par2}, @dots{})
+## @deftypefnx {Function File} {[@var{t}, @var{y}, @var{xe}, @var{ye}, @var{ie}] =} ode45 (@dots{})
+## @deftypefnx {Function File} {@var{sol} =} ode45 (@var{fun}, @var{trange}, @var{init}, @dots{})
+##
+## Solve a set of non-stiff Ordinary Differential Equations (non-stiff ODEs)
+## with the well known explicit Dormand-Prince method of order 4.
+##
+## The first input argument must be a function handle or inline 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.  Usually, 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 called is
+## @command{integrate_n_steps}.  If there is only one time value, then
+## @code{ode45} will raise an error unless the options structure has
+## non-empty fields named @var{"TimeStepNumber"} and @var{"TimeStepSize"}. 
+## If the option @var{"TimeStepSize"} is not empty, then the stepper called
+## will be @command{integrate_const}.  If @var{"TimeStepNumber"} is also
+## specified then the integrate function @command{integrate_n_steps} will be
+## used; otherwise, @command{integrate_adaptive} is used.  For this last
+## possibility the user can set the tolerance for the timestep computation by
+## changing the option @var{"Tau"}, that has a default value of @math{1e-6}.
+##
+## The third input argument @var{init} contains the initial value for the
+## unknowns.  If this 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}.
+##
+## If present, the fourth input argument specifies options to the ODE solver.
+## It is a structure typically generated by @code{odeset}.
+##
+## The function usually produces just 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}.
+##
+## For example, solve an anonymous implementation of the Van der Pol equation
+##
+## @example
+## @group
+## fvdp = @@(t,y) [y(2); (1 - y(1)^2) * y(2) - y(1)];
+## [T,Y] = ode45 (fvdp, [0 20], [2 0]);
+## @end group
+## @end example
+## @seealso{odeset, odeget}
+## @end deftypefn
+
+function varargout = ode45 (vfun, vtrange, vinit, varargin)
+
+  vorder = 5;  # runge_kutta_45_dorpri uses local extrapolation
+  vsolver = "ode45";
+
+  ## FIXME: Octave core function's usually do print_usage ()
+  ##        rather than displaying full help string when improperly called.
+  if (nargin == 0)  # Check number and types of all input arguments
+    help (vsolver);
+    error ("OdePkg:InvalidArgument",
+           "number of input arguments must be greater than zero");
+  endif
+
+  if (nargin < 3)
+    print_usage ();
+  endif
+  
+  if (nargin >= 4)
+    if (! isstruct (varargin{1}))
+      ## varargin{1:len} are parameters for vfun
+      vodeoptions = odeset;
+      vodeoptions.vfunarguments = varargin;
+    elseif (length (varargin) > 1)
+      ## varargin{1} is an OdePkg options structure vopt
+      vodeoptions = odepkg_structure_check (varargin{1}, "ode45");
+      vodeoptions.vfunarguments = {varargin{2:length(varargin)}};
+    else  # if (isstruct (varargin{1}))
+      vodeoptions = odepkg_structure_check (varargin{1}, "ode45");
+      vodeoptions.vfunarguments = {};
+    endif
+  else  # nargin == 3
+    vodeoptions = odeset; 
+    vodeoptions.vfunarguments = {};
+  endif
+
+  if (! isvector (vtrange) || ! isnumeric (vtrange))
+    error ("OdePkg:InvalidArgument",
+           "second input argument must be a valid vector");
+  endif
+
+  if (length (vtrange) < 2
+      && (isempty (vodeoptions.TimeStepSize)
+          || isempty (vodeoptions.TimeStepNumber)))
+    error ("OdePkg:InvalidArgument",
+           "second input argument must be a valid vector");
+  elseif (vtrange(2) == vtrange(1))
+    error ("OdePkg:InvalidArgument",
+           "second input argument must be a valid vector");
+  else
+    vodeoptions.vdirection = sign (vtrange(2) - vtrange(1));
+  endif
+  vtrange = vtrange(:);
+
+  if (! isvector (vinit) || ! isnumeric (vinit))
+    error ("OdePkg:InvalidArgument",
+           "third input argument must be a valid numerical value");
+  endif
+  vinit = vinit(:);
+
+  if (! (isa (vfun, "function_handle")))
+    error ("OdePkg:InvalidArgument",
+           "first input argument must be a valid function handle");
+  endif
+
+  ## Start preprocessing, have a look which options are set in vodeoptions,
+  ## check if an invalid or unused option is set
+  if (isempty (vodeoptions.TimeStepNumber)
+      && isempty (vodeoptions.TimeStepSize))
+    integrate_func = "adaptive";
+    vodeoptions.vstepsizefixed = false;
+  elseif (! isempty (vodeoptions.TimeStepNumber)
+          && ! isempty (vodeoptions.TimeStepSize))
+    integrate_func = "n_steps";
+    vodeoptions.vstepsizefixed = true;
+    if (sign (vodeoptions.TimeStepSize) != vodeoptions.vdirection)
+      warning ("OdePkg:InvalidArgument",
+               "option 'TimeStepSize' has a wrong sign",
+               "it will be corrected automatically");
+      vodeoptions.TimeStepSize = (-1)*vodeoptions.TimeStepSize;
+    endif
+  elseif (isempty (vodeoptions.TimeStepNumber)
+          && ! isempty (vodeoptions.TimeStepSize))
+    integrate_func = "const";
+    vodeoptions.vstepsizefixed = true;
+    if (sign (vodeoptions.TimeStepSize) != vodeoptions.vdirection)
+      warning ("OdePkg:InvalidArgument",
+               "option 'TimeStepSize' has a wrong sign",
+               "it will be corrected automatically");
+      vodeoptions.TimeStepSize = (-1)*vodeoptions.TimeStepSize;
+    endif
+  else
+    warning ("OdePkg:InvalidArgument",
+             "assuming an adaptive integrate function");
+    integrate_func = "adaptive";
+  endif
+
+  ## Get the default options that can be set with "odeset" temporarily
+  vodetemp = odeset;
+
+  ## Implementation of the option RelTol has been finished.
+  ## This option can be set by the user to another value than default value.
+  if (isempty (vodeoptions.RelTol) && ! vodeoptions.vstepsizefixed)
+    vodeoptions.RelTol = 1e-3;
+    warning ("OdePkg:InvalidArgument",
+             "Option 'RelTol' not set, new value %f is used",
+             vodeoptions.RelTol);
+  elseif (! isempty (vodeoptions.RelTol) && vodeoptions.vstepsizefixed)
+    warning ("OdePkg:InvalidArgument",
+             "Option 'RelTol' will be ignored if fixed time stamps are given");
+  endif
+
+  ## Implementation of the option AbsTol has been finished.
+  ## This option can be set by the user to another value than default value.
+  if (isempty (vodeoptions.AbsTol) && ! vodeoptions.vstepsizefixed)
+    vodeoptions.AbsTol = 1e-6;
+    warning ("OdePkg:InvalidArgument",
+             "Option 'AbsTol' not set, new value %f is used",
+             vodeoptions.AbsTol);
+  elseif (! isempty (vodeoptions.AbsTol) && vodeoptions.vstepsizefixed)
+    warning ("OdePkg:InvalidArgument",
+             "Option 'AbsTol' will be ignored if fixed time stamps are given");
+  else
+    vodeoptions.AbsTol = vodeoptions.AbsTol(:); # Create column vector
+  endif
+
+  ## Implementation of the option NormControl has been finished.
+  ## This option can be set by the user to another value than default value.
+  if (strcmp (vodeoptions.NormControl, "on"))
+    vodeoptions.vnormcontrol = true;
+  else 
+    vodeoptions.vnormcontrol = false; 
+  endif
+
+  ## Implementation of the option NonNegative has been finished.
+  ## This option can be set by the user to another value than default value.
+  if (! isempty (vodeoptions.NonNegative))
+    if (isempty (vodeoptions.Mass))
+      vodeoptions.vhavenonnegative = true;
+    else
+      vodeoptions.vhavenonnegative = false;
+      warning ("OdePkg:InvalidArgument",
+               "Option 'NonNegative' will be ignored if mass matrix is set");
+    endif
+  else 
+    vodeoptions.vhavenonnegative = false;
+  endif
+
+  ## Implementation of the option OutputFcn has been finished.
+  ## This option can be set by the user to another value than default value.
+  if (isempty (vodeoptions.OutputFcn) && nargout == 0)
+    vodeoptions.OutputFcn = @odeplot;
+    vodeoptions.vhaveoutputfunction = true;
+  elseif (isempty (vodeoptions.OutputFcn))
+    vodeoptions.vhaveoutputfunction = false;
+  else 
+    vodeoptions.vhaveoutputfunction = true;
+  endif
+
+  ## Implementation of the option OutputSel has been finished.
+  ## This option can be set by the user to another value than default value.
+  if (! isempty (vodeoptions.OutputSel))
+    vodeoptions.vhaveoutputselection = true;
+  else 
+    vodeoptions.vhaveoutputselection = false; 
+  endif
+
+  ## Implementation of the option OutputSave has been finished.
+  ## This option can be set by the user to another value than default value.
+  if (isempty (vodeoptions.OutputSave))
+    vodeoptions.OutputSave = 1;
+  endif
+
+  ## Implementation of the option Refine has been finished.
+  ## This option can be set by the user to another value than default value.
+  if (vodeoptions.Refine > 0)
+    vodeoptions.vhaverefine = true;
+  else 
+    vodeoptions.vhaverefine = false;
+  endif
+
+  ## Implementation of the option Stats has been finished.
+  ## This option can be set by the user to another value than default value.
+
+  ## Implementation of the option InitialStep has been finished.
+  ## This option can be set by the user to another value than default value.
+  if (isempty (vodeoptions.InitialStep) && strcmp (integrate_func, "adaptive"))
+    vodeoptions.InitialStep = ...
+      vodeoptions.vdirection * starting_stepsize (vorder, vfun, vtrange(1),
+                                                  vinit,
+                                                  vodeoptions.AbsTol,
+                                                  vodeoptions.RelTol,
+                                                  vodeoptions.vnormcontrol);
+    warning ("OdePkg:InvalidArgument",
+             "option 'InitialStep' not set, estimated value %f is used",
+             vodeoptions.InitialStep);
+  elseif(isempty (vodeoptions.InitialStep))
+    vodeoptions.InitialStep = odeget (vodeoptions, "TimeStepSize");
+  endif
+
+  ## Implementation of the option MaxStep has been finished. This option
+  ## can be set by the user to another value than default value.
+  if (isempty (vodeoptions.MaxStep) && ! vodeoptions.vstepsizefixed)
+    vodeoptions.MaxStep = abs (vtrange(end) - vtrange(1)) / 10;
+    warning ("OdePkg:InvalidArgument",
+             "Option 'MaxStep' not set, new value %f is used",
+             vodeoptions.MaxStep);
+  endif
+
+  ## Implementation of the option Events has been finished.
+  ## This option can be set by the user to another value than default value.
+  if (! isempty (vodeoptions.Events))
+    vodeoptions.vhaveeventfunction = true;
+  else 
+    vodeoptions.vhaveeventfunction = false;
+  endif
+
+  ## 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 (! isequal (vodeoptions.Jacobian, vodetemp.Jacobian))
+    warning ("OdePkg:InvalidArgument",
+             "option 'Jacobian' will be ignored by this solver");
+  endif
+
+  if (! isequal (vodeoptions.JPattern, vodetemp.JPattern))
+    warning ("OdePkg:InvalidArgument",
+             "option 'JPattern' will be ignored by this solver");
+  endif
+
+  if (! isequal (vodeoptions.Vectorized, vodetemp.Vectorized))
+    warning ("OdePkg:InvalidArgument",
+             "option 'Vectorized' will be ignored by this solver");
+  endif
+
+  if (! isequal (vodeoptions.NewtonTol, vodetemp.NewtonTol))
+    warning ("OdePkg:InvalidArgument",
+             "option 'NewtonTol' will be ignored by this solver");
+  endif
+
+  if (! isequal (vodeoptions.MaxNewtonIterations,vodetemp.MaxNewtonIterations))
+    warning ("OdePkg:InvalidArgument",
+             "option 'MaxNewtonIterations' will be ignored by this solver");
+  endif
+
+  ## Implementation of the option Mass has been finished.
+  ## This option can be set by the user to another value than default value.
+  if (! isempty (vodeoptions.Mass) && isnumeric (vodeoptions.Mass))
+    vhavemasshandle = false;
+    vmass = vodeoptions.Mass;  # constant mass
+  elseif (isa (vodeoptions.Mass, "function_handle"))
+    vhavemasshandle = true;    # mass defined by a function handle
+  else  # no mass matrix - creating a diag-matrix of ones for mass
+    vhavemasshandle = false;   # vmass = diag (ones (length (vinit), 1), 0);
+  endif
+
+  ## Implementation of the option MStateDependence has been finished.
+  ## This option can be set by the user to another value than default value.
+  if (strcmp (vodeoptions.MStateDependence, "none"))
+    vmassdependence = false;
+  else
+    vmassdependence = true;
+  endif
+
+  ## Other options that are not used by this solver.
+  ## Print a warning message to tell the user that the option is ignored.
+  if (! isequal (vodeoptions.MvPattern, vodetemp.MvPattern))
+    warning ("OdePkg:InvalidArgument",
+             "option 'MvPattern' will be ignored by this solver");
+  endif
+
+  if (! isequal (vodeoptions.MassSingular, vodetemp.MassSingular))
+    warning ("OdePkg:InvalidArgument",
+             "option 'MassSingular' will be ignored by this solver");
+  endif
+
+  if (! isequal (vodeoptions.InitialSlope, vodetemp.InitialSlope))
+    warning ("OdePkg:InvalidArgument",
+             "option 'InitialSlope' will be ignored by this solver");
+  endif
+
+  if (! isequal (vodeoptions.MaxOrder, vodetemp.MaxOrder))
+    warning ("OdePkg:InvalidArgument",
+             "option 'MaxOrder' will be ignored by this solver");
+  endif
+
+  if (! isequal (vodeoptions.BDF, vodetemp.BDF))
+    warning ("OdePkg:InvalidArgument",
+             "option 'BDF' will be ignored by this solver");
+  endif
+
+  ## Starting the initialisation of the core solver ode45
+  SubOpts = vodeoptions;
+  
+  if (vhavemasshandle)   # Handle only the dynamic mass matrix,
+    if (vmassdependence) # constant mass matrices have already
+      vmass = @(t,x) vodeoptions.Mass (t, x, vodeoptions.vfunarguments{:});
+      vfun = @(t,x) vmass (t, x, vodeoptions.vfunarguments{:}) ...
+             \ vfun (t, x, vodeoptions.vfunarguments{:});
+    else                 # if (vmassdependence == false)
+      vmass = @(t) vodeoptions.Mass (t, vodeoptions.vfunarguments{:});
+      vfun = @(t,x) vmass (t, vodeoptions.vfunarguments{:}) ...
+             \ vfun (t, x, vodeoptions.vfunarguments{:});
+    endif
+  endif
+
+  switch (integrate_func)
+    case "adaptive"
+      solution = integrate_adaptive (@runge_kutta_45_dorpri,
+                                     vorder, vfun, vtrange, vinit, SubOpts);
+    case "n_steps"
+      solution = integrate_n_steps (@runge_kutta_45_dorpri,
+                                    vfun, vtrange(1), vinit,
+                                    vodeoptions.TimeStepSize,
+                                    vodeoptions.TimeStepNumber, SubOpts);
+    case "const"
+      solution = integrate_const (@runge_kutta_45_dorpri,
+                                  vfun, vtrange, vinit,
+                                  vodeoptions.TimeStepSize, SubOpts);
+  endswitch
+
+  ## Postprocessing, do whatever when terminating integration algorithm
+  if (vodeoptions.vhaveoutputfunction)  # Cleanup plotter
+    feval (vodeoptions.OutputFcn, solution.t(end),
+           solution.x(end,:)', "done", vodeoptions.vfunarguments{:});
+  endif
+  if (vodeoptions.vhaveeventfunction)   # Cleanup event function handling
+    odepkg_event_handle (vodeoptions.Events, solution.t(end),
+                         solution.x(end,:)', "done",
+                         vodeoptions.vfunarguments{:});
+  endif
+
+  ## Print additional information if option Stats is set
+  if (strcmp (vodeoptions.Stats, "on"))
+    vhavestats = true;
+    vnsteps    = solution.vcntloop-2;        # vcntloop from 2..end
+    vnfailed   = (solution.vcntcycles-1)-(vnsteps)+1; # vcntcycl from 1..end
+    vnfevals   = 7*(solution.vcntcycles-1);  # number of ode evaluations
+    vndecomps  = 0;                          # number of LU decompositions
+    vnpds      = 0;                          # number of partial derivatives
+    vnlinsols  = 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", vnsteps);
+      printf ("Number of failed attempts:  %d\n", vnfailed);
+      printf ("Number of function calls:   %d\n", vnfevals);
+    endif
+  else
+    vhavestats = 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 = vsolver;  # Solver name is saved in field solver
+    if (vodeoptions.vhaveeventfunction) 
+      varargout{1}.ie = solution.vevent{2};  # Index info which event occurred
+      varargout{1}.xe = solution.vevent{3};  # Time info when an event occurred
+      varargout{1}.ye = solution.vevent{4};  # Results when an event occurred
+    endif
+    if (vhavestats)
+      varargout{1}.stats = struct ();
+      varargout{1}.stats.nsteps   = vnsteps;
+      varargout{1}.stats.nfailed  = vnfailed;
+      varargout{1}.stats.nfevals  = vnfevals;
+      varargout{1}.stats.npds     = vnpds;
+      varargout{1}.stats.ndecomps = vndecomps;
+      varargout{1}.stats.nlinsols = vnlinsols;
+    endif
+  elseif (nargout == 5)
+    varargout = cell (1,5);
+    varargout{1} = solution.t;
+    varargout{2} = solution.x;
+    if (vodeoptions.vhaveeventfunction) 
+      varargout{3} = solution.vevent{3};     # Time info when an event occurred
+      varargout{4} = solution.vevent{4};     # Results when an event occurred
+      varargout{5} = solution.vevent{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 (vt, vy)  # The Van der Pol
+%! ydot = [vy(2); (1 - vy(1)^2) * vy(2) - vy(1)];
+%!endfunction
+%!function [vref] = fref ()        # The computed reference solution
+%! vref = [0.32331666704577, -1.83297456798624];
+%!endfunction
+%!function [vjac] = fjac (vt, vy, varargin) # its Jacobian
+%! vjac = [0, 1; -1 - 2 * vy(1) * vy(2), 1 - vy(1)^2];
+%!endfunction
+%!function [vjac] = fjcc (vt, vy, varargin) # sparse type
+%! vjac = sparse ([0, 1; -1 - 2 * vy(1) * vy(2), 1 - vy(1)^2])
+%!endfunction
+%!function [vval, vtrm, vdir] = feve (vt, vy, varargin)
+%! vval = fpol (vt, vy, varargin); # We use the derivatives
+%! vtrm = zeros (2,1);             # that's why component 2
+%! vdir = ones (2,1);              # seems to not be exact
+%!endfunction
+%!function [vval, vtrm, vdir] = fevn (vt, vy, varargin)
+%! vval = fpol (vt, vy, varargin); # We use the derivatives
+%! vtrm = ones (2,1);              # that's why component 2
+%! vdir = ones (2,1);              # seems to not be exact
+%!endfunction
+%!function [vmas] = fmas (vt, vy, varargin)
+%! vmas = [1, 0; 0, 1];            # Dummy mass matrix for tests
+%!endfunction
+%!function [vmas] = fmsa (vt, vy, varargin)
+%! vmas = sparse ([1, 0; 0, 1]);   # A sparse dummy matrix
+%!endfunction
+%!function [vout] = fout (vt, vy, vflag, varargin)
+%! if (regexp (char (vflag), 'init') == 1)
+%!   if (any (size (vt) != [2, 1])) error ('"fout" step "init"'); endif
+%! elseif (isempty (vflag))
+%!   if (any (size (vt) != [1, 1])) error ('"fout" step "calc"'); endif
+%!   vout = false;
+%! elseif (regexp (char (vflag), 'done') == 1)
+%!   if (any (size (vt) != [1, 1])) error ('"fout" step "done"'); endif
+%! else
+%!   error ('"fout" invalid vflag');
+%! endif
+%!endfunction
+%!
+%! ## Turn off output of warning messages for all tests, turn them on
+%! ## again if the last test is called
+%!error  # ouput argument
+%! warning ("off", "OdePkg:InvalidArgument");
+%! B = ode45 (1, [0 25], [3 15 1]);
+%!error  # input argument number one
+%! [vt, vy] = ode45 (1, [0 25], [3 15 1]);
+%!error  # input argument number two
+%! [vt, vy] = ode45 (@fpol, 1, [3 15 1]);
+%!test  # two output arguments
+%! [vt, vy] = ode45 (@fpol, [0 2], [2 0]);
+%! assert ([vt(end), vy(end,:)], [2, fref], 1e-2);
+%!test  # not too many steps
+%! [vt, vy] = ode45 (@fpol, [0 2], [2 0]);
+%! assert (size (vt) < 20);
+%!test  # anonymous function instead of real function
+%! fvdb = @(vt,vy) [vy(2); (1 - vy(1)^2) * vy(2) - vy(1)];
+%! [vt, vy] = ode45 (fvdb, [0 2], [2 0]);
+%! assert ([vt(end), vy(end,:)], [2, fref], 1e-2);
+%!test  # extra input arguments passed through
+%! [vt, vy] = ode45 (@fpol, [0 2], [2 0], 12, 13, "KL");
+%! assert ([vt(end), vy(end,:)], [2, fref], 1e-2);
+%!test  # empty OdePkg structure *but* extra input arguments
+%! vopt = odeset;
+%! [vt, vy] = ode45 (@fpol, [0 2], [2 0], vopt, 12, 13, "KL");
+%! assert ([vt(end), vy(end,:)], [2, fref], 1e-2);
+%!error  # strange OdePkg structure
+%! vopt = struct ("foo", 1);
+%! [vt, vy] = ode45 (@fpol, [0 2], [2 0], vopt);
+%!test  # Solve vdp in fixed step sizes
+%! vopt = odeset("TimeStepSize", 0.1);
+%! [vt, vy] = ode45 (@fpol, [0,2], [2 0], vopt);
+%! assert (vt(:), [0:0.1:2]', 1e-2);
+%!test  # Solve another anonymous function below zero
+%! vref = [0, 14.77810590694212];
+%! [vt, vy] = ode45 (@(t,y) y, [-2 0], 2);
+%! assert ([vt(end), vy(end,:)], vref, 1e-1);
+%!test  # InitialStep option
+%! vopt = odeset ("InitialStep", 1e-8);
+%! [vt, vy] = ode45 (@fpol, [0 0.2], [2 0], vopt);
+%! assert ([vt(2)-vt(1)], [1e-8], 1e-9);
+%!test  # MaxStep option
+%! vopt = odeset ("MaxStep", 1e-3);
+%! vsol = ode45 (@fpol, [0 0.2], [2 0], vopt);
+%! assert ([vsol.x(5)-vsol.x(4)], [1e-3], 1e-3);
+%!test  # Solve with intermidiate step
+%! vsol = ode45 (@fpol, [0 1 2], [2 0]);
+%! assert (any((vsol.x-1) == 0));
+%! assert ([vsol.x(end), vsol.y(end,:)], [2, fref], 1e-3);
+%!test  # Solve in backward direction starting at t=0
+%! vref = [-1.205364552835178, 0.951542399860817];
+%! vsol = ode45 (@fpol, [0 -2], [2 0]);
+%! assert ([vsol.x(end), vsol.y(end,:)], [-2, vref], 1e-2);
+%!test  # Solve in backward direction starting at t=2
+%! vref = [-1.205364552835178, 0.951542399860817];
+%! vsol = ode45 (@fpol, [2 -2], fref);
+%! assert ([vsol.x(end), vsol.y(end,:)], [-2, vref], 1e-2);
+%!test  # Solve in backward direction starting at t=2, with intermidiate step
+%! vref = [-1.205364552835178, 0.951542399860817];
+%! vsol = ode45 (@fpol, [2 0 -2], fref);
+%! idx = find(vsol.x < 0, 1, "first") - 1;
+%! assert ([vsol.x(idx), vsol.y(idx,:)], [0 2 0], 1e-2);
+%! assert ([vsol.x(end), vsol.y(end,:)], [-2, vref], 1e-2);
+%!test  # Solve another anonymous function in backward direction
+%! vref = [-1, 0.367879437558975];
+%! vsol = ode45 (@(t,y) y, [0 -1], 1);
+%! assert ([vsol.x(end), vsol.y(end,:)], vref, 1e-3);
+%!test  # Solve another anonymous function below zero
+%! vref = [0, 14.77810590694212];
+%! vsol = ode45 (@(t,y) y, [-2 0], 2);
+%! assert ([vsol.x(end), vsol.y(end,:)], vref, 1e-3);
+%!test  # Solve in backward direction starting at t=0 with MaxStep option
+%! vref = [-1.205364552835178, 0.951542399860817];
+%! vopt = odeset ("MaxStep", 1e-3);
+%! vsol = ode45 (@fpol, [0 -2], [2 0], vopt);
+%! assert ([abs(vsol.x(8)-vsol.x(7))], [1e-3], 1e-3);
+%! assert ([vsol.x(end), vsol.y(end,:)], [-2, vref], 1e-3);
+%!test  # AbsTol option
+%! vopt = odeset ("AbsTol", 1e-5);
+%! vsol = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert ([vsol.x(end), vsol.y(end,:)], [2, fref], 1e-3);
+%!test  # AbsTol and RelTol option
+%! vopt = odeset ("AbsTol", 1e-8, "RelTol", 1e-8);
+%! vsol = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert ([vsol.x(end), vsol.y(end,:)], [2, fref], 1e-3);
+%!test  # RelTol and NormControl option -- higher accuracy
+%! vopt = odeset ("RelTol", 1e-8, "NormControl", "on");
+%! vsol = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert ([vsol.x(end), vsol.y(end,:)], [2, fref], 1e-5);
+%!test  # Keeps initial values while integrating
+%! vopt = odeset ("NonNegative", 2);
+%! vsol = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert ([vsol.x(end), vsol.y(end,:)], [2, 2, 0], 0.5);
+%!test  # Details of OutputSel and Refine can't be tested
+%! vopt = odeset ("OutputFcn", @fout, "OutputSel", 1, "Refine", 5);
+%! vsol = ode45 (@fpol, [0 2], [2 0], vopt);
+%!test  # Details of OutputSave can't be tested
+%! vopt = odeset ("OutputSave", 1, "OutputSel", 1);
+%! vsla = ode45 (@fpol, [0 2], [2 0], vopt);
+%! vopt = odeset ("OutputSave", 2);
+%! vslb = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert (length (vsla.x) + 1 >= 2 * length (vslb.x))
+%!test  # Stats must add further elements in vsol
+%! vopt = odeset ("Stats", "on");
+%! vsol = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert (isfield (vsol, "stats"));
+%! assert (isfield (vsol.stats, "nsteps"));
+%!test  # Events option add further elements in vsol
+%! vopt = odeset ("Events", @feve);
+%! vsol = ode45 (@fpol, [0 10], [2 0], vopt);
+%! assert (isfield (vsol, "ie"));
+%! assert (vsol.ie(1), 2);
+%! assert (isfield (vsol, "xe"));
+%! assert (isfield (vsol, "ye"));
+%!test  # Events option, now stop integration
+%! vopt = odeset ("Events", @fevn, "NormControl", "on");
+%! vsol = ode45 (@fpol, [0 10], [2 0], vopt);
+%! assert ([vsol.ie, vsol.xe, vsol.ye], 
+%!         [2.0, 2.496110, -0.830550, -2.677589], 6e-1);
+%!test  # Events option, five output arguments
+%! vopt = odeset ("Events", @fevn, "NormControl", "on");
+%! [vt, vy, vxe, vye, vie] = ode45 (@fpol, [0 10], [2 0], vopt);
+%! assert ([vie, vxe, vye],
+%!         [2.0, 2.496110, -0.830550, -2.677589], 6e-1);
+%!test  # Jacobian option
+%! vopt = odeset ("Jacobian", @fjac);
+%! vsol = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert ([vsol.x(end), vsol.y(end,:)], [2, fref], 1e-3);
+%!test  # Jacobian option and sparse return value
+%! vopt = odeset ("Jacobian", @fjcc);
+%! vsol = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert ([vsol.x(end), vsol.y(end,:)], [2, fref], 1e-3);
+%!
+%!## test for JPattern option is missing
+%!## test for Vectorized option is missing
+%!## test for NewtonTol option is missing
+%!## test for MaxNewtonIterations option is missing
+%!
+%!test  # Mass option as function
+%! vopt = odeset ("Mass", @fmas);
+%! vsol = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert ([vsol.x(end), vsol.y(end,:)], [2, fref], 1e-3);
+%!test  # Mass option as matrix
+%! vopt = odeset ("Mass", eye (2,2));
+%! vsol = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert ([vsol.x(end), vsol.y(end,:)], [2, fref], 1e-3);
+%!test  # Mass option as sparse matrix
+%! vopt = odeset ("Mass", sparse (eye (2,2)));
+%! vsol = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert ([vsol.x(end), vsol.y(end,:)], [2, fref], 1e-3);
+%!test  # Mass option as function and sparse matrix
+%! vopt = odeset ("Mass", @fmsa);
+%! vsol = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert ([vsol.x(end), vsol.y(end,:)], [2, fref], 1e-3);
+%!test  # Mass option as function and MStateDependence
+%! vopt = odeset ("Mass", @fmas, "MStateDependence", "strong");
+%! vsol = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert ([vsol.x(end), vsol.y(end,:)], [2, fref], 1e-3);
+%!test  # Set BDF option to something else than default
+%! vopt = odeset ("BDF", "on");
+%! [vt, vy] = ode45 (@fpol, [0 2], [2 0], vopt);
+%! assert ([vt(end), vy(end,:)], [2, fref], 1e-3);
+%!
+%!## test for MvPattern option is missing
+%!## test for InitialSlope option is missing
+%!## test for MaxOrder option is missing
+%!
+%! warning ("on", "OdePkg:InvalidArgument");
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/odeget.m	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,164 @@
+## 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 to @var{field} from @var{ode_opt}.
+##
+## If called 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)
+
+  if (nargin < 1 || nargin > 4)
+    print_usage ();
+  endif
+
+  ## Shortcut for empty options 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
+
+  if (nargin == 4 && strcmpi (opt, "fast"))
+    try
+      val = ode_opt.(field);
+    catch
+      val = default;
+    end_try_catch
+    return;
+  endif
+
+  if (nargin == 4 && strcmpi (opt, "fast_not_empty"))
+    try
+      val = ode_opt.(field);
+      if (isempty (val))
+        val = default;
+      endif
+    catch
+      val = default;
+    end_try_catch
+    return;
+  endif
+
+  ## Check if the given struct is a valid OdePkg struct
+  ode_struct_value_check (ode_opt);
+
+  ## Define all the possible OdePkg fields
+  persistent options = {"AbsTol"; "Algorithm"; "BDF"; "Choice"; "Eta"; "Events";
+                        "Explicit"; "InexactSolver"; "InitialSlope";
+                        "InitialStep"; "Jacobian"; "JConstant"; "JPattern";
+                        "Mass"; "MassConstant"; "MassSingular";
+                        "MaxNewtonIterations"; "MaxOrder"; "MaxStep";
+                        "MStateDependence"; "MvPattern"; "NewtonTol";
+                        "NonNegative"; "NormControl"; "OutputFcn"; "OutputSave";
+                        "OutputSel"; "PolynomialDegree"; "QuadratureOrder";
+                        "Refine"; "RelTol"; "Restart"; "Stats";
+                        "TimeStepNumber"; "TimeStepSize"; "UseJacobian";
+                        "Vectorized"};
+  
+  exactmatch = true;
+  match = find (strcmpi (field, options));
+  if (isempty (match))
+    match = find (strncmpi (field, options, length (field)));
+    exactmatch = false;
+  endif
+
+  if (isempty (match))
+    if (nargin == 2)
+      error ("odeget: invalid property '%s'", field);
+    else
+      ## FIXME: Should we warn, but complete the action, or just error out?
+      warning ("odeget:InvalidArgument",
+               "odeget: invalid property '%s'.  Using supplied default value.",
+               field);
+      val = default;
+    endif
+  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 OdePkg 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)
+%!error <invalid property 'foo'> odeget (struct ("opt1", 1), "foo")
+%!warning <Using supplied default value> odeget (struct ("opt1", 1), "foo", 3);
+%!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	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,312 @@
+## 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)
+
+  ## Special calling syntax to display defaults
+  if (nargin == 0 && nargout == 0)
+    print_options ();
+    return;
+  endif
+
+  ## Column vector of all possible OdePkg options
+  persistent options = {"AbsTol"; "Algorithm"; "BDF"; "Choice"; "Eta"; "Events";
+                        "Explicit"; "InexactSolver"; "InitialSlope";
+                        "InitialStep"; "Jacobian"; "JConstant"; "JPattern";
+                        "Mass"; "MassConstant"; "MassSingular";
+                        "MaxNewtonIterations"; "MaxOrder"; "MaxStep";
+                        "MStateDependence"; "MvPattern"; "NewtonTol";
+                        "NonNegative"; "NormControl"; "OutputFcn"; "OutputSave";
+                        "OutputSel"; "PolynomialDegree"; "QuadratureOrder";
+                        "Refine"; "RelTol"; "Restart"; "Stats";
+                        "TimeStepNumber"; "TimeStepSize"; "UseJacobian";
+                        "Vectorized"};
+
+  ## initialize output
+  odestruct = cell2struct (cell (numel (options), 1), options);
+
+  if (nargin == 0)
+    return;
+  endif
+
+  if (isstruct (varargin{1}))
+    oldstruct = varargin{1};
+    ode_struct_value_check (oldstruct);
+
+    oldstruct_fldnames = (fieldnames (oldstruct)).';
+
+    ## Copy oldstruct values into output odestruct
+    for fldname = oldstruct_fldnames
+      name = lower (fldname{1});
+
+      exactmatch = true;
+      match = find (strcmpi (name, options));
+      if (isempty (match))
+        match = find (strncmpi (name, options, length (name)));
+        exactmatch = false;
+      endif
+
+      if (isempty (match))
+        error ("odeset: invalid property '%s'", fldname{1});
+      elseif (numel (match) == 1)
+        if (! exactmatch)
+          warning ("odeset:NoExactMatching",
+                   "no exact match for '%s'.  Assuming '%s'.",
+                   name, options{match});
+        endif
+        odestruct.(options{match}) = oldstruct.(fldname{1});
+      else
+        error ("odeset: no exact match for '%s'.  Possible fields found: %s.",
+               name, strjoin (options(match), ", "));
+      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};
+      ode_struct_value_check (newstruct);
+
+      newstruct_fldnames = (fieldnames (newstruct)).';
+
+      ## Update the first struct with the values from the second one
+      for fldname = newstruct_fldnames
+        name = lower (fldname{1});
+
+        exactmatch = true;
+        match = find (strcmpi (name, options));
+        if (isempty (match))
+          match = find (strncmpi (name, options, length (name)));
+          exactmatch = false;
+        endif
+
+        if (isempty (match))
+          error ("odeset: invalid property '%s'", fldname{1});
+        elseif (numel (match) == 1)
+          if (! exactmatch)
+            warning ("odeset:NoExactMatching",
+                     "no exact match for '%s'.  Assuming '%s'.",
+                     name, options{match});
+          endif
+          odestruct.(options{match}) = newstruct.(fldname{1});
+        else
+          error ("odeset: no exact match for '%s'.  Possible fields found: %s.",
+                 name, strjoin (options(match), ", "));
+        endif
+      endfor
+
+      ## Done copying newstruct to oldstruct
+      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 = lower (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))
+        error ("odeset: invalid property '%s'", varargin{i});
+      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 OdePkg struct
+    ode_struct_value_check (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 = lower (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))
+        error ("odeset: invalid property '%s'", varargin{i});
+      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 OdePkg struct
+    ode_struct_value_check (odestruct);
+
+  endif
+
+endfunction
+
+## function useful to print all the 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 ("          Algorithm:  string, {['gmres'], 'pcg', 'bicgstab'}");
+  disp ("                BDF:  binary, {'on', ['off']}");
+  disp ("             Choice:  switch, {[1], 2}");
+  disp ("                Eta:  scalar, >=0, <1, [0.5]");
+  disp ("             Events:  function_handle, []");
+  disp ("           Explicit:  binary, {'yes', ['no']}");
+  disp ("      InexactSolver:  string, {'inexact_newton', 'fsolve', []}");
+  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 ("MaxNewtonIterations:  scalar, integer, >0, [1e3]");
+  disp ("           MaxOrder:  switch, {1, 2, 3, 4, [5]}");
+  disp ("            MaxStep:  scalar, >0, []");
+  disp ("   MStateDependence:  switch, {'none', ['weak'], 'strong'}");
+  disp ("          MvPattern:  sparse matrix, []");
+  disp ("          NewtonTol:  scalar or vector, >0, []");
+  disp ("        NonNegative:  vector of integers, []");
+  disp ("        NormControl:  binary, {'on', ['off']}");
+  disp ("          OutputFcn:  function_handle, []");
+  disp ("         OutputSave:  scalar, integer, >0, []");
+  disp ("          OutputSel:  scalar or vector, []");
+  disp ("   PolynomialDegree:  scalar, integer, >0, []");
+  disp ("    QuadratureOrder:  scalar, integer, >0, []");
+  disp ("             Refine:  scalar, integer, >0, []");
+  disp ("             RelTol:  scalar, >0, [1e-3]");
+  disp ("            Restart:  scalar, integer, >0, [20]");
+  disp ("              Stats:  binary, {'on', ['off']}");
+  disp ("     TimeStepNumber:  scalar, integer, >0, []");
+  disp ("       TimeStepSize:  scalar, >0, []");
+  disp ("        UseJacobian:  binary, {'yes', ['no']}");
+  disp ("         Vectorized:  binary, {'on', ['off']}");
+
+endfunction
+
+
+%!demo
+%! # A new OdePkg options structure with default values is created.
+%!
+%! odeoptA = odeset ();
+
+%!demo
+%! # A new OdePkg options structure with manually set options 
+%! # for "AbsTol" and "RelTol" is created.
+%!
+%! odeoptB = odeset ("AbsTol", 1e-2, "RelTol", 1e-1);
+
+%!demo
+%! # A new OdePkg 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 correct resp. valid option
+## has been set are implemented in ode_struct_value_check.m.
+%!test
+%! odeoptA = odeset ();
+%! assert (isstruct (odeoptA));
+%! fields = fieldnames (odeoptA); 
+%! assert (numel (fields), 37); 
+%! 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); 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/AbsRel_Norm.m	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,51 @@
+## Copyright (C) 2014, 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 res = AbsRel_Norm (x, x_old, AbsTol, RelTol, normcontrol, y)
+
+  n = length (x);
+
+  if (nargin == 5)
+    y = zeros (size (x));
+  elseif (nargin != 6)
+    error ("OdePkg:InvalidArgument",
+           "invalid number of input arguments");
+  endif
+
+  if (length (x_old) != n
+      || length (y) != n)
+    error ("OdePkg:InvalidArgument",
+           "invalid dimensions of input arguments");
+  endif
+  
+  if ((length (AbsTol) != 1 && length (AbsTol) != n)
+      || (length (RelTol) != 1 && length (RelTol) != n))
+    error ("OdePkg:InvalidArgument",
+           "invalid dimensions of input arguments");
+  endif
+  
+  sc = AbsTol + max (abs (x), abs (x_old)) .* RelTol;
+  if (normcontrol)
+    res = max (abs (x - y) ./ sc);
+  else
+    res = sqrt ((1 / n) * sum (((x - y) ./ sc).^2));
+  endif
+
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/integrate_adaptive.m	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,334 @@
+## 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}, @var{y}] =} integrate_adaptive (@var{@@stepper}, @var{order}, @var{@@fun}, @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.
+##
+## This function must be called with two output arguments: @var{t} and @var{y}.
+## Variable @var{t} is a column vector and contains the time stamps, instead
+## @var{y} is a matrix in which each column refers to a different unknown
+## of the problem and the rows number is the same of @var{t} rows number so
+## that each row of @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 an inline function
+## representing the stepper, that is 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 an inline function that
+## defines the set of 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 integration
+## interval, that is @var{[tspan(1),tspan(end)]} and all the 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)
+
+  solution = struct ();
+
+  ## first values for time and solution
+  t = tspan(1);
+  x = x0(:);
+  
+  ## get first initial timestep
+  dt = odeget (options, "InitialStep",
+               starting_stepsize (order, func, t, x, options.AbsTol,
+                                  options.RelTol, options.vnormcontrol),
+               "fast_not_empty");
+  vdirection = odeget (options, "vdirection", [], "fast");
+  if (sign (dt) != vdirection)
+    dt = -dt;
+  endif
+  dt = vdirection * min (abs (dt), options.MaxStep);
+
+  ## Set parameters
+  k = length (tspan);
+  counter = 2;
+  comp = 0.0;
+  tk = tspan(1);
+  options.comp = comp;
+  
+  ## Factor multiplying the stepsize guess
+  facmin = 0.8;
+  fac = 0.38^(1/(order+1));  # formula taken from Hairer
+  t_caught = false;
+
+
+  ## Initialize the OutputFcn
+  if (options.vhaveoutputfunction)
+    if (options.vhaveoutputselection)
+      solution.vretout = x(options.OutputSel,end);
+    else 
+      solution.vretout = x;
+    endif
+    feval (options.OutputFcn, tspan, solution.vretout,
+           "init", options.vfunarguments{:});
+  endif
+
+  ## Initialize the EventFcn
+  if (options.vhaveeventfunction)
+    odepkg_event_handle (options.Events, t(end), x,
+                         "init", options.vfunarguments{:});
+  endif
+
+  solution.vcntloop = 2;
+  solution.vcntcycles = 1;
+  vcntiter = 0;
+  solution.vunhandledtermination = true;
+  solution.vcntsave = 2;
+  
+  z = t;
+  u = x;
+
+  k_vals = []; 
+  
+  while (counter <= k)
+    facmax = 1.5;
+
+    ## Compute integration step from t to t+dt
+    if (isempty (k_vals))
+      [s, y, y_est, new_k_vals] = stepper (func, z(end), u(:,end),
+                                           dt, options);
+    else
+      [s, y, y_est, new_k_vals] = stepper (func, z(end), u(:,end),
+                                           dt, options, k_vals);
+    endif
+    
+    if (options.vhavenonnegative)
+      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.vhaveoutputfunction && options.vhaverefine)
+      vSaveVUForRefine = u(:,end);
+    endif
+
+    err = AbsRel_Norm (y(:,end), u(:,end), options.AbsTol, options.RelTol,
+                       options.vnormcontrol, y_est(:,end));
+    
+    ## Solution accepted only if the error is less or equal to 1.0
+    if (err <= 1)
+      
+      [tk, options.comp] = kahan (tk, options.comp, dt);
+      s(end) = tk;
+
+      ## values on this interval for time and solution
+      z = [z(end); s];
+      u = [u(:,end), y];
+      k_vals = new_k_vals;
+      
+      ## 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++;
+        
+        ## 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 (vdirection * z(end) > vdirection * tspan(counter))
+
+        ## initialize 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++;
+          endif
+          ## else, loop until there are requested values inside this subinterval
+          while ((counter <= k)
+                 && (vdirection * z(i) > vdirection * tspan(counter)))
+            ## choose interpolation scheme according to order of the solver
+
+            u_interp = ...
+            ode_rk_interpolate (order, [z(i-1) z(i)], [u(:,i-1) u(:,i)],
+                                tspan(counter), k_vals, dt,
+                                options.vfunarguments{:});
+            
+
+            ## add the interpolated value of the solution
+            u = [u(:,1:i-1), u_interp, u(:,i:end)];
+            
+            ## add the time requested
+            z = [z(1:i-1); tspan(counter); z(i:end)];
+
+            ## update counters
+            counter++;
+            i++;
+          endwhile
+
+          ## if new time requested is not out of this interval
+          if ((counter <= k)
+              && (vdirection * z(end) > vdirection * tspan(counter)))
+            ## update the counter
+            i++;
+          else
+            ## stop the cycle and go on with the next iteration
+            i = length (z) + 1;
+          endif
+
+        endwhile
+      endif
+
+      if (mod (solution.vcntloop-1, options.OutputSave) == 0)
+        x = [x,u(:,2:end)];
+        t = [t;z(2:end)];
+        solution.vcntsave = solution.vcntsave + 1;    
+      endif
+      solution.vcntloop = solution.vcntloop + 1;
+      vcntiter = 0;
+      
+      ## Call plot only if a valid result has been found, therefore this
+      ## code fragment has moved here.  Stop integration if plot function
+      ## returns false
+      if (options.vhaveoutputfunction)
+        for vcnt = 0:options.Refine  # Approximation between told and t
+          if (options.vhaverefine)   # Do interpolation
+            vapproxtime = (vcnt + 1) / (options.Refine + 2);
+            vapproxvals = (1 - vapproxtime) * vSaveVUForRefine ...
+                          + (vapproxtime) * y(:,end);
+            vapproxtime = s(end) + vapproxtime * dt;
+          else
+            vapproxvals = x(:,end);
+            vapproxtime = t(end);
+          endif
+          if (options.vhaveoutputselection)
+            vapproxvals = vapproxvals(options.OutputSel);
+          endif
+          vpltret = feval (options.OutputFcn, vapproxtime,
+                           vapproxvals, [], options.vfunarguments{:});
+          if (vpltret)  # Leave refinement loop
+            break;
+          endif
+        endfor
+        if (vpltret)  # Leave main loop
+          solution.vunhandledtermination = false;
+          break;
+        endif
+      endif
+      
+      ## Call event only if a valid result has been found, therefore this
+      ## code fragment has moved here.  Stop integration if veventbreak is
+      ## true
+      if (options.vhaveeventfunction)
+        solution.vevent = odepkg_event_handle (options.Events, t(end),
+                                               x(:,end), [],
+                                               options.vfunarguments{:});
+        if (! isempty (solution.vevent{1})
+            && solution.vevent{1} == 1)
+          t(solution.vcntloop-1,:) = solution.vevent{3}(end,:);
+          x(:,solution.vcntloop-1) = solution.vevent{4}(end,:)';
+          solution.vunhandledtermination = false; 
+          break;
+        endif
+      endif
+      
+    else
+      
+      facmax = 1.0;
+      
+    endif
+    
+    ## Compute next timestep, formula taken from Hairer
+    err += eps;    # adding an eps to avoid divisions by zero
+    dt = dt * min (facmax,
+                   max (facmin, fac * (1 / err)^(1 / (order + 1))));
+    dt = vdirection * min (abs (dt), options.MaxStep);
+    
+    ## Update counters that count the number of iteration cycles
+    solution.vcntcycles += 1;  # Needed for cost statistics
+    vcntiter += 1;  # Needed to find iteration problems
+
+    ## Stop solving because in the last 1000 steps no successful valid
+    ## value has been found
+    if (vcntiter >= 5000)
+      error (["Solving has not been successful.  The iterative",
+              " integration loop exited at time t = %f before endpoint at",
+              " tend = %f was reached.  This happened because the iterative",
+              " integration loop does not find a valid solution at this time",
+              " stamp.  Try to reduce the value of 'InitialStep' and/or",
+              " 'MaxStep' with the command 'odeset'.\n"],
+             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 (vdirection * z(end) < vdirection * tspan(end))
+    if (solution.vunhandledtermination == true)
+      error ("OdePkg:InvalidArgument",
+             ["Solving has not been successful.  The iterative",
+              " integration loop exited at time t = %f",
+              " before endpoint at tend = %f was reached.  This may",
+              " happen if the stepsize grows smaller than defined in",
+              " vminstepsize.  Try to reduce the value of 'InitialStep'",
+              " and/or 'MaxStep' with the command 'odeset'.\n"],
+             z(end), tspan(end));
+    else
+      warning ("OdePkg:InvalidArgument",
+               ["Solver has been stopped by a call of 'break' in the main",
+                " iteration loop at time t = %f before endpoint at tend = %f ",
+                " was reached.  This may happen because the @odeplot function",
+                " returned 'true' or the @event function returned",
+                " 'true'.\n"],
+               z(end), tspan(end));
+    endif
+  endif
+
+  ## Compute how many values are out of time inerval
+  d = vdirection * t((end-(j-1)):end) > vdirection * 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_const.m	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,285 @@
+## 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}, @var{y}] =} integrate_const (@var{@@stepper}, @var{@@fun}, @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}.
+##
+## This function must be called with two output arguments: @var{t} and @var{y}.
+## Variable @var{t} is a column vector and contains the time stamps, instead
+## @var{y} is a matrix in which each column refers to a different unknown of
+## the problem and the rows number is the same of @var{t} rows number so that
+## each row of @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 an inline function
+## representing the stepper, that is 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 an inline function that
+## defines the set of 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 time vector which defines integration
+## interval, that is @var{[tspan(1),tspan(end)]} and all the 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(:);
+
+  vdirection = odeget (options, "vdirection", [], "fast");
+  if (sign (dt) != vdirection)
+    error ("OdePkg:InvalidArgument",
+           "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.vhaveoutputfunction)
+    if (options.vhaveoutputselection)
+      solution.vretout = x(options.OutputSel,end);
+    else 
+      solution.vretout = x;
+    endif
+    feval (options.OutputFcn, tspan, solution.vretout, "init",
+           options.vfunarguments{:});
+  endif
+
+  ## Initialize the EventFcn
+  if (options.vhaveeventfunction)
+    odepkg_event_handle (options.Events, t(end), x, "init",
+                         options.vfunarguments{:});
+  endif
+  
+  solution.vcntloop = 2;
+  solution.vcntcycles = 1;
+  #vu = vinit;
+  #vk = vu.' * zeros(1,6);
+  vcntiter = 0;
+  solution.vunhandledtermination = true;
+  solution.vcntsave = 2;
+  
+  z = t;
+  u = x;
+  k_vals = feval (func, t , x, options.vfunarguments{:});
+
+  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.vhavenonnegative)
+      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.vhaveoutputfunction && options.vhaverefine)
+      vSaveVUForRefine = 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++;
+
+    ## 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 (vdirection * z(end) > vdirection * 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++;
+        endif
+        ## else, loop until there are requested values inside this subinterval
+        while ((counter <= k)
+               && vdirection * z(i) > vdirection * 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++;
+          i++;
+        endwhile
+
+        ## if new time requested is not out of this interval
+        if ((counter <= k)
+            && vdirection * z(end) > vdirection * tspan(counter))
+          ## update the counter
+          i++;
+        else
+          ## else, stop the cycle and go on with the next iteration
+          i = length (z)+1;
+        endif
+
+      endwhile
+    endif
+
+    if (mod (solution.vcntloop-1, options.OutputSave) == 0)
+      x = [x,u(:,2:end)];
+      t = [t;z(2:end)];
+      solution.vcntsave = solution.vcntsave + 1;    
+    endif
+    solution.vcntloop = solution.vcntloop + 1;
+    vcntiter = 0;
+      
+    ## Call plot only if a valid result has been found, therefore this
+    ## code fragment has moved here.  Stop integration if plot function
+    ## returns false
+    if (options.vhaveoutputfunction)
+      for vcnt = 0:options.Refine  # Approximation between told and t
+        if (options.vhaverefine)  # Do interpolation
+          vapproxtime = (vcnt + 1) / (options.Refine + 2);
+          vapproxvals = (1 - vapproxtime) * vSaveVUForRefine ...
+                        + (vapproxtime) * y(:,end);
+          vapproxtime = s(end) + vapproxtime*dt;
+        else
+          vapproxvals = x(:,end);
+          vapproxtime = t(end);
+        endif
+        if (options.vhaveoutputselection)
+          vapproxvals = vapproxvals(options.OutputSel);
+        endif
+        vpltret = feval (options.OutputFcn, vapproxtime, vapproxvals, [],
+                         options.vfunarguments{:});
+        if (vpltret)  # Leave refinement loop
+          break;
+        endif
+      endfor
+      if (vpltret)  # Leave main loop
+        solution.vunhandledtermination = false;
+        break;
+      endif
+    endif
+      
+    ## Call event only if a valid result has been found, therefore this
+    ## code fragment has moved here.  Stop integration if veventbreak is true
+    if (options.vhaveeventfunction)
+      solution.vevent = odepkg_event_handle (options.Events, t(end), x(:,end),
+                                             [], options.vfunarguments{:});
+      if (! isempty (solution.vevent{1})
+          && solution.vevent{1} == 1)
+        t(solution.vcntloop-1,:) = solution.vevent{3}(end,:);
+        x(:,solution.vcntloop-1) = solution.vevent{4}(end,:)';
+        solution.vunhandledtermination = false; 
+        break;
+      endif
+    endif
+    
+    ## Update counters that count the number of iteration cycles
+    solution.vcntcycles = solution.vcntcycles + 1;  # Needed for cost statistics
+    vcntiter = vcntiter + 1;  # Needed to find iteration problems
+
+    ## Stop solving because the last 1000 steps no successful valid
+    ## value has been found
+    if (vcntiter >= 5000)
+      error (["Solving has not been successful.  The iterative",
+              " integration loop exited at time t = %f before endpoint at",
+              " tend = %f was reached.  This happened because the iterative",
+              " integration loop does not find a valid solution at this time",
+              " stamp.  Try to reduce the value of 'InitialStep' and/or",
+              " 'MaxStep' with the command 'odeset'.\n"],
+             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 (vdirection * z(end) < vdirection * tspan(end))
+    if (solution.vunhandledtermination == true)
+      error ("OdePkg:InvalidArgument",
+             ["Solving has not been successful.  The iterative integration"
+              " loop exited at time t = %f before endpoint at tend = %f was",
+              " reached.  This may happen if the stepsize grows smaller than",
+              " defined in vminstepsize.  Try to reduce the value of",
+              " 'InitialStep' and/or 'MaxStep' with the command 'odeset'.\n"],
+             z(end), tspan(end));
+    else
+      warning ("OdePkg:InvalidArgument",
+               ["Solver has been stopped by a call of 'break' in the main",
+                " iteration loop at time t = %f before endpoint at tend = %f",
+                " was reached.  This may happen because the @odeplot function",
+                " returned 'true' or the @event function returned 'true'.\n"],
+               z(end), tspan(end));
+    endif
+  endif
+
+  ## compute how many values are out of time inerval
+  d = vdirection * t((end-(j-1)):end) > vdirection * 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	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,226 @@
+## 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}, @var{y}] =} integrate_n_steps (@var{@@stepper}, @var{@@fun}, @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.
+##
+## This function must be called with two output arguments: @var{t} and @var{y}.
+## Variable @var{t} is a column vector and contains the time stamps, instead
+## @var{y} is a matrix in which each column refers to a different unknown of
+## the problem and the rows number is the same of @var{t} rows number so that
+## each row of @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 an inline function
+## representing the stepper, that is 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 an inline function that
+## defines the set of 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;
+
+  vdirection = odeget (options, "vdirection", [], "fast");
+  if (sign (dt) != vdirection)
+    error ("OdePkg:InvalidArgument", "option 'InitialStep' has a wrong sign");
+  endif
+
+  comp = 0.0;
+  tk = t0;
+  options.comp = comp;
+  
+  ## Initialize the OutputFcn
+  if (options.vhaveoutputfunction)
+    if (options.vhaveoutputselection)
+      solution.vretout = x(options.OutputSel,end);
+    else 
+      solution.vretout = x;
+    endif
+    feval (options.OutputFcn, tspan, solution.vretout, "init",
+           options.vfunarguments{:});
+  endif
+
+  ## Initialize the EventFcn
+  if (options.vhaveeventfunction)
+    odepkg_event_handle (options.Events, t(end), x, "init",
+                         options.vfunarguments{:});
+  endif
+  
+  solution.vcntloop = 2;
+  solution.vcntcycles = 1;
+  #vu = vinit;
+  #vk = vu.' * zeros(1,6);
+  vcntiter = 0;
+  solution.vunhandledtermination = true;
+  solution.vcntsave = 2;
+  
+  z = t;
+  u = x;
+  k_vals = feval (func, t , x, options.vfunarguments{:});
+
+  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.vhavenonnegative)
+      x(options.NonNegative,end) = abs (x(options.NonNegative,end));
+      y(options.NonNegative,end) = abs (y(options.NonNegative,end));
+    endif
+    
+    if (options.vhaveoutputfunction && options.vhaverefine)
+      vSaveVUForRefine = u(:,end);
+    endif
+
+    ## values on this interval for time and solution
+    z = [t(end);s];
+    u = [x(:,end),y];
+
+    if (mod (solution.vcntloop-1, options.OutputSave) == 0)
+      x = [x,u(:,2:end)];
+      t = [t;z(2:end)];
+      solution.vcntsave = solution.vcntsave + 1;    
+    endif
+    solution.vcntloop = solution.vcntloop + 1;
+    vcntiter = 0;
+      
+    ## Call plot only if a valid result has been found, therefore this code
+    ## fragment has moved here.  Stop integration if plot function returns false
+    if (options.vhaveoutputfunction)
+      for vcnt = 0:options.Refine  # Approximation between told and t
+        if (options.vhaverefine)  # Do interpolation
+          vapproxtime = (vcnt + 1) / (options.Refine + 2);
+          vapproxvals = (1 - vapproxtime) * vSaveVUForRefine ...
+                        + (vapproxtime) * y(:,end);
+          vapproxtime = s(end) + vapproxtime*dt;
+        else
+          vapproxvals = x(:,end);
+          vapproxtime = t(end);
+        endif
+        if (options.vhaveoutputselection)
+          vapproxvals = vapproxvals(options.OutputSel);
+        endif
+        vpltret = feval (options.OutputFcn, vapproxtime, vapproxvals, [],
+                         options.vfunarguments{:});
+        if (vpltret)  # Leave refinement loop
+          break;
+        endif
+      endfor
+      if (vpltret)  # Leave main loop
+        solution.vunhandledtermination = false;
+        break;
+      endif
+    endif
+      
+    ## Call event only if a valid result has been found, therefore this
+    ## code fragment has moved here.  Stop integration if veventbreak is
+    ## true
+    if (options.vhaveeventfunction)
+      solution.vevent = odepkg_event_handle (options.Events, t(end), x(:,end),
+                                             [], options.vfunarguments{:});
+      if (! isempty (solution.vevent{1})
+          && solution.vevent{1} == 1)
+        t(solution.vcntloop-1,:) = solution.vevent{3}(end,:);
+        x(:,solution.vcntloop-1) = solution.vevent{4}(end,:)';
+        solution.vunhandledtermination = false; 
+        break;
+      endif
+    endif
+    
+    ## Update counters that count the number of iteration cycles
+    solution.vcntcycles = solution.vcntcycles + 1;  # Needed for cost statistics
+    vcntiter = vcntiter + 1;  # Needed to find iteration problems
+
+    ## Stop solving because the last 1000 steps no successful valid
+    ## value has been found
+    if (vcntiter >= 5000)
+      error (["Solving has not been successful.  The iterative",
+              " integration loop exited at time t = %f before endpoint at",
+              " tend = %f was reached.  This happened because the iterative",
+              " integration loop does not find a valid solution at this time",
+              " stamp.  Try to reduce the value of 'InitialStep' and/or",
+              " 'MaxStep' with the command 'odeset'.\n"],
+             s(end), tspan(end));
+    endif
+  endfor
+
+  ## Check if integration of the ode has been successful
+  #if (vdirection * z(end) < vdirection * tspan(end))
+  #  if (solution.vunhandledtermination == true)
+  #    error ("OdePkg:InvalidArgument",
+  #           ["Solving has not been successful.  The iterative",
+  #            " integration loop exited at time t = %f",
+  #            " before endpoint at tend = %f was reached.  This may",
+  #            " happen if the stepsize grows smaller than defined in",
+  #            " vminstepsize.  Try to reduce the value of 'InitialStep'",
+  #            " and/or 'MaxStep' with the command 'odeset'.\n"],
+  #           z(end), tspan(end));
+  #  else
+  #    warning ("OdePkg:InvalidArgument",
+  #             ["Solver has been stopped by a call of 'break' in the main",
+  #              " iteration loop at time t = %f before endpoint at tend = %f",
+  #              " was reached.  This may happen because the @odeplot function",
+  #              " returned 'true' or the @event function returned",
+  #              " 'true'.\n"],
+  #             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	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,53 @@
+## 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{temp})
+## @deftypefnx {Function File} {[@var{sum}, @var{comp}] =} kahan (@var{sum}, @var{comp}, @var{temp})
+##
+## This function is the implementation of the Kahan summation algorithm,
+## also known as compensated summation.
+##
+## It significantly reduces the numerical error in the total obtained by adding
+## a sequence of finite precision floating point numbers, compared to the
+## obvious approach.  For more details
+## see @url{http://en.wikipedia.org/wiki/Kahan_summation_algorithm}.
+## This function is called in @command{integrate_adaptive} and in
+## @command{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 kahan function.
+##
+## The second input argument contains the compensation term and it is returned
+## as second output argument so that it can be reused in the next calls of the
+## same computation.
+##
+## The third input argument is the variable that contains the term 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_rk_interpolate.m	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,106 @@
+## 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 = ode_rk_interpolate (order, z, u, t, k_vals, dt, args)
+
+  switch order
+
+    #{
+    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.vfunarguments{:});
+      ## 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/ode_struct_value_check.m	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,391 @@
+## 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{arg})
+## @deftypefnx {Function File} {} ode_struct_value_check (@var{arg}, @var{"solver"})
+##
+## If this function is called with one input argument of type structure array
+## then check the field names and the field values of the OdePkg structure
+## @var{arg}.  Optionally if this function is called with a second input
+## argument @var{"solver"} of type string that specifies the name of a valid
+## OdePkg solver then a higher level error detection is performed.  The function
+## does not modify any of the field names or field values but terminates with
+## an error if an invalid option or value is found.
+##
+## This function is an OdePkg internal helper function; Therefore, it should
+## never be necessary for a user to call this function directly.
+## @end deftypefn
+##
+## @seealso{odeset, odeget}
+
+function ode_struct_value_check (arg, solver = [])
+
+  fields = (fieldnames (arg)).';
+  fields_nb = length (fields);
+
+  for fldname = fields  # Cycle over all fields
+    opt = fldname{1};
+    val = arg.(opt);
+
+    switch (opt)
+
+      case "AbsTol"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isreal (val)
+              || ! isvector (val) || any (val <= 0))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "Algorithm"
+        if (! isempty (val))
+          if (! ischar (val))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "BDF"
+        if (! isempty (val))
+          if (! strcmp (val, "on") && ! strcmp (val, "off"))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "Choice"
+        if (! isempty (val))
+          if (! isnumeric (val))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          elseif (val != 1 && val != 2)
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "Eta"
+        if (! isempty (val))
+          if (! isreal (val) || val < 0 || val >= 1)
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "Events"
+        if (! isempty (val))
+          if (! isa (val, "function_handle"))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "Explicit"
+        if (! isempty (val))
+          if (! strcmp (val, "yes") && ! strcmp (val, "no"))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "InexactSolver"
+        if (! isempty (val))
+          if (! ischar (val))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "InitialSlope"
+        if (! isempty (val))
+          if (! ischar (val)
+              && (! isnumeric (val) || (! isvector (val) && ! isreal (val))))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "InitialStep"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isreal (val) || ! isscalar (val)
+              || val <= 0)
+            error ("OdePkg:InvalidArgument",
+                   "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 ("OdePkg:InvalidArgument",
+                     "invalid value assigned to field %s", opt);
+            endif
+          endif
+        endif
+
+      case "JConstant"
+        if (! isempty (val))
+          if (! strcmp (val, "on") && ! strcmp (val, "off"))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "JPattern"
+        if (! isempty (val))
+          if (! isnumeric (val) && ! isvector (val))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "Mass"
+        if (! isempty (val))
+          if ((! isnumeric (val) || ! ismatrix (val))
+              && ! isa (val, "function_handle"))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "MassConstant"
+        if (! isempty (val))
+          if (! strcmp (val, "on") && ! strcmp (val, "off"))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "MassSingular"
+        if (! isempty (val))
+          if (! any (strcmp (val, {"yes", "no", "maybe"})))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "MaxNewtonIterations"
+        if (! isempty (val))
+          if (! isnumeric (val)
+              || val != fix (val) || val <= 0)
+            error ("OdePkg:InvalidArgument",
+                   "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 ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "MaxStep"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isscalar (val) || val <= 0)
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "MStateDependence"
+        if (! isempty (val))
+          if (! any (strcmp (val, {"none", "weak", "strong"})))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "MvPattern"
+        if (! isempty (val))
+          if (! isnumeric (val) && ! isvector (val))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "NewtonTol"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isreal (val) || any (val <= 0))
+            error ("OdePkg:InvalidArgument",
+                   "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 ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "NormControl"
+        if (! isempty (val))
+          if (! strcmp (val, "on") && ! strcmp (val, "off"))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "OutputFcn"
+        if (! isempty (val))
+          if (! isa (val, "function_handle"))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "OutputSave"
+        if (! isempty (val))
+          if (! isscalar (val) && val != Inf)
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          elseif ((val != fix (val) || val <= 0) && val != Inf)
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "OutputSel"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isvector (val))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "PolynomialDegree"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isvector (val) || any (val <= 0))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "QuadratureOrder"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isvector (val) || any (val <= 0))
+            error ("OdePkg:InvalidArgument",
+                   "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 ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "RelTol"
+        if (! isempty (val))
+          if (! isnumeric (val) || ! isreal (val) || any (val <= 0))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+          if (any (strcmp (solver, {"ode23", "ode23d", "ode45", "ode45d",
+                                    "ode54", "ode54d", "ode78", "ode78d"})))
+            if (! isscalar (val))
+              error ("OdePkg:InvalidArgument",
+                     "invalid value assigned to field %s", opt);
+            endif
+          endif
+        endif
+
+      case "Restart"
+        if (! isempty (val))
+          if (! isnumeric (val) || val != fix (val) || val <= 0)
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "Stats"
+        if (! isempty (val))
+          if (! strcmp (val, "on") && ! strcmp (val, "off"))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "TimeStepNumber"
+        if (! isempty (val))
+          if (val != fix (val) || val <= 0)
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "TimeStepSize"
+        if (! isempty (val))
+          if (! isreal (val) || val == 0)
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "UseJacobian"
+        if (! isempty (val))
+          if (! strcmp (val, "yes") && ! strcmp (val, "no"))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      case "Vectorized"
+        if (! isempty (val))
+          if (! strcmp (val, "on") && ! strcmp (val, "off"))
+            error ("OdePkg:InvalidArgument",
+                   "invalid value assigned to field %s", opt);
+          endif
+        endif
+
+      otherwise
+        warning ("OdePkg:InvalidArgument",
+                 "invalid field '%s' in ODE options", opt);
+    endswitch
+  endfor
+
+endfunction
+
+
+%!demo
+%! # Return the checked OdePkg options structure that is created by
+%! # the command odeset.
+%!
+%! ode_struct_value_check (odeset);
+%!
+%!demo
+%! # Create the OdePkg options structure A with odeset and check it 
+%! # with odepkg_structure_check.  This actually is unnecessary
+%! # because odeset automatically calls odepkg_structure_check before
+%! # returning.
+%!
+%! A = odeset ();
+%! ode_struct_value_check (A);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/odepkg_event_handle.m	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,157 @@
+## 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} =} odepkg_event_handle (@var{@@fun}, @var{time}, @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{@@fun} in the form of a function handle.
+##
+## The second input argument @var{time} 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
+## @command{odepkg_event_handle} 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
+## @command{odepkg_event_handle} 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
+## @command{odepkg_event_handle} to the event function.
+##
+## This function is an OdePkg 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 vretval = odepkg_event_handle (vevefun, vt, vy, vflag, varargin)
+
+  ## No error handling has been implemented in this function to achieve
+  ## the highest performance available.
+
+  ## vretval{1} is true or false; either to terminate or to continue
+  ## vretval{2} is the index information for which event occured
+  ## vretval{3} is the time information column vector
+  ## vretval{4} is the line by line result information matrix
+
+  ## These persistent variables are needed to store the results and the
+  ## time value from the processing in the time stamp before, veveold
+  ## are the results from the event function, vtold the time stamp,
+  ## vretcell the return values cell array, vyold the result of the ode
+  ## and vevecnt the counter for how often this event handling
+  ## has been called
+  persistent veveold;  persistent vtold;
+  persistent vretcell; persistent vyold;
+  persistent vevecnt;
+
+  ## Call the event function if an event function has been defined to
+  ## initialize the internal variables of the event function an to get
+  ## a value for veveold
+  if (strcmp (vflag, "init"))
+
+    if (! iscell (vy))
+      vinpargs = {vevefun, vt, vy};
+    else
+      vinpargs = {vevefun, vt, vy{1}, vy{2}};
+      vy = vy{1};  # Delete cell element 2
+    endif
+    if (nargin > 4)
+      vinpargs = {vinpargs{:}, varargin{:}};
+    endif
+    [veveold, vterm, vdir] = feval (vinpargs{:});
+
+    ## We assume that all return values must be column vectors
+    veveold = veveold(:)'; vterm = vterm(:)'; vdir = vdir(:)';
+    vtold = vt; vyold = vy; vevecnt = 1; vretcell = cell (1,4);
+
+  ## Process the event, find the zero crossings either for a rising
+  ## or for a falling edge
+  elseif (isempty (vflag))
+
+    if (! iscell (vy))
+      vinpargs = {vevefun, vt, vy};
+    else
+      vinpargs = {vevefun, vt, vy{1}, vy{2}};
+      vy = vy{1};  # Delete cell element 2
+    endif
+    if (nargin > 4)
+      vinpargs = {vinpargs{:}, varargin{:}};
+    endif
+    [veve, vterm, vdir] = feval (vinpargs{:});
+
+    ## We assume that all return values must be column vectors
+    veve = veve(:)'; vterm = vterm(:)'; vdir = vdir(:)';
+
+    ## Check if one or more signs of the event has changed
+    vsignum = (sign (veveold) != sign (veve));
+    if (any (vsignum))          # One or more values have changed
+      vindex = find (vsignum);  # Get the index of the changed values
+
+      if (any (vdir(vindex) == 0))
+        ## Rising or falling (both are possible)
+        ## Don't change anything, keep the index
+      elseif (any (vdir(vindex) == sign (veve(vindex))))
+        ## Detected rising or falling, need a new index
+        vindex = find (vdir == sign (veve));
+      else
+        ## Found a zero crossing but must not be notified
+        vindex = [];
+      endif
+
+      ## Create new output values if a valid index has been found
+      if (! isempty (vindex))
+        ## Change the persistent result cell array
+        vretcell{1} = any (vterm(vindex));     # Stop integration or not
+        vretcell{2}(vevecnt,1) = vindex(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
+        vtnew = vt - veve(1,vindex) * (vt - vtold) / ...
+                                      (veve(1,vindex) - veveold(1,vindex));
+        vynew = (vy - (vt - vtnew) * (vy - vyold) / (vt - vtold))';
+        vretcell{3}(vevecnt,1) = vtnew;
+        vretcell{4}(vevecnt,:) = vynew;
+        vevecnt = vevecnt + 1;
+      endif
+
+    endif  # Check for one or more signs ...
+    veveold = veve; vtold = vt; vretval = vretcell; vyold = vy;
+
+  elseif (strcmp (vflag, "done"))  # Clear this event handling function
+    clear ("veveold", "vtold", "vretcell", "vyold", "vevecnt");
+    vretcell = cell (1,4);
+
+  endif
+endfunction
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/odepkg_structure_check.m	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,498 @@
+## 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{newstruct} =} odepkg_structure_check (@var{oldstruct})
+## @deftypefnx {Function File} {@var{newstruct} =} odepkg_structure_check (@var{oldstruct}, @var{"solver"})
+##
+## If this function is called with one input argument of type structure array
+## then check the field names and the field values of the OdePkg structure
+## @var{oldstruct} and return the structure as @var{newstruct} if no error is
+## found.
+##
+## Optionally if this function is called with a second input argument
+## @var{"solver"} of type string taht specifies the name of a valid OdePkg
+## solver then a higher level error detection is performed.  The function
+## does not modify any of the field names or field values but terminates with
+## an error if an invalid option or value is found.
+##
+## This function is an OdePkg 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.
+##
+## Run examples with the command
+##
+## @example
+## demo odepkg_structure_check
+## @end example
+## @end deftypefn
+##
+## @seealso{odepkg}
+
+function vret = odepkg_structure_check (varargin)
+
+  ## Check the number of input arguments
+  if (nargin == 0)
+    help ("odepkg_structure_check");
+    error ("OdePkg:InvalidArgument",
+           "Number of input arguments must be greater than zero");
+  elseif (nargin > 2)
+    print_usage ();
+  elseif (nargin == 1 && isstruct (varargin{1}))
+    vret = varargin{1};
+    vsol = "";
+    vfld = fieldnames (vret);
+    vlen = length (vfld);
+  elseif (nargin == 2 && isstruct (varargin{1}) && ischar (varargin{2}))
+    vret = varargin{1};
+    vsol = varargin{2};
+    vfld = fieldnames (vret);
+    vlen = length (vfld);
+  endif
+
+  for vcntarg = 1:vlen  # Run through the number of given structure field names
+
+    switch (vfld{vcntarg})
+
+      case "RelTol"
+        if (isempty   (vret.(vfld{vcntarg})) || ...
+           (isnumeric (vret.(vfld{vcntarg})) && ...
+           isreal    (vret.(vfld{vcntarg})) && ...
+           all       (vret.(vfld{vcntarg}) > 0)))  # "all" is a MatLab need
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+        if (any (strcmp (vsol, {"ode23", "ode45", "ode54", "ode78", 
+                                "ode23d", "ode45d", "ode54d", "ode78d"})))
+          if (! isscalar (vret.(vfld{vcntarg}))
+              && ! isempty (vret.(vfld{vcntarg})))
+            error ("OdePkg:InvalidParameter",
+                   'Value of option "RelTol" must be a scalar');
+          endif
+        endif
+
+      case "AbsTol"
+        if (isempty   (vret.(vfld{vcntarg})) || ...
+           (isnumeric (vret.(vfld{vcntarg})) && ...
+            isreal    (vret.(vfld{vcntarg})) && ...
+            all       (vret.(vfld{vcntarg}) > 0)))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "NormControl"
+        if (isempty   (vret.(vfld{vcntarg})) || ...
+           (strcmp (vret.(vfld{vcntarg}), "on") || ...
+            strcmp (vret.(vfld{vcntarg}), "off")))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "NonNegative"
+        if (isempty  (vret.(vfld{vcntarg})) || ...
+            (isnumeric (vret.(vfld{vcntarg}))
+             && isvector (vret.(vfld{vcntarg}))))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "OutputFcn"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            isa     (vret.(vfld{vcntarg}), "function_handle"))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "OutputSel"
+        if (isempty  (vret.(vfld{vcntarg})) || ...
+            (isnumeric (vret.(vfld{vcntarg}))
+             && isvector (vret.(vfld{vcntarg}))) || ...
+            isscalar (vret.(vfld{vcntarg})))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "OutputSave"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            (isscalar (vret.(vfld{vcntarg})) && ...
+             mod (vret.(vfld{vcntarg}), 1) == 0 && ...
+             vret.(vfld{vcntarg}) > 0) || ...
+            vret.(vfld{vcntarg}) == Inf)
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+        
+      case "Refine"
+        if (isempty   (vret.(vfld{vcntarg})) || ...
+           (isscalar (vret.(vfld{vcntarg})) && ...
+            mod (vret.(vfld{vcntarg}), 1) == 0 && ...
+            vret.(vfld{vcntarg}) >= 0 && ...
+            vret.(vfld{vcntarg}) <= 5))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "Stats"
+        if (isempty   (vret.(vfld{vcntarg})) || ...
+           (strcmp (vret.(vfld{vcntarg}), "on") || ...
+            strcmp (vret.(vfld{vcntarg}), "off")))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "InitialStep"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            (isscalar (vret.(vfld{vcntarg})) && ...
+             isreal (vret.(vfld{vcntarg}))))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "MaxStep"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            (isscalar (vret.(vfld{vcntarg})) && ...
+             vret.(vfld{vcntarg}) > 0) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "Events"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            isa     (vret.(vfld{vcntarg}), "function_handle"))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "Jacobian"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            isnumeric (vret.(vfld{vcntarg})) || ...
+            isa (vret.(vfld{vcntarg}), "function_handle") || ...
+            iscell (vret.(vfld{vcntarg})))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "JPattern"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            isvector (vret.(vfld{vcntarg})) || ...
+            isnumeric (vret.(vfld{vcntarg})))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "Vectorized"
+        if (isempty   (vret.(vfld{vcntarg})) || ...
+           (strcmp (vret.(vfld{vcntarg}), "on") || ...
+            strcmp (vret.(vfld{vcntarg}), "off")))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "Mass"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            (isnumeric (vret.(vfld{vcntarg})) || ...
+            isa (vret.(vfld{vcntarg}), "function_handle")))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "MStateDependence"
+        if (isempty   (vret.(vfld{vcntarg})) || ...
+           (strcmp (vret.(vfld{vcntarg}), "none") || ...
+            strcmp (vret.(vfld{vcntarg}), "weak") || ...
+            strcmp (vret.(vfld{vcntarg}), "strong")))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "MvPattern"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            (isvector (vret.(vfld{vcntarg})) || ...
+            isnumeric (vret.(vfld{vcntarg}))))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "MassSingular"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            (strcmp (vret.(vfld{vcntarg}), "yes") || ...
+            strcmp (vret.(vfld{vcntarg}), "no") || ...
+            strcmp (vret.(vfld{vcntarg}), "maybe")))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "InitialSlope"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            isvector (vret.(vfld{vcntarg})))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "MaxOrder"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            (mod (vret.(vfld{vcntarg}), 1) == 0 && ...
+             vret.(vfld{vcntarg}) > 0 && ...
+             vret.(vfld{vcntarg}) < 8))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "BDF"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            (strcmp (vret.(vfld{vcntarg}), "on") || ...
+             strcmp (vret.(vfld{vcntarg}), "off")))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "NewtonTol"
+        if (isempty   (vret.(vfld{vcntarg})) || ...
+           (isnumeric (vret.(vfld{vcntarg})) && ...
+            isreal    (vret.(vfld{vcntarg})) && ...
+            all       (vret.(vfld{vcntarg}) > 0)))  # "all" is a MatLab need
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "MaxNewtonIterations"
+        if (isempty (vret.(vfld{vcntarg})) || ...
+            (mod (vret.(vfld{vcntarg}), 1) == 0 && ...
+             vret.(vfld{vcntarg}) > 0))
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      ## new fields added
+      case "Algorithm"
+        if ( isempty (vret.(vfld{vcntarg})) || ischar (vret.(vfld{vcntarg})) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "Choice"
+        if ( isempty (vret.(vfld{vcntarg}))
+            || (isnumeric (vret.(vfld{vcntarg})) && (vret.(vfld{vcntarg})==1)
+                || vret.(vfld{vcntarg})==2 ) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "Eta"
+        if ( isempty (vret.(vfld{vcntarg}))
+            || ( isreal (vret.(vfld{vcntarg}))
+                && vret.(vfld{vcntarg})>=0 && vret.(vfld{vcntarg})<1) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "Explicit"
+        if ( isempty (vret.(vfld{vcntarg}))
+            || (ischar (vret.(vfld{vcntarg}))
+                && (strcmp (vret.(vfld{vcntarg}),"yes")
+                || strcmp (vret.(vfld{vcntarg}),"no"))) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "InexactSolver"
+        if ( isempty (vret.(vfld{vcntarg})) || ischar (vret.(vfld{vcntarg})) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "InitialSlope"
+        if ( isempty (vret.(vfld{vcntarg}))
+            || ( ischar (vret.(vfld{vcntarg}))
+                || (isnumeric (vret.(vfld{vcntarg}))
+                    && (isvector (vret.(vfld{vcntarg}))
+                        || isreal (vret.(vfld{vcntarg}))))) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "JConstant"
+        if ( isempty (vret.(vfld{vcntarg}))
+            || (ischar (vret.(vfld{vcntarg}))
+                && (strcmp (vret.(vfld{vcntarg}),"yes")
+                    || strcmp (vret.(vfld{vcntarg}),"no"))) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "MassConstant"
+        if ( isempty (vret.(vfld{vcntarg}))
+            || (strcmp (vret.(vfld{vcntarg}),"on")
+                || strcmp (vret.(vfld{vcntarg}),"off")) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "PolynomialDegree"
+        if ( isempty (vret.(vfld{vcntarg}))
+            || (isnumeric (vret.(vfld{vcntarg}))
+                && mod(vret.(vfld{vcntarg}),1)==0 && vret.(vfld{vcntarg})>0) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "QuadratureOrder"
+        if ( isempty (vret.(vfld{vcntarg}))
+            || (isnumeric (vret.(vfld{vcntarg}))
+                && mod(vret.(vfld{vcntarg}),1)==0 && vret.(vfld{vcntarg})>0) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "Restart"
+        if ( isempty (vret.(vfld{vcntarg}))
+            || (isnumeric (vret.(vfld{vcntarg}))
+                && mod(vret.(vfld{vcntarg}),1)==0 && vret.(vfld{vcntarg})>0) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "TimeStepNumber"
+        if ( isempty (vret.(vfld{vcntarg}))
+            || (isnumeric (vret.(vfld{vcntarg}))
+                && mod(vret.(vfld{vcntarg}),1)==0 && vret.(vfld{vcntarg})>0) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "TimeStepSize"
+        if ( isempty (vret.(vfld{vcntarg}))
+            || ( isreal (vret.(vfld{vcntarg})) && vret.(vfld{vcntarg})!=0) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      case "UseJacobian"
+        if ( isempty (vret.(vfld{vcntarg}))
+            || (ischar (vret.(vfld{vcntarg}))
+                && (strcmp (vret.(vfld{vcntarg}),"yes")
+                    || strcmp (vret.(vfld{vcntarg}),"no"))) )
+        else
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s" or no valid parameter value',
+                 vfld{vcntarg});
+        endif
+
+      otherwise
+          error ("OdePkg:InvalidParameter",
+                 'Unknown parameter name "%s"',
+                 vfld{vcntarg});
+
+    endswitch
+
+  endfor
+
+endfunction
+
+
+%!demo
+%! # Return the checked OdePkg options structure that is created by
+%! # the command odeset.
+%!
+%! odepkg_structure_check (odeset);
+
+%!demo
+%! # Create the OdePkg options structure A with odeset and check it 
+%! # with odepkg_structure_check.  This actually is unnecessary
+%! # because odeset automatically calls odepkg_structure_check before
+%! # returning.
+%!
+%! A = odeset (); odepkg_structure_check (A);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/ode/private/runge_kutta_45_dorpri.m	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,113 @@
+## 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 a 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 a FSAL scheme.
+## @end deftypefn
+##
+## @seealso{odepkg}
+
+function [t_out, x_out, x_est, k] = ...
+         runge_kutta_45_dorpri (f, t, x, dt, varargin)
+
+  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)];
+  ## x_est according to Shampine 1986:
+  ## persistent c_prime = [(1951/21600) 0 (22642/50085) (451/720), ...
+  ##                       (-12231/42400) (649/6300) (1/60)];
+  persistent c_prime = [(5179/57600) 0 (7571/16695) (393/640), ...
+                        (-92097/339200) (187/2100)  (1/40)];
+
+  s = t + dt * b;
+  cc = dt * c;
+  aa = dt * a;
+  k = zeros (rows (x), 7);
+
+  if (nargin >= 5)  # options are passed
+    args = varargin{1}.vfunarguments;
+    if (nargin >= 6)  # both the options and the k values are passed
+      k(:,1) = varargin{2}(:,end);  # FSAL property
+    else      
+      k(:,1) = feval (f, t, x, args{:});
+    endif
+  else
+    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_out = t + dt;
+  x_out = 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 + dt, x_out, 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/starting_stepsize.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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{@@fun}, @var{t0}, @var{x0})
+##
+## This function file can be used to determine a good initial step for an ODE
+## solver of order @var{order}.  The algorithm is that one described in [1].
+##
+## Second input argument, which is @var{@@fun}, is the function describing
+## the differential equations, @var{t0} is the initial time and @var{x0} is
+## the initial condition.
+## 
+## This function returns a good guess for the initial timestep @var{h}.
+##
+## References:
+## [1] E. Hairer, S.P. Norsett and G. Wanner,
+## "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/fminsearch.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/optimization/fminsearch.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/lsqnonneg.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/optimization/lsqnonneg.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/optimization/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/qp.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/optimization/qp.m	Sat Oct 10 16:52:59 2015 -0700
@@ -116,13 +116,12 @@
 
 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--;
@@ -130,6 +129,10 @@
     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/path/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/path/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/path/savepath.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/pkg/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/pkg/pkg.m	Sat Oct 10 16:52:59 2015 -0700
@@ -362,22 +362,20 @@
   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
 
@@ -428,13 +426,13 @@
       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);
@@ -461,11 +459,11 @@
       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
@@ -481,11 +479,11 @@
       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
@@ -506,7 +504,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,7 +512,7 @@
                                   auto, verbose);
         local_packages = save_order (local_packages);
         save (local_list, "local_packages");
-        if (nargout == 0)
+        if (! nargout)
           clear ("local_packages");
         endif
       endif
@@ -530,48 +528,36 @@
         error ("you must specify at least one package or 'all' when calling 'pkg describe'");
       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 ("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;
+      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");
--- a/scripts/pkg/private/installed_packages.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/pkg/private/installed_packages.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/appearance/annotation.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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));
--- a/scripts/plot/appearance/axis.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/appearance/axis.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/legend.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/appearance/legend.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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",
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/appearance/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/specular.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/appearance/specular.m	Sat Oct 10 16:52:59 2015 -0700
@@ -88,7 +88,7 @@
 
   ## Allow postive values only
   retval(retval < 0) = 0;
-  retval = retval .^ se;
+  retval .^= se;
 
 endfunction
 
--- a/scripts/plot/appearance/text.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/appearance/text.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/draw/colorbar.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/colorbar.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/errorbar.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/hist.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/hist.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/loglogerr.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/plotmatrix.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/plotmatrix.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/polar.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/__contour__.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/private/__contour__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -28,40 +28,42 @@
 
   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
+    else  # skip numeric arguments
       i++;
     endif
   endwhile
--- a/scripts/plot/draw/private/__errcomm__.m	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/private/__errplot__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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")),
--- a/scripts/plot/draw/private/__scatter__.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/private/__scatter__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/private/__stem__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/semilogxerr.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/semilogxerr.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/semilogyerr.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/surfnorm.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/draw/surfnorm.m	Sat Oct 10 16:52:59 2015 -0700
@@ -41,7 +41,13 @@
 ##
 ## 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
+## mag = sqrt (nx.^2 + ny.^2 + nz.^2);
+## nx ./= len;  ny ./= len;  nz ./= len;
+## @end example
 ##
 ## An example of the use of @code{surfnorm} is
 ##
@@ -50,10 +56,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 +94,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 +127,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 +140,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 +179,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/__actual_axis_position__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/__gnuplot_drawnow__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/__pltopt__.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/__pltopt__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/cla.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/findobj.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/findobj.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/ginput.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/graphics_toolkit.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -1,88 +1,101 @@
-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 \
+  scripts/plot/util/private/__tight_eps_bbox__.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/print.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/print.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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 x2tics;\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 ("__gnuplot_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 ("__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++;
+            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 ("__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} = 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.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 = 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 ("__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++;
+          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 -= 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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/private/__gnuplot_get_var__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/private/__gnuplot_ginput__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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);
--- a/scripts/plot/util/private/__gnuplot_has_feature__.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/private/__gnuplot_has_feature__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/private/__gnuplot_print__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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"));
--- a/scripts/plot/util/private/__go_draw_axes__.m	Sat Oct 10 16:46:00 2015 -0700
+++ /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 x2tics;\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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/private/__opengl_print__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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";
--- a/scripts/plot/util/private/__print_parse_opts__.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/private/__print_parse_opts__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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
@@ -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/rotate.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/plot/util/rotate.m	Sat Oct 10 16:52:59 2015 -0700
@@ -111,7 +111,7 @@
     origin = [a, b, c];
   endif
 
-  direction = direction / norm (direction);
+  direction /= norm (direction);
 
   u = direction(1);
   v = direction(2);
--- a/scripts/polynomial/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/polynomial/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/polynomial/pchip.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/polynomial/polyaffine.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/polynomial/polyder.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/polynomial/private/__splinefit__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/polynomial/residue.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/prefs/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/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/prefdir.m \
+  scripts/prefs/preferences.m \
+  scripts/prefs/rmpref.m \
+  scripts/prefs/setpref.m
+
+scripts_prefsdir = $(fcnfiledir)/prefs
 
-FCN_FILES += $(prefs_FCN_FILES)
+scripts_prefs_DATA = $(scripts_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/set/intersect.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/set/intersect.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/set/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/private/validsetargs.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/set/private/validsetargs.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/set/setdiff.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/set/setxor.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/set/union.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/signal/arch_fit.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/signal/arch_rnd.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/signal/bartlett.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/signal/blackman.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/signal/freqz.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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)
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/signal/hamming.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/signal/hanning.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/signal/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/spectral_adf.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/signal/spectral_adf.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/signal/spectral_xdf.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/signal/stft.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/bicgstab.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/sparse/bicgstab.m	Sat Oct 10 16:52:59 2015 -0700
@@ -163,7 +163,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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/sparse/cgs.m	Sat Oct 10 16:52:59 2015 -0700
@@ -147,9 +147,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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/sparse/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/sparse/private/__sprand__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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++;
+      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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/sparse/qmr.m	Sat Oct 10 16:52:59 2015 -0700
@@ -181,9 +181,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/sprand.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/sparse/sprand.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/sparse/sprandn.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/sparse/sprandsym.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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
 
--- a/scripts/sparse/svds.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/sparse/svds.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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)
@@ -225,7 +225,7 @@
       endif
     endif
 
-    s = s * max_a;
+    s *= max_a;
   endif
 
   if (nargout < 2)
--- a/scripts/specfun/factor.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/specfun/factor.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/specfun/legendre.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/specfun/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/special-matrix/gallery.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/special-matrix/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/startup/local-rcfile	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/startup/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -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/gls.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/statistics/base/gls.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/kurtosis.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/statistics/base/kurtosis.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ /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/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/statistics/base/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/skewness.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/statistics/base/skewness.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/distributions/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/statistics/distributions/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/poissinv.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/statistics/distributions/poissinv.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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,27 +60,132 @@
   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);
+
+  limit = 20;                           # After 'limit' iterations, use approx
+  if (! isempty (k))
+    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 (any (m))
+          inv(kk(m)) += 1;
+          cdf(m) += poisspdf (i, lambda(kk(m)));
+        else
+          break;
+        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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/statistics/distributions/unidpdf.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/statistics/models/logistic_regression.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/statistics/models/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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/kruskal_wallis_test.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/statistics/tests/kruskal_wallis_test.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/statistics/tests/manova.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/statistics/tests/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/statistics/tests/wilcoxon_test.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/strings/cstrcat.m	Sat Oct 10 16:52:59 2015 -0700
@@ -45,14 +45,16 @@
 
 function st = cstrcat (varargin)
 
-  if (nargin < 1)
-    print_usage ();
-  elseif (! iscellstr (varargin))
+  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: expecting arguments to 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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/strings/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/strings/strcat.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/testfun/__run_test_suite__.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/testfun/__run_test_suite__.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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");
@@ -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)
--- a/scripts/testfun/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/testfun/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/testfun/private/html_compare_plot_demos.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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/test.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/testfun/test.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
--- a/scripts/time/datevec.m	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/time/datevec.m	Sat Oct 10 16:52:59 2015 -0700
@@ -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
 
--- a/scripts/time/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/scripts/time/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ /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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -0,0 +1,247 @@
+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)
+
+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)
+
+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)
+
+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 file names 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	Sat Oct 10 16:46:00 2015 -0700
+++ /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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/bug-35448/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/bug-36025/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/bug-38236/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/bug-38691/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/build-bc-overload-tests.sh	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/build-sparse-tests.sh	Sat Oct 10 16:52:59 2015 -0700
@@ -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;
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/class-concat/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/classdef/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/classes/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/ctor-vs-method/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/diag-perm.tst	Sat Oct 10 16:52:59 2015 -0700
@@ -263,3 +263,10 @@
 %! 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]));
--- a/test/fcn-handle-derived-resolution/module.mk	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/fcn-handle-derived-resolution/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/index.tst	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/nest/module.mk	Sat Oct 10 16:52:59 2015 -0700
@@ -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	Sat Oct 10 16:46:00 2015 -0700
+++ b/test/parser.tst	Sat Oct 10 16:52:59 2015 -0700
@@ -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