changeset 20536:1f330d33388f

maint: Periodic merge of stable to default.
author Rik <rik@octave.org>
date Tue, 22 Sep 2015 04:50:47 -0700
parents bb09279e5c99 (diff) caa5de39147e (current diff)
children afdb856e44f1
files NEWS libinterp/octave-value/ov-fcn-handle.cc libinterp/octave-value/ov-usr-fcn.cc
diffstat 574 files changed, 18020 insertions(+), 15408 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Tue Sep 22 04:47:25 2015 -0700
+++ b/.hgignore	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/.hgtags	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/Makefile.am	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/NEWS	Tue Sep 22 04:50:47 2015 -0700
@@ -1,3 +1,67 @@
+Summary of important user-visible changes for version 4.2:
+---------------------------------------------------------
+
+ ** 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
+
+ ** 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
+      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
+
+
 Summary of important user-visible changes for version 4.0:
 ---------------------------------------------------------
 
--- a/bootstrap	Tue Sep 22 04:47:25 2015 -0700
+++ b/bootstrap	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/build-aux/common.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/build-aux/mk-opts.pl	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/build-aux/move-if-change	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/configure.ac	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/doxyhtml/Doxyfile.in	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/arith.txi	Tue Sep 22 04:50:47 2015 -0700
@@ -315,6 +315,8 @@
 @anchor{XREFgammaln}
 @DOCSTRING(lgamma)
 
+@DOCSTRING(psi)
+
 @node Rational Approximations
 @section Rational Approximations
 
--- a/doc/interpreter/audio.txi	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/audio.txi	Tue Sep 22 04:50:47 2015 -0700
@@ -182,6 +182,3 @@
 
 @DOCSTRING(soundsc)
 
-@DOCSTRING(wavread)
-
-@DOCSTRING(wavwrite)
--- a/doc/interpreter/config-images.sh	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/config-images.sh	Tue Sep 22 04:50:47 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/doccheck/aspell-octave.en.pws	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/doccheck/aspell-octave.en.pws	Tue Sep 22 04:50:47 2015 -0700
@@ -74,7 +74,6 @@
 binornd
 Biomathematics
 bitmapped
-bitmax
 bitwise
 bivariate
 Blackman
--- a/doc/interpreter/find-docstring-files.sh	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/genpropdoc.m	Tue Sep 22 04:50:47 2015 -0700
@@ -123,6 +123,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 +196,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 +283,7 @@
       ## Specific properties
       case "alphamap"
         s.doc = sprintf (doc_notimpl, "Transparency");
+
       case "closerequestfcn"
         s.valid = valid_fcn;
 
@@ -325,10 +327,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 +369,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 +398,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 +420,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 +470,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 +492,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 +526,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 +538,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 +560,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 +573,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 +636,9 @@
 @xref{XREFaxesposition, , @w{position property}}.";
         s.valid = valid_4elvec;
 
+      case "pickableparts"
+        s.doc = doc_unused;
+
       case "plotboxaspectratio"
       case "plotboxaspectratiomode"
       case "position"
@@ -585,6 +653,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 +664,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 +678,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 +695,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 +727,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 +768,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 +808,9 @@
         s.valid = valid_cellstring;
 
       case "zticklabelmode"
+      case "zticklabelrotation"
+        s.doc = doc_unused;
+
       case "ztickmode"
     endswitch
 
@@ -734,6 +834,7 @@
         s.doc = doc_unused;
 
       case "interpreter"
+        
       case "linestyle"
         s.doc = "@xref{Line Styles}.";
 
@@ -836,6 +937,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");
 
@@ -1338,4 +1443,5 @@
   elseif (! isempty (default))
     str = ["def. " default];
   endif
+
 endfunction
--- a/doc/interpreter/geometry.txi	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/geometry.txi	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/geometryimages.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/graphics_properties.mk	Tue Sep 22 04:50:47 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/images.awk	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/images.awk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/interpimages.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/numbers.txi	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/octave.texi	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/plot.txi	Tue Sep 22 04:50:47 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)
 
--- a/doc/interpreter/plotimages.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/plotimages.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/sparseimages.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/splineimages.m	Tue Sep 22 04:50:47 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/system.txi	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/interpreter/system.txi	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/doc/liboctave/liboctave.texi	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 2015 -0700
@@ -0,0 +1,567 @@
+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
+
+$(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)
+
+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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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/data/Makefile.am	Tue Sep 22 04:47:25 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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/Canvas.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/graphics/Canvas.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -348,18 +348,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 +371,85 @@
   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
@@ -452,7 +509,7 @@
           break;
         }
     }
-  else if (m_mouseMode == NoMode)
+  else if (m_mouseMode == NoMode && m_updateCurrentPoint)
     {
       graphics_object obj = gh_manager::get_object (m_handle);
 
@@ -465,6 +522,23 @@
                                      "windowbuttonmotionfcn");
         }
     }
+
+  // Update mouse coordinates in the figure window status bar 
+  graphics_object obj = gh_manager::get_object (m_handle);
+
+  if (obj.valid_object ())
+    {
+      graphics_object currentObj, axesObj;
+      select_object (obj, event, currentObj, axesObj, true);
+
+      if (axesObj.valid_object ())
+        {
+          Figure* fig = 
+            dynamic_cast<Figure*> (Backend::toolkitObject (obj));
+          axes::properties& ap = Utils::properties<axes> (axesObj);
+          fig->updateStatusBar (ap.pixel2coord (event->x (), event->y ()));
+        }
+    }    
 }
 
 void
@@ -512,66 +586,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)));
+      
+      select_object (obj, event, currentObj, axesObj);
 
-          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 (! 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)
--- a/libgui/graphics/Canvas.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/graphics/Canvas.h	Tue Sep 22 04:50:47 2015 -0700
@@ -70,6 +70,7 @@
   virtual void toggleAxes (const graphics_handle& handle) = 0;
   virtual void toggleGrid (const graphics_handle& handle) = 0;
   virtual void autoAxes (const graphics_handle& handle) = 0;
+  void enableCurrentPointUpdates (bool on) { m_updateCurrentPoint = on; }
 
 protected:
   virtual void draw (const graphics_handle& handle) = 0;
@@ -85,7 +86,8 @@
       m_mouseMode (NoMode),
       m_clickMode (false),
       m_eventMask (0),
-      m_rectMode (false)
+      m_rectMode (false),
+      m_updateCurrentPoint (false)
     { }
 
   void canvasToggleAxes (const graphics_handle& handle);
@@ -106,6 +108,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;
@@ -117,6 +122,7 @@
   graphics_handle m_mouseAxes;
   int m_eventMask;
   bool m_rectMode;
+  bool m_updateCurrentPoint;
 };
 
 }; // namespace QtHandles
--- a/libgui/graphics/Figure.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/graphics/Figure.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -129,20 +129,32 @@
 {
   m_container = new Container (win);
   win->setCentralWidget (m_container);
-
+  
   figure::properties& fp = properties<figure> ();
 
-  createFigureToolBarAndMenuBar ();
+  // Enable mouse tracking
+  m_container->setMouseTracking (true);
+  foreach (QWidget* w, m_container->findChildren<QWidget*> ())
+    { w->setMouseTracking (true); }
+  
+  // Status bar
+  m_statusBar = win->statusBar ();
+  m_statusBar->setVisible (true);
+  int boffset = m_statusBar->sizeHint ().height ();
+  
 
-  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 ();
   else
     m_figureToolBar->hide ();
   if (fp.menubar_is ("figure") || hasUiMenuChildren (fp))
-    offset += m_menuBar->sizeHint ().height () + 1;
+    toffset += m_menuBar->sizeHint ().height () + 1;
   else
     m_menuBar->hide ();
 
@@ -150,7 +162,7 @@
   m_outerRect = boundingBoxToRect (fp.get_boundingbox (false));
 
   //qDebug () << "Figure::Figure:" << m_innerRect;
-  win->setGeometry (m_innerRect.adjusted (0, -offset, 0, 0));
+  win->setGeometry (m_innerRect.adjusted (0, -toffset, 0, boffset));
   //qDebug () << "Figure::Figure(adjusted)" << m_innerRect.adjusted (0, -offset, 0, 0);
   win->setWindowTitle (Utils::fromStdString (fp.get_title ()));
 
@@ -411,17 +423,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;
 
@@ -471,9 +486,7 @@
         {
           bool hasCallback = ! fp.get_windowbuttonmotionfcn ().is_empty ();
 
-          m_container->setMouseTracking (hasCallback);
-          foreach (QWidget* w, m_container->findChildren<QWidget*> ())
-            { w->setMouseTracking (hasCallback); }
+          m_container->canvas (m_handle)->enableCurrentPointUpdates (hasCallback);
         }
       break;
 
@@ -551,6 +564,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)
 {
--- a/libgui/graphics/Figure.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/graphics/Figure.h	Tue Sep 22 04:50:47 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);
@@ -132,6 +134,7 @@
   bool m_blockUpdates;
   QToolBar* m_figureToolBar;
   MenuBar* m_menuBar;
+  QStatusBar* m_statusBar;
   QRect m_innerRect;
   QRect m_outerRect;
   MouseModeActionGroup* m_mouseModeGroup;
--- a/libgui/graphics/ListBoxControl.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/graphics/ListBoxControl.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/graphics/QtHandlesUtils.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/graphics/module.mk	Tue Sep 22 04:50:47 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)
--- a/libgui/link-deps.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/link-deps.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 2015 -0700
@@ -0,0 +1,137 @@
+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/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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/qterminal-module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/qterminal/libqterminal/unix/kpty.cpp	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/qterminal/libqterminal/unix/kpty_p.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/dialog.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -519,7 +519,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/m-editor/file-editor-tab.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/m-editor/file-editor-tab.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/m-editor/file-editor-tab.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/m-editor/find-dialog.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/m-editor/find-dialog.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/m-editor/octave-qscintilla.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/m-editor/octave-qscintilla.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/main-window.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/main-window.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/octave-qt-link.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/resource-manager.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/settings-dialog.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/settings-dialog.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libgui/src/shortcut-manager.cc	Tue Sep 22 04:50:47 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/libinterp/Makefile.am	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/Cell.cc	Tue Sep 22 04:50:47 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)
     {
--- a/libinterp/corefcn/__contourc__.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/__contourc__.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/__dispatch__.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -50,15 +50,12 @@
 
   if (nargin > 0 && nargin < 4)
     {
-      if (nargin > 0)
-        {
-          f = args(0).string_value ();
+      f = args(0).string_value ();
 
-          if (error_state)
-            {
-              error ("__dispatch__: first argument must be a function name");
-              return retval;
-            }
+      if (error_state)
+        {
+          error ("__dispatch__: first argument must be a function name");
+          return retval;
         }
 
       if (nargin > 1)
--- a/libinterp/corefcn/__pchip_deriv__.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/__pchip_deriv__.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/__qp__.cc	Tue Sep 22 04:50:47 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/besselj.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/besselj.cc	Tue Sep 22 04:50:47 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)
                 {
--- a/libinterp/corefcn/bitfcns.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/bitfcns.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -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);
@@ -546,8 +544,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 +566,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;
@@ -678,43 +676,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 +687,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 +746,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 +817,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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/bsxfun.cc	Tue Sep 22 04:50:47 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);
     }
 }
 
@@ -391,7 +391,7 @@
             }
 
           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;
@@ -404,10 +404,10 @@
               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))));
+                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)
                 {
@@ -427,7 +427,7 @@
                 {
                   octave_idx_type ncount = 1;
                   for (octave_idx_type i = 1; i < nd; i++)
-                    ncount *= dvc (i);
+                    ncount *= dvc(i);
 
 #define BSXDEF(T) \
                   T result_ ## T; \
--- a/libinterp/corefcn/cellfun.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/cellfun.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -1714,7 +1714,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++)
@@ -1959,8 +1959,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 +1979,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 +2029,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 +2090,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 +2154,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];
     }
 
@@ -2339,7 +2337,7 @@
                    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)
@@ -2409,7 +2407,7 @@
 
       if (! error_state)
         {
-          if (lb.length () != ub.length ())
+          if (lb.numel () != ub.numel ())
             error ("cellslices: the lengths of LB and UB must match");
           else
             {
@@ -2472,7 +2470,7 @@
               else
                 {
                   // generic code.
-                  octave_idx_type n = lb.length ();
+                  octave_idx_type n = lb.numel ();
                   retcell = Cell (1, n);
                   const dim_vector dv = x.dims ();
                   int ndims = dv.length ();
--- a/libinterp/corefcn/daspk.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/daspk.cc	Tue Sep 22 04:50:47 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 ();
@@ -426,7 +426,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);
--- a/libinterp/corefcn/dasrt.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/dasrt.cc	Tue Sep 22 04:50:47 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 ();
--- a/libinterp/corefcn/dassl.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/dassl.cc	Tue Sep 22 04:50:47 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 ();
@@ -427,7 +427,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);
--- a/libinterp/corefcn/data.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/data.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -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
@@ -2051,7 +2096,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)
@@ -2115,8 +2160,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,7 +2628,7 @@
       // 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)--;
@@ -4065,8 +4109,8 @@
 
             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
+                if (val == 1 && dims.length () == 2 && dims(0) == 1)
+                  retval = Range (1.0, 0.0, dims(1));  // packed form
                 else
                   retval = NDArray (dims, val);
               }
@@ -4675,7 +4719,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 ();
@@ -4848,7 +4892,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 (),
@@ -5263,7 +5307,7 @@
       else
         {
           CVT lv = octave_value_extract<CVT> (limit);
-          CVT bv (lv.length (), bs);
+          CVT bv (lv.numel (), bs);
           retval = linspace (bv, lv, n);
         }
     }
@@ -5273,7 +5317,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
@@ -5298,9 +5342,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\
@@ -5328,6 +5374,8 @@
 
       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
         npoints = arg_3.idx_type_value ();
     }
@@ -5337,7 +5385,14 @@
       octave_value arg_1 = args(0);
       octave_value arg_2 = args(1);
 
-      if (arg_1.is_single_type () || arg_2.is_single_type ())
+      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 ())
         {
           if (arg_1.is_complex_type () || arg_2.is_complex_type ())
             retval = do_linspace<FloatComplexMatrix> (arg_1, arg_2, npoints);
@@ -5369,12 +5424,32 @@
 %! 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 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)
 
 %!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
@@ -5433,7 +5508,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));
@@ -5514,15 +5589,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)
             {
@@ -8127,8 +8202,8 @@
 
           if (! error_state)
             {
-              dims = dim_vector::alloc (size.length ());
-              for (octave_idx_type i = 0; i < size.length (); i++)
+              dims = dim_vector::alloc (size.numel ());
+              for (octave_idx_type i = 0; i < size.numel (); i++)
                 dims(i) = size(i);
             }
         }
--- a/libinterp/corefcn/debug.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/debug.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -263,7 +263,7 @@
           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)
@@ -292,7 +292,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create breakpoint table!");
+      error ("unable to create breakpoint table!");
       retval = false;
     }
 
--- a/libinterp/corefcn/display.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/display.cc	Tue Sep 22 04:50:47 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/dot.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/dot.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -173,7 +173,7 @@
                       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);
+                      FloatComplexNDArray z (dimz);
                       if (! error_state)
                         F77_XFCN (cdotc3, CDOTC3, (m, n, k,
                                                    x.data (), y.data (),
@@ -185,7 +185,7 @@
                       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);
+                      ComplexNDArray z (dimz);
                       if (! error_state)
                         F77_XFCN (zdotc3, ZDOTC3, (m, n, k,
                                                    x.data (), y.data (),
@@ -200,7 +200,7 @@
                       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);
+                      FloatNDArray z (dimz);
                       if (! error_state)
                         F77_XFCN (sdot3, SDOT3, (m, n, k, x.data (), y.data (),
                                                  z.fortran_vec ()));
@@ -211,7 +211,7 @@
                       NDArray x = argx.array_value ();
                       NDArray y = argy.array_value ();
                       get_red_dims (dimx, dimy, dim, dimz, m, n, k);
-                      NDArray z(dimz);
+                      NDArray z (dimz);
                       if (! error_state)
                         F77_XFCN (ddot3, DDOT3, (m, n, k, x.data (), y.data (),
                                                  z.fortran_vec ()));
@@ -340,7 +340,7 @@
                 {
                   FloatComplexNDArray x = argx.float_complex_array_value ();
                   FloatComplexNDArray y = argy.float_complex_array_value ();
-                  FloatComplexNDArray z(dimz);
+                  FloatComplexNDArray z (dimz);
                   if (! error_state)
                     F77_XFCN (cmatm3, CMATM3, (m, n, k, np,
                                                x.data (), y.data (),
@@ -351,7 +351,7 @@
                 {
                   ComplexNDArray x = argx.complex_array_value ();
                   ComplexNDArray y = argy.complex_array_value ();
-                  ComplexNDArray z(dimz);
+                  ComplexNDArray z (dimz);
                   if (! error_state)
                     F77_XFCN (zmatm3, ZMATM3, (m, n, k, np,
                                                x.data (), y.data (),
@@ -365,7 +365,7 @@
                 {
                   FloatNDArray x = argx.float_array_value ();
                   FloatNDArray y = argy.float_array_value ();
-                  FloatNDArray z(dimz);
+                  FloatNDArray z (dimz);
                   if (! error_state)
                     F77_XFCN (smatm3, SMATM3, (m, n, k, np,
                                                x.data (), y.data (),
@@ -376,7 +376,7 @@
                 {
                   NDArray x = argx.array_value ();
                   NDArray y = argy.array_value ();
-                  NDArray z(dimz);
+                  NDArray z (dimz);
                   if (! error_state)
                     F77_XFCN (dmatm3, DMATM3, (m, n, k, np,
                                                x.data (), y.data (),
--- a/libinterp/corefcn/dynamic-ld.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/dynamic-ld.cc	Tue Sep 22 04:50:47 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;
     }
@@ -295,13 +295,12 @@
               retval = f (oct_file, relative);
 
               if (! retval)
-                ::error ("failed to install .oct file function '%s'",
-                         fcn_name.c_str ());
+                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 ());
+        error ("%s is not a valid shared library", file_name.c_str ());
     }
 
   return retval;
@@ -363,12 +362,11 @@
             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 ());
+            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 ());
+        error ("%s is not a valid shared library", file_name.c_str ());
     }
 
   return retval;
--- a/libinterp/corefcn/eig.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/eig.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -324,6 +324,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/fft.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/fft.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -112,9 +112,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)
     {
--- a/libinterp/corefcn/fft2.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/fft2.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -96,14 +96,14 @@
       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)
     {
--- a/libinterp/corefcn/file-io.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/file-io.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -230,7 +230,7 @@
         retval = (std::ios::in | std::ios::out | std::ios::app
                   | std::ios::binary);
       else
-        ::error ("invalid mode specified");
+        error ("invalid mode specified");
     }
 
   return retval;
@@ -576,13 +576,13 @@
               retval = do_stream_open (name, mode, arch, fid);
             }
           else
-            ::error ("%s: architecture type must be a string", fcn);
+            error ("%s: architecture type must be a string", fcn);
         }
       else
-        ::error ("%s: file mode must be a string", fcn);
+        error ("%s: file mode must be a string", fcn);
     }
   else
-    ::error ("%s: file name must be a string", fcn);
+    error ("%s: file name must be a string", fcn);
 
   return retval;
 }
@@ -946,7 +946,7 @@
               result = os.printf (args(fmt_n), 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
@@ -1001,7 +1001,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 ();
@@ -1129,10 +1129,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 ();
@@ -1205,7 +1205,7 @@
           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
@@ -1242,7 +1242,7 @@
                     }
                 }
               else
-                ::error ("%s: format must be a string", who.c_str ());
+                error ("%s: format must be a string", who.c_str ());
             }
         }
       else
@@ -1264,7 +1264,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 +1301,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
     {
@@ -1353,12 +1352,12 @@
                         }
                     }
                   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
@@ -1431,19 +1430,19 @@
                                           output_type, skip, flt_fmt, count);
                     }
                   else
-                    ::error ("fread: ARCH architecture type must be a string");
+                    error ("fread: ARCH architecture type must be a string");
                 }
               else
-                ::error ("fread: SKIP must be an integer");
+                error ("fread: SKIP must be an integer");
             }
           else
-            ::error ("fread: invalid PRECISION specified");
+            error ("fread: invalid PRECISION specified");
         }
       else
-        ::error ("fread: PRECISION must be a string");
+        error ("fread: PRECISION must be a string");
     }
   else
-    ::error ("fread: invalid SIZE specified");
+    error ("fread: invalid SIZE specified");
 
   return retval;
 }
@@ -1704,16 +1703,16 @@
                                        skip, flt_fmt);
                 }
               else
-                ::error ("fwrite: ARCH architecture type must be a string");
+                error ("fwrite: ARCH architecture type must be a string");
             }
           else
-            ::error ("fwrite: SKIP must be an integer");
+            error ("fwrite: SKIP must be an integer");
         }
       else
-        ::error ("fwrite: invalid PRECISION specified");
+        error ("fwrite: invalid PRECISION specified");
     }
   else
-    ::error ("fwrite: PRECISION must be a string");
+    error ("fwrite: PRECISION must be a string");
 
   return retval;
 }
@@ -1934,13 +1933,13 @@
                   retval = octave_stream_list::insert (ops);
                 }
               else
-                ::error ("popen: invalid MODE specified");
+                error ("popen: invalid MODE specified");
             }
           else
-            ::error ("popen: MODE must be a string");
+            error ("popen: MODE must be a string");
         }
       else
-        ::error ("popen: COMMAND must be a string");
+        error ("popen: COMMAND must be a string");
     }
   else
     print_usage ();
@@ -2001,7 +2000,7 @@
           if (args(0).is_string ())
             dir = args(0).string_value ();
           else
-            ::error ("DIR must be a string");
+            error ("DIR must be a string");
         }
 
       std::string pfx ("oct-");
@@ -2010,7 +2009,7 @@
           if (args(1).is_string ())
             pfx = args(1).string_value ();
           else
-            ::error ("PREFIX must be a string");
+            error ("PREFIX must be a string");
         }
 
       retval = octave_tempnam (dir, pfx);
@@ -2209,6 +2208,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 +2218,7 @@
   int tmp = x % obase;
 
   if (tmp > ibase - 1)
-    ::error ("umask: invalid digit");
+    error ("umask: invalid digit");
   else
     {
       retval = tmp;
@@ -2227,7 +2228,7 @@
           tmp = x % obase;
           if (tmp > ibase - 1)
             {
-              ::error ("umask: invalid digit");
+              error ("umask: invalid digit");
               break;
             }
           retval += mult * tmp;
@@ -2269,7 +2270,7 @@
           if (mask < 0)
             {
               status = -1;
-              ::error ("umask: MASK must be a positive integer value");
+              error ("umask: MASK must be a positive integer value");
             }
           else
             {
@@ -2282,7 +2283,7 @@
       else
         {
           status = -1;
-          ::error ("umask: MASK must be an integer");
+          error ("umask: MASK must be an integer");
         }
     }
   else
--- a/libinterp/corefcn/filter.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/filter.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/find.cc	Tue Sep 22 04:50:47 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++)
           {
--- a/libinterp/corefcn/gl-render.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/gl-render.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/gl-render.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/graphics.cc	Tue Sep 22 04:50:47 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)
@@ -1047,7 +1084,6 @@
 {
   if (do_set (v))
     {
-
       // Notify graphics toolkit.
       if (id >= 0 && do_notify_toolkit)
         {
@@ -1559,7 +1595,6 @@
 
       if (go.valid_object ())
         gh_manager::free (*p);
-
     }
 
   if (clear)
@@ -1569,30 +1604,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 +1652,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,27 +1664,29 @@
 
   if (type.compare ("string"))
     {
-      std::string val = (args.length () > 0 ? args(0).string_value () : "");
+      std::string sv = (args.length () > 0 ? args(0).string_value () : "");
 
       if (! error_state)
-        retval = property (new string_property (name, h, val));
+        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 (args.length () < 1)
+        error ("addproperty: missing possible values for radio property");
+      else
+        {
+          std::string sv = args(0).string_value ();
 
           if (! error_state)
             {
-              retval = property (new radio_property (name, h, vals));
+              retval = property (new radio_property (name, h, sv));
 
               if (args.length () > 1)
                 retval.set (args(1));
@@ -1659,23 +1694,21 @@
           else
             error ("addproperty: invalid argument for radio property, expected a string value");
         }
-      else
-        error ("addproperty: missing possible values for radio property");
     }
   else if (type.compare ("double"))
     {
-      double d = (args.length () > 0 ? args(0).double_value () : 0);
+      double dv = (args.length () > 0 ? args(0).double_value () : 0.0);
 
       if (! error_state)
-        retval = property (new double_property (name, h, d));
+        retval = property (new double_property (name, h, dv));
     }
   else if (type.compare ("handle"))
     {
-      double hh = (args.length () > 0 ? args(0).double_value () : octave_NaN);
+      double hv = (args.length () > 0 ? args(0).double_value () : octave_NaN);
 
       if (! error_state)
         {
-          graphics_handle gh (hh);
+          graphics_handle gh (hv);
 
           retval = property (new handle_property (name, h, gh));
         }
@@ -1694,7 +1727,6 @@
       if (args.length () > 0)
         {
           retval.set (args(0));
-
           // FIXME: additional argument could define constraints,
           //        but is this really useful?
         }
@@ -1963,6 +1995,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 +2005,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 +2027,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];
@@ -2143,17 +2175,19 @@
 
   if (nargin == 0)
     error ("graphics_object::set: Nothing to set");
-  else if (nargin % 2 == 0)
+  else if (nargin % 2 != 0)
+    error ("set: invalid number of arguments");
+  else
     {
       for (int i = 0; i < nargin; i += 2)
         {
-          caseless_str name = args(i).string_value ();
+          caseless_str pname = args(i).string_value ();
 
           if (! error_state)
             {
               octave_value val = args(i+1);
 
-              set_value_or_default (name, val);
+              set_value_or_default (pname, val);
 
               if (error_state)
                 break;
@@ -2162,8 +2196,6 @@
             error ("set: expecting argument %d to be a property name", i);
         }
     }
-  else
-    error ("set: invalid number of arguments");
 }
 
 /*
@@ -2181,23 +2213,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);
+      set_value_or_default (pname, val);
 
       if (error_state)
         break;
@@ -2256,11 +2288,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);
+      // 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);
 
       if (error_state)
         break;
@@ -2351,46 +2385,46 @@
 // 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 (sval.compare ("default") == 0)
+        {
+          default_val = get_default (pname);
 
           if (error_state)
             return;
 
-          rep->set (name, default_val);
-        }
-      else if (tval.compare ("factory") == 0)
-        {
-          default_val = get_factory_default (name);
+          rep->set (pname, default_val);
+        }
+      else if (sval.compare ("factory") == 0)
+        {
+          default_val = get_factory_default (pname);
 
           if (error_state)
             return;
 
-          rep->set (name, default_val);
+          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 +2460,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 +2473,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 +2518,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 +2576,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 +2588,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 +2662,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 +2700,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 +2763,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
@@ -2769,7 +2799,7 @@
           boolNDArray result (handles.dims ());
 
           for (octave_idx_type i = 0; i < handles.numel (); i++)
-            result.xelem (i) = is_handle (handles (i));
+            result.xelem (i) = is_handle (handles(i));
 
           retval = result;
         }
@@ -2781,16 +2811,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 +2859,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 +2875,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 +2882,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 +2890,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 +2920,7 @@
         {
           std::string pname = q->first;
 
-          obj.set (pname, q->second);
+          bgo.set (pname, q->second);
 
           if (error_state)
             {
@@ -2919,17 +2948,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;
 }
@@ -2985,14 +3014,14 @@
 }
 
 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 +3031,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 +3068,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 +3090,40 @@
 void
 base_properties::mark_modified (void)
 {
-  __modified__ = "on";
-  graphics_object parent_obj = gh_manager::get_object (get_parent ());
-  if (parent_obj)
-    parent_obj.mark_modified ();
+  // Mark existing object as modified
+  __modified__ = "on";  
+  // 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 +3132,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 +3176,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);
+  property p = get_property (pname);
 
   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);
+    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 (! error_state && p.ok ())
-    p.delete_listener (v, mode);
+    p.delete_listener (val, mode);
 }
 
 // ---------------------------------------------------------------------
@@ -3180,10 +3211,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 +3224,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
@@ -3252,11 +3283,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 +3307,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 +3332,6 @@
       if (! retval.empty ())
         retval += "\n";
     }
-  else
-    error ("base_graphics_object::values_as_string: invalid graphics object");
 
   return retval;
 }
@@ -3312,11 +3341,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 +3361,6 @@
       if (! retval.empty ())
         retval += "\n";
     }
-  else
-    error ("base_graphics_object::value_as_string: invalid graphics object");
 
   return retval;
 }
@@ -3341,16 +3370,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 +3395,6 @@
             }
         }
     }
-  else
-    error ("base_graphics_object::values_as_struct: invalid graphics object");
 
   return retval;
 }
@@ -3459,170 +3488,6 @@
     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)
 {
@@ -3667,56 +3532,57 @@
     }
 }
 
-// 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.
+// 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 +3609,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 +3636,25 @@
 // ---------------------------------------------------------------------
 
 void
-figure::properties::set_currentaxes (const octave_value& v)
-{
-  graphics_handle val (v);
+figure::properties::set_currentaxes (const octave_value& val)
+{
+  graphics_handle hax (val);
 
   if (error_state)
     return;
 
-  if (xisnan (val.value ()) || is_handle (val))
-    currentaxes = 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,11 +3712,11 @@
 void
 figure::properties::set_visible (const octave_value& val)
 {
-  std::string s = val.string_value ();
+  std::string sval = val.string_value ();
 
   if (! error_state)
     {
-      if (s == "on")
+      if (sval == "on")
         xset (0, "currentfigure", __myhandle__.value ());
 
       visible = val;
@@ -3896,7 +3762,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 +3779,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;
@@ -3973,20 +3839,20 @@
 }
 
 void
-figure::properties::set_paperunits (const octave_value& v)
+figure::properties::set_paperunits (const octave_value& val)
 {
   if (! error_state)
     {
-      caseless_str typ = get_papertype ();
-      caseless_str punits = v.string_value ();
+      caseless_str punits = val.string_value ();
+      caseless_str ptype = get_papertype ();
       if (! error_state)
         {
-          if (punits.compare ("normalized") && typ.compare ("<custom>"))
-            error ("set: can't set the paperunits to normalized when the papertype is custom");
+          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 (v, true))
+              if (paperunits.set (val, true))
                 {
                   update_paperunits (old_paperunits);
                   mark_modified ();
@@ -3997,19 +3863,19 @@
 }
 
 void
-figure::properties::set_papertype (const octave_value& v)
+figure::properties::set_papertype (const octave_value& val)
 {
   if (! error_state)
     {
-      caseless_str typ = v.string_value ();
+      caseless_str ptype = val.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");
+          if (punits.compare ("normalized") && ptype.compare ("<custom>"))
+            error ("set: can't set paperunits to normalized when papertype is custom");
           else
             {
-              if (papertype.set (v, true))
+              if (papertype.set (val, true))
                 {
                   update_papertype ();
                   mark_modified ();
@@ -4020,9 +3886,9 @@
 }
 
 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 +3911,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 +4170,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 +4198,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 +4222,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 +4244,7 @@
     {
       paperorientation.set ("portrait");
     }
+
   std::string punits = get_paperunits ();
   if (punits == "centimeters")
     {
@@ -4391,93 +4258,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,12 +4448,12 @@
 */
 
 void
-figure::properties::set_units (const octave_value& v)
+figure::properties::set_units (const octave_value& val)
 {
   if (! error_state)
     {
       caseless_str old_units = get_units ();
-      if (units.set (v, true))
+      if (units.set (val, true))
         {
           update_units (old_units);
           mark_modified ();
@@ -4644,10 +4511,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 +4549,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 +4635,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 +4658,7 @@
     }
   if (ext(1)+ext(3) > pos(1)+pos(3))
     pos(3) = ext(1)+ext(3)-pos(1);
+
   return pos;
 }
 
@@ -4975,7 +4845,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 +4856,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 +4893,7 @@
   yticklabelmode = "auto";
   zticklabelmode = "auto";
 
-  interpreter = "none";
+  ticklabelinterpreter = "tex";
 
   color = color_values ("white");
   xcolor = color_values ("black");
@@ -5169,7 +5038,7 @@
 
   update_transform ();
   sync_positions ();
-  override_defaults (obj);
+  override_defaults (bgo);
 }
 
 void
@@ -5234,8 +5103,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 +5114,9 @@
 xform_vector (void)
 {
   ColumnVector v (4, 0.0);
+
   v(3) = 1;
+
   return v;
 }
 
@@ -5251,7 +5124,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 +5142,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 +5155,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 +5179,7 @@
 inline void
 xform (ColumnVector& v, const Matrix& m)
 {
-  v = m*v;
+  v = m * v;
 }
 
 inline void
@@ -5334,9 +5221,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 +5244,9 @@
     1,1,1,1
   };
   Matrix m (4, 8);
+
   memcpy (m.fortran_vec (), data, sizeof (double)*32);
+
   return m;
 }
 
@@ -5363,7 +5254,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 +5296,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 +5310,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 +5379,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 +5399,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 +5477,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 +5515,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 +5539,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 +5567,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 +5595,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 +5661,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 +5733,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 +5752,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 +5778,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 +5834,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 +5853,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 +5888,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 +5944,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 +5991,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 +6068,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 +6088,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 +6129,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 +6155,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 +6175,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 +6230,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 +6299,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 +6325,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 +6344,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 +6399,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 +6412,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,11 +6457,11 @@
 }
 
 void
-axes::properties::set_xticklabel (const octave_value& v)
-{
-  if (!error_state)
-    {
-      if (xticklabel.set (convert_ticklabel_string (v), false))
+axes::properties::set_xticklabel (const octave_value& val)
+{
+  if (! error_state)
+    {
+      if (xticklabel.set (convert_ticklabel_string (val), false))
         {
           set_xticklabelmode ("manual");
           xticklabel.run_listeners (POSTSET);
@@ -6588,11 +6475,11 @@
 }
 
 void
-axes::properties::set_yticklabel (const octave_value& v)
-{
-  if (!error_state)
-    {
-      if (yticklabel.set (convert_ticklabel_string (v), false))
+axes::properties::set_yticklabel (const octave_value& val)
+{
+  if (! error_state)
+    {
+      if (yticklabel.set (convert_ticklabel_string (val), false))
         {
           set_yticklabelmode ("manual");
           yticklabel.run_listeners (POSTSET);
@@ -6606,11 +6493,11 @@
 }
 
 void
-axes::properties::set_zticklabel (const octave_value& v)
-{
-  if (!error_state)
-    {
-      if (zticklabel.set (convert_ticklabel_string (v), false))
+axes::properties::set_zticklabel (const octave_value& val)
+{
+  if (! error_state)
+    {
+      if (zticklabel.set (convert_ticklabel_string (val), false))
         {
           set_zticklabelmode ("manual");
           zticklabel.run_listeners (POSTSET);
@@ -6665,21 +6552,21 @@
 }
 
 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)
+axes::properties::set_linestyleorder (const octave_value& val)
+{
+  if (! error_state)
+    {
+      linestyleorder.set (convert_linestyleorder_string (val), false);
+    }
+}
+
+void
+axes::properties::set_units (const octave_value& val)
 {
   if (! error_state)
     {
       caseless_str old_units = get_units ();
-      if (units.set (v, true))
+      if (units.set (val, true))
         {
           update_units (old_units);
           mark_modified ();
@@ -6690,9 +6577,9 @@
 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,12 +6600,12 @@
 }
 
 void
-axes::properties::set_fontunits (const octave_value& v)
+axes::properties::set_fontunits (const octave_value& val)
 {
   if (! error_state)
     {
       caseless_str old_fontunits = get_fontunits ();
-      if (fontunits.set (v, true))
+      if (fontunits.set (val, true))
         {
           update_fontunits (old_fontunits);
           mark_modified ();
@@ -6731,23 +6618,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 +6650,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 +6679,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;
@@ -6863,8 +6749,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 +6776,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 +6800,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 +6826,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 +6883,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 +6911,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 +6944,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 +6971,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 +7002,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 +7036,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 +7047,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 +7091,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 +7131,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 +7145,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 +7159,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 +7173,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 +7187,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 +7406,6 @@
     }
 
   xproperties.update_transform ();
-
 }
 
 void
@@ -7944,11 +7848,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 +7859,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,12 +8030,12 @@
 }
 
 void
-text::properties::set_fontunits (const octave_value& v)
+text::properties::set_fontunits (const octave_value& val)
 {
   if (! error_state)
     {
       caseless_str old_fontunits = get_fontunits ();
-      if (fontunits.set (v, true))
+      if (fontunits.set (val, true))
         {
           update_fontunits (old_fontunits);
           mark_modified ();
@@ -8146,7 +8048,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 +8058,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 +8145,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 +8169,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 +8180,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 +8188,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 +8220,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 +8365,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 +8507,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 +8598,7 @@
     }
   else
     {
-      limits.resize (4,1);
+      limits.resize (4, 1);
       limits(0) = min_val;
       limits(1) = max_val;
       limits(2) = min_pos;
@@ -8881,7 +8780,7 @@
 %! unwind_protect_cleanup
 %!   close (hf);
 %! end_unwind_protect;
- */
+*/
 
 // ---------------------------------------------------------------------
 
@@ -8890,10 +8789,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 +8818,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 +8836,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 +8862,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,12 +8883,12 @@
 }
 
 void
-uicontrol::properties::set_fontunits (const octave_value& v)
+uicontrol::properties::set_fontunits (const octave_value& val)
 {
   if (! error_state)
     {
       caseless_str old_fontunits = get_fontunits ();
-      if (fontunits.set (v, true))
+      if (fontunits.set (val, true))
         {
           update_fontunits (old_fontunits);
           mark_modified ();
@@ -9003,23 +8901,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 +8929,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 +8965,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,12 +8992,12 @@
 }
 
 void
-uipanel::properties::set_units (const octave_value& v)
+uipanel::properties::set_units (const octave_value& val)
 {
   if (! error_state)
     {
       caseless_str old_units = get_units ();
-      if (units.set (v, true))
+      if (units.set (val, true))
         {
           update_units (old_units);
           mark_modified ();
@@ -9112,21 +9010,21 @@
 {
   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)
+uipanel::properties::set_fontunits (const octave_value& val)
 {
   if (! error_state)
     {
       caseless_str old_fontunits = get_fontunits ();
-      if (fontunits.set (v, true))
+      if (fontunits.set (val, true))
         {
           update_fontunits (old_fontunits);
           mark_modified ();
@@ -9139,38 +9037,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 +9080,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 +9134,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 +9155,7 @@
           // constructed.
 
           axes::properties& props =
-            dynamic_cast<axes::properties&> (obj.get_properties ());
+            dynamic_cast<axes::properties&> (go.get_properties ());
 
           graphics_object tgo;
 
@@ -9276,11 +9173,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 +9191,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 +9393,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
@@ -9566,7 +9462,7 @@
           fcn = c(0).function_value ();
           if (! error_state)
             {
-              for (int i = 1; i < c.length () ; i++)
+              for (int i = 1; i < c.numel () ; i++)
                 args(1+i) = c(i);
             }
         }
@@ -9813,7 +9709,7 @@
           boolNDArray result (handles.dims ());
 
           for (octave_idx_type i = 0; i < handles.numel (); i++)
-            result.xelem (i) = is_handle_visible (handles (i));
+            result.xelem (i) = is_handle_visible (handles(i));
 
           retval = result;
         }
@@ -9865,7 +9761,7 @@
       if (! error_state)
         {
           // loop over graphics objects
-          for (octave_idx_type n = 0; n < hcv.length (); n++)
+          for (octave_idx_type n = 0; n < hcv.numel (); n++)
             gh_manager::get_object (hcv(n)).reset_default_properties ();
 
           if (! error_state)
@@ -10080,44 +9976,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,7 +10025,7 @@
                             retval = pmap.getfield (property)(0);
                           else
                             {
-                              std::string s = obj.value_as_string (property);
+                              std::string s = go.value_as_string (property);
                               if (! error_state)
                                 octave_stdout << s;
                             }
@@ -10143,17 +10039,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 ();
+                          std::string s = go.values_as_string ();
                           if (! error_state)
                             octave_stdout << s;
                         }
                     }
                   else
                     {
-                      obj.set (args.splice (0, 1));
+                      go.set (args.splice (0, 1));
                       request_drawnow = true;
                     }
                 }
@@ -10186,10 +10082,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,22 +10128,22 @@
 
       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));
 
               if (! error_state)
                 {
                   for (octave_idx_type n = 1; n < len; n++)
                     {
-                      std::string t = get_graphics_object_type (hcv(n));
+                      std::string typ = get_graphics_object_type (hcv(n));
 
                       if (error_state)
                         break;
 
-                      if (t != t0)
+                      if (typ != typ0)
                         {
                           error ("get: vector of handles must all have same type");
                           break;
@@ -10273,9 +10169,9 @@
 
                       for (octave_idx_type n = 0; ! error_state && n < len; n++)
                         {
-                          graphics_object obj = gh_manager::get_object (hcv(n));
-
-                          if (obj)
+                          graphics_object go = gh_manager::get_object (hcv(n));
+
+                          if (go)
                             {
                               for (octave_idx_type m = 0;
                                    ! error_state && m < plen;
@@ -10283,7 +10179,7 @@
                                 {
                                   caseless_str property = plist(m);
 
-                                  vals(n, m) = obj.get (property);
+                                  vals(n, m) = go.get (property);
                                 }
                             }
                           else
@@ -10314,14 +10210,14 @@
                     {
                       for (octave_idx_type n = 0; ! error_state && n < len; n++)
                         {
-                          graphics_object obj = gh_manager::get_object (hcv(n));
-
-                          if (obj)
+                          graphics_object go = gh_manager::get_object (hcv(n));
+
+                          if (go)
                             {
                               if (nargin == 1)
-                                vals(n) = obj.get ();
+                                vals(n) = go.get ();
                               else
-                                vals(n) = obj.get (property);
+                                vals(n) = go.get (property);
                             }
                           else
                             {
@@ -10396,16 +10292,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));
@@ -10446,8 +10342,7 @@
   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))
           {
@@ -10538,12 +10433,12 @@
 
               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))
                             {
@@ -10566,10 +10461,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 +10512,6 @@
 int
 calc_dimensions (const graphics_object& go)
 {
-
   int nd = 2;
 
   if (go.isa ("surface"))
@@ -10630,13 +10523,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,17 +10715,15 @@
 
       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;
                 }
             }
@@ -10883,9 +10774,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 ())
@@ -10998,15 +10889,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
@@ -11197,7 +11088,7 @@
         {
           Matrix hlist = gh_manager::figure_handle_list (true);
 
-          for (int i = 0; ! error_state && i < hlist.length (); i++)
+          for (int i = 0; ! error_state && i < hlist.numel (); i++)
             {
               graphics_handle h = gh_manager::lookup (hlist(i));
 
@@ -11649,11 +11540,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,12 +11557,12 @@
 {
   gh_manager::auto_lock guard;
 
-  graphics_object obj = gh_manager::get_object (handle);
   int ret = false;
-
-  if (obj)
-    {
-      obj.set (caseless_str (property), arg);
+  graphics_object go = gh_manager::get_object (handle);
+
+  if (go)
+    {
+      go.set (caseless_str (property), arg);
 
       if (! error_state)
         ret = true;
@@ -11683,12 +11574,12 @@
 }
 
 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);
 
@@ -11724,11 +11615,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 (go.get_properties ().has_property (pname))
                     {
@@ -11773,11 +11664,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);
                           octave_value pvalue = go.get (pname);
 
                           if (compare_property_values (pvalue, args(5)))
@@ -11872,8 +11763,7 @@
             {
               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 +11809,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),
@@ -11972,8 +11862,7 @@
             }
 
           if (! error_state
-              && timeout_index < 0
-              && args.length () > (max_arg_index + 1))
+              && timeout_index < 0 && args.length () > (max_arg_index + 1))
             {
               caseless_str s = args(max_arg_index + 1).string_value ();
 
@@ -12012,10 +11901,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 +11925,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;
@@ -12123,7 +12012,6 @@
             }
           else
             ax_props.clear_zoom_stack (false);
-
         }
     }
   else
@@ -12140,3 +12028,4 @@
 
   return retval;
 }
+
--- a/libinterp/corefcn/graphics.in.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/graphics.in.h	Tue Sep 22 04:50:47 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
           {
@@ -2365,7 +2365,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create gh_manager!");
+        error ("unable to create gh_manager!");
 
         retval = false;
       }
@@ -3218,29 +3218,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 ()
@@ -3449,6 +3445,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 +3466,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 +3474,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 +3494,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 +3512,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 +3875,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 +3889,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 +3965,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 +3981,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 +3996,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"
@@ -5913,7 +5950,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create gh_manager!");
+        error ("unable to create gh_manager!");
 
         retval = false;
       }
--- a/libinterp/corefcn/help.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/help.cc	Tue Sep 22 04:50:47 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;
@@ -1303,7 +1303,7 @@
 
   if (! error_state)
     {
-      int argc = argv.length ();
+      int argc = argv.numel ();
 
       if (argc > 1)
         {
--- a/libinterp/corefcn/hex2num.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/hex2num.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/input.cc	Tue Sep 22 04:50:47 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 ();
 
@@ -1028,6 +1028,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\
@@ -1098,7 +1145,7 @@
               // because it will be easier for Emacs if the names
               // appear in a single column.
 
-              int len = list.length ();
+              int len = list.numel ();
 
               for (int i = 0; i < len; i++)
                 octave_stdout << list[i] << "\n";
@@ -1113,6 +1160,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\
--- a/libinterp/corefcn/jit-typeinfo.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/jit-typeinfo.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -257,7 +257,7 @@
                                 double value)
 {
   NDArray *array = mat->array;
-  if (array->nelem () < index)
+  if (array->numel () < index)
     array->resize1 (index);
 
   double *data = array->fortran_vec ();
--- a/libinterp/corefcn/jit-typeinfo.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/jit-typeinfo.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/load-path.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -180,7 +180,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 +250,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 +333,7 @@
 
   if (! instance)
     {
-      ::error ("unable to create load path object!");
+      error ("unable to create load path object!");
 
       retval = false;
     }
@@ -408,7 +408,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++)
     {
@@ -803,7 +803,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 +1373,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 +1488,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 +1534,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 +1567,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 +1612,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 +1670,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 +1716,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 +1893,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 +2150,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 +2161,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)
--- a/libinterp/corefcn/load-save.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/load-save.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/load-save.h	Tue Sep 22 04:50:47 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/ls-hdf5.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/ls-hdf5.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/ls-hdf5.h	Tue Sep 22 04:50:47 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-mat4.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/ls-mat4.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/lsode.cc	Tue Sep 22 04:50:47 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 ();
--- a/libinterp/corefcn/lu.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/lu.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -177,13 +177,13 @@
             {
               if (!issparse)
                 error ("lu: can not define pivoting threshold THRES for full matrices");
-              else if (tmp.nelem () == 1)
+              else if (tmp.numel () == 1)
                 {
                   thres.resize (1,2);
                   thres(0) = tmp(0);
                   thres(1) = tmp(0);
                 }
-              else if (tmp.nelem () == 2)
+              else if (tmp.numel () == 2)
                 thres = tmp;
               else
                 error ("lu: expecting 2-element vector for THRES");
--- a/libinterp/corefcn/luinc.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/luinc.cc	Tue Sep 22 04:50:47 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;
--- a/libinterp/corefcn/matrix_type.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/matrix_type.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -292,7 +292,7 @@
                             error ("matrix_type: Invalid permutation vector PERM");
                           else
                             {
-                              octave_idx_type len = perm.length ();
+                              octave_idx_type len = perm.numel ();
                               dim_vector dv = args(0).dims ();
 
                               if (len != dv(0))
@@ -306,10 +306,7 @@
                                            (perm (i))
                                            - 1;
 
-                                  if (str_typ == "upper")
-                                    mattyp.mark_as_permuted (len, p);
-                                  else
-                                    mattyp.mark_as_permuted (len, p);
+                                  mattyp.mark_as_permuted (len, p);
                                 }
                             }
                         }
@@ -465,7 +462,7 @@
                             error ("matrix_type: Invalid permutation vector PERM");
                           else
                             {
-                              octave_idx_type len = perm.length ();
+                              octave_idx_type len = perm.numel ();
                               dim_vector dv = args(0).dims ();
 
                               if (len != dv(0))
@@ -479,10 +476,7 @@
                                            (perm (i))
                                            - 1;
 
-                                  if (str_typ == "upper")
-                                    mattyp.mark_as_permuted (len, p);
-                                  else
-                                    mattyp.mark_as_permuted (len, p);
+                                  mattyp.mark_as_permuted (len, p);
                                 }
                             }
                         }
--- a/libinterp/corefcn/max.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/max.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -271,7 +271,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 +282,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 ())
--- a/libinterp/corefcn/mex.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/mex.cc	Tue Sep 22 04:50:47 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];
--- a/libinterp/corefcn/mex.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/mex.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/mgorth.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/module.mk	Tue Sep 22 04:50:47 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) \
+	  -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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/oct-errno.in.cc	Tue Sep 22 04:50:47 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-hdf5-id.cc	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/oct-hdf5.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/oct-hist.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -250,7 +250,7 @@
 
   hlist = command_history::list (limit, numbered_output);
 
-  int len = hlist.length ();
+  int len = hlist.numel ();
 
   if (nargout == 0)
     {
@@ -360,7 +360,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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/oct-lvalue.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/oct-lvalue.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/oct-map.cc	Tue Sep 22 04:50:47 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 ());
--- a/libinterp/corefcn/oct-map.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/oct-map.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/oct-obj.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/oct-stream.cc	Tue Sep 22 04:50:47 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)
     {
@@ -235,7 +235,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 +259,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 +342,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 +489,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 +517,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 +547,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 +664,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 +688,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 +871,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 +1603,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 +1867,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));
+            }
         }
     }
 
@@ -3189,7 +3206,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]);
 
--- a/libinterp/corefcn/oct-stream.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/oct-stream.h	Tue Sep 22 04:50:47 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/octave-link.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/octave-link.cc	Tue Sep 22 04:50:47 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;
 }
--- a/libinterp/corefcn/pager.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/pager.cc	Tue Sep 22 04:50:47 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;
     }
--- a/libinterp/corefcn/pr-output.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/pr-output.cc	Tue Sep 22 04:50:47 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)
     {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libinterp/corefcn/psi.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/quad.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/quadcc.cc	Tue Sep 22 04:50:47 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/rand.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/rand.cc	Tue Sep 22 04:50:47 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++)
--- a/libinterp/corefcn/regexp.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/regexp.cc	Tue Sep 22 04:50:47 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;
             }
         }
@@ -282,14 +379,14 @@
         {
           string_vector named_tokens = rx_lst.begin ()->named_tokens ();
 
-          for (int j = 0; j < named_pats.length (); j++)
+          for (int j = 0; j < named_pats.numel (); j++)
             nmap.assign (named_pats(j), named_tokens(j));
 
           retval(5) = nmap;
         }
       else
         {
-          for (int j = 0; j < named_pats.length (); j++)
+          for (int j = 0; j < named_pats.numel (); j++)
             {
               Cell tmp (dim_vector (1, sz));
 
@@ -354,7 +451,7 @@
               double e = p->end ();
 
               string_vector tmp = p->tokens ();
-              tokens(i) = Cell (dim_vector (1, tmp.length ()), tmp);
+              tokens(i) = Cell (dim_vector (1, tmp.numel ()), tmp);
               match_string(i) = p->match_string ();
               token_extents(i) = p->token_extents ();
               end(i) = e;
@@ -1065,6 +1162,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,
--- a/libinterp/corefcn/sighandlers.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/sighandlers.cc	Tue Sep 22 04:50:47 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/strfns.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/strfns.cc	Tue Sep 22 04:50:47 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
--- a/libinterp/corefcn/sub2ind.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/sub2ind.cc	Tue Sep 22 04:50:47 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);
--- a/libinterp/corefcn/symtab.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/symtab.cc	Tue Sep 22 04:50:47 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 ())
                 {
@@ -1728,8 +1729,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 +1749,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 +1813,44 @@
   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 ();
+
+      if (! error_state)
+        {
+          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
+        error ("__get_cmd_line_function_text__: expecting function name");
+    }
+  else
+    print_usage ();
+
+  return retval;
+}
+
 #if 0
 
 // FIXME: should we have functions like this in Octave?
--- a/libinterp/corefcn/symtab.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/symtab.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/syscalls.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -204,7 +204,7 @@
 
               if (! error_state)
                 {
-                  int len = tmp.length ();
+                  int len = tmp.numel ();
 
                   exec_args.resize (len + 1);
 
@@ -316,7 +316,7 @@
 
               if (! error_state)
                 {
-                  int len = tmp.length ();
+                  int len = tmp.numel ();
 
                   arg_list.resize (len + 1);
 
@@ -819,15 +819,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 +865,7 @@
 @seealso{pipe, umask}\n\
 @end deftypefn")
 {
-  octave_value_list retval;
+  octave_value_list retval (2);
 
   retval(1) = std::string ();
   retval(0) = -1;
@@ -848,23 +878,28 @@
         {
           std::string name = args(0).string_value ();
 
-          if (args(1).is_scalar_type ())
-            {
-              long mode = args(1).long_value ();
+          int octal_mode = args(1).int_value ();
 
-              if (! error_state)
+          if (! error_state)
+            {
+              if (octal_mode < 0)
+                error ("mkfifo: MODE must be a positive integer value");
+              else
                 {
-                  std::string msg;
+                  int mode = convert (octal_mode, 8, 10);
 
-                  int status = octave_mkfifo (name, mode, msg);
+                  if (! error_state)
+                    {
+                      std::string msg;
 
-                  retval(0) = status;
+                      int status = octave_mkfifo (name, mode, msg);
 
-                  if (status < 0)
-                    retval(1) = msg;
+                      retval(0) = status;
+
+                      if (status < 0)
+                        retval(1) = msg;
+                    }
                 }
-              else
-                error ("mkfifo: invalid MODE");
             }
           else
             error ("mkfifo: MODE must be an integer");
@@ -878,6 +913,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\
--- a/libinterp/corefcn/time.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/time.cc	Tue Sep 22 04:50:47 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\
@@ -211,6 +214,7 @@
            wday = 1\n\
            yday = 47\n\
            isdst = 0\n\
+           gmtoff = -21600\n\
            zone = CST\n\
         @}\n\
 @end group\n\
@@ -399,6 +403,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\
--- a/libinterp/corefcn/toplev.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/toplev.h	Tue Sep 22 04:50:47 2015 -0700
@@ -134,7 +134,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create call stack object!");
+        error ("unable to create call stack object!");
 
         retval = false;
       }
--- a/libinterp/corefcn/tril.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/tril.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -218,7 +218,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
         {
--- a/libinterp/corefcn/tsearch.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/tsearch.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -103,7 +103,7 @@
       maxy(k) = max (REF (y, k, 0), REF (y, k, 1), REF (y, k, 2)) + eps;
     }
 
-  const octave_idx_type np = xi.length ();
+  const octave_idx_type np = xi.numel ();
   ColumnVector values (np);
 
   double x0, y0, a11, a12, a21, a22, det;
--- a/libinterp/corefcn/txt-eng-ft.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/txt-eng-ft.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/typecast.cc	Tue Sep 22 04:50:47 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);
--- a/libinterp/corefcn/urlwrite.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/urlwrite.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -81,7 +81,7 @@
 
     if (! instance)
       {
-        ::error ("unable to create ch_manager!");
+        error ("unable to create ch_manager!");
 
         retval = false;
       }
@@ -712,7 +712,7 @@
           else
             {
               string_vector sv = curl.list ();
-              octave_idx_type n = sv.length ();
+              octave_idx_type n = sv.numel ();
 
               if (n == 0)
                 {
@@ -1050,7 +1050,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);
 
@@ -1145,7 +1145,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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/utils.cc	Tue Sep 22 04:50:47 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 =
@@ -399,7 +399,7 @@
 
           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);
@@ -631,11 +631,7 @@
         {
           switch (s[++j])
             {
-            case '0':
-              retval[i] = '\0';
-              break;
-
-            case 'a':
+            case 'a': // alarm
               retval[i] = '\a';
               break;
 
@@ -675,6 +671,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]);
@@ -745,9 +793,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 *
@@ -1159,7 +1218,7 @@
           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)));
--- a/libinterp/corefcn/variables.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/variables.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -395,6 +395,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)
     {
@@ -682,6 +690,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")
 
 */
 
@@ -1247,7 +1256,7 @@
                   break;
 
                 case 'e':
-                  os << varval.capacity ();
+                  os << varval.numel ();
                   break;
 
                 case 'n':
@@ -1395,7 +1404,7 @@
 
             octave_value val = p->varval;
 
-            elements += val.capacity ();
+            elements += val.numel ();
             bytes += val.byte_size ();
           }
 
@@ -1467,7 +1476,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 ()
@@ -2208,7 +2217,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 +2243,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 +2254,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 +2284,7 @@
         {
           string_vector lvars = symbol_table::variable_names ();
 
-          int lcount = lvars.length ();
+          int lcount = lvars.numel ();
 
           for (int i = 0; i < lcount; i++)
             {
--- a/libinterp/corefcn/xdiv.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/xdiv.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/corefcn/xpow.cc	Tue Sep 22 04:50:47 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/__glpk__.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/dldfcn/__glpk__.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/dldfcn/__init_fltk__.cc	Tue Sep 22 04:50:47 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/__magick_read__.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/dldfcn/__magick_read__.cc	Tue Sep 22 04:50:47 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;
@@ -711,7 +716,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;
@@ -776,7 +781,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 +803,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 ()
@@ -1546,6 +1551,23 @@
   // 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;
--- a/libinterp/dldfcn/audiodevinfo.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/dldfcn/audiodevinfo.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/dldfcn/audioread.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -115,7 +115,7 @@
       if (error_state)
         return retval;
 
-      if (range.nelem () != 2)
+      if (range.numel () != 2)
         {
           error ("audioread: invalid specification for range of frames");
           return retval;
--- a/libinterp/dldfcn/ccolamd.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/dldfcn/ccolamd.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/dldfcn/chol.cc	Tue Sep 22 04:50:47 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 (),
@@ -162,10 +169,6 @@
           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;
@@ -266,18 +269,12 @@
                   octave_idx_type info;
 
                   FloatCHOL fact;
-                  if (LLt)
-                    fact = FloatCHOL (m.transpose (), info);
-                  else
-                    fact = FloatCHOL (m, info);
+                  fact = FloatCHOL (m, info, LLt != true);
 
                   if (nargout == 2 || info == 0)
                     {
                       retval(1) = info;
-                      if (LLt)
-                        retval(0) = get_chol_l (fact);
-                      else
-                        retval(0) = get_chol_r (fact);
+                      retval(0) = get_chol (fact);
                     }
                   else
                     error ("chol: input matrix must be positive definite");
@@ -323,18 +320,12 @@
                   octave_idx_type info;
 
                   CHOL fact;
-                  if (LLt)
-                    fact = CHOL (m.transpose (), info);
-                  else
-                    fact = CHOL (m, info);
+                  fact = CHOL (m, info, LLt != true);
 
                   if (nargout == 2 || info == 0)
                     {
                       retval(1) = info;
-                      if (LLt)
-                        retval(0) = get_chol_l (fact);
-                      else
-                        retval(0) = get_chol_r (fact);
+                      retval(0) = get_chol (fact);
                     }
                   else
                     error ("chol: input matrix must be positive definite");
@@ -349,18 +340,12 @@
                   octave_idx_type info;
 
                   ComplexCHOL fact;
-                  if (LLt)
-                    fact = ComplexCHOL (m.transpose (), info);
-                  else
-                    fact = ComplexCHOL (m, info);
+                  fact = ComplexCHOL (m, info, LLt != true);
 
                   if (nargout == 2 || info == 0)
                     {
                       retval(1) = info;
-                      if (LLt)
-                        retval(0) = get_chol_l (fact);
-                      else
-                        retval(0) = get_chol_r (fact);
+                      retval(0) = get_chol (fact);
                     }
                   else
                     error ("chol: input matrix must be positive definite");
--- a/libinterp/dldfcn/colamd.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/dldfcn/colamd.cc	Tue Sep 22 04:50:47 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);
--- a/libinterp/dldfcn/config-module.awk	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/dldfcn/config-module.awk	Tue Sep 22 04:50:47 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/link-deps.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/link-deps.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/mkdefs	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/mkops	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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) \
+	  -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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/module.mk	Tue Sep 22 04:50:47 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) \
 	  -DMAKE_BUILTINS $< > $@-t1 && \
-	$(srcdir)/mkdefs $(srcdir) $< < $@-t1 > $@-t && \
+	$(srcdir)/libinterp/mkdefs $(srcdir)/libinterp $< < $@-t1 > $@-t && \
 	mv $@-t $@ && \
 	rm -f $@-t1
 
-noinst_LTLIBRARIES += octave-value/liboctave-value.la
+noinst_LTLIBRARIES += libinterp/octave-value/liboctave-value.la
 
-octave_value_liboctave_value_la_SOURCES = $(OCTAVE_VALUE_SRC)
+libinterp_octave_value_liboctave_value_la_SOURCES = $(OCTAVE_VALUE_SRC)
 
 ## FIXME -- maybe it would be better to limit the JAVA flags to
 ## the compile commands for ov-java.cc?  Does JAVA_LIBS need to be
 ## added to LIBOCTINTERP_LINK_DEPS (see libinterp/link-deps.mk)?
 ## Should we have a separate set of JAVA_LDFLAGS?
 
-octave_value_liboctave_value_la_CPPFLAGS = \
-  $(liboctinterp_la_CPPFLAGS) \
+libinterp_octave_value_liboctave_value_la_CPPFLAGS = \
+  $(libinterp_liboctinterp_la_CPPFLAGS) \
   $(HDF5_CPPFLAGS) \
   $(JAVA_CPPFLAGS)
 
-octave_value_liboctave_value_la_LIBADD = $(JAVA_LIBS)
+libinterp_octave_value_liboctave_value_la_CFLAGS = $(AM_CFLAGS) $(WARN_CFLAGS)
+
+libinterp_octave_value_liboctave_value_la_CXXFLAGS = $(AM_CXXFLAGS) $(WARN_CXXFLAGS)
+
+libinterp_octave_value_liboctave_value_la_LIBADD = $(JAVA_LIBS)
--- a/libinterp/octave-value/ov-base-diag.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-base-diag.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -38,7 +38,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
--- a/libinterp/octave-value/ov-base-int.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-base-int.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-base-mat.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -358,7 +358,7 @@
                 for (octave_idx_type i = 0; i < n_idx; i++)
                   {
                     j += idx_vec(i)(0) * k;
-                    k *= dv (i);
+                    k *= dv(i);
                   }
                 matrix(j) = rhs;
               }
--- a/libinterp/octave-value/ov-base-sparse.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-base-sparse.cc	Tue Sep 22 04:50:47 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"
 
@@ -394,8 +394,8 @@
   matrix.maybe_compress ();
 
   os << "# nnz: "      << nnz () << "\n";
-  os << "# rows: "     << dv (0) << "\n";
-  os << "# columns: "  << dv (1) << "\n";
+  os << "# rows: "     << dv(0) << "\n";
+  os << "# columns: "  << dv(1) << "\n";
 
   os << this->matrix;
 
--- a/libinterp/octave-value/ov-base-sparse.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-base-sparse.h	Tue Sep 22 04:50:47 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.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-base.h	Tue Sep 22 04:50:47 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; }
 
--- a/libinterp/octave-value/ov-bool-mat.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-bool-mat.cc	Tue Sep 22 04:50:47 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.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-bool.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-builtin.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -109,7 +109,7 @@
     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;
--- a/libinterp/octave-value/ov-cell.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-cell.cc	Tue Sep 22 04:50:47 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"
@@ -156,7 +156,7 @@
           {
             Cell tcell = tmp.cell_value ();
 
-            if (tcell.length () == 1)
+            if (tcell.numel () == 1)
               retval(0) = tcell(0,0);
             else
               retval = octave_value (octave_value_list (tcell), true);
@@ -208,7 +208,7 @@
           {
             const Cell tcell = tmp.cell_value ();
 
-            if (tcell.length () == 1)
+            if (tcell.numel () == 1)
               retval = tcell(0,0);
             else
               retval = octave_value (octave_value_list (tcell), true);
@@ -617,7 +617,7 @@
       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 +638,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 +767,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 +777,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 +786,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 +799,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 +849,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 +898,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)
@@ -1470,7 +1470,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-class.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-class.cc	Tue Sep 22 04:50:47 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"
@@ -406,7 +406,7 @@
                   {
                     Cell t = tmp.index (idx.front ());
 
-                    retval(0) = (t.length () == 1) ? t(0)
+                    retval(0) = (t.numel () == 1) ? t(0)
                                                    : octave_value (t, true);
 
                     // We handled two index elements, so tell
@@ -427,7 +427,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;
@@ -508,7 +508,7 @@
 {
   octave_value retval;
 
-  if (val.length () == 1)
+  if (val.numel () == 1)
     {
       retval = val(0);
 
@@ -1277,7 +1277,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,7 +1310,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;
@@ -1985,23 +1985,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);
--- a/libinterp/octave-value/ov-class.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-class.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-classdef.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -578,8 +578,7 @@
                            meth_name.c_str ());
                 }
               else
-                error ("fevalStatic: method not found: %s",
-                       meth_name.c_str ());
+                error ("fevalStatic: method not found: %s", meth_name.c_str ());
             }
           else
             error ("fevalStatic: invalid method name, expected a string value");
@@ -740,8 +739,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);
@@ -993,7 +992,7 @@
                   if (retlist.length () > 0)
                     retval = retlist(0);
                   else
-                    ::error ("overloaded method `subsasgn' did not return any value");
+                    error ("overloaded method `subsasgn' did not return any value");
                 }
             }
         }
@@ -1256,12 +1255,12 @@
                         retval(0) = sym;
                       }
                     else
-                      ::error ("cannot call superclass constructor with "
-                               "variable `%s'", mname.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 ());
+                  error ("`%s' is not a direct superclass of `%s'",
+                         cname.c_str (), ctx.get_name ().c_str ());
               }
             else
               {
@@ -1286,21 +1285,21 @@
                           retval = meth.execute (idx, nargout, true,
                                                  meth_name);
                         else
-                          ::error ("no method `%s' found in superclass `%s'",
-                                   meth_name.c_str (), cname.c_str ());
+                          error ("no method `%s' found in superclass `%s'",
+                                 meth_name.c_str (), cname.c_str ());
                       }
                     else
-                      ::error ("`%s' is not a superclass of `%s'",
-                               cname.c_str (), ctx.get_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 ());
+                  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;
   }
@@ -1476,17 +1475,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;
 
@@ -1626,16 +1634,17 @@
     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;
           }
 
+        bool is_scalar = true;
+        Array<idx_vector> iv (dim_vector (1, ival.length ()));
+
         for (int i = 0; ! error_state && i < ival.length (); i++)
           {
             iv(i) = ival(i).index_vector ();
@@ -1704,8 +1713,8 @@
       // 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;
     }
 
@@ -1774,9 +1783,9 @@
                     }
                 }
               else
-                ::error ("can't assign %s object into array of %s objects.",
-                         rhs_obj.class_name ().c_str (),
-                         class_name ().c_str ());
+                error ("can't assign %s object into array of %s objects.",
+                       rhs_obj.class_name ().c_str (),
+                       class_name ().c_str ());
             }
         }
       else
@@ -1874,8 +1883,8 @@
       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;
     }
 
@@ -1937,6 +1946,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
@@ -2167,8 +2182,8 @@
                     }
                 }
               else
-                ::error ("%s: invalid constructor output arguments",
-                         meth.get_name ().c_str ());
+                error ("%s: invalid constructor output arguments",
+                       meth.get_name ().c_str ());
             }
         }
     }
@@ -2533,7 +2548,7 @@
                                              "meta.class");
                     }
                   else
-                    ::error ("method `%s' is not static", nm.c_str ());
+                    error ("method `%s' is not static", nm.c_str ());
                 }
               else
                 {
@@ -2544,22 +2559,21 @@
                       if (prop.is_constant ())
                         retval(0) = prop.get_value (true, "meta.class");
                       else
-                        ::error ("property `%s' is not constant",
-                                 nm.c_str ());
+                        error ("property `%s' is not constant", nm.c_str ());
                     }
                   else
-                    ::error ("no such method or property `%s'", nm.c_str ());
+                    error ("no such method or property `%s'", nm.c_str ());
                 }
             }
           else
-            ::error ("invalid meta.class indexing, expected a method or property name");
+            error ("invalid meta.class indexing, expected a method or property name");
         }
       else
-        ::error ("invalid meta.class indexing");
+        error ("invalid meta.class indexing");
       break;
 
     default:
-      ::error ("invalid meta.class indexing");
+      error ("invalid meta.class indexing");
       break;
     }
 
@@ -2654,8 +2668,8 @@
             obj = to_cdef (ctor_retval(0));
           else
             {
-              ::error ("%s: invalid number of output arguments for classdef constructor",
-                       ctor_name.c_str ());
+              error ("%s: invalid number of output arguments for classdef constructor",
+                     ctor_name.c_str ());
               return;
             }
         }
@@ -2829,8 +2843,8 @@
                 slist.push_back (sclass);
               else
                 {
-                  ::error ("`%s' cannot inherit from `%s', because it is sealed",
-                           full_class_name.c_str (), sclass_name.c_str ());
+                  error ("`%s' cannot inherit from `%s', because it is sealed",
+                         full_class_name.c_str (), sclass_name.c_str ());
                   return retval;
                 }
             }
@@ -3142,8 +3156,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;
         }
     }
@@ -3209,8 +3223,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;
         }
     }
@@ -3314,8 +3328,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 ());
     }
 }
 
--- a/libinterp/octave-value/ov-classdef.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-classdef.h	Tue Sep 22 04:50:47 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 ();
   }
 
@@ -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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-complex.cc	Tue Sep 22 04:50:47 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>;
--- a/libinterp/octave-value/ov-cx-mat.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-cx-mat.cc	Tue Sep 22 04:50:47 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";
 
@@ -584,7 +584,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-fcn-handle.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-fcn-handle.cc	Tue Sep 22 04:50:47 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)
                     {
@@ -1869,6 +1869,11 @@
       if (args(0).is_string ())
         {
           std::string nm = args(0).string_value ();
+          if (nm[0] == '@')
+            {
+              error ("str2func: Can't process anonymous functions.");
+              return retval;
+            }
           retval = make_fcn_handle (nm, nargin != 2);
         }
       else
--- a/libinterp/octave-value/ov-fcn-inline.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-fcn-inline.cc	Tue Sep 22 04:50:47 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 << ", ";
@@ -751,7 +751,7 @@
                     {
                       bool have_arg = false;
 
-                      for (int j = 0; j < fargs.length (); j++)
+                      for (int j = 0; j < fargs.numel (); j++)
                         if (tmp_arg == fargs (j))
                           {
                             have_arg = true;
@@ -773,7 +773,7 @@
               // Sort the arguments into ascii order.
               fargs.sort ();
 
-              if (fargs.length () == 0)
+              if (fargs.numel () == 0)
                 fargs.append (std::string ("x"));
 
             }
@@ -920,9 +920,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;
--- a/libinterp/octave-value/ov-float.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-float.cc	Tue Sep 22 04:50:47 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>;
--- a/libinterp/octave-value/ov-flt-complex.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-flt-complex.cc	Tue Sep 22 04:50:47 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>;
--- a/libinterp/octave-value/ov-flt-cx-mat.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-flt-cx-mat.cc	Tue Sep 22 04:50:47 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";
 
@@ -546,7 +546,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-mat.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-flt-re-mat.cc	Tue Sep 22 04:50:47 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";
 
@@ -573,7 +573,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-int16.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-int16.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-int32.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-int64.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-int8.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-java.cc	Tue Sep 22 04:50:47 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);
+                    }
                 }
             }
         }
@@ -1060,14 +1069,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 +1106,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 +1117,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 +1126,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 +1138,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 +1147,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 +1226,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 +1347,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 +1372,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 +1393,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 +1404,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 +1414,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 +1424,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));
@@ -1603,7 +1612,7 @@
               Cell c = val.cell_value ();
               octave_function *fcn = c(0).function_value ();
 
-              for (int i=1; i<c.length (); i++)
+              for (int i=1; i<c.numel (); i++)
                 oct_args(len+i-1) = c(i);
 
               if (! error_state)
@@ -1837,6 +1846,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)
--- a/libinterp/octave-value/ov-java.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-java.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-lazy-idx.cc	Tue Sep 22 04:50:47 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,14 +161,14 @@
 
 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");
--- a/libinterp/octave-value/ov-mex-fcn.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-mex-fcn.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -136,7 +136,7 @@
     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;
--- a/libinterp/octave-value/ov-oncleanup.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-oncleanup.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -111,23 +111,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 +130,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 +139,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 +148,8 @@
                              const char * /* name */,
                              bool /* save_as_floats */)
 {
-  warn_save_load ();
+  warning ("save: unable to save onCleanup variables, skipping");
+
   return true;
 }
 
@@ -160,7 +157,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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-oncleanup.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-perm.cc	Tue Sep 22 04:50:47 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,
@@ -261,7 +261,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 +439,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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-range.cc	Tue Sep 22 04:50:47 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 ());
@@ -131,7 +131,7 @@
       idx_vector i = idx(0).index_vector ();
       if (! error_state)
         {
-          if (i.is_scalar () && i(0) < range.nelem ())
+          if (i.is_scalar () && i(0) < range.numel ())
             retval = range.elem (i(0));
           else
             retval = range.index (i);
@@ -173,7 +173,7 @@
 {
   double retval = lo_ieee_nan_value ();
 
-  octave_idx_type nel = range.nelem ();
+  octave_idx_type nel = range.numel ();
 
   if (nel > 0)
     {
@@ -193,7 +193,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 +264,7 @@
 {
   bool retval = false;
 
-  if (range.nelem () != 0)
+  if (range.numel () != 0)
     {
       // FIXME: this is a potential waste of memory.
 
@@ -283,7 +283,7 @@
 
   Complex retval (tmp, tmp);
 
-  octave_idx_type nel = range.nelem ();
+  octave_idx_type nel = range.numel ();
 
   if (nel > 0)
     {
@@ -305,7 +305,7 @@
 
   FloatComplex retval (tmp, tmp);
 
-  octave_idx_type nel = range.nelem ();
+  octave_idx_type nel = range.numel ();
 
   if (nel > 0)
     {
@@ -370,7 +370,7 @@
 {
   bool retval = false;
 
-  octave_idx_type n = range.nelem ();
+  octave_idx_type n = range.numel ();
 
   indent (os);
 
@@ -392,7 +392,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 +434,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 +487,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 +583,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 +693,7 @@
 octave_value
 octave_range::fast_elem_extract (octave_idx_type n) const
 {
-  return (n < range.nelem ()) ? octave_value (range.elem (n))
+  return (n < range.numel ()) ? octave_value (range.elem (n))
                               : octave_value ();
 }
 
--- a/libinterp/octave-value/ov-range.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-range.h	Tue Sep 22 04:50:47 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-mat.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-re-mat.cc	Tue Sep 22 04:50:47 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";
 
@@ -685,7 +685,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-scalar.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-scalar.cc	Tue Sep 22 04:50:47 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>;
--- a/libinterp/octave-value/ov-str-mat.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-str-mat.cc	Tue Sep 22 04:50:47 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"
@@ -292,7 +292,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 +300,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";
@@ -442,7 +442,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
@@ -592,7 +592,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 +697,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-struct.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-struct.cc	Tue Sep 22 04:50:47 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"
@@ -157,7 +157,7 @@
               {
                 const Cell t = tmp.index (idx.front ());
 
-                retval(0) = (t.length () == 1) ? t(0) : octave_value (t, true);
+                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.
@@ -176,7 +176,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;
@@ -223,7 +223,7 @@
               {
                 const Cell t = tmp.index (idx.front (), auto_add);
 
-                retval = (t.length () == 1) ? t(0) : octave_value (t, true);
+                retval = (t.numel () == 1) ? t(0) : octave_value (t, true);
 
                 // We handled two index elements, so tell
                 // next_subsref to skip both of them.
@@ -242,7 +242,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;
@@ -679,7 +679,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 +735,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 +751,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 +766,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,7 +820,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;
@@ -1400,7 +1400,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 +1461,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 +1476,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 +1504,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;
@@ -2017,7 +2017,7 @@
 
   string_vector keys = m.fieldnames ();
 
-  if (keys.length () == 0)
+  if (keys.numel () == 0)
     retval = Cell (0, 1);
   else
     retval = Cell (keys);
--- a/libinterp/octave-value/ov-typeinfo.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-typeinfo.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-uint16.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-uint32.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-uint64.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-uint8.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov-usr-fcn.cc	Tue Sep 22 04:50:47 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;
 }
@@ -161,7 +161,7 @@
                     tree_break_command::breaking--;
                 }
               else
-                ::error ("max_recursion_depth exceeded");
+                error ("max_recursion_depth exceeded");
             }
         }
       else
@@ -514,7 +514,7 @@
 
   if (call_depth >= Vmax_recursion_depth)
     {
-      ::error ("max_recursion_depth exceeded");
+      error ("max_recursion_depth exceeded");
       return retval;
     }
 
@@ -555,8 +555,8 @@
         }
       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;
         }
     }
--- a/libinterp/octave-value/ov.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -2998,7 +2998,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 () == ":")
--- a/libinterp/octave-value/ov.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/octave-value/ov.h	Tue Sep 22 04:50:47 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 (); }
--- a/libinterp/operators/module.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/operators/module.mk	Tue Sep 22 04:50:47 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-int.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/operators/op-int.h	Tue Sep 22 04:50:47 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/parse-tree/module.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/parse-tree/module.mk	Tue Sep 22 04:50:47 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/pt-arg-list.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/parse-tree/pt-arg-list.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -195,7 +195,7 @@
         retval = 1;
     }
   else
-    ::error ("invalid use of end");
+    error ("invalid use of end");
 
   return retval;
 }
@@ -244,7 +244,7 @@
 
           if (error_state)
             {
-              ::error ("evaluating argument list element number %d", k+1);
+              error ("evaluating argument list element number %d", k+1);
               args.clear ();
               break;
             }
--- a/libinterp/parse-tree/pt-assign.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/parse-tree/pt-assign.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -260,6 +260,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.
--- a/libinterp/parse-tree/pt-cell.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/parse-tree/pt-cell.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/parse-tree/pt-colon.cc	Tue Sep 22 04:50:47 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;
 }
@@ -133,7 +133,7 @@
                     retval = tmp2 (0);
                 }
               else
-                ::error ("can not find overloaded colon function");
+                error ("can not find overloaded colon function");
             }
         }
       else
@@ -160,7 +160,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-eval.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/parse-tree/pt-eval.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -337,7 +337,7 @@
       {
         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++)
           {
@@ -412,8 +412,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 ());
       }
   }
 }
@@ -878,8 +878,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
--- a/libinterp/parse-tree/pt-exp.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/parse-tree/pt-exp.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -47,8 +47,8 @@
       if (t1.is_defined ())
         return t1.is_true ();
       else
-        ::error ("%s: undefined value used in conditional expression",
-                 warn_for);
+        error ("%s: undefined value used in conditional expression",
+               warn_for);
     }
 
   return expr_value;
@@ -57,14 +57,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 +77,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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/parse-tree/pt-id.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -50,12 +50,12 @@
     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
--- a/libinterp/parse-tree/pt-id.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/parse-tree/pt-id.h	Tue Sep 22 04:50:47 2015 -0700
@@ -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,
--- a/libinterp/parse-tree/pt-mat.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/parse-tree/pt-mat.cc	Tue Sep 22 04:50:47 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
--- a/libinterp/parse-tree/pt-misc.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/parse-tree/pt-misc.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -200,7 +200,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	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/parse-tree/pt-pr-code.cc	Tue Sep 22 04:50:47 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/template-inst/module.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/libinterp/template-inst/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/Array-util.cc	Tue Sep 22 04:50:47 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)
         {
@@ -217,7 +217,7 @@
 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++)
     {
@@ -235,7 +235,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 +257,7 @@
 {
   dim_vector retval;
 
-  int n = ra_idx.length ();
+  int n = ra_idx.numel ();
 
   assert (n == dimensions.length ());
 
@@ -298,7 +298,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 +317,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 +337,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 +360,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 +376,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 +423,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 +530,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)
     {
@@ -560,7 +560,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 +572,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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/Array.cc	Tue Sep 22 04:50:47 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
@@ -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)));
@@ -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?
@@ -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;
@@ -1183,6 +1183,7 @@
     gripe_invalid_assignment_size ();
 }
 
+// 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
+  // any empty RHS can be assigned to an empty LHS
+  else if ((il != 0 && jl != 0) || (rhdv(0) != 0 && rhdv(1) != 0))
     gripe_assignment_dimension_mismatch ();
 }
 
+// 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,7 +1387,19 @@
             }
         }
       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_assignment_dimension_mismatch ();
+        }
     }
 }
 
@@ -1439,7 +1454,7 @@
       return;
     }
 
-  octave_idx_type n = dimensions (dim);
+  octave_idx_type n = dimensions(dim);
   if (i.is_colon ())
     {
       *this = Array<T> ();
@@ -1492,7 +1507,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 +1605,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 +1791,7 @@
 
   dim_vector dv = m.dims ();
 
-  if (m.length () < 1)
+  if (m.numel () < 1)
     return m;
 
   if (dim >= dv.length ())
@@ -1897,7 +1912,7 @@
 
   dim_vector dv = m.dims ();
 
-  if (m.length () < 1)
+  if (m.numel () < 1)
     {
       sidx = Array<octave_idx_type> (dv);
       return m;
@@ -2231,7 +2246,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 +2262,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 +2332,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 +2548,8 @@
     (*current_liboctave_error_handler) ("Matrix must be 2-dimensional");
   else
     {
-      octave_idx_type nnr = dv (0);
-      octave_idx_type nnc = dv (1);
+      octave_idx_type nnr = dv(0);
+      octave_idx_type nnc = dv(1);
 
       if (nnr == 0 && nnc == 0)
         ; // do nothing for empty matrix
--- a/liboctave/array/Array.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/Array.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/CColVector.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/CDiagMatrix.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/CMatrix.cc	Tue Sep 22 04:50:47 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;
@@ -1193,7 +1193,7 @@
     {
       if (mattype.is_hermitian ())
         {
-          ComplexCHOL chol (*this, info, calc_cond);
+          ComplexCHOL chol (*this, info, true, calc_cond);
           if (info == 0)
             {
               if (calc_cond)
@@ -1229,7 +1229,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 ();
 
@@ -1320,7 +1320,7 @@
 ComplexMatrix
 ComplexMatrix::fourier2d (void) const
 {
-  dim_vector dv(rows (), cols ());
+  dim_vector dv (rows (), cols ());
 
   ComplexMatrix retval (rows (), cols ());
   const Complex *in (data ());
@@ -1334,7 +1334,7 @@
 ComplexMatrix
 ComplexMatrix::ifourier2d (void) const
 {
-  dim_vector dv(rows (), cols ());
+  dim_vector dv (rows (), cols ());
 
   ComplexMatrix retval (rows (), cols ());
   const Complex *in (data ());
@@ -2844,7 +2844,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)
@@ -2957,11 +2957,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 ();
@@ -3085,7 +3085,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;
 }
 
@@ -3109,7 +3109,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;
 }
 
@@ -3999,21 +3999,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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/CNDArray.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/CRowVector.cc	Tue Sep 22 04:50:47 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/DiagArray2.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/DiagArray2.cc	Tue Sep 22 04:50:47 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));
 }
 
--- a/liboctave/array/DiagArray2.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/DiagArray2.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/MArray.cc	Tue Sep 22 04:50:47 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/PermMatrix.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/PermMatrix.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/PermMatrix.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/Range.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -44,24 +44,24 @@
   // 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);
       double b = rng_base;
       double increment = rng_inc;
-      if (rng_nelem > 0)
+      if (rng_numel > 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++)
+          for (octave_idx_type i = 1; i < rng_numel; i++)
             cache(i) = b + i * increment;
         }
 
@@ -72,9 +72,9 @@
       // 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;
+      if ((rng_inc > 0 && cache(rng_numel-1) >= rng_limit)
+          || (rng_inc < 0 && cache(rng_numel-1) <= rng_limit))
+        cache(rng_numel-1) = rng_limit;
     }
 
   return cache;
@@ -83,12 +83,12 @@
 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
     {
@@ -109,7 +109,7 @@
 #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
     {
@@ -158,11 +158,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,26 +181,26 @@
       // 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.
           if (retval <= rng_limit)
@@ -215,11 +215,11 @@
 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.
           if (retval >= rng_limit)
@@ -255,7 +255,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));
 
@@ -336,9 +336,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;
@@ -351,7 +351,7 @@
 {
   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)
     {
@@ -377,7 +377,7 @@
       if (is)
         {
           is >> a.rng_inc;
-          a.rng_nelem = a.nelem_internal ();
+          a.rng_numel = a.numel_internal ();
         }
     }
 
@@ -387,13 +387,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 +401,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 +410,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 +419,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 +428,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 +437,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 +524,7 @@
 }
 
 octave_idx_type
-Range::nelem_internal (void) const
+Range::numel_internal (void) const
 {
   octave_idx_type retval = -1;
 
--- a/liboctave/array/Range.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/Range.h	Tue Sep 22 04:50:47 2015 -0700
@@ -35,33 +35,34 @@
 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 () { }
 
   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 () { }
 
   // 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;
   }
 
   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;
 
@@ -137,11 +138,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 +151,10 @@
   // For operators' usage (to allow all values to be set directly).
   Range (double b, double l, double i, octave_idx_type n)
     : rng_base (b), rng_limit (l), rng_inc (i),
-      rng_nelem (n), cache ()
+      rng_numel (n), cache ()
   {
     if (! xfinite (b) || ! xfinite (i) || ! xfinite (l))
-      rng_nelem = -2;
+      rng_numel = -2;
   }
 };
 
--- a/liboctave/array/Sparse.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/Sparse.cc	Tue Sep 22 04:50:47 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>
@@ -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.
 
@@ -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.
 
@@ -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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/Sparse.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/boolMatrix.cc	Tue Sep 22 04:50:47 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/chMatrix.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/chMatrix.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/chNDArray.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/dColVector.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/dDiagMatrix.cc	Tue Sep 22 04:50:47 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");
--- a/liboctave/array/dMatrix.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/dMatrix.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/dNDArray.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/dRowVector.cc	Tue Sep 22 04:50:47 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/dim-vector.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/dim-vector.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/fCColVector.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/fCDiagMatrix.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/fCMatrix.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/fCNDArray.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/fCRowVector.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/fColVector.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/fDiagMatrix.cc	Tue Sep 22 04:50:47 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");
--- a/liboctave/array/fMatrix.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/fMatrix.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/fNDArray.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/fRowVector.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/idx-vector.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -121,7 +121,7 @@
 }
 
 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)
     {
@@ -405,7 +405,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++)
--- a/liboctave/array/intNDArray.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/intNDArray.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/array/module.mk	Tue Sep 22 04:50:47 2015 -0700
@@ -1,140 +1,142 @@
-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-defs.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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/Faddeeva/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/amos/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/blas-xtra/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/daspk/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/dasrt/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/dassl/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/fftpack/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/lapack-xtra/module.mk	Tue Sep 22 04:50:47 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/module.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/misc/module.mk	Tue Sep 22 04:50:47 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/module.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/odepack/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/ordered-qz/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/quadpack/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/ranlib/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/slatec-err/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/cruft/slatec-fn/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/CmplxCHOL.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/CmplxCHOL.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/CmplxLU.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/CmplxQR.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/CollocWt.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/DASPK.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/DASRT.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/DASSL.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/EIG.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/LSODE.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/ODES.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/ODES.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/Quad.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/SparseCmplxLU.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/SparsedbleLU.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/base-dae.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/base-de.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/base-lu.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/base-min.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/dbleCHOL.cc	Tue Sep 22 04:50:47 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,19 @@
       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 +178,7 @@
 }
 
 static Matrix
-chol2inv_internal (const Matrix& r)
+chol2inv_internal (const Matrix& r, bool is_upper = true)
 {
   Matrix retval;
 
@@ -161,17 +195,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 +240,7 @@
 Matrix
 CHOL::inverse (void) const
 {
-  return chol2inv_internal (chol_mat);
+  return chol2inv_internal (chol_mat, is_upper);
 }
 
 void
@@ -205,7 +259,7 @@
 {
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       ColumnVector utmp = u;
 
@@ -225,7 +279,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       ColumnVector utmp = u;
 
@@ -247,7 +301,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 +363,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 +389,7 @@
 
   octave_idx_type n = chol_mat.rows ();
 
-  if (u.length () == n)
+  if (u.numel () == n)
     {
       if (singular (chol_mat))
         info = 2;
@@ -361,7 +415,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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/dbleCHOL.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/dbleLU.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/dbleQR.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/eigs-base.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/fCmplxCHOL.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/fCmplxLU.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/fCmplxQR.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/fEIG.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/floatCHOL.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/floatCHOL.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/floatLU.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/floatQR.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/lo-mappers.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/lo-specfun.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/lo-specfun.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/oct-rand.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/oct-spparms.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/numeric/sparse-base-chol.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/operators/mk-ops.awk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/operators/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/operators/mx-inlines.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/operators/sparse-mk-ops.awk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/system/file-ops.cc	Tue Sep 22 04:50:47 2015 -0700
@@ -152,7 +152,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 ();
 
@@ -187,7 +187,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 ();
 
@@ -346,7 +346,7 @@
 {
   string_vector retval;
 
-  int n = names.length ();
+  int n = names.numel ();
 
   retval.resize (n);
 
@@ -580,7 +580,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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/system/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/system/oct-time.cc	Tue Sep 22 04:50:47 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/f2c-main.c	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/util/f2c-main.c	Tue Sep 22 04:50:47 2015 -0700
@@ -20,6 +20,10 @@
 
 */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <assert.h>
 
 
--- a/liboctave/util/glob-match.h	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/util/glob-match.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/util/kpse.cc	Tue Sep 22 04:50:47 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-regexp.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/util/lo-regexp.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/util/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/util/oct-glob.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/util/oct-shlib.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/util/pathsearch.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/util/sparse-util.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/util/sparse-util.h	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/util/str-vec.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/util/str-vec.h	Tue Sep 22 04:50:47 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/url-transfer.cc	Tue Sep 22 04:47:25 2015 -0700
+++ b/liboctave/util/url-transfer.cc	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/m4/acinclude.m4	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/run-octave.in	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/@ftp/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/audio/@audioplayer/set.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/audio/@audiorecorder/set.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/audio/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/audio/mu2lin.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:50:47 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.4.
+## Use @code{flintmax (precision) - 1} for the equivalent functionality.
+##
+## Return the largest integer @var{r} that can be represented within a
+## floating point value.
+##
+## The default class is @qcode{"double"}, but @qcode{"single"} is a valid
+## option.  On IEEE 754 compatible systems, @code{bitmax} is
+## @w{@math{2^{53} - 1}} for @qcode{"double"} and @w{@math{2^{24} - 1}} for
+## @qcode{"single"}.
+##
+## @seealso{flintmax, intmax, realmax, realmin}
+## @end deftypefn
+
+## Deprecated in version 4.2
+
+function r = bitmax (precision)
+
+  persistent warned = false;
+  if (! warned)
+    warned = true;
+    warning ("Octave:deprecated-function",
+             "bitmax is obsolete and will be removed from a future version of Octave, please use flintmax instead");
+  endif
+
+  if (nargin == 0)
+    precision = "double";
+  endif
+  r = flintmax (precision) - 1;
+
+endfunction
--- a/scripts/deprecated/default_save_options.m	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/deprecated/luinc.m	Tue Sep 22 04:50:47 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})
--- a/scripts/deprecated/module.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/deprecated/module.mk	Tue Sep 22 04:50:47 2015 -0700
@@ -1,42 +1,35 @@
-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/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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/elfun/cosd.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/elfun/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/general/bitcmp.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/general/bitget.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/general/bitset.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/general/cplxpair.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/general/del2.m	Tue Sep 22 04:50:47 2015 -0700
@@ -156,7 +156,7 @@
     endif
   endfor
 
-  D = D ./ nd;
+  D ./= nd;
 endfunction
 
 
--- a/scripts/general/inputParser.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/general/inputParser.m	Tue Sep 22 04:50:47 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 ();
--- a/scripts/general/module.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/general/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/general/num2str.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/general/profexplore.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/general/quadl.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/general/randi.m	Tue Sep 22 04:50:47 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,20 +58,22 @@
   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");
     endif
   else
-    imin = fix (bounds(1));
-    imax = fix (bounds(2));
+    imin = bounds(1);
+    imax = bounds(2);
     if (imax < imin)
       error ("randi: require IMIN <= IMAX");
     endif
@@ -85,21 +86,12 @@
     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
 
 
@@ -121,22 +113,44 @@
 %! 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, "uint8");
+%! assert (ri, fix (ri));
+%! assert (min (ri), uint8 (-5));
+%! assert (max (ri), uint8 (10));
+%! assert (class (ri), "uint8");
+%!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 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/general/rat.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/general/rotdim.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/geometry/griddata.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/geometry/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/gui/listdlg.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/gui/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/gui/private/__fltk_file_filter__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/gui/waitbar.m	Tue Sep 22 04:50:47 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/get_first_help_sentence.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/help/get_first_help_sentence.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/help/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/help/private/__strip_html_tags__.m	Tue Sep 22 04:50:47 2015 -0700
@@ -77,6 +77,6 @@
   endfor
 
   ## Actually remove the elements
-  text = text (keep);
+  text = text(keep);
 endfunction
 
--- a/scripts/help/type.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/help/type.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/cmpermute.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/cmunique.m	Tue Sep 22 04:50:47 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/cubehelix.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/cubehelix.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/hsv2rgb.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/imformats.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/imread.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/imshow.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/imwrite.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/iscolormap.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/module.mk	Tue Sep 22 04:50:47 2015 -0700
@@ -1,64 +1,77 @@
-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/white.m \
+  scripts/image/winter.m
 
-IMAGES += \
-  image/default.img
+SCRIPTS_IMAGES += \
+  scripts/image/default.img
+
+scripts_imagedir = $(fcnfiledir)/image
+
+scripts_image_DATA = $(scripts_image_FCN_FILES)
+
+scripts_image_privatedir = $(fcnfiledir)/image/private
 
-FCN_FILES += $(image_FCN_FILES)
+scripts_image_private_DATA = $(scripts_image_PRIVATE_FCN_FILES)
 
-PKG_ADD_FILES += image/PKG_ADD
+FCN_FILES += \
+  $(scripts_image_FCN_FILES) \
+  $(scripts_image_PRIVATE_FCN_FILES)
 
-DIRSTAMP_FILES += image/$(octave_dirstamp)
+PKG_ADD_FILES += scripts/image/PKG_ADD
+
+DIRSTAMP_FILES += scripts/image/$(octave_dirstamp)
--- a/scripts/image/ntsc2rgb.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/ntsc2rgb.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/private/__imwrite__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/rgb2hsv.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/image/rgb2ntsc.m	Tue Sep 22 04:50:47 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)
--- a/scripts/io/module.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/io/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/io/strread.m	Tue Sep 22 04:50:47 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/io/textread.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/io/textread.m	Tue Sep 22 04:50:47 2015 -0700
@@ -144,7 +144,6 @@
     if (varargin{headerlines + 1} > 0)
       fskipl (fid, varargin{headerlines + 1});
       varargin(headerlines:headerlines+1) = [];
-      nargin = nargin - 2;
     elseif (varargin{headerlines + 1} < 0)
       warning ("textread: negative headerline value ignored");
     endif
--- a/scripts/java/module.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/java/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/linear-algebra/duplication_matrix.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/linear-algebra/housh.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/linear-algebra/krylov.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/linear-algebra/logm.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/linear-algebra/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/linear-algebra/normest.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/linear-algebra/onenormest.m	Tue Sep 22 04:50:47 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/edit.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/miscellaneous/edit.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/miscellaneous/fullfile.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/miscellaneous/inputname.m	Tue Sep 22 04:50:47 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/menu.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/miscellaneous/menu.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/miscellaneous/module.mk	Tue Sep 22 04:50:47 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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/module.mk	Tue Sep 22 04:50:47 2015 -0700
@@ -0,0 +1,217 @@
+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/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)
--- a/scripts/optimization/fminsearch.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/optimization/fminsearch.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/optimization/lsqnonneg.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/optimization/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/optimization/qp.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/path/module.mk	Tue Sep 22 04:50:47 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/pkg/module.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/pkg/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/pkg/pkg.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/pkg/private/installed_packages.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/appearance/annotation.m	Tue Sep 22 04:50:47 2015 -0700
@@ -1096,7 +1096,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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/appearance/axis.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/appearance/legend.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/appearance/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/appearance/specular.m	Tue Sep 22 04:50:47 2015 -0700
@@ -88,7 +88,7 @@
 
   ## Allow postive values only
   retval(retval < 0) = 0;
-  retval = retval .^ se;
+  retval .^= se;
 
 endfunction
 
--- a/scripts/plot/draw/colorbar.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/colorbar.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/errorbar.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/hist.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/loglogerr.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/plotmatrix.m	Tue Sep 22 04:50:47 2015 -0700
@@ -138,7 +138,7 @@
         have_line_spec = true;
         linespec = varargin(i);
         varargin(i) = [];
-        nargin = nargin - 1;
+        nargin -= 1;
         break;
       else
         print_usage ("plotmatrix");
--- a/scripts/plot/draw/polar.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/polar.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/private/__contour__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/private/__errplot__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/private/__scatter__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/private/__stem__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/semilogxerr.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/semilogyerr.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/draw/surfnorm.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/__actual_axis_position__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/__gnuplot_drawnow__.m	Tue Sep 22 04:50:47 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;
@@ -185,8 +185,8 @@
                || any (strcmp (term, {"canvas", "emf", "gif", "jpeg", ...
                                       "pbm", "png", "pngcairo", "svg"}))))
           ## Convert to inches
-          gnuplot_pos = gnuplot_pos / 72;
-          gnuplot_size = gnuplot_size / 72;
+          gnuplot_pos /= 72;
+          gnuplot_size /= 72;
         endif
         if (all (gnuplot_size > 0))
           terminals_with_size = {"canvas", "emf", "epslatex", "fig", ...
--- a/scripts/plot/util/__pltopt__.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/__pltopt__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/cla.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/findobj.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/ginput.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/graphics_toolkit.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/print.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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"
+            ## ignore uimenu objects
+            kids(i) = [];
+          otherwise
+            error ("__gnuplot_draw_figure__: unknown object class, %s", type);
+        endswitch
+      endfor
+      if (isempty (kids))
+        fputs (plot_stream, "\nreset; clear;\n");
+        fflush (plot_stream);
+      else
+        fputs (plot_stream, "\nunset multiplot;\n");
+      endif
+    else
+      fputs (plot_stream, "\nreset; clear;\n");
+      fflush (plot_stream);
+    endif
+  else
+    error ("__gnuplot_draw_figure__: expecting figure object, found '%s'",
+           htype);
+  endif
+
+endfunction
+
--- a/scripts/plot/util/private/__gnuplot_get_var__.m	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/private/__gnuplot_get_var__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/private/__gnuplot_ginput__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/private/__gnuplot_has_feature__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/private/__gnuplot_print__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/private/__opengl_print__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/private/__print_parse_opts__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/plot/util/rotate.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/polynomial/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/polynomial/pchip.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/polynomial/polyaffine.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/polynomial/polyder.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/polynomial/private/__splinefit__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/polynomial/residue.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/prefs/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/set/intersect.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/set/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/set/private/validsetargs.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/set/setdiff.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/set/setxor.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/set/union.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/signal/arch_fit.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/signal/arch_rnd.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/signal/bartlett.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/signal/blackman.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/signal/freqz.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/signal/hamming.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/signal/hanning.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/signal/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/signal/spectral_adf.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/signal/spectral_xdf.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/signal/stft.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/sparse/bicgstab.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/sparse/cgs.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/sparse/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/sparse/qmr.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/sparse/sprand.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/sparse/sprandn.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/sparse/sprandsym.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/sparse/svds.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/specfun/factor.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/specfun/legendre.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/specfun/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/special-matrix/gallery.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/special-matrix/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/startup/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/statistics/base/gls.m	Tue Sep 22 04:50:47 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/module.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/statistics/base/module.mk	Tue Sep 22 04:50:47 2015 -0700
@@ -1,43 +1,47 @@
-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/mahalanobis.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/distributions/module.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/statistics/distributions/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/statistics/distributions/poissinv.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/statistics/distributions/unidpdf.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/statistics/models/logistic_regression.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/statistics/models/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/statistics/tests/kruskal_wallis_test.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/statistics/tests/manova.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/statistics/tests/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/statistics/tests/wilcoxon_test.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/strings/cstrcat.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/strings/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/strings/strcat.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/testfun/__run_test_suite__.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/testfun/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/testfun/private/html_compare_plot_demos.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/testfun/test.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/time/datevec.m	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/scripts/time/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/test/bug-35448/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/test/bug-36025/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/test/bug-38236/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/test/bug-38691/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/test/build-bc-overload-tests.sh	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/test/build-sparse-tests.sh	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/test/class-concat/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/test/classdef/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/test/classes/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/test/ctor-vs-method/module.mk	Tue Sep 22 04:50:47 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/fcn-handle-derived-resolution/module.mk	Tue Sep 22 04:47:25 2015 -0700
+++ b/test/fcn-handle-derived-resolution/module.mk	Tue Sep 22 04:50:47 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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/module.mk	Tue Sep 22 04:50:47 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	Tue Sep 22 04:47:25 2015 -0700
+++ b/test/nest/module.mk	Tue Sep 22 04:50:47 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)