changeset 15093:959953dba519 classdef

maint: periodic merge of default to classdef
author John W. Eaton <jwe@octave.org>
date Fri, 03 Aug 2012 14:35:44 -0400
parents 069c552587a0 (current diff) 6c5b6c0ab528 (diff)
children 7c7b9ea23a86
files src/DLD-FUNCTIONS/__delaunayn__.cc src/DLD-FUNCTIONS/__dsearchn__.cc src/DLD-FUNCTIONS/__fltk_uigetfile__.cc src/DLD-FUNCTIONS/__glpk__.cc src/DLD-FUNCTIONS/__init_fltk__.cc src/DLD-FUNCTIONS/__init_gnuplot__.cc src/DLD-FUNCTIONS/__magick_read__.cc src/DLD-FUNCTIONS/__voronoi__.cc src/DLD-FUNCTIONS/amd.cc src/DLD-FUNCTIONS/ccolamd.cc src/DLD-FUNCTIONS/chol.cc src/DLD-FUNCTIONS/colamd.cc src/DLD-FUNCTIONS/config-module.awk src/DLD-FUNCTIONS/config-module.sh src/DLD-FUNCTIONS/convhulln.cc src/DLD-FUNCTIONS/dmperm.cc src/DLD-FUNCTIONS/eigs.cc src/DLD-FUNCTIONS/fftw.cc src/DLD-FUNCTIONS/module-files src/DLD-FUNCTIONS/oct-qhull.h src/DLD-FUNCTIONS/qr.cc src/DLD-FUNCTIONS/symbfact.cc src/DLD-FUNCTIONS/symrcm.cc src/DLD-FUNCTIONS/tsearch.cc src/DLD-FUNCTIONS/urlwrite.cc src/Makefile.am src/bitfcns.cc src/data.cc src/data.h src/debug.cc src/debug.h src/defaults.cc src/defaults.in.h src/defun.cc src/defun.h src/dirfns.cc src/dirfns.h src/error.cc src/error.h src/file-io.cc src/file-io.h src/graphics.cc src/graphics.in.h src/help.cc src/help.h src/input.cc src/input.h src/lex.h src/lex.ll src/load-path.cc src/load-path.h src/load-save.cc src/load-save.h src/ls-oct-ascii.cc src/ls-oct-ascii.h src/mappers.cc src/oct-hist.cc src/oct-hist.h src/oct-parse.yy src/pager.cc src/pager.h src/parse-private.h src/parse-tree/lex.h src/parse-tree/lex.ll src/parse-tree/module.mk src/parse-tree/oct-parse.yy src/parse.h src/pr-output.cc src/pr-output.h src/profiler.cc src/profiler.h src/sighandlers.cc src/sighandlers.h src/sparse.cc src/strfns.cc src/symtab.cc src/symtab.h src/syscalls.cc src/sysdep.cc src/sysdep.h src/toplev.cc src/toplev.h src/utils.cc src/utils.h src/variables.cc src/variables.h
diffstat 106 files changed, 931 insertions(+), 474 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate
+++ b/.hgsubstate
@@ -1,1 +1,1 @@
-33f823397dbb0edb57503f2f6dad2362456bc6a9 gnulib
+0e3af50c9e20938bd1cea0182bf749ce61cb6782 gnulib
--- a/autogen.sh
+++ b/autogen.sh
@@ -30,9 +30,9 @@
 
 (cd doc/interpreter; ./config-images.sh)
 
-echo "generating src/DLD-FUNCTIONS/module.mk..."
+echo "generating src/dldfcn/module.mk..."
 
-(cd src/DLD-FUNCTIONS; ./config-module.sh)
+(cd src/dldfcn; ./config-module.sh)
 
 echo "bootstrapping..."
 
--- a/configure.ac
+++ b/configure.ac
@@ -44,7 +44,7 @@
 AC_REVISION($Revision: 1.603 $)
 AC_PREREQ([2.62])
 AC_CONFIG_SRCDIR([src/octave.cc])
-AC_CONFIG_HEADER([config.h])
+AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_MACRO_DIR([m4])
 
@@ -52,9 +52,11 @@
 
 OCTAVE_HOST_TYPE
 
-AC_DEFINE(OCTAVE_SOURCE, 1, [Define if this is Octave.])
+AC_DEFINE(OCTAVE_SOURCE, 1, [Define to 1 if this is Octave.])
   
-dnl FIXME -- we should probably only generate this file if it is missing.
+dnl FIXME: Can this MSVC test be moved down to the section on finding a
+dnl        a C compiler which already has an MSVC exception test?
+dnl FIXME: We should probably only generate this file if it is missing.
 ### Produce unistd.h for MSVC target, this simplifies changes in
 ### Octave source tree and avoid problems with lex-generated code.
 case "$canonical_host_type" in
@@ -72,24 +74,8 @@
 
 AC_USE_SYSTEM_EXTENSIONS
 
-### Check for MSVC
-have_msvc=no
-case "$canonical_host_type" in
-  *-*-msdosmsvc)
-    have_msvc=yes
-  ;;
-  *-*-mingw*)
-    AC_MSG_CHECKING([for MSVC compiler])
-    AC_PREPROC_IFELSE([AC_LANG_SOURCE([
-#ifndef _MSC_VER
-#error "Not MSVC compiler"
-#endif
-])], have_msvc=yes, have_msvc=no)
-    AC_MSG_RESULT([$have_msvc])
-  ;;
-esac
+### Path separator.
 
-### Path separator.
 sepchar=:
 AC_ARG_WITH(sepchar,
   [AS_HELP_STRING([--with-sepchar=<char>],
@@ -113,7 +99,7 @@
 AC_DEFINE_UNQUOTED(SEPCHAR, ['$sepchar'], [Define this to be the path separator for your system, as a character constant.])
 AC_DEFINE_UNQUOTED(SEPCHAR_STR, ["$sepchar"], [Define this to the path separator, as a string.])
 
-### some defaults
+### Set default file locations
 
 OCTAVE_SET_DEFAULT(man1dir, '$(mandir)/man1')
 OCTAVE_SET_DEFAULT(man1ext, '.1')
@@ -155,9 +141,9 @@
 config_opts=$ac_configure_args
 AC_SUBST(config_opts)
 
-### Make it possible to have Octave's array and matrix classes do bounds
-### checking on element references.  This slows some operations down a
-### bit, so it is turned off by default.
+### Enable bounds checking on element references within Octave's array and
+### matrix classes.  This slows down some operations a bit, so it is turned off
+### by default.
 
 BOUNDS_CHECKING=false
 AC_ARG_ENABLE(bounds-check,
@@ -165,29 +151,37 @@
      [bounds checking for indexing in internal array classes (default is no)])],
   [if test "$enableval" = yes; then BOUNDS_CHECKING=true; fi], [])
 if $BOUNDS_CHECKING; then
-  AC_DEFINE(BOUNDS_CHECKING, 1, [Define to use internal bounds checking.])
+  AC_DEFINE(BOUNDS_CHECKING, 1, [Define to 1 to use internal bounds checking.])
 fi
 
+### Use Octave's built-in memory allocator rather than straightforward malloc.
+### Disabled by default.
+
 USE_OCTAVE_ALLOCATOR=false
 AC_ARG_ENABLE(octave-allocator,
   [AS_HELP_STRING([--enable-octave-allocator],
      [use the obsolete octave_allocator class for many of Octave's objects (mostly octave_value types).  You probably do NOT want to enable this feature.  (default is no)])],
   [if test "$enableval" = yes; then USE_OCTAVE_ALLOCATOR=true; fi], [])
 if $USE_OCTAVE_ALLOCATOR; then
-  AC_DEFINE(USE_OCTAVE_ALLOCATOR, 1, [Define to use octave_allocator class.])
+  AC_DEFINE(USE_OCTAVE_ALLOCATOR, 1, [Define to 1 to use octave_allocator class.])
 fi
 
+### Use atomic operations for internal reference counting.  This is required
+### for thread-safe behavior but incurs a significant slowdown, and is thus
+### disabled by default.
+
 USE_ATOMIC_REFCOUNT=false
 AC_ARG_ENABLE(atomic-refcount,
   [AS_HELP_STRING([--enable-atomic-refcount],
-     [use atomic operations for internal reference counting. This is required for thread-safe behavior.  (default is no)])],
+     [use atomic operations for internal reference counting.  This is required for thread-safe behavior.  (default is no)])],
   [if test "$enableval" = yes; then USE_ATOMIC_REFCOUNT=true; fi], [])
 if $USE_ATOMIC_REFCOUNT; then
-  AC_DEFINE(USE_ATOMIC_REFCOUNT, 1, [Define to use atomic operations for reference counting.])
+  AC_DEFINE(USE_ATOMIC_REFCOUNT, 1, [Define to 1 to use atomic operations for reference counting.])
 fi
 
-### Make it possible to disable running Make in the doc directory.
-### Useful for building on systems without TeX, for example.
+### Disable running Make in the doc directory.
+### This is useful, for example, when building Octave on systems without TeX.
+
 DOCDIR=doc
 AC_ARG_ENABLE(docs,
   [AS_HELP_STRING([--enable-docs], [build documentation (default is yes)])],
@@ -215,23 +209,23 @@
       OCTAVE_IDX_TYPE=int
     elif test $ac_cv_sizeof_long -eq 8; then
       OCTAVE_IDX_TYPE=long
-      AC_DEFINE(IDX_TYPE_LONG, 1, [Define to 1 if octave index type is long])
+      AC_DEFINE(IDX_TYPE_LONG, 1, [Define to 1 if octave index type is long.])
     else
       warn_64_bit="no suitable type found for octave_idx_type so disabling 64-bit features"
       OCTAVE_CONFIGURE_WARNING([warn_64_bit])
       USE_64_BIT_IDX_T=false
     fi
   else
-    warn_64_bit="pointers are not 64-bits wide so disabling 64-bit features"
+    warn_64_bit="pointers are not 64-bits wide; disabling 64-bit features"
     OCTAVE_CONFIGURE_WARNING([warn_64_bit])
     USE_64_BIT_IDX_T=false
   fi
 fi
 AC_SUBST(OCTAVE_IDX_TYPE)
 AC_DEFINE_UNQUOTED(OCTAVE_IDX_TYPE, $OCTAVE_IDX_TYPE,
-  [Define to the type of octave_idx_type (64 or 32 bit signed integer)])
+  [Define to the type of octave_idx_type (64 or 32 bit signed integer).])
 if $USE_64_BIT_IDX_T; then
-  AC_DEFINE(USE_64_BIT_IDX_T, 1, [Define if using 64-bit integers for array dimensions and indexing])
+  AC_DEFINE(USE_64_BIT_IDX_T, 1, [Define to 1 if using 64-bit integers for array dimensions and indexing.])
 fi
 AC_SUBST(USE_64_BIT_IDX_T)
 
@@ -240,14 +234,14 @@
 ### GNU libc, just disable them for all platforms.
 
 AC_MSG_NOTICE([defining __NO_MATH_INLINES avoids buggy GNU libc exp function])
-AC_DEFINE(__NO_MATH_INLINES, 1, [Define if your version of GNU libc has buggy inline assembly code for math functions like exp.])
+AC_DEFINE(__NO_MATH_INLINES, 1, [Define to 1 if your version of GNU libc has buggy inline assembly code for math functions like exp.])
 
-### See which C++ compiler to use (we expect to find g++).
+### Determine which C++ compiler to use (we expect to find g++).
 
 AC_PROG_CXX
 AC_PROG_CXXCPP
 
-### Do special things for g++.
+### Check version number when using g++.
 
 gxx_version=`$CXX -v 2>&1 | grep "^.*g.. version" | \
   sed -e 's/^.*g.. version *//' -e 's/cygnus-//' -e 's/egcs-//' -e 's/ .*//'`
@@ -269,18 +263,35 @@
 OCTAVE_CXX_ISO_COMPLIANT_LIBRARY
 OCTAVE_CXX_BROKEN_REINTERPRET_CAST
 
-### See which C compiler to use (we expect to find gcc).
+### Determine which C compiler to use (we expect to find gcc).
 
 AC_PROG_CC
 AC_PROG_CPP
 AC_PROG_GCC_TRADITIONAL
 
-### gnulib
+## Check for MSVC
+have_msvc=no
+case "$canonical_host_type" in
+  *-*-msdosmsvc)
+    have_msvc=yes
+  ;;
+  *-*-mingw*)
+    AC_MSG_CHECKING([for MSVC compiler])
+    AC_PREPROC_IFELSE([AC_LANG_SOURCE([
+#ifndef _MSC_VER
+#error "Not MSVC compiler"
+#endif
+])], have_msvc=yes, have_msvc=no)
+    AC_MSG_RESULT([$have_msvc])
+  ;;
+esac
+
+### gnulib initialization
 
 gl_EARLY
 gl_INIT
 
-### Do special things for gcc.
+### Check version number when using gcc.
 
 gcc_version=`$CC -v 2>&1 | grep "^.*gcc version" | \
   sed -e 's/^.*g.. version *//' -e 's/cygnus-//' -e 's/egcs-//'`
@@ -297,9 +308,9 @@
 fi
 AC_SUBST(CC_VERSION)
 
-### The flag to create dependency varies depending on the compier.
+### Determine the compiler flag necessary to create dependencies
 
-# Assume GCC.
+## Assume GCC.
 INCLUDE_DEPS=true
 DEPEND_FLAGS="-M"
 DEPEND_EXTRA_SED_PATTERN=""
@@ -327,40 +338,14 @@
 AC_SUBST(DEPEND_FLAGS)
 AC_SUBST(DEPEND_EXTRA_SED_PATTERN)
 
+### Check for pthread library
+
 AX_PTHREAD
-### Include pthread libs and flags here in case other tests need them.
-### They seem to be required for the OpenGL tests on Debian systems.
+## Include pthread libs and flags here in case other tests need them.
+## They seem to be required for the OpenGL tests on Debian systems.
 LIBS="$PTHREAD_LIBS $LIBS"
 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
 
-AC_PATH_X
-if test "$have_x" = "yes"; then
-  AC_DEFINE(HAVE_X_WINDOWS, 1, [Define if you have X11])
-
-  if test "$x_includes" != "NONE"; then
-    X11_INCFLAGS="$x_includes"
-  fi
-  AC_SUBST(X11_INCFLAGS)
-
-  if test -z $x_libraries; then
-    AC_CHECK_LIB(X11, XrmInitialize, [X11_LIBS=-lX11], [X11_LIBS=])
-  elif test $x_libraries != "NONE"; then
-    AC_CHECK_LIB(X11, XrmInitialize, 
-      [X11_LIBS="-L$x_libraries -lX11"], [X11_LIBS=], "-L$x_libraries")
-  fi
-  AC_SUBST(X11_LIBS)
-fi
-
-### On MacOSX system the Carbon framework is used to determine ScreenSize
-OCTAVE_HAVE_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>], [CGMainDisplayID ()],
-  [have_framework_carbon="yes"], [have_framework_carbon="no"])
-if test $have_framework_carbon = "yes"; then
-  AC_DEFINE(HAVE_FRAMEWORK_CARBON, 1, [Define if framework CARBON is available.])
-  CARBON_LIBS="-Wl,-framework -Wl,Carbon"
-  AC_MSG_NOTICE([adding -Wl,-framework -Wl,Carbon to CARBON_LIBS])
-  AC_SUBST(CARBON_LIBS)
-fi
-
 ### When compiling math for x87, problems may arise in some code comparing
 ### floating-point intermediate results.
 ### Generally, it helps to store the result in a local volatile variable,
@@ -376,12 +361,14 @@
   ac_float_truncate=)
 
 AC_DEFINE_UNQUOTED(FLOAT_TRUNCATE, $ac_float_truncate, 
-          [Define to volatile if you need truncating intermediate FP results])
+          [Define to volatile if you need to truncate intermediate FP results.])
+
+### Determine extra CFLAGS that may be necessary for Octave.
 
-### On Intel systems with gcc, we may need to compile with -mieee-fp
-### and -ffloat-store to get full support for IEEE floating point.
-###
-### On Alpha/OSF systems, we need -mieee.
+## On Intel systems with gcc, we may need to compile with -mieee-fp
+## and -ffloat-store to get full support for IEEE floating point.
+##
+## On Alpha/OSF systems, we need -mieee.
 
 ieee_fp_flag=
 case "$canonical_host_type" in
@@ -394,10 +381,10 @@
         XTRA_CFLAGS="$XTRA_CFLAGS -mieee-fp"
         AC_MSG_NOTICE([adding -mieee-fp to XTRA_CFLAGS])])
 
-###      OCTAVE_CC_FLAG(-ffloat-store, [
-###        float_store_flag=-ffloat-store
-###        XTRA_CFLAGS="$XTRA_CFLAGS -ffloat-store"
-###        AC_MSG_RESULT([adding -ffloat-store to XTRA_CFLAGS])])
+##      OCTAVE_CC_FLAG(-ffloat-store, [
+##        float_store_flag=-ffloat-store
+##        XTRA_CFLAGS="$XTRA_CFLAGS -ffloat-store"
+##        AC_MSG_RESULT([adding -ffloat-store to XTRA_CFLAGS])])
     fi
     if test "$GXX" = yes; then
       OCTAVE_CXX_FLAG(-mieee-fp, [
@@ -405,10 +392,10 @@
         XTRA_CXXFLAGS="$XTRA_CXXFLAGS -mieee-fp"
         AC_MSG_NOTICE([adding -mieee-fp to XTRA_CXXFLAGS])])
 
-###      OCTAVE_CXX_FLAG(-ffloat-store, [
-###        float_store_flag=-ffloat-store
-###        XTRA_CXXFLAGS="$XTRA_CXXFLAGS -ffloat-store"
-###        AC_MSG_RESULT([adding -ffloat-store to XTRA_CXXFLAGS])])
+##      OCTAVE_CXX_FLAG(-ffloat-store, [
+##        float_store_flag=-ffloat-store
+##        XTRA_CXXFLAGS="$XTRA_CXXFLAGS -ffloat-store"
+##        AC_MSG_RESULT([adding -ffloat-store to XTRA_CXXFLAGS])])
     fi
   ;;
   alpha*-*-*)
@@ -444,8 +431,12 @@
   ;;
 esac
 
-## Test whether the compiler supports OpenMP. Experimental so disable by 
-## default. Enable it with the flag --enable-openmp
+AC_SUBST(XTRA_CFLAGS)
+AC_SUBST(XTRA_CXXFLAGS)
+
+### Test whether the compiler supports OpenMP.  This is experimental so disable
+### it by default.  Enable it with the flag --enable-openmp.
+
 USE_OPENMP=false
 AC_ARG_ENABLE(openmp,
   [AS_HELP_STRING([--enable-openmp],
@@ -457,21 +448,15 @@
     OCTAVE_CHECK_OPENMP(-fopenmp)
     ;;
     *-*-msdosmsvc)
-    ## FIXME is this the right flag for MSVC?
+    ## FIXME: is this the right flag for MSVC?
     OCTAVE_CHECK_OPENMP(-openmp)
     ;;
     ## Add other compilers supporting OpenMP here
   esac
 fi
 
-AC_SUBST(XTRA_CFLAGS)
-AC_SUBST(XTRA_CXXFLAGS)
-
-## Avoid #define of min/max from windows.h header
-if test "$have_msvc" = "yes"; then
-  AC_DEFINE(NOMINMAX, 1, [Define if you want to avoid min/max macro definition in Windows headers])
-fi
-
+dnl FIXME: This is OS-specific tests.  Can this be moved further down in
+dnl configure.ac to reside with other similar tests?
 ### Use -static if compiling on Alpha OSF/1 1.3 systems.
 
 case "$canonical_host_type" in
@@ -502,15 +487,18 @@
   BUILD_CXX='$(CXX)'
   BUILD_CXXFLAGS='$(CXXFLAGS)'
   BUILD_LDFLAGS='$(LDFLAGS)'
-  case "$canonical_host_type" in
-    sparc-sun-solaris2*)
-      if test "$GCC" != yes; then
-        ## The Sun C++ compiler never seems to complete compiling
-        ## gendoc.cc unless we reduce the optimization level...
-        BUILD_CXXFLAGS="-g -O1"
-      fi
-    ;;
-  esac
+  ## 2012/07/31: Commented out special build requirements
+  ## for Sun compiler now that gendoc.cc is no longer part of build.
+  ##################################################################
+  #case "$canonical_host_type" in
+  #  sparc-sun-solaris2*)
+  #    if test "$GCC" != yes; then
+  #      ## The Sun C++ compiler never seems to complete compiling
+  #      ## gendoc.cc unless we reduce the optimization level...
+  #      ## BUILD_CXXFLAGS="-g -O1"
+  #    fi
+  #  ;;
+  #esac
   BUILD_EXEEXT='$(EXEEXT)'
 fi
 
@@ -536,6 +524,8 @@
   ;;
 esac
 
+### Determine the Fortran compiler and how to invoke it
+
 ## Default FFLAGS is -O.
 if test "x$FFLAGS" = x; then
   FFLAGS="-O"
@@ -590,13 +580,13 @@
 AC_SUBST(F77_APPEND_EXTRA_UNDERSCORE)
 
 if test -z "$F77"; then
-  AC_MSG_ERROR([in order to build octave, you must have a compatible Fortran compiler or wrapper script for f2c that functions as a Fortran compiler installed and in your path.  See the file INSTALL for more information.])
+  AC_MSG_ERROR([in order to build Octave, you must have a compatible Fortran compiler or wrapper script for f2c that functions as a Fortran compiler installed and in your path.  See the file INSTALL for more information.])
 fi
 
 OCTAVE_CHECK_FORTRAN_HAVE_ISNAN
 F77_ISNAN_MACRO=
 if test "x$octave_cv_fortran_have_isnan" = xno; then
-   AC_MSG_NOTICE([substituting ISNAN(X) with X.NE.X in fortran sources])
+   AC_MSG_NOTICE([substituting ISNAN(X) with X.NE.X in Fortran sources])
    F77_ISNAN_MACRO="s|ISNAN(\(@<:@^)@:>@*\))|(\1.NE.\1)|"
 fi
 AC_SUBST(F77_ISNAN_MACRO)
@@ -631,7 +621,7 @@
       OCTAVE_CHECK_FORTRAN_INTEGER_SIZE
     fi
     if test "x$octave_cv_fortran_integer_size" = xno; then
-      AC_MSG_ERROR([in order to build octave with 64-bit indexing support your Fortran compiler must have an option for setting the default integer size to 8 bytes.  See the file INSTALL for more information.])
+      AC_MSG_ERROR([in order to build Octave with 64-bit indexing support your Fortran compiler must have an option for setting the default integer size to 8 bytes.  See the file INSTALL for more information.])
     fi
   else
     AC_MSG_ERROR([your Fortran compiler must have an option to make integers the same size as octave_idx_type ($OCTAVE_IDX_TYPE).  See the file INSTALL for more information.])
@@ -648,15 +638,15 @@
 AC_SUBST(F77_FLOAT_STORE_FLAG)
 ])
 
+### Check that C compiler and libraries support IEEE754 data format.
 OCTAVE_IEEE754_DATA_FORMAT
 
+### Check C++ library for various capabilities.
 OCTAVE_CXX_BITWISE_OP_TEMPLATES
 OCTAVE_CXX_COMPLEX_SETTERS
 OCTAVE_CXX_COMPLEX_REFERENCE_ACCESSORS
 
-OCTAVE_CARBON_CGDISPLAYBITSPERPIXEL
-
-### Check for the QHull library
+### Check for the Qhull library
 
 OCTAVE_CHECK_LIBRARY(qhull, QHull,
   [Qhull library not found -- this will result in loss of functionality of some geometry functions.],
@@ -664,10 +654,10 @@
   [warn_qhull=
    OCTAVE_CHECK_QHULL_VERSION
    OCTAVE_CHECK_QHULL_OK([TEXINFO_QHULL="@set HAVE_QHULL"
-     AC_DEFINE(HAVE_QHULL, 1, [Define if QHull is available.])], [
-     warn_qhull="Qhull library found, but seems not to work properly -- this will result in loss of functionality of some geometry functions.  Please try recompiling the library with -fno-strict-aliasing."])])
+     AC_DEFINE(HAVE_QHULL, 1, [Define to 1 if Qhull is available.])], [
+     warn_qhull="Qhull library found, but does not seem to work properly -- this will result in loss of functionality of some geometry functions.  Please try recompiling the library with -fno-strict-aliasing."])])
 
-### Check for pcre regex library.
+### Check for PCRE regex library.
 
 REGEX_LIBS=
 
@@ -715,26 +705,25 @@
   [ZLIB library not found.  Octave will not be able to save or load compressed data files or HDF5 files.],
   [zlib.h], [gzclearerr])
 
-### Check for the llvm library
-dnl
+### Check for the LLVM library
 dnl
-dnl llvm is odd and has its own pkg-config like script. We should probably check
-dnl for existance and 
+dnl LLVM is odd and has its own pkg-config like script.  We should probably
+dnl check for existence and ???.
 dnl
 save_CPPFLAGS="$CPPFLAGS"
 save_CXXFLAGS="$CXXFLAGS"
 save_LIBS="$LIBS"
 save_LDFLAGS="$LDFLAGS"
 
-warn_llvm="LLVM library fails tests. JIT compilation will be disabled."
+warn_llvm="LLVM library fails tests.  JIT compilation will be disabled."
 
 AC_ARG_VAR(LLVM_CONFIG, [path to llvm-config utility])
 
 AC_ARG_ENABLE([jit-debug],
-  AS_HELP_STRING([--enable-jit-debug], [Enable debug printing of jit IRs]))
+  AS_HELP_STRING([--enable-jit-debug], [Enable debug printing of JIT IRs]))
 
 AS_IF([test "x$enable_jit_debug" = "xyes"], [
-  AC_DEFINE(OCTAVE_JIT_DEBUG, 1, [Define for jit debug printing])
+  AC_DEFINE(OCTAVE_JIT_DEBUG, 1, [Define to 1 for JIT debug printing.])
 ])
 
 LLVM_CXXFLAGS=
@@ -743,7 +732,7 @@
 LLVM_LIBS=
 
 if test "x$ac_cv_env_LLVM_CONFIG_set" = "xset"; then
-  # We use -isystem if avaiable because we do not want to see warnings in llvm
+  ## We use -isystem if available because we do not want to see warnings in LLVM
   LLVM_INCLUDE_FLAG=-I
   OCTAVE_CC_FLAG(-isystem ., [
     LLVM_INCLUDE_FLAG=-isystem
@@ -756,8 +745,8 @@
   LLVM_CXXFLAGS=
 
   dnl
-  dnl We define some extra flags that llvm requires in order to include headers.
-  dnl Idealy we should get these from llvm-config, but llvm-config isn't very
+  dnl We define some extra flags that LLVM requires in order to include headers.
+  dnl Ideally we should get these from llvm-config, but llvm-config isn't very
   dnl helpful.
   dnl
   CPPFLAGS="-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS $LLVM_CPPFLAGS $CPPFLAGS"
@@ -782,11 +771,11 @@
   AC_LANG_POP(C++)
   
 else
-  warn_llvm="LLVM_CONFIG not set. JIT compilation will be disabled."
+  warn_llvm="LLVM_CONFIG not set.  JIT compilation will be disabled."
 fi
 
 if test -z "$warn_llvm"; then
-  AC_DEFINE(HAVE_LLVM, 1, [Define if LLVM is available])
+  AC_DEFINE(HAVE_LLVM, 1, [Define to 1 if LLVM is available.])
 else
   LLVM_CXXFLAGS=
   LLVM_CPPFLAGS=
@@ -817,7 +806,7 @@
   [warn_hdf5=
    OCTAVE_HDF5_HAS_ENFORCED_16_API
    TEXINFO_HDF5="@set HAVE_HDF5"
-   AC_DEFINE(HAVE_HDF5, 1, [Define if HDF5 is available and newer than version 1.6.])
+   AC_DEFINE(HAVE_HDF5, 1, [Define to 1 if HDF5 is available and newer than version 1.6.])
    if test "$have_msvc" = "yes"; then
      OCTAVE_HDF5_DLL
    fi
@@ -825,14 +814,9 @@
 CPPFLAGS="$save_CPPFLAGS"
 LIBS="$save_LIBS"
 
-
-# Subdirectory of libcruft to build if fftw is not found:
+### Check for FFTW library.  Default to Fortran FFTPACK if it is not available.
 
-FFT_DIR="fftpack"
-AC_SUBST(FFT_DIR)
-
-# Checks for FFTW header and library.
-
+## Check for FFTW header and library.
 OCTAVE_CHECK_LIBRARY(fftw3, FFTW3,
   [FFTW3 library not found.  The slower FFTPACK library will be used instead.],
   [fftw3.h], [fftw_plan_dft_1d])
@@ -844,7 +828,11 @@
 AM_CONDITIONAL([AMCOND_HAVE_FFTW],
   [test -n "$FFTW3_LIBS" && test -n "$FFTW3F_LIBS"])
 
-# Checks for GLPK header and library.
+## Subdirectory of libcruft to build if FFTW is not found:
+FFT_DIR="fftpack"
+AC_SUBST(FFT_DIR)
+
+### Check for GLPK library and header.
 
 save_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="$Z_CPPFLAGS $CPPFLAGS"
@@ -856,7 +844,7 @@
 LIBS="$save_LIBS"
 CPPFLAGS="$save_CPPFLAGS"
 
-# Checks for CURL header and library.
+### Checks for cURL header and library.
 
 save_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="$Z_CPPFLAGS $CPPFLAGS"
@@ -868,7 +856,7 @@
 LIBS="$save_LIBS"
 CPPFLAGS="$save_CPPFLAGS"
 
-### Graphics/ImageMagick++
+### Check for either of Graphics/ImageMagick++ libraries
 
 AC_ARG_WITH([magick],
   [AS_HELP_STRING([--with-magick=LIB],
@@ -918,7 +906,7 @@
 ])
 
 if test -z "$warn_magick"; then
-  AC_DEFINE(HAVE_MAGICK, 1, [Define if Graphics/ImageMagick++ is available.])
+  AC_DEFINE(HAVE_MAGICK, 1, [Define to 1 if Graphics/ImageMagick++ is available.])
 else
   MAGICK_CPPFLAGS=
   MAGICK_LDFLAGS=
@@ -928,9 +916,37 @@
 AC_SUBST(MAGICK_LDFLAGS)
 AC_SUBST(MAGICK_LIBS)
 
-# ---------------------------------------------------------------------
+### Check for X11 libraries
+
+AC_PATH_X
+if test "$have_x" = "yes"; then
+  AC_DEFINE(HAVE_X_WINDOWS, 1, [Define to 1 if you have X11.])
+
+  if test "$x_includes" != "NONE"; then
+    X11_INCFLAGS="$x_includes"
+  fi
+  AC_SUBST(X11_INCFLAGS)
 
-## libraries needed for native graphics renderer
+  if test -z $x_libraries; then
+    AC_CHECK_LIB(X11, XrmInitialize, [X11_LIBS=-lX11], [X11_LIBS=])
+  elif test $x_libraries != "NONE"; then
+    AC_CHECK_LIB(X11, XrmInitialize, 
+      [X11_LIBS="-L$x_libraries -lX11"], [X11_LIBS=], "-L$x_libraries")
+  fi
+  AC_SUBST(X11_LIBS)
+fi
+
+### Check for the Carbon framework on MacOSX systems
+OCTAVE_HAVE_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>], [CGMainDisplayID ()],
+  [have_framework_carbon="yes"], [have_framework_carbon="no"])
+if test $have_framework_carbon = "yes"; then
+  AC_DEFINE(HAVE_FRAMEWORK_CARBON, 1, [Define to 1 if framework CARBON is available.])
+  CARBON_LIBS="-Wl,-framework -Wl,Carbon"
+  AC_MSG_NOTICE([adding -Wl,-framework -Wl,Carbon to CARBON_LIBS])
+  AC_SUBST(CARBON_LIBS)
+fi
+
+### Check for list of libraries needed for native graphics renderer.
 
 warn_freetype=""
 native_graphics=true
@@ -947,6 +963,7 @@
    fi],
   [check_opengl=true])
 
+## Check for OpenGL library
 if $check_opengl; then
   OCTAVE_OPENGL
 fi
@@ -956,18 +973,18 @@
 
 if test -z "$OPENGL_LIBS"; then
   if $check_opengl; then
-    warn_fltk_opengl="OpenGL libs (GL and GLU) not found. Native graphics will be disabled."
+    warn_fltk_opengl="OpenGL libs (GL and GLU) not found.  Native graphics will be disabled."
     OCTAVE_CONFIGURE_WARNING([warn_fltk_opengl])
     native_graphics=false
   fi
 fi
 
 if test -n "$OPENGL_LIBS"; then
-  AC_DEFINE(HAVE_OPENGL, 1, [Define if OpenGL is available])
+  AC_DEFINE(HAVE_OPENGL, 1, [Define to 1 if OpenGL is available.])
 
-  ## freetype 2
+  ## Check for FreeType 2 library
 
-  AC_CHECK_FT2([9.0.3], [AC_DEFINE(HAVE_FREETYPE, 1, [Define to 1 if you have Freetype library.])
+  AC_CHECK_FT2([9.0.3], [AC_DEFINE(HAVE_FREETYPE, 1, [Define to 1 if you have FreeType library.])
     XTRA_CXXFLAGS="$XTRA_CXXFLAGS $FT2_CFLAGS"],
     [warn_freetype="FreeType library not found.  Native graphics will be disabled."])
 
@@ -976,7 +993,7 @@
     native_graphics=false
   fi
 
-  ## fontconfig library
+  ## Check for fontconfig library
 
   warn_fontconfig=""
   if test -z "$warn_freetype"; then
@@ -984,7 +1001,7 @@
       have_fontconfig=yes
       OPENGL_LIBS="$FONTCONFIG_LIBS $OPENGL_LIBS"
       XTRA_CXXFLAGS="$XTRA_CXXFLAGS $FONTCONFIG_CFLAGS"
-      AC_DEFINE(HAVE_FONTCONFIG, 1, [Define to 1 if fontconfig is present])], [
+      AC_DEFINE(HAVE_FONTCONFIG, 1, [Define to 1 if fontconfig is present.])], [
       have_fontconfig=no
       warn_fontconfig="Fontconfig library not found.  Native graphics will be disabled."])
   fi
@@ -994,7 +1011,7 @@
     native_graphics=false
   fi
 
-  ## fltk (www.fltk.org)
+  ## Check for FLTK (www.fltk.org) library
 
   AC_ARG_WITH([fltk-prefix], [
     AS_HELP_STRING([--with-fltk-prefix=PFX],
@@ -1050,7 +1067,7 @@
          AC_MSG_RESULT([no])
          warn_fltk_opengl="FLTK does not have OpenGL support.  Native graphics will be disabled."
         ],[
-         AC_DEFINE(HAVE_FLTK, 1, [Define if FLTK is available])
+         AC_DEFINE(HAVE_FLTK, 1, [Define to 1 if FLTK is available.])
          AC_MSG_RESULT([yes])
         ])
          
@@ -1068,7 +1085,7 @@
 AC_SUBST(GRAPHICS_CFLAGS)
 AC_SUBST(GRAPHICS_LIBS)
 
-# ----------------------------------------------------------------------
+### Start determination of shared vs. static libraries
 
 OCTAVE_PROG_AR
 
@@ -1099,7 +1116,7 @@
 fi
 AC_SUBST(XTRA_CRUFT_SH_LDFLAGS)
 
-### Checks for BLAS and LAPACK libraries:
+### Check for BLAS and LAPACK libraries:
 
 ## Need to adjust FFLAGS to include correct integer size.
 save_FFLAGS="$FFLAGS"
@@ -1163,7 +1180,7 @@
       else
         ## wrapper in libcruft, remove from BLAS_LIBS
         BLAS_LIBS="`echo $BLAS_LIBS | sed -e 's/blaswrap.[[^ ]]* //g'`"
-        AC_DEFINE(USE_BLASWRAP, [1], [Define this if BLAS functions need to be wrapped (potentially needed for 64-bit OSX only).])
+        AC_DEFINE(USE_BLASWRAP, 1, [Define to 1 if BLAS functions need to be wrapped (potentially needed for 64-bit OSX only).])
       fi
     ;;
   esac
@@ -1172,20 +1189,20 @@
 if test "x$ax_blas_f77_func_ok" = "xno"; then
   if $USE_64_BIT_IDX_T && test "$ax_blas_integer_size_ok" = "no" ; then
     ## Attempt to be more informative.
-    AC_MSG_ERROR([BLAS doesn't seem to support 64-bit integers. This is incompatible with --enable-64.])
+    AC_MSG_ERROR([BLAS doesn't seem to support 64-bit integers.  This is incompatible with --enable-64.])
   else
     AC_MSG_ERROR([A BLAS library was detected but found incompatible with your Fortran 77 compiler settings.])
   fi
 fi
 
 if test x$ax_blas_ok = xno || test x$ax_lapack_ok = xno; then
-  AC_MSG_ERROR([You are required to have BLAS and LAPACK libraries])
+  AC_MSG_ERROR([BLAS and LAPACK libraries are required])
 fi
 
 ### Check for the qrupdate library
+
 ## No need to adjust FFLAGS because only link is attempted. 
 ## Must supply proper LIBS, however.
-
 save_LIBS="$LIBS"
 LIBS="$LAPACK_LIBS $BLAS_LIBS $FLIBS $LIBS"
 OCTAVE_CHECK_LIBRARY(qrupdate, qrupdate,
@@ -1203,13 +1220,13 @@
   [octave_qrupdate_luu=yes])
   AC_MSG_RESULT([$octave_qrupdate_luu])
   if test "$octave_qrupdate_luu" = yes; then
-    AC_DEFINE(HAVE_QRUPDATE_LUU, [1], [Define if qrupdate supports LU updates])
+    AC_DEFINE(HAVE_QRUPDATE_LUU, 1, [Define to 1 if qrupdate supports LU updates.])
   fi
   AC_LANG_POP([Fortran 77])
 fi
 LIBS="$save_LIBS"
 
-# Check for AMD library
+### Check for AMD library
 
 OCTAVE_CHECK_LIBRARY(amd, AMD,
   [AMD library not found.  This will result in some lack of functionality for sparse matrices.],
@@ -1217,7 +1234,7 @@
   [amd_postorder],
   [], [don't use AMD library, disable some sparse matrix functionality])
 
-# Check for CAMD library
+### Check for CAMD library
 
 OCTAVE_CHECK_LIBRARY(camd, CAMD,
   [CAMD library not found.  This will result in some lack of functionality for sparse matrices.],
@@ -1225,7 +1242,7 @@
   [camd_postorder],
   [], [don't use CAMD library, disable some sparse matrix functionality])
 
-# Check for COLAMD library
+### Check for COLAMD library
 
 OCTAVE_CHECK_LIBRARY(colamd, COLAMD,
   [COLAMD library not found.  This will result in some lack of functionality for sparse matrices.],
@@ -1233,7 +1250,7 @@
   [colamd],
   [], [don't use COLAMD library, disable some sparse matrix functionality])
 
-# Check for CCOLAMD library
+### Check for CCOLAMD library
 
 OCTAVE_CHECK_LIBRARY(ccolamd, CCOLAMD,
   [CCOLAMD library not found.  This will result in some lack of functionality for sparse matrices.],
@@ -1241,8 +1258,8 @@
   [ccolamd],
   [], [don't use CCOLAMD library, disable some sparse matrix functionality])
 
-# Check for CHOLMOD library.  If your cholmod library requires cblas,
-# then you will need to configure with --with-cholmod="-lcholmod -lcblas".
+### Check for CHOLMOD library.  If your cholmod library requires cblas,
+### then you will need to configure with --with-cholmod="-lcholmod -lcblas".
 
 save_LIBS="$LIBS"
 LIBS="$COLAMD_LDFLAGS $COLAMD_LIBS $AMD_LDFLAGS $AMD_LIBS $LAPACK_LIBS $BLAS_LIBS $FLIBS $LIBS"
@@ -1253,7 +1270,7 @@
   [], [don't use CHOLMOD library, disable some sparse matrix functionality])
 LIBS="$save_LIBS"
 
-# Check for CXSparse library
+### Check for CXSparse library
 
 OCTAVE_CHECK_LIBRARY(cxsparse, CXSparse,
   [CXSparse library not found.  This will result in some lack of functionality for sparse matrices.],
@@ -1261,7 +1278,7 @@
   [cs_di_sqr],
   [C++], [don't use CXSparse library, disable some sparse matrix functionality])
 
-# Check for UMFPACK library.
+### Check for UMFPACK library.
 
 save_LIBS="$LIBS"
 save_CPPFLAGS="$CPPFLAGS"
@@ -1298,6 +1315,8 @@
   LIBS="$save_LIBS"
 fi
 
+### Check for ARPACK library.
+
 save_LIBS="$LIBS"
 LIBS="$LAPACK_LIBS $BLAS_LIBS $FLIBS $LIBS"
 OCTAVE_CHECK_LIBRARY(arpack, ARPACK,
@@ -1307,10 +1326,14 @@
   [Fortran 77], [don't use the ARPACK library, disable eigs function],
   [warn_arpack=
    OCTAVE_CHECK_ARPACK_OK([
-     AC_DEFINE(HAVE_ARPACK, 1, [Define if ARPACK is available.])], [
-     warn_arpack="ARPACK library found, but seems not to work properly -- disabling eigs function"])])
+     AC_DEFINE(HAVE_ARPACK, 1, [Define to 1 if ARPACK is available.])], [
+     warn_arpack="ARPACK library found, but does not seem to work properly -- disabling eigs function"])])
 LIBS="$save_LIBS"
 
+### Check for readline library.
+
+OCTAVE_ENABLE_READLINE
+
 ### Enable dynamic linking.  --enable-shared implies this, so
 ### --enable-dl is only need if you are only building static libraries
 ### and want to try dynamic linking too (works on some systems, for
@@ -1714,8 +1737,8 @@
 AC_MSG_CHECKING([whether unordered_map requires tr1 namespace])
 unordered_map_requires_tr1_namespace=no
 if test "$ac_cv_header_unordered_map" = "yes"; then
-  ### Have <unordered_map>, but still have to check whether
-  ### tr1 namespace is required (like MSVC, for instance).
+  ## Have <unordered_map>, but still have to check whether
+  ## tr1 namespace is required (like MSVC, for instance).
   AC_COMPILE_IFELSE([
     AC_LANG_PROGRAM([
       #include <unordered_map>
@@ -1726,7 +1749,7 @@
   unordered_map_requires_tr1_namespace=yes
 fi
 if test "$unordered_map_requires_tr1_namespace" = "yes"; then
-  AC_DEFINE(USE_UNORDERED_MAP_WITH_TR1, 1, [Defines whether unordered_map requires the use of tr1 namespace.])
+  AC_DEFINE(USE_UNORDERED_MAP_WITH_TR1, 1, [Define to 1 if unordered_map requires the use of tr1 namespace.])
 fi
 AC_MSG_RESULT([$unordered_map_requires_tr1_namespace])
 AC_LANG_POP(C++)
@@ -1746,6 +1769,11 @@
   AC_MSG_WARN([I couldn't find termios.h, termio.h, or sgtty.h!])
 fi
 
+### For MSVC compilers, avoid #define of min/max from windows.h header
+if test "$have_msvc" = "yes"; then
+  AC_DEFINE(NOMINMAX, 1, [Define to 1 if you want to avoid min/max macro definition in Windows headers.])
+fi
+
 ### Checks for functions and variables.
 
 AC_CHECK_FUNCS(basename canonicalize_file_name \
@@ -1795,7 +1823,7 @@
     )],
     [AC_MSG_RESULT(yes)
      HAVE_MKSTEMPS=yes
-     AC_DEFINE(HAVE_MKSTEMPS, 1, [Define if mkstemps is available in libiberty.])
+     AC_DEFINE(HAVE_MKSTEMPS, 1, [Define to 1 if mkstemps is available in libiberty.])
     ],
     [AC_MSG_RESULT(no)
      HAVE_MKSTEMPS=no
@@ -1815,21 +1843,24 @@
 #error "Wrong version"
 #endif]], [])],
       AC_MSG_RESULT([none]), [
-        AC_DEFINE(_WIN32_WINNT, 0x0403, [Define to 0x0403 to access InitializeCriticalSectionAndSpinCount])
+        AC_DEFINE(_WIN32_WINNT, 0x0403, [Define to 0x0403 to access InitializeCriticalSectionAndSpinCount.])
         AC_MSG_RESULT([0x0403])])
     AC_MSG_CHECKING([whether _USE_MATH_DEFINES needs to be defined])
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]],
 [[int x = M_LN2;]])],
       AC_MSG_RESULT([no]), [
-        AC_DEFINE(_USE_MATH_DEFINES, 1, [Define if your system needs it to define math constants like M_LN2])
+        AC_DEFINE(_USE_MATH_DEFINES, 1, [Define to 1 if your system needs to define math constants like M_LN2.])
         AC_MSG_RESULT([yes])])
   ;;
 esac
 
+## Check for CGDisplayBitsPerPixel function on Mac OSX systems with Carbon
+OCTAVE_CARBON_CGDISPLAYBITSPERPIXEL
+
 ### Dynamic linking is now enabled only if we are building shared
 ### libs and some API for dynamic linking is detected.
 
-## FIXME -- a lot of the following duplicates the functionality of
+## FIXME: A lot of the following duplicates the functionality of
 ## code generated by the dlopen option for LT_INIT.
 
 LD_CXX='$(CXX)'
@@ -1846,23 +1877,23 @@
     dlopen)
       dlopen_api=true
       DL_API_MSG="(dlopen)"
-      AC_DEFINE(HAVE_DLOPEN_API, 1, [Define if your system has dlopen, dlsym, dlerror, and dlclose for dynamic linking])
+      AC_DEFINE(HAVE_DLOPEN_API, 1, [Define to 1 if your system has dlopen, dlsym, dlerror, and dlclose for dynamic linking.])
       OCTAVE_CXX_FLAG(-rdynamic, [RDYNAMIC_FLAG=-rdynamic])
     ;;
     shl_load)
       shl_load_api=true
       DL_API_MSG="(shl_load)"
-      AC_DEFINE(HAVE_SHL_LOAD_API, 1, [Define if your system has shl_load and shl_findsym for dynamic linking])
+      AC_DEFINE(HAVE_SHL_LOAD_API, 1, [Define to 1 if your system has shl_load and shl_findsym for dynamic linking.])
     ;;
     LoadLibrary)
       loadlibrary_api=true
       DL_API_MSG="(LoadLibrary)"
-      AC_DEFINE(HAVE_LOADLIBRARY_API, 1, [Define if your system has LoadLibrary for dynamic linking])
+      AC_DEFINE(HAVE_LOADLIBRARY_API, 1, [Define to 1 if your system has LoadLibrary for dynamic linking.])
     ;;
     dyld)
       dyld_api=true
       DL_API_MSG="(dyld)"
-      AC_DEFINE(HAVE_DYLD_API, 1, [Define if your system has dyld for dynamic linking])
+      AC_DEFINE(HAVE_DYLD_API, 1, [Define to 1 if your system has dyld for dynamic linking.])
     ;;
   esac
 
@@ -1878,7 +1909,7 @@
 fi
 
 if $ENABLE_DYNAMIC_LINKING; then
-  AC_DEFINE(ENABLE_DYNAMIC_LINKING, 1, [Define if using dynamic linking])
+  AC_DEFINE(ENABLE_DYNAMIC_LINKING, 1, [Define to 1 if using dynamic linking.])
 fi
 
 AM_CONDITIONAL([AMCOND_ENABLE_DYNAMIC_LINKING],
@@ -1959,14 +1990,13 @@
 fi
 AC_SUBST(TERM_LIBS)
 
-OCTAVE_ENABLE_READLINE
-
+### Return type of matherr() 
 AC_MSG_CHECKING([for struct exception in math.h])
 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]],
   [[struct exception *x; x->type; x->name;]])],
   [AC_MSG_RESULT(yes)
    AC_DEFINE(EXCEPTION_IN_MATH, 1,
-     [Define if your math.h declares struct exception for matherr().])],
+     [Define to 1 if your math.h declares struct exception for matherr().])],
   [AC_MSG_RESULT(no)])
 
 ### Signal stuff.
@@ -1979,17 +2009,17 @@
 #endif
 ])
 
-### A system dependent kluge or two.
+### A system dependent kludge or two.
 
 AC_CHECK_FUNCS(getrusage)
 case "$canonical_host_type" in
   *-*-cygwin*)
-    AC_DEFINE(RUSAGE_TIMES_ONLY, 1, [Define if your struct rusage only has time information.])
+    AC_DEFINE(RUSAGE_TIMES_ONLY, 1, [Define to 1 if your struct rusage only has time information.])
   ;;
 esac
 
-### Checks for other programs used for building, testing, installing,
-### and running Octave.
+### Checks for other programs used in building, testing, installing, and
+### running Octave.
 
 AC_PROG_AWK
 OCTAVE_PROG_FIND
@@ -2159,7 +2189,7 @@
 #define OCTAVE_HAVE_POSIX_FILESYSTEM 1
 #endif
 
-/* Define if we expect to have <windows.h>, Sleep, etc. */
+/* Define to 1 if we expect to have <windows.h>, Sleep, etc. */
 #if defined (__WIN32__) && ! defined (__CYGWIN__)
 #define OCTAVE_USE_WINDOWS_API 1
 #endif
@@ -2189,7 +2219,7 @@
 
 /* To be able to use long doubles for 64-bit mixed arithmetics, we need
    them at least 80 bits wide and we need roundl declared in math.h.
-   FIXME -- maybe substitute this by a more precise check in the future.  */
+   FIXME: Maybe substitute this by a more precise check in the future?  */
 #if (SIZEOF_LONG_DOUBLE >= 10) && defined (HAVE_ROUNDL)
 #define OCTAVE_INT_USE_LONG_DOUBLE
 #endif
@@ -2197,7 +2227,7 @@
 #define OCTAVE_EMPTY_CPP_ARG
 
 /* Octave is currently unable to use FFTW unless both float
-   and double versions are both available.  */
+   and double versions are available.  */
 #if defined (HAVE_FFTW3) && defined (HAVE_FFTW3F)
 #define HAVE_FFTW
 #endif
@@ -2252,7 +2282,7 @@
 
 #include <stdint.h>
 
-/* Tag indicating octave config.h has been included */
+/* Tag indicating Octave config.h has been included */
 #define OCTAVE_CONFIG_INCLUDED 1
 ])
 
@@ -2337,16 +2367,16 @@
   GLPK libraries:              $GLPK_LIBS
   graphics CFLAGS:             $GRAPHICS_CFLAGS
   graphics libraries:          $GRAPHICS_LIBS
-  Magick++ CPPFLAGS:           $MAGICK_CPPFLAGS
-  Magick++ LDFLAGS:            $MAGICK_LDFLAGS
-  Magick++ libraries:          $MAGICK_LIBS
-  LLVM CPPFLAGS:               $LLVM_CPPFLAGS
-  LLVM LDFLAGS:                $LLVM_LDFLAGS
-  LLVM libraries:              $LLVM_LIBS
   HDF5 CPPFLAGS:               $HDF5_CPPFLAGS
   HDF5 LDFLAGS:                $HDF5_LDFLAGS
   HDF5 libraries:              $HDF5_LIBS
   LAPACK libraries:            $LAPACK_LIBS
+  LLVM CPPFLAGS:               $LLVM_CPPFLAGS
+  LLVM LDFLAGS:                $LLVM_LDFLAGS
+  LLVM libraries:              $LLVM_LIBS
+  Magick++ CPPFLAGS:           $MAGICK_CPPFLAGS
+  Magick++ LDFLAGS:            $MAGICK_LDFLAGS
+  Magick++ libraries:          $MAGICK_LIBS
   OPENGL libraries:            $OPENGL_LIBS
   PTHREAD flags:               $PTHREAD_CFLAGS
   PTHREAD libraries:           $PTHREAD_LIBS
@@ -2413,7 +2443,7 @@
   AC_MSG_WARN([Are you sure that is what you want to do?])
   AC_MSG_WARN([])
   AC_MSG_WARN([This option enables experimental SMP multithreding])
-  AC_MSG_WARN([code that has had very little testing. There is no])
+  AC_MSG_WARN([code that has had very little testing.  There is no])
   AC_MSG_WARN([certainity that the results returned by Octave with])
   AC_MSG_WARN([this option enabled will be correct.])
   AC_MSG_WARN([])
@@ -2460,9 +2490,9 @@
 if $USE_ATOMIC_REFCOUNT; then
   AC_MSG_WARN([])
   AC_MSG_WARN([Using atomic reference counting.])
-  AC_MSG_WARN([This feature allows to access octave data safely from])
-  AC_MSG_WARN([another thread, for instance from a GUI. However this])
-  AC_MSG_WARN([results in a small performance penalty in the octave])
+  AC_MSG_WARN([This feature allows access to Octave data safely from])
+  AC_MSG_WARN([another thread, for instance from a GUI.  However this])
+  AC_MSG_WARN([results in a small performance penalty in the Octave])
   AC_MSG_WARN([interpreter.])
   AC_MSG_WARN([])
   if $USE_OCTAVE_ALLOCATOR; then
--- a/liboctave/lo-specfun.cc
+++ b/liboctave/lo-specfun.cc
@@ -2137,15 +2137,6 @@
 }
 
 static void
-gripe_betainc_nonconformant (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2, octave_idx_type r3,
-                             octave_idx_type c3)
-{
-  (*current_liboctave_error_handler)
-   ("betainc: nonconformant arguments (x is %dx%d, a is %dx%d, b is %dx%d)",
-     r1, c1, r2, c2, r3, c3);
-}
-
-static void
 gripe_betainc_nonconformant (const dim_vector& d1, const dim_vector& d2,
                              const dim_vector& d3)
 {
@@ -2159,15 +2150,6 @@
 }
 
 static void
-gripe_betaincinv_nonconformant (octave_idx_type r1, octave_idx_type c1, octave_idx_type r2, octave_idx_type c2, octave_idx_type r3,
-                                octave_idx_type c3)
-{
-  (*current_liboctave_error_handler)
-   ("betaincinv: nonconformant arguments (x is %dx%d, a is %dx%d, b is %dx%d)",
-     r1, c1, r2, c2, r3, c3);
-}
-
-static void
 gripe_betaincinv_nonconformant (const dim_vector& d1, const dim_vector& d2,
                                 const dim_vector& d3)
 {
--- a/m4/acinclude.m4
+++ b/m4/acinclude.m4
@@ -85,7 +85,7 @@
 [[operator delete((void *)0, (void *)0);]])],
 octave_cv_placement_delete=yes, octave_cv_placement_delete=no)])
 if test $octave_cv_placement_delete = yes; then
-AC_DEFINE(HAVE_PLACEMENT_DELETE,1,[Define if C++ supports operator delete(void *, void *)])
+AC_DEFINE(HAVE_PLACEMENT_DELETE,1,[Define to 1 if C++ supports operator delete(void *, void *).])
 fi
 AC_LANG_POP(C++)
 ])
@@ -100,7 +100,7 @@
 [[void test(char *); int length(); char x[length()]; test(x);]])],
 octave_cv_dynamic_auto_arrays=yes, octave_cv_dynamic_auto_arrays=no)])
 if test $octave_cv_dynamic_auto_arrays = yes; then
-AC_DEFINE(HAVE_DYNAMIC_AUTO_ARRAYS,1,[Define if C++ supports dynamic auto arrays])
+AC_DEFINE(HAVE_DYNAMIC_AUTO_ARRAYS,1,[Define to 1 if C++ supports dynamic auto arrays.])
 fi
 AC_LANG_POP(C++)
 ])
@@ -120,7 +120,7 @@
 int z3 = std::bit_xor<int>() (x, y);]])],
 octave_cv_cxx_bitwise_op_templates=yes, octave_cv_cxx_bitwise_op_templates=no)])
 if test $octave_cv_cxx_bitwise_op_templates = yes; then
-AC_DEFINE(HAVE_CXX_BITWISE_OP_TEMPLATES,1,[Define if C++ library has templated bitwise operators])
+AC_DEFINE(HAVE_CXX_BITWISE_OP_TEMPLATES,1,[Define to 1 if C++ library has templated bitwise operators.])
 fi
 AC_LANG_POP(C++)
 ])
@@ -137,7 +137,7 @@
 [[std::complex<double> x; x.real (1.0); x.imag (2.0);]])],
 octave_cv_cxx_complex_setters=yes, octave_cv_cxx_complex_setters=no)])
 if test $octave_cv_cxx_complex_setters = yes; then
-AC_DEFINE(HAVE_CXX_COMPLEX_SETTERS,1,[Define if C++ complex class has void real (T) and void imag (T) methods])
+AC_DEFINE(HAVE_CXX_COMPLEX_SETTERS,1,[Define to 1 if C++ complex class has void real (T) and void imag (T) methods.])
 fi
 AC_LANG_POP(C++)
 ])
@@ -153,7 +153,7 @@
 [[std::complex<double> x; x.real () = 1.0; x.imag () = 1.0;]])],
 octave_cv_cxx_complex_reference_accessors=yes, octave_cv_cxx_complex_reference_accessors=no)])
 if test $octave_cv_cxx_complex_reference_accessors = yes; then
-AC_DEFINE(HAVE_CXX_COMPLEX_REFERENCE_ACCESSORS,1,[Define if C++ complex class has T& real (void) and T& imag (void) methods])
+AC_DEFINE(HAVE_CXX_COMPLEX_REFERENCE_ACCESSORS,1,[Define to 1 if C++ complex class has T& real (void) and T& imag (void) methods.])
 fi
 AC_LANG_POP(C++)
 ])
@@ -172,7 +172,7 @@
 ]])],
 octave_cv_carbon_cgdisplaybitsperpixel=yes, octave_cv_carbon_cgdisplaybitsperpixel=no)])
 if test $octave_cv_carbon_cgdisplaybitsperpixel = yes; then
-AC_DEFINE(HAVE_CARBON_CGDISPLAYBITSPERPIXEL,1,[Define if Carbon Framework has CGDisplayBitsPerPixel])
+AC_DEFINE(HAVE_CARBON_CGDISPLAYBITSPERPIXEL,1,[Define to 1 if Carbon Framework has CGDisplayBitsPerPixel.])
 fi
 AC_LANG_POP(C++)
 ])
@@ -275,7 +275,7 @@
   ])
   AC_MSG_RESULT([$octave_cv_cxx_new_friend_template_decl])
   if test $octave_cv_cxx_new_friend_template_decl = yes; then
-    AC_DEFINE(CXX_NEW_FRIEND_TEMPLATE_DECL,1,[Define if your compiler supports `<>' stuff for template friends.])
+    AC_DEFINE(CXX_NEW_FRIEND_TEMPLATE_DECL,1,[Define to 1 if your compiler supports `<>' stuff for template friends.])
   fi
 ])
 dnl
@@ -528,7 +528,7 @@
 	m4_ifblank([$8], [
 	  warn_$1=
 	  AC_DEFINE([HAVE_]m4_toupper([$1]), 1,
-            [Define if $2 is available.])
+            [Define to 1 if $2 is available.])
 	  [TEXINFO_]m4_toupper([$1])="@set [HAVE_]m4_toupper([$1])"], [$8])
       fi
       LIBS="$octave_check_library_save_LIBS"
@@ -761,7 +761,7 @@
   ])
   AC_MSG_RESULT([$octave_cv_cxx_iso_compliant_library])
   if test $octave_cv_cxx_iso_compliant_library = yes; then
-    AC_DEFINE(CXX_ISO_COMPLIANT_LIBRARY, 1, [Define if your C++ runtime library is ISO compliant.])
+    AC_DEFINE(CXX_ISO_COMPLIANT_LIBRARY, 1, [Define to 1 if your C++ runtime library is ISO compliant.])
   fi
 ])
 dnl
@@ -783,7 +783,7 @@
     LIBS="$TERM_LIBS"
     AC_CHECK_LIB(readline, rl_set_keyboard_input_timeout, [
       READLINE_LIBS="-lreadline"
-      AC_DEFINE(USE_READLINE, 1, [Define to use the readline library.])
+      AC_DEFINE(USE_READLINE, 1, [Define to 1 to use the readline library.])
     ], [
       AC_MSG_WARN([I need GNU Readline 4.2 or later])
       AC_MSG_ERROR([this is fatal unless you specify --disable-readline])
@@ -810,7 +810,7 @@
       octave_cv_cxx_broken_reinterpret_cast=no,
       octave_cv_cxx_broken_reinterpret_cast=yes)])
   if test $octave_cv_cxx_broken_reinterpret_cast = yes ; then
-    AC_DEFINE(CXX_BROKEN_REINTERPRET_CAST, 1, [Define if C++ reinterpret_cast fails for function pointers.])
+    AC_DEFINE(CXX_BROKEN_REINTERPRET_CAST, 1, [Define to 1 if C++ reinterpret_cast fails for function pointers.])
 fi
   AC_LANG_POP(C++)])
 dnl
@@ -938,7 +938,7 @@
   AC_MSG_RESULT([$octave_cv_ieee754_data_format])
 fi
 if test "$octave_cv_ieee754_data_format" = yes; then
-  AC_DEFINE(HAVE_IEEE754_DATA_FORMAT, 1, [Define if your system uses IEEE 754 data format.])
+  AC_DEFINE(HAVE_IEEE754_DATA_FORMAT, 1, [Define to 1 if your system uses IEEE 754 data format.])
 else
   ## If the format is unknown, then you will probably not have a
   ## useful system, so we will abort here.  Anyone wishing to
@@ -1001,7 +1001,7 @@
   AC_MSG_RESULT([$octave_cv_umfpack_seperate_split])
 fi
 if test "$octave_cv_umfpack_seperate_split" = yes; then
-  AC_DEFINE(UMFPACK_SEPARATE_SPLIT, 1, [Define if the UMFPACK Complex solver allow matrix and RHS to be split independently])
+  AC_DEFINE(UMFPACK_SEPARATE_SPLIT, 1, [Define to 1 if the UMFPACK Complex solver allow matrix and RHS to be split independently.])
 fi
 ])
 dnl
@@ -1023,7 +1023,7 @@
       CFLAGS="$save_CFLAGS"
       LIBS="$save_LIBS"])])
   if test "$octave_cv_hdf5_dll" = yes; then
-    AC_DEFINE(_HDF5USEDLL_, 1, [Define if using HDF5 dll (Win32)])
+    AC_DEFINE(_HDF5USEDLL_, 1, [Define to 1 if using HDF5 dll (Win32).])
   fi])
 dnl
 dnl Check whether HDF5 library has version 1.6 API functions.
@@ -1038,11 +1038,11 @@
       octave_cv_hdf5_has_enforced_16_api=yes], [
       octave_cv_hdf5_has_enforced_16_api=no])])
   if test "$octave_cv_hdf5_has_enforced_16_api" != "yes"; then
-    AC_DEFINE(HAVE_HDF5_18, 1, [Define if >=HDF5-1.8 is available.])
+    AC_DEFINE(HAVE_HDF5_18, 1, [Define to 1 if >=HDF5-1.8 is available.])
   fi
 ])
 dnl
-dnl Check for the QHull version.
+dnl Check for the Qhull version.
 dnl
 AC_DEFUN([OCTAVE_CHECK_QHULL_VERSION],
   [AC_CACHE_CHECK([for qh_version in $QHULL_LIBS],
@@ -1081,11 +1081,11 @@
 ]])], [octave_cv_lib_qhull_version=yes], [octave_cv_lib_qhull_version=no])])
   if test "$octave_cv_lib_qhull_version" = no; then
     AC_DEFINE(NEED_QHULL_VERSION, 1,
-      [Define if the QHull library needs a qh_version variable defined.])
+      [Define to 1 if the Qhull library needs a qh_version variable defined.])
   fi
 ])
 dnl
-dnl Check whether QHull works (does not crash)
+dnl Check whether Qhull works (does not crash)
 dnl
 AC_DEFUN([OCTAVE_CHECK_QHULL_OK],
   [AC_CACHE_CHECK([whether the qhull library works],
@@ -1291,10 +1291,10 @@
 dnl
 dnl Check for OpenGL.  If found, define OPENGL_LIBS
 dnl
-dnl FIXME -- the following tests should probably check for the
+dnl FIXME: The following tests should probably check for the
 dnl libraries separately.
 dnl
-dnl FIXME -- should we allow a way to specify a directory for OpenGL
+dnl FIXME: Should we allow a way to specify a directory for OpenGL
 dnl libraries and header files?
 dnl
 AC_DEFUN([OCTAVE_OPENGL], [
@@ -1307,7 +1307,7 @@
   [have_framework_opengl="yes"], [have_framework_opengl="no"])
 
 if test $have_framework_opengl = "yes"; then
-  AC_DEFINE(HAVE_FRAMEWORK_OPENGL, 1, [Define if framework OPENGL is available.])
+  AC_DEFINE(HAVE_FRAMEWORK_OPENGL, 1, [Define to 1 if framework OPENGL is available.])
   OPENGL_LIBS="-Wl,-framework -Wl,OpenGL"
   AC_MSG_NOTICE([adding -Wl,-framework -Wl,OpenGL to OPENGL_LIBS])
   OCTAVE_GLUTESSCALLBACK_THREEDOTS
@@ -1382,7 +1382,7 @@
 AC_LANG_POP(C++)
 if test $octave_cv_glutesscallback_threedots = "yes"; then
   AC_DEFINE(HAVE_GLUTESSCALLBACK_THREEDOTS, 1, 
-    [Define if gluTessCallback is called with (...)])
+    [Define to 1 if gluTessCallback is called with (...).])
 fi
 ])
 dnl
@@ -1408,7 +1408,7 @@
 ]])],octave_cv_openmp=yes, octave_cv_openmmp=no, octave_cv_openmp=no)])
 AC_MSG_RESULT($octave_cv_openmp)
 if test "$octave_cv_openmp" = yes; then
-  AC_DEFINE(HAVE_OPENMP,1,[Define if compiler supports OpenMP])
+  AC_DEFINE(HAVE_OPENMP,1,[Define to 1 if compiler supports OpenMP.])
   CXXFLAGS="$CXXFLAGS $1"
 else
   CFLAGS="$XCFLAGS"
@@ -1627,7 +1627,7 @@
 take_func(std::$1);
 ]])],
 [AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_CMATH_[]AS_TR_CPP($1),1,[Define if <cmath> provides $1])],
+ AC_DEFINE(HAVE_CMATH_[]AS_TR_CPP($1),1,[Define to 1 if <cmath> provides $1.])],
 [AC_MSG_RESULT([no])])
 AC_MSG_CHECKING([for std::$1 (float variant) in <cmath>])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@@ -1640,13 +1640,13 @@
 take_func(std::$1);
 ]])],
 [AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_CMATH_[]AS_TR_CPP($1)F,1,[Define if <cmath> provides float variant of $1])],
+ AC_DEFINE(HAVE_CMATH_[]AS_TR_CPP($1)F,1,[Define to 1 if <cmath> provides float variant of $1.])],
 [AC_MSG_RESULT([no])])
 AC_LANG_POP(C++)
 ])
 
 dnl Check whether fast signed integer arithmetics using bit tricks
-dnl can be used in oct-inttypes.h. Defines HAVE_FAST_INT_OPS if
+dnl can be used in oct-inttypes.h.  Defines HAVE_FAST_INT_OPS if
 dnl the following conditions hold:
 dnl 1. Signed numbers are represented by twos complement
 dnl    (see <http://en.wikipedia.org/wiki/Two%27s_complement>)
@@ -1711,7 +1711,7 @@
 AC_LANG_POP(C++)])
 if test $octave_cv_fast_int_ops = yes; then
   AC_DEFINE(HAVE_FAST_INT_OPS, 1,
-    [Define if signed integers use two's complement])
+    [Define to 1 if signed integers use two's complement.])
 fi
 ])
 dnl
@@ -1719,7 +1719,7 @@
 dnl "-framework $1" for the given prologue $2 and the given body $3 of
 dnl a source file.  Arguments 2 and 3 optionally can also be empty.
 dnl Add options (lower case letters $1) "--with-framework-$1" and
-dnl "--without-framework-$1". If this test is successful then perform
+dnl "--without-framework-$1".  If this test is successful then perform
 dnl $4, otherwise do $5.
 dnl
 dnl OCTAVE_HAVE_FRAMEWORK
--- a/scripts/image/image.m
+++ b/scripts/image/image.m
@@ -72,6 +72,11 @@
     firstnonnumeric = 4;
   endif
 
+  if (iscomplex (img))
+    warning ("image: only showing real part of complex image");
+    img = real (img);
+  endif
+
   oldax = gca ();
   unwind_protect
     axes (ax);
@@ -241,3 +246,6 @@
 %! hold off;
 %! title ("line, image, line, image, line");
 
+## Test input validation
+%!error <can not be complex> image (1+i)
+%!error <matrix is empty> image ([])
--- a/scripts/pkg/pkg.m
+++ b/scripts/pkg/pkg.m
@@ -428,7 +428,7 @@
           endif
           warning ("creating the directory %s\n", prefix);
         endif
-        local_packages = prefix = canonicalize_filename (prefix);
+        local_packages = prefix = canonicalize_file_name (prefix);
         user_prefix = true;
         if (length (files) >= 2 && ischar (files{2}))
           archprefix = files{2};
--- a/scripts/plot/gtext.m
+++ b/scripts/plot/gtext.m
@@ -18,16 +18,24 @@
 
 ## -*- texinfo -*-
 ## @deftypefn  {Function File} {} gtext (@var{s})
+## @deftypefnx {Function File} {} gtext (@{@var{s1}, @var{s2}, @dots{}@})
 ## @deftypefnx {Function File} {} gtext (@{@var{s1}; @var{s2}; @dots{}@})
 ## @deftypefnx {Function File} {} gtext (@dots{}, @var{prop}, @var{val})
+## @deftypefnx {Function File} {@var{h} =} gtext (@dots{})
 ## Place text on the current figure using the mouse.  The text is defined
-## by the string @var{s}.  If @var{s} is a cell array, each element of the cell
-## array is written to a separate line.  Additional arguments are passed to
-## the underlying text object as properties.
+## by the string @var{s}.  If @var{s} is a cell string organized as a row
+## vector then each string of the cell array is written to a separate line.
+## If @var{s} is organized as a column vector then one string element of the
+## cell array is placed for every mouse click.  Additional inputs besides a
+## string or cellstr are passed to the underlying text object as Property-value
+## pairs.
+##
+## The optional return value @var{h} is a graphics handle to the created
+## text object.
 ## @seealso{ginput, text}
 ## @end deftypefn
 
-function gtext (s, varargin)
+function h = gtext (s, varargin)
 
   if (nargin < 1)
     print_usage ();
@@ -37,9 +45,21 @@
     error ("gtext: S must be a string or cell array of strings");
   endif
 
+  htmp = -1;
   if (! isempty (s))
-    [x, y] = ginput (1);
-    text (x, y, s, varargin{:});
+    if (ischar (s) || isrow (s))
+      [x, y] = ginput (1);
+      htmp = text (x, y, s, varargin{:});
+    else
+      for i = 1:numel (s)
+        [x, y] = ginput (1);
+        htmp = text (x, y, s{i}, varargin{:});
+      endfor
+    endif
+  endif
+
+  if (nargout > 0)
+    h = htmp;
   endif
 
 endfunction
--- a/scripts/polynomial/splinefit.m
+++ b/scripts/polynomial/splinefit.m
@@ -221,19 +221,19 @@
   pp = __splinefit__ (x, y, breaks, args{:});
 endfunction
 
+
 %!shared xb, yb, x
 %! xb = 0:2:10;
-%! yb = randn (size (xb));
+%! yb = 2*rand (size (xb)) - 1;
 %! x = 0:0.1:10;
 
 %!test
 %! y = interp1 (xb, yb, x, "linear");
-%! assert (ppval (splinefit (x, y, xb, "order", 1), x), y, 10 * eps ());
+%! assert (ppval (splinefit (x, y, xb, "order", 1), x), y, 15 * eps ());
 %!test
 %! y = interp1 (xb, yb, x, "spline");
-%! assert (ppval (splinefit (x, y, xb, "order", 3), x), y, 10 * eps ());
+%! assert (ppval (splinefit (x, y, xb, "order", 3), x), y, 15 * eps ());
 %!test
 %! y = interp1 (xb, yb, x, "spline");
-%! assert (ppval (splinefit (x, y, xb), x), y, 10 * eps ());
+%! assert (ppval (splinefit (x, y, xb), x), y, 15 * eps ());
 
-
--- a/scripts/testfun/demo.m
+++ b/scripts/testfun/demo.m
@@ -123,19 +123,11 @@
     ## Process each demo without failing
     try
       block = code(idx(doidx(i)):idx(doidx(i)+1)-1);
-      ## FIXME: need to check for embedded test functions, which cause
-      ## segfaults, until issues with subfunctions in functions are resolved.
-      embed_func = regexp (block, '^\s*function ', 'once', 'lineanchors');
-      if (isempty (embed_func))
-        ## Use an environment without variables
-        eval (cstrcat ("function __demo__ ()\n", block, "\nendfunction"));
-        ## Display the code that will be executed before executing it
-        printf ("%s example %d:%s\n\n", name, doidx(i), block);
-        __demo__;
-      else
-        error (["Functions embedded in %!demo blocks are not allowed.\n", ...
-                "Use the %!function/%!endfunction syntax instead to define shared functions for testing.\n"]);
-      endif
+      ## Use an environment without variables
+      eval (cstrcat ("function __demo__ ()\n", block, "\nendfunction"));
+      ## Display the code that will be executed before executing it
+      printf ("%s example %d:%s\n\n", name, doidx(i), block);
+      __demo__;
     catch
       ## Let the programmer know which demo failed.
       printf ("%s example %d: failed\n%s\n", name, doidx(i), lasterr ());
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,13 +22,14 @@
 
 ## Search local directories before those specified by the user.
 AM_CPPFLAGS = \
-  -I../libgnu -I$(top_srcdir)/libgnu \
   -I$(top_srcdir)/libcruft/misc \
   -I../liboctave -I$(top_srcdir)/liboctave \
+  -Iinterpfcn -I$(srcdir)/interpfcn \
+  -Icorefcn \
   -Ioctave-value -I$(srcdir)/octave-value \
   -Iparse-tree -I$(srcdir)/parse-tree \
-  -Icorefcn -I$(srcdir)/corefcn \
   -I. -I$(srcdir) \
+  -I../libgnu -I$(top_srcdir)/libgnu \
   @CPPFLAGS@
 
 AUTOMAKE_OPTIONS = subdir-objects
@@ -66,28 +67,28 @@
 ## (except builtins.cc) to be available.
 BUILT_SOURCES = \
   $(BUILT_SOURCES_EXTRA) \
-  defaults.h \
-  graphics.h \
-  graphics-props.cc \
-  lex.cc \
+  interpfcn/defaults.h \
+  interpfcn/graphics.h \
+  interpfcn/graphics-props.cc \
+  parse-tree/lex.cc \
   mxarray.h \
   oct-conf.h \
   oct-errno.cc \
   oct-gperf.h \
-  oct-parse.cc \
+  parse-tree/oct-parse.cc \
   ops.cc \
   version.h \
   builtins.cc
 
 BUILT_DISTFILES = \
   oct-gperf.h \
-  oct-parse.h
+  parse-tree/oct-parse.h
 
 ## Files that are created during build process and installed,
 ## BUT not distributed in tarball.
 BUILT_NODISTFILES = \
-  defaults.h \
-  graphics.h \
+  interpfcn/defaults.h \
+  interpfcn/graphics.h \
   oct-conf.h \
   oct-errno.cc \
   ops.cc \
@@ -123,20 +124,6 @@
   version.in.h \
   $(BUILT_DISTFILES)
 
-OPT_HANDLERS = \
-  DASPK-opts.cc \
-  DASRT-opts.cc \
-  DASSL-opts.cc \
-  LSODE-opts.cc \
-  Quad-opts.cc
-
-OPT_INC = \
-  ../liboctave/DASPK-opts.h \
-  ../liboctave/DASRT-opts.h \
-  ../liboctave/DASSL-opts.h \
-  ../liboctave/LSODE-opts.h \
-  ../liboctave/Quad-opts.h
-
 JIT_INCLUDES = \
   jit-util.h \
   jit-typeinfo.h \
@@ -149,32 +136,20 @@
   c-file-ptr-stream.h \
   comment-list.h \
   cutils.h \
-  data.h \
-  debug.h \
   defun-dld.h \
   defun-int.h \
-  defun.h \
-  dirfns.h \
   display.h \
   dynamic-ld.h \
-  error.h \
-  file-io.h \
   gl-render.h \
   gl2ps.h \
   gl2ps-renderer.h \
-  graphics-props.cc \
+  interpfcn/graphics-props.cc \
   gripes.h \
-  help.h \
-  input.h \
-  lex.h \
-  load-path.h \
-  load-save.h \
   ls-ascii-helper.h \
   ls-hdf5.h \
   ls-mat-ascii.h \
   ls-mat4.h \
   ls-mat5.h \
-  ls-oct-ascii.h \
   ls-oct-binary.h \
   ls-utils.h \
   mex.h \
@@ -183,7 +158,6 @@
   oct-fstrm.h \
   oct-gperf.h \
   oct-hdf5.h \
-  oct-hist.h \
   oct-iostrm.h \
   oct-lvalue.h \
   oct-map.h \
@@ -196,25 +170,14 @@
   oct.h \
   octave.h \
   ops.h \
-  pager.h \
-  parse.h \
-  parse-private.h \
-  pr-output.h \
   procstream.h \
-  profiler.h \
-  sighandlers.h \
   siglist.h \
   sparse-xdiv.h \
   sparse-xpow.h \
-  symtab.h \
-  sysdep.h \
   token.h \
-  toplev.h \
   txt-eng-ft.h \
   txt-eng.h \
   unwind-prot.h \
-  utils.h \
-  variables.h \
   xdiv.h \
   xnorm.h \
   xpow.h \
@@ -222,11 +185,12 @@
   $(OV_INCLUDES) \
   $(OV_SPARSE_INCLUDES) \
   $(PT_INCLUDES) \
+  $(INTERPFCN_INCLUDES) \
   $(JIT_INCLUDES)
 
 nodist_octinclude_HEADERS = \
-  defaults.h \
-  graphics.h \
+  interpfcn/defaults.h \
+  interpfcn/graphics.h \
   oct-conf.h \
   mxarray.h \
   version.h
@@ -239,79 +203,50 @@
 
 DIST_SRC = \
   Cell.cc \
-  bitfcns.cc \
   c-file-ptr-stream.cc \
   comment-list.cc \
   cutils.c \
-  data.cc \
-  debug.cc \
-  defaults.cc \
-  defun.cc \
-  dirfns.cc \
   display.cc \
   dynamic-ld.cc \
-  error.cc \
-  file-io.cc \
   gl-render.cc \
   gl2ps-renderer.cc \
-  graphics.cc \
   gripes.cc \
-  help.cc \
-  input.cc \
-  lex.ll \
-  load-path.cc \
-  load-save.cc \
   ls-ascii-helper.cc \
   ls-hdf5.cc \
   ls-mat-ascii.cc \
   ls-mat4.cc \
   ls-mat5.cc \
-  ls-oct-ascii.cc \
   ls-oct-binary.cc \
   ls-utils.cc \
-  mappers.cc \
   matherr.c \
   mex.cc \
   oct-fstrm.cc \
-  oct-hist.cc \
   oct-iostrm.cc \
   oct-lvalue.cc \
   oct-map.cc \
   oct-obj.cc \
-  oct-parse.yy \
   oct-prcstrm.cc \
   oct-procbuf.cc \
   oct-stream.cc \
   oct-strstrm.cc \
   octave.cc \
-  pager.cc \
-  pr-output.cc \
   procstream.cc \
-  profiler.cc \
-  sighandlers.cc \
   siglist.c \
-  sparse.cc \
   sparse-xdiv.cc \
   sparse-xpow.cc \
-  strfns.cc \
-  symtab.cc \
-  syscalls.cc \
-  sysdep.cc \
   token.cc \
-  toplev.cc \
   txt-eng-ft.cc \
   unwind-prot.cc \
-  utils.cc \
-  variables.cc \
   xdiv.cc \
   xgl2ps.c \
   xnorm.cc \
   xpow.cc \
   zfstream.cc \
-  $(COREFCN_SRC) \
   $(OCTAVE_VALUE_SRC) \
   $(PARSE_TREE_SRC) \
-  $(JIT_SRC)
+  $(JIT_SRC) \
+  $(INTERPFCN_SRC) \
+  $(COREFCN_SRC)
 
 noinst_LTLIBRARIES =
 
@@ -319,15 +254,16 @@
 include octave-value/module.mk
 include operators/module.mk
 include template-inst/module.mk
+include interpfcn/module.mk
 include corefcn/module.mk
-include DLD-FUNCTIONS/module.mk
+include dldfcn/module.mk
 
-$(srcdir)/DLD-FUNCTIONS/module.mk: $(srcdir)/DLD-FUNCTIONS/config-module.sh $(srcdir)/DLD-FUNCTIONS/config-module.awk $(srcdir)/DLD-FUNCTIONS/module-files
-	$(srcdir)/DLD-FUNCTIONS/config-module.sh $(top_srcdir)
+$(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 = $(DLD_FUNCTIONS_LIBS:.la=.oct)
-  OCT_STAMP_FILES = $(subst DLD-FUNCTIONS/,DLD-FUNCTIONS/$(am__leading_dot),$(DLD_FUNCTIONS_LIBS:.la=.oct-stamp))
+  OCT_FILES = $(DLDFCN_LIBS:.la=.oct)
+  OCT_STAMP_FILES = $(subst dldfcn/,dldfcn/$(am__leading_dot),$(DLDFCN_LIBS:.la=.oct-stamp))
   DLD_LIBOCTINTERP_LIBADD = liboctinterp.la
 else
   OCT_FILES =
@@ -342,8 +278,8 @@
 
 nodist_liboctinterp_la_SOURCES = \
   builtins.cc \
-  defaults.h \
-  graphics.h \
+  interpfcn/defaults.h \
+  interpfcn/graphics.h \
   mxarray.h \
   oct-conf.h \
   oct-errno.cc \
@@ -393,17 +329,17 @@
 ## Section for defining and creating DEF_FILES
 SRC_DEF_FILES := $(shell $(srcdir)/find-defun-files.sh "$(srcdir)" $(DIST_SRC))
 
-DLD_FUNCTIONS_DEF_FILES = $(DLD_FUNCTIONS_SRC:.cc=.df)
+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) $(DLD_FUNCTIONS_DEF_FILES)
+  DEF_FILES = $(SRC_DEF_FILES) $(DLDFCN_DEF_FILES)
 endif
 
-ALL_DEF_FILES = $(SRC_DEF_FILES) $(DLD_FUNCTIONS_DEF_FILES)
+ALL_DEF_FILES = $(SRC_DEF_FILES) $(DLDFCN_DEF_FILES)
 
 $(SRC_DEF_FILES): mkdefs Makefile
 
@@ -425,13 +361,6 @@
 ## defaults.h and oct-conf.h must depend on Makefile.  Calling configure
 ## may change default/config values.  However, calling configure will also
 ## regenerate the Makefiles from Makefile.am and trigger the rules below.
-defaults.h: defaults.in.h Makefile
-	@$(do_subst_default_vals)
-
-graphics.h: graphics.in.h genprops.awk Makefile
-	$(AWK) -f $(srcdir)/genprops.awk $< > $@-t
-	mv $@-t $@
-
 oct-conf.h: oct-conf.in.h Makefile
 	@$(do_subst_config_vals)
 
@@ -463,10 +392,6 @@
 	$(srcdir)/mkbuiltins $(DEF_FILES) > $@-t
 	mv $@-t $@
 
-graphics-props.cc: graphics.in.h genprops.awk Makefile
-	$(AWK) -v emit_graphics_props=1 -f $(srcdir)/genprops.awk $< > $@-t
-	mv $@-t $@
-
 ops.cc: $(OPERATORS_SRC) mkops
 	$(srcdir)/mkops $(OPERATORS_SRC) > $@-t
 	mv $@-t $@
@@ -481,24 +406,14 @@
 	fi
 	mv $@-t $@
 
-$(OPT_HANDLERS) : %.cc : $(top_srcdir)/liboctave/%.in $(top_srcdir)/build-aux/mk-opts.pl
-	$(PERL) $(top_srcdir)/build-aux/mk-opts.pl --opt-handler-fcns $< > $@-t
-	mv $@-t $@
+if AMCOND_ENABLE_DYNAMIC_LINKING
+DLDFCN_PKG_ADD_FILE = dldfcn/PKG_ADD
 
-$(OPT_INC) : %.h : %.in
-	$(MAKE) -C $(@D) $(@F)
-
-if AMCOND_ENABLE_DYNAMIC_LINKING
-DLD_FUNCTIONS_PKG_ADD_FILE = DLD-FUNCTIONS/PKG_ADD
-
-DLD-FUNCTIONS/PKG_ADD: $(DLD_FUNCTIONS_DEF_FILES) mk-pkg-add
-	$(srcdir)/mk-pkg-add $(DLD_FUNCTIONS_DEF_FILES) > $@-t
+dldfcn/PKG_ADD: $(DLDFCN_DEF_FILES) mk-pkg-add
+	$(srcdir)/mk-pkg-add $(DLDFCN_DEF_FILES) > $@-t
 	mv $@-t $@
 endif
 
-lex.lo lex.o oct-parse.lo oct-parse.o: \
-  AM_CXXFLAGS := $(filter-out -Wold-style-cast, $(AM_CXXFLAGS))
-
 __fltk_uigetfile__.lo __fltk_uigetfile__.o: \
   AM_CXXFLAGS := $(filter-out $(DLL_CXXDEFS), $(AM_CXXFLAGS) $(GRAPHICS_CFLAGS))
 
@@ -516,9 +431,9 @@
 	$(top_srcdir)/build-aux/move-if-change $@ DOCSTRINGS
 	touch $@
 
-all-local: $(OCT_STAMP_FILES) $(DLD_FUNCTIONS_PKG_ADD_FILE) .DOCSTRINGS
+all-local: $(OCT_STAMP_FILES) $(DLDFCN_PKG_ADD_FILE) .DOCSTRINGS
 else
-all-local: $(OCT_STAMP_FILES) $(DLD_FUNCTIONS_PKG_ADD_FILE)
+all-local: $(OCT_STAMP_FILES) $(DLDFCN_PKG_ADD_FILE)
 endif
 
 if AMCOND_BUILD_COMPILED_AUX_PROGRAMS
@@ -572,11 +487,11 @@
 if AMCOND_ENABLE_DYNAMIC_LINKING
 install-oct:
 	$(top_srcdir)/build-aux/mkinstalldirs $(DESTDIR)$(octfiledir)
-	if [ -n "`cat $(DLD_FUNCTIONS_PKG_ADD_FILE)`" ]; then \
-	  $(INSTALL_DATA) $(DLD_FUNCTIONS_PKG_ADD_FILE) $(DESTDIR)$(octfiledir)/PKG_ADD; \
+	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 $(DLD_FUNCTIONS_LIBS); do \
+	for ltlib in $(DLDFCN_LIBS); do \
 	  f=`echo $$ltlib | $(SED) 's,.*/,,'`; \
 	  dl=`$(SED) -n -e "s/dlname='\([^']*\)'/\1/p" < $$f`; \
 	  if [ -n "$$dl" ]; then \
@@ -601,9 +516,9 @@
 
 CLEANFILES = \
   $(bin_SCRIPTS) \
-  $(DLD_FUNCTIONS_PKG_ADD_FILE) \
-  graphics-props.cc \
-  oct-parse.output
+  $(DLDFCN_PKG_ADD_FILE) \
+  interpfcn/graphics-props.cc \
+  parse-tree/oct-parse.output
 
 DISTCLEANFILES = \
   .DOCSTRINGS \
rename from src/bitfcns.cc
rename to src/corefcn/bitfcns.cc
rename from src/mappers.cc
rename to src/corefcn/mappers.cc
--- a/src/corefcn/module.mk
+++ b/src/corefcn/module.mk
@@ -1,6 +1,29 @@
 EXTRA_DIST += \
   corefcn/module.mk
 
+## 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
+
+OPT_INC = \
+  $(top_builddir)/liboctave/DASPK-opts.h \
+  $(top_builddir)/liboctave/DASRT-opts.h \
+  $(top_builddir)/liboctave/DASSL-opts.h \
+  $(top_builddir)/liboctave/LSODE-opts.h \
+  $(top_builddir)/liboctave/Quad-opts.h
+
+$(OPT_HANDLERS): corefcn/%.cc : $(top_builddir)/liboctave/%.in
+	$(PERL) $(top_srcdir)/build-aux/mk-opts.pl --opt-handler-fcns $< > $@-t
+	mv $@-t $@
+
+$(OPT_INC) : %.h : %.in
+	$(MAKE) -C $(top_builddir)/liboctave $(@F)
+
 COREFCN_SRC = \
   corefcn/__contourc__.cc \
   corefcn/__dispatch__.cc \
@@ -10,6 +33,7 @@
   corefcn/balance.cc \
   corefcn/besselj.cc \
   corefcn/betainc.cc \
+  corefcn/bitfcns.cc \
   corefcn/bsxfun.cc \
   corefcn/cellfun.cc \
   corefcn/colloc.cc \
@@ -40,6 +64,7 @@
   corefcn/lsode.cc \
   corefcn/lu.cc \
   corefcn/luinc.cc \
+  corefcn/mappers.cc \
   corefcn/matrix_type.cc \
   corefcn/max.cc \
   corefcn/md5sum.cc \
@@ -53,13 +78,16 @@
   corefcn/rcond.cc \
   corefcn/regexp.cc \
   corefcn/schur.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/syl.cc \
+  corefcn/syscalls.cc \
   corefcn/time.cc \
   corefcn/tril.cc \
   corefcn/typecast.cc
rename from src/sparse.cc
rename to src/corefcn/sparse.cc
rename from src/strfns.cc
rename to src/corefcn/strfns.cc
rename from src/syscalls.cc
rename to src/corefcn/syscalls.cc
--- a/src/syscalls.cc
+++ b/src/corefcn/syscalls.cc
@@ -936,7 +936,7 @@
 @end table\n\
 \n\
 If the call is successful @var{err} is 0 and @var{msg} is an empty\n\
-string.  If the file does not exist, or some other error occurs, @var{s}\n\
+string.  If the file does not exist, or some other error occurs, @var{info}\n\
 is an empty matrix, @var{err} is @minus{}1, and @var{msg} contains the\n\
 corresponding system error message.\n\
 \n\
@@ -947,8 +947,8 @@
 For example:\n\
 \n\
 @example\n\
-[s, err, msg] = stat (\"/vmlinuz\")\n\
-  @result{} s =\n\
+[info, err, msg] = stat (\"/vmlinuz\")\n\
+  @result{} info =\n\
      @{\n\
        atime = 855399756\n\
        rdev = 0\n\
rename from src/DLD-FUNCTIONS/__delaunayn__.cc
rename to src/dldfcn/__delaunayn__.cc
rename from src/DLD-FUNCTIONS/__dsearchn__.cc
rename to src/dldfcn/__dsearchn__.cc
rename from src/DLD-FUNCTIONS/__fltk_uigetfile__.cc
rename to src/dldfcn/__fltk_uigetfile__.cc
rename from src/DLD-FUNCTIONS/__glpk__.cc
rename to src/dldfcn/__glpk__.cc
rename from src/DLD-FUNCTIONS/__init_fltk__.cc
rename to src/dldfcn/__init_fltk__.cc
rename from src/DLD-FUNCTIONS/__init_gnuplot__.cc
rename to src/dldfcn/__init_gnuplot__.cc
rename from src/DLD-FUNCTIONS/__magick_read__.cc
rename to src/dldfcn/__magick_read__.cc
rename from src/DLD-FUNCTIONS/__voronoi__.cc
rename to src/dldfcn/__voronoi__.cc
rename from src/DLD-FUNCTIONS/amd.cc
rename to src/dldfcn/amd.cc
rename from src/DLD-FUNCTIONS/ccolamd.cc
rename to src/dldfcn/ccolamd.cc
rename from src/DLD-FUNCTIONS/chol.cc
rename to src/dldfcn/chol.cc
rename from src/DLD-FUNCTIONS/colamd.cc
rename to src/dldfcn/colamd.cc
rename from src/DLD-FUNCTIONS/config-module.awk
rename to src/dldfcn/config-module.awk
--- a/src/DLD-FUNCTIONS/config-module.awk
+++ b/src/dldfcn/config-module.awk
@@ -5,10 +5,10 @@
   print "## DO NOT EDIT -- generated from module-files by config-module.awk";
   print ""
   print "EXTRA_DIST += \\"
-  print "  DLD-FUNCTIONS/config-module.sh \\"
-  print "  DLD-FUNCTIONS/config-module.awk \\"
-  print "  DLD-FUNCTIONS/module-files \\"
-  print "  DLD-FUNCTIONS/oct-qhull.h"
+  print "  dldfcn/config-module.sh \\"
+  print "  dldfcn/config-module.awk \\"
+  print "  dldfcn/module-files \\"
+  print "  dldfcn/oct-qhull.h"
   print ""
 }
 /^#.*/ { next; }
@@ -20,20 +20,20 @@
   libraries[nfiles] = $4;
 } END {
   sep = " \\\n";
-  print "DLD_FUNCTIONS_SRC = \\";
+  print "DLDFCN_SRC = \\";
   for (i = 1; i <= nfiles; i++) {
     if (i == nfiles)
       sep = "\n";
-    printf ("  DLD-FUNCTIONS/%s%s", files[i], sep);
+    printf ("  dldfcn/%s%s", files[i], sep);
   }
   print "";
 
   sep = " \\\n";
-  print "DLD_FUNCTIONS_LIBS = $(DLD_FUNCTIONS_SRC:.cc=.la)";
+  print "DLDFCN_LIBS = $(DLDFCN_SRC:.cc=.la)";
   print "";
   print "if AMCOND_ENABLE_DYNAMIC_LINKING";
   print "";
-  print "octlib_LTLIBRARIES += $(DLD_FUNCTIONS_LIBS)";
+  print "octlib_LTLIBRARIES += $(DLDFCN_LIBS)";
   print "";
   print "## Use stamp files to avoid problems with checking timestamps";
   print "## of symbolic links";
@@ -41,18 +41,18 @@
   for (i = 1; i <= nfiles; i++) {
     basename = files[i];
     sub (/\.cc$/, "", basename);
-    printf ("DLD-FUNCTIONS/$(am__leading_dot)%s.oct-stamp: DLD-FUNCTIONS/%s.la\n", basename, basename);
+    printf ("dldfcn/$(am__leading_dot)%s.oct-stamp: dldfcn/%s.la\n", basename, basename);
     print "\trm -f $(<:.la=.oct)";
     print "\tla=$(<F) && \\";
     print "\t  of=$(<F:.la=.oct) && \\";
-    print "\t  cd DLD-FUNCTIONS && \\";
+    print "\t  cd dldfcn && \\";
     print "\t  $(LN_S) .libs/`$(SED) -n -e \"s/dlname='\\([^']*\\)'/\\1/p\" < $$la` $$of && \\";
     print "\t  touch $(@F)";
     print "";
   }
   print "else";
   print "";
-  print "noinst_LTLIBRARIES += $(DLD_FUNCTIONS_LIBS)";
+  print "noinst_LTLIBRARIES += $(DLDFCN_LIBS)";
   print "";
   print "endif";
 
@@ -60,18 +60,18 @@
     basename = files[i];
     sub (/\.cc$/, "", basename);
     print "";
-    printf ("DLD_FUNCTIONS_%s_la_SOURCES = DLD-FUNCTIONS/%s\n",
+    printf ("dldfcn_%s_la_SOURCES = dldfcn/%s\n",
 	    basename, files[i]);
     if (cppflags[i])
       {
-        printf ("DLD-FUNCTIONS/%s.df: CPPFLAGS += %s\n",
+        printf ("dldfcn/%s.df: CPPFLAGS += %s\n",
                 basename, cppflags[i]);
-        printf ("DLD_FUNCTIONS_%s_la_CPPFLAGS = $(AM_CPPFLAGS) %s\n",
+        printf ("dldfcn_%s_la_CPPFLAGS = $(AM_CPPFLAGS) %s\n",
                 basename, cppflags[i]);
       }
-    printf ("DLD_FUNCTIONS_%s_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED_LDFLAG) %s $(OCT_LINK_OPTS)\n",
+    printf ("dldfcn_%s_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED_LDFLAG) %s $(OCT_LINK_OPTS)\n",
             basename, ldflags[i]);
-    printf ("DLD_FUNCTIONS_%s_la_LIBADD = $(DLD_LIBOCTINTERP_LIBADD) ../liboctave/liboctave.la ../libcruft/libcruft.la %s $(OCT_LINK_DEPS)\n",
+    printf ("dldfcn_%s_la_LIBADD = $(DLD_LIBOCTINTERP_LIBADD) ../liboctave/liboctave.la ../libcruft/libcruft.la %s $(OCT_LINK_DEPS)\n",
             basename, libraries[i]);
   }
 }
rename from src/DLD-FUNCTIONS/config-module.sh
rename to src/dldfcn/config-module.sh
--- a/src/DLD-FUNCTIONS/config-module.sh
+++ b/src/dldfcn/config-module.sh
@@ -12,7 +12,7 @@
 
 move_if_change="$top_srcdir/build-aux/move-if-change"
 
-dld_dir=$top_srcdir/src/DLD-FUNCTIONS
+dld_dir=$top_srcdir/src/dldfcn
 
 $AWK -f $dld_dir/config-module.awk < $dld_dir/module-files > $dld_dir/module.mk-t
 
rename from src/DLD-FUNCTIONS/convhulln.cc
rename to src/dldfcn/convhulln.cc
rename from src/DLD-FUNCTIONS/dmperm.cc
rename to src/dldfcn/dmperm.cc
rename from src/DLD-FUNCTIONS/eigs.cc
rename to src/dldfcn/eigs.cc
rename from src/DLD-FUNCTIONS/fftw.cc
rename to src/dldfcn/fftw.cc
rename from src/DLD-FUNCTIONS/module-files
rename to src/dldfcn/module-files
rename from src/DLD-FUNCTIONS/oct-qhull.h
rename to src/dldfcn/oct-qhull.h
rename from src/DLD-FUNCTIONS/qr.cc
rename to src/dldfcn/qr.cc
rename from src/DLD-FUNCTIONS/symbfact.cc
rename to src/dldfcn/symbfact.cc
rename from src/DLD-FUNCTIONS/symrcm.cc
rename to src/dldfcn/symrcm.cc
rename from src/DLD-FUNCTIONS/tsearch.cc
rename to src/dldfcn/tsearch.cc
rename from src/DLD-FUNCTIONS/urlwrite.cc
rename to src/dldfcn/urlwrite.cc
--- a/src/gl-render.cc
+++ b/src/gl-render.cc
@@ -2488,6 +2488,10 @@
   Matrix x = props.get_xdata ().matrix_value ();
   Matrix y = props.get_ydata ().matrix_value ();
 
+  // Someone wants us to draw an empty image? No way.
+  if (x.is_empty () || y.is_empty ())
+    return;
+
   if (w > 1 && x(1) == x(0))
     x(1) = x(1) + (w-1);
 
rename from src/data.cc
rename to src/interpfcn/data.cc
rename from src/data.h
rename to src/interpfcn/data.h
rename from src/debug.cc
rename to src/interpfcn/debug.cc
rename from src/debug.h
rename to src/interpfcn/debug.h
rename from src/defaults.cc
rename to src/interpfcn/defaults.cc
rename from src/defaults.in.h
rename to src/interpfcn/defaults.in.h
--- a/src/defaults.in.h
+++ b/src/interpfcn/defaults.in.h
@@ -1,4 +1,4 @@
-// defaults.h.in
+// DO NOT EDIT!  Generated automatically from defaults.in.h by configure
 /*
 
 Copyright (C) 1993-2012 John W. Eaton
rename from src/defun.cc
rename to src/interpfcn/defun.cc
rename from src/defun.h
rename to src/interpfcn/defun.h
rename from src/dirfns.cc
rename to src/interpfcn/dirfns.cc
rename from src/dirfns.h
rename to src/interpfcn/dirfns.h
--- a/src/dirfns.h
+++ b/src/interpfcn/dirfns.h
@@ -29,11 +29,6 @@
 
 #include "oct-time.h"
 
-extern std::string polite_directory_format (const std::string&);
-extern std::string base_pathname (const std::string&);
-extern std::string make_absolute (const std::string&, const std::string&);
-extern std::string get_working_directory (const std::string&);
-
 // The time we last time we changed directories.
 extern octave_time Vlast_chdir_time;
 
rename from src/error.cc
rename to src/interpfcn/error.cc
rename from src/error.h
rename to src/interpfcn/error.h
rename from src/file-io.cc
rename to src/interpfcn/file-io.cc
rename from src/file-io.h
rename to src/interpfcn/file-io.h
rename from src/graphics.cc
rename to src/interpfcn/graphics.cc
--- a/src/graphics.cc
+++ b/src/interpfcn/graphics.cc
@@ -1201,10 +1201,14 @@
   // check value type
   if (type_constraints.size () > 0)
     {
-      for (std::list<std::string>::const_iterator it = type_constraints.begin ();
-           ! xok && it != type_constraints.end (); ++it)
-        if ((*it) == v.class_name ())
-          xok = true;
+      if(type_constraints.find (v.class_name()) != type_constraints.end())
+        xok = true;
+
+      // check if complex is allowed (it's also of class "double", so
+      // checking that alone is not enough to ensure real type)
+      if (type_constraints.find ("real") != type_constraints.end ()
+          && v.is_complex_type ())
+        xok = false;
     }
   else
     xok = v.is_numeric_type ();
rename from src/graphics.in.h
rename to src/interpfcn/graphics.in.h
--- a/src/graphics.in.h
+++ b/src/interpfcn/graphics.in.h
@@ -1413,7 +1413,7 @@
   octave_value get (void) const { return data; }
 
   void add_constraint (const std::string& type)
-    { type_constraints.push_back (type); }
+    { type_constraints.insert (type); }
 
   void add_constraint (const dim_vector& dims)
     { size_constraints.push_back (dims); }
@@ -1486,7 +1486,7 @@
   double xmax;
   double xminp;
   double xmaxp;
-  std::list<std::string> type_constraints;
+  std::set<std::string> type_constraints;
   std::list<dim_vector> size_constraints;
 };
 
@@ -4432,6 +4432,7 @@
         cdata.add_constraint ("uint8");
         cdata.add_constraint ("uint16");
         cdata.add_constraint ("int16");
+        cdata.add_constraint ("real");
         cdata.add_constraint (dim_vector (-1, -1));
         cdata.add_constraint (dim_vector (-1, -1, 3));
       }
rename from src/help.cc
rename to src/interpfcn/help.cc
rename from src/help.h
rename to src/interpfcn/help.h
rename from src/input.cc
rename to src/interpfcn/input.cc
rename from src/input.h
rename to src/interpfcn/input.h
rename from src/load-path.cc
rename to src/interpfcn/load-path.cc
rename from src/load-path.h
rename to src/interpfcn/load-path.h
rename from src/load-save.cc
rename to src/interpfcn/load-save.cc
rename from src/load-save.h
rename to src/interpfcn/load-save.h
rename from src/ls-oct-ascii.cc
rename to src/interpfcn/ls-oct-ascii.cc
rename from src/ls-oct-ascii.h
rename to src/interpfcn/ls-oct-ascii.h
new file mode 100644
--- /dev/null
+++ b/src/interpfcn/module.mk
@@ -0,0 +1,65 @@
+EXTRA_DIST += \
+  interpfcn/module.mk
+
+INTERPFCN_INCLUDES = \
+  interpfcn/data.h \
+  interpfcn/debug.h \
+  interpfcn/defun.h \
+  interpfcn/dirfns.h \
+  interpfcn/error.h \
+  interpfcn/file-io.h \
+  interpfcn/help.h \
+  interpfcn/input.h \
+  interpfcn/load-path.h \
+  interpfcn/load-save.h \
+  interpfcn/ls-oct-ascii.h \
+  interpfcn/oct-hist.h \
+  interpfcn/pager.h \
+  interpfcn/pr-output.h \
+  interpfcn/profiler.h \
+  interpfcn/sighandlers.h \
+  interpfcn/symtab.h \
+  interpfcn/sysdep.h \
+  interpfcn/toplev.h \
+  interpfcn/utils.h \
+  interpfcn/variables.h
+
+INTERPFCN_SRC = \
+  interpfcn/data.cc \
+  interpfcn/debug.cc \
+  interpfcn/defaults.cc \
+  interpfcn/defun.cc \
+  interpfcn/dirfns.cc \
+  interpfcn/error.cc \
+  interpfcn/file-io.cc \
+  interpfcn/graphics.cc \
+  interpfcn/help.cc \
+  interpfcn/input.cc \
+  interpfcn/load-path.cc \
+  interpfcn/load-save.cc \
+  interpfcn/ls-oct-ascii.cc \
+  interpfcn/oct-hist.cc \
+  interpfcn/pager.cc \
+  interpfcn/pr-output.cc \
+  interpfcn/profiler.cc \
+  interpfcn/sighandlers.cc \
+  interpfcn/symtab.cc \
+  interpfcn/sysdep.cc \
+  interpfcn/toplev.cc \
+  interpfcn/utils.cc \
+  interpfcn/variables.cc
+
+## 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.
+interpfcn/defaults.h: interpfcn/defaults.in.h Makefile
+	@$(do_subst_default_vals)
+
+interpfcn/graphics.h: interpfcn/graphics.in.h genprops.awk Makefile
+	$(AWK) -f $(srcdir)/genprops.awk $< > $@-t
+	mv $@-t $@
+
+interpfcn/graphics-props.cc: interpfcn/graphics.in.h genprops.awk Makefile
+	$(AWK) -v emit_graphics_props=1 -f $(srcdir)/genprops.awk $< > $@-t
+	mv $@-t $@
+
rename from src/oct-hist.cc
rename to src/interpfcn/oct-hist.cc
rename from src/oct-hist.h
rename to src/interpfcn/oct-hist.h
rename from src/pager.cc
rename to src/interpfcn/pager.cc
rename from src/pager.h
rename to src/interpfcn/pager.h
rename from src/pr-output.cc
rename to src/interpfcn/pr-output.cc
rename from src/pr-output.h
rename to src/interpfcn/pr-output.h
rename from src/profiler.cc
rename to src/interpfcn/profiler.cc
rename from src/profiler.h
rename to src/interpfcn/profiler.h
rename from src/sighandlers.cc
rename to src/interpfcn/sighandlers.cc
rename from src/sighandlers.h
rename to src/interpfcn/sighandlers.h
rename from src/symtab.cc
rename to src/interpfcn/symtab.cc
rename from src/symtab.h
rename to src/interpfcn/symtab.h
rename from src/sysdep.cc
rename to src/interpfcn/sysdep.cc
rename from src/sysdep.h
rename to src/interpfcn/sysdep.h
rename from src/toplev.cc
rename to src/interpfcn/toplev.cc
rename from src/toplev.h
rename to src/interpfcn/toplev.h
rename from src/utils.cc
rename to src/interpfcn/utils.cc
rename from src/utils.h
rename to src/interpfcn/utils.h
rename from src/variables.cc
rename to src/interpfcn/variables.cc
rename from src/variables.h
rename to src/interpfcn/variables.h
--- a/src/jit-ir.cc
+++ b/src/jit-ir.cc
@@ -599,6 +599,22 @@
 }
 
 // -------------------- jit_magic_end --------------------
+jit_magic_end::jit_magic_end (const std::vector<context>& full_context)
+{
+  // for now we only support end in 1 dimensional indexing
+  resize_arguments (full_context.size ());
+
+  size_t i;
+  std::vector<context>::const_iterator iter;
+  for (iter = full_context.begin (), i = 0; iter != full_context.end (); ++iter,
+         ++i)
+    {
+      if (iter->count != 1)
+        throw jit_fail_exception ("end is only supported in linear contexts");
+      stash_argument (i, iter->value);
+    }
+}
+
 const jit_function&
 jit_magic_end::overload () const
 {
--- a/src/jit-ir.h
+++ b/src/jit-ir.h
@@ -1074,6 +1074,10 @@
 
 #undef JIT_CALL_CONST
 
+  jit_call (const jit_operation& aoperation,
+            const std::vector<jit_value *>& args)
+  : jit_instruction (args), moperation (aoperation)
+  {}
 
   const jit_operation& operation (void) const { return moperation; }
 
@@ -1151,9 +1155,23 @@
 jit_magic_end : public jit_instruction
 {
 public:
-  jit_magic_end (const std::vector<jit_value *>& context)
-    : jit_instruction (context)
-  {}
+  class
+  context
+  {
+  public:
+    context (void) : value (0), index (0), count (0)
+    {}
+
+    context (jit_value *avalue, size_t aindex, size_t acount)
+      : value (avalue), index (aindex), count (acount)
+    {}
+
+    jit_value *value;
+    size_t index;
+    size_t count;
+  };
+
+  jit_magic_end (const std::vector<context>& full_context);
 
   const jit_function& overload () const;
 
--- a/src/jit-typeinfo.cc
+++ b/src/jit-typeinfo.cc
@@ -243,6 +243,57 @@
   *ret = *mat;
 }
 
+static void
+make_indices (double *indices, octave_idx_type idx_count,
+              Array<idx_vector>& result)
+{
+  result.resize (dim_vector (1, idx_count));
+  for (octave_idx_type i = 0; i < idx_count; ++i)
+    result(i) = idx_vector (indices[i]);
+}
+
+extern "C" double
+octave_jit_paren_scalar (jit_matrix *mat, double *indicies,
+                         octave_idx_type idx_count)
+{
+  // FIXME: Replace this with a more optimal version
+  try
+    {
+      Array<idx_vector> idx;
+      make_indices (indicies, idx_count, idx);
+
+      Array<double> ret = mat->array->index (idx);
+      return ret.xelem (0);
+    }
+  catch (const octave_execution_exception&)
+    {
+      gripe_library_execution_error ();
+      return 0;
+    }
+}
+
+extern "C" void
+octave_jit_paren_scalar_subsasgn (jit_matrix *ret, jit_matrix *mat,
+                                  double *indices, octave_idx_type idx_count,
+                                  double value)
+{
+  // FIXME: Replace this with a more optimal version
+  try
+    {
+      Array<idx_vector> idx;
+      make_indices (indices, idx_count, idx);
+
+      Matrix temp (1, 1);
+      temp.xelem(0) = value;
+      mat->array->assign (idx, temp);
+      ret->update (mat->array);
+    }
+  catch (const octave_execution_exception&)
+    {
+      gripe_library_execution_error ();
+    }
+}
+
 extern "C" void
 octave_jit_paren_subsasgn_matrix_range (jit_matrix *result, jit_matrix *mat,
                                         jit_range *index, double value)
@@ -657,6 +708,16 @@
 }
 
 // -------------------- jit_operation --------------------
+jit_operation::~jit_operation (void)
+{
+  for (generated_map::iterator iter = generated.begin ();
+       iter != generated.end (); ++iter)
+    {
+      delete iter->first;
+      delete iter->second;
+    }
+}
+
 void
 jit_operation::add_overload (const jit_function& func,
                             const std::vector<jit_type*>& args)
@@ -691,23 +752,26 @@
 const jit_function&
 jit_operation::overload (const std::vector<jit_type*>& types) const
 {
-  // FIXME: We should search for the next best overload on failure
   static jit_function null_overload;
-  if (types.size () >= overloads.size ())
-    return null_overload;
-
   for (size_t i  =0; i < types.size (); ++i)
     if (! types[i])
       return null_overload;
 
+  if (types.size () >= overloads.size ())
+    return do_generate (types);
+
   const Array<jit_function>& over = overloads[types.size ()];
   dim_vector dv (over.dims ());
   Array<octave_idx_type> idx = to_idx (types);
   for (octave_idx_type i = 0; i < dv.length (); ++i)
     if (idx(i) >= dv(i))
-      return null_overload;
+      return do_generate (types);
 
-  return over(idx);
+  const jit_function& ret = over(idx);
+  if (! ret.valid ())
+    return do_generate (types);
+
+  return ret;
 }
 
 Array<octave_idx_type>
@@ -731,6 +795,175 @@
   return idx;
 }
 
+const jit_function&
+jit_operation::do_generate (const signature_vec& types) const
+{
+  static jit_function null_overload;
+  generated_map::const_iterator find = generated.find (&types);
+  if (find != generated.end ())
+    {
+      if (find->second)
+        return *find->second;
+      else
+        return null_overload;
+    }
+
+  jit_function *ret = generate (types);
+  generated[new signature_vec (types)] = ret;
+  return ret ? *ret : null_overload;
+}
+
+jit_function *
+jit_operation::generate (const signature_vec& types) const
+{
+  return 0;
+}
+
+bool
+jit_operation::signature_cmp
+::operator() (const signature_vec *lhs, const signature_vec *rhs)
+{
+  const signature_vec& l = *lhs;
+  const signature_vec& r = *rhs;
+
+  if (l.size () < r.size ())
+    return true;
+  else if (l.size () > r.size ())
+    return false;
+
+  for (size_t i = 0; i < l.size (); ++i)
+    {
+      if (l[i]->type_id () < r[i]->type_id ())
+        return true;
+      else if (l[i]->type_id () > r[i]->type_id ())
+        return false;
+    }
+
+  return false;
+}
+
+// -------------------- jit_index_operation --------------------
+jit_function *
+jit_index_operation::generate (const signature_vec& types) const
+{
+  if (types.size () > 2 && types[0] == jit_typeinfo::get_matrix ())
+    {
+      // indexing a matrix with scalars
+      jit_type *scalar = jit_typeinfo::get_scalar ();
+      for (size_t i = 1; i < types.size (); ++i)
+        if (types[i] != scalar)
+          return 0;
+
+      return generate_matrix (types);
+    }
+
+  return 0;
+}
+
+llvm::Value *
+jit_index_operation::create_arg_array (llvm::IRBuilderD& builder,
+                                       const jit_function &fn, size_t start_idx,
+                                       size_t end_idx) const
+{
+  size_t n = end_idx - start_idx;
+  llvm::Type *scalar_t = jit_typeinfo::get_scalar_llvm ();
+  llvm::ArrayType *array_t = llvm::ArrayType::get (scalar_t, n);
+  llvm::Value *array = llvm::UndefValue::get (array_t);
+  for (size_t i = start_idx; i < end_idx; ++i)
+    {
+      llvm::Value *idx = fn.argument (builder, i);
+      array = builder.CreateInsertValue (array, idx, i - start_idx);
+    }
+
+  llvm::Value *array_mem = builder.CreateAlloca (array_t);
+  builder.CreateStore (array, array_mem);
+  return builder.CreateBitCast (array_mem, scalar_t->getPointerTo ());
+}
+
+// -------------------- jit_paren_subsref --------------------
+jit_function *
+jit_paren_subsref::generate_matrix (const signature_vec& types) const
+{
+  std::stringstream ss;
+  ss << "jit_paren_subsref_matrix_scalar" << (types.size () - 1);
+
+  jit_type *scalar = jit_typeinfo::get_scalar ();
+  jit_function *fn = new jit_function (module, jit_convention::internal,
+                                       ss.str (), scalar, types);
+  fn->mark_can_error ();
+  llvm::BasicBlock *body = fn->new_block ();
+  llvm::IRBuilder<> builder (body);
+
+  llvm::Value *array = create_arg_array (builder, *fn, 1, types.size ());
+  jit_type *index = jit_typeinfo::get_index ();
+  llvm::Value *nelem = llvm::ConstantInt::get (index->to_llvm (),
+                                               types.size () - 1);
+  llvm::Value *mat = fn->argument (builder, 0);
+  llvm::Value *ret = paren_scalar.call (builder, mat, array, nelem);
+  fn->do_return (builder, ret);
+  return fn;
+}
+
+void
+jit_paren_subsref::do_initialize (void)
+{
+  std::vector<jit_type *> types (3);
+  types[0] = jit_typeinfo::get_matrix ();
+  types[1] = jit_typeinfo::get_scalar_ptr ();
+  types[2] = jit_typeinfo::get_index ();
+
+  jit_type *scalar = jit_typeinfo::get_scalar ();
+  paren_scalar = jit_function (module, jit_convention::external,
+                               "octave_jit_paren_scalar", scalar, types);
+  paren_scalar.add_mapping (engine, &octave_jit_paren_scalar);
+  paren_scalar.mark_can_error ();
+}
+
+// -------------------- jit_paren_subsasgn --------------------
+jit_function *
+jit_paren_subsasgn::generate_matrix (const signature_vec& types) const
+{
+  std::stringstream ss;
+  ss << "jit_paren_subsasgn_matrix_scalar" << (types.size () - 2);
+
+  jit_type *matrix = jit_typeinfo::get_matrix ();
+  jit_function *fn = new jit_function (module, jit_convention::internal,
+                                       ss.str (), matrix, types);
+  fn->mark_can_error ();
+  llvm::BasicBlock *body = fn->new_block ();
+  llvm::IRBuilder<> builder (body);
+
+  llvm::Value *array = create_arg_array (builder, *fn, 1, types.size () - 1);
+  jit_type *index = jit_typeinfo::get_index ();
+  llvm::Value *nelem = llvm::ConstantInt::get (index->to_llvm (),
+                                               types.size () - 2);
+
+  llvm::Value *mat = fn->argument (builder, 0);
+  llvm::Value *value = fn->argument (builder, types.size () - 1);
+  llvm::Value *ret = paren_scalar.call (builder, mat, array, nelem, value);
+  fn->do_return (builder, ret);
+  return fn;
+}
+
+void
+jit_paren_subsasgn::do_initialize (void)
+{
+  if (paren_scalar.valid ())
+    return;
+
+  jit_type *matrix = jit_typeinfo::get_matrix ();
+  std::vector<jit_type *> types (4);
+  types[0] = matrix;
+  types[1] = jit_typeinfo::get_scalar_ptr ();
+  types[2] = jit_typeinfo::get_index ();
+  types[3] = jit_typeinfo::get_scalar ();
+
+  paren_scalar = jit_function (module, jit_convention::external,
+                               "octave_jit_paren_scalar", matrix, types);
+  paren_scalar.add_mapping (engine, &octave_jit_paren_scalar_subsasgn);
+  paren_scalar.mark_can_error ();
+}
+
 // -------------------- jit_typeinfo --------------------
 void
 jit_typeinfo::initialize (llvm::Module *m, llvm::ExecutionEngine *e)
@@ -784,6 +1017,7 @@
   matrix = new_type ("matrix", any, matrix_t);
   complex = new_type ("complex", any, complex_t);
   scalar = new_type ("scalar", complex, scalar_t);
+  scalar_ptr = new_type ("scalar_ptr", 0, scalar_t->getPointerTo ());
   range = new_type ("range", any, range_t);
   string = new_type ("string", any, string_t);
   boolean = new_type ("bool", any, bool_t);
@@ -813,6 +1047,9 @@
   if (sizeof (void *) == 4)
     complex->mark_sret ();
 
+  paren_subsref_fn.initialize (module, engine);
+  paren_subsasgn_fn.initialize (module, engine);
+
   // bind global variables
   lerror_state = new llvm::GlobalVariable (*module, bool_t, false,
                                            llvm::GlobalValue::ExternalLinkage,
--- a/src/jit-typeinfo.h
+++ b/src/jit-typeinfo.h
@@ -314,17 +314,22 @@
 jit_operation
 {
 public:
+  // type signature vector
+  typedef std::vector<jit_type *> signature_vec;
+
+  virtual ~jit_operation (void);
+
   void add_overload (const jit_function& func)
   {
     add_overload (func, func.arguments ());
   }
 
   void add_overload (const jit_function& func,
-                     const std::vector<jit_type*>& args);
+                     const signature_vec& args);
 
-  const jit_function& overload (const std::vector<jit_type *>& types) const;
+  const jit_function& overload (const signature_vec& types) const;
 
-  jit_type *result (const std::vector<jit_type *>& types) const
+  jit_type *result (const signature_vec& types) const
   {
     const jit_function& temp = overload (types);
     return temp.result ();
@@ -346,14 +351,79 @@
   const std::string& name (void) const { return mname; }
 
   void stash_name (const std::string& aname) { mname = aname; }
+protected:
+  virtual jit_function *generate (const signature_vec& types) const;
 private:
-  Array<octave_idx_type> to_idx (const std::vector<jit_type*>& types) const;
+  Array<octave_idx_type> to_idx (const signature_vec& types) const;
+
+  const jit_function& do_generate (const signature_vec& types) const;
+
+  struct signature_cmp
+  {
+    bool operator() (const signature_vec *lhs, const signature_vec *rhs);
+  };
+
+  typedef std::map<const signature_vec *, jit_function *, signature_cmp>
+  generated_map;
+
+  mutable generated_map generated;
 
   std::vector<Array<jit_function> > overloads;
 
   std::string mname;
 };
 
+class
+jit_index_operation : public jit_operation
+{
+public:
+  jit_index_operation (void) : module (0), engine (0) {}
+
+  void initialize (llvm::Module *amodule, llvm::ExecutionEngine *aengine)
+  {
+    module = amodule;
+    engine = aengine;
+    do_initialize ();
+  }
+protected:
+  virtual jit_function *generate (const signature_vec& types) const;
+
+  virtual jit_function *generate_matrix (const signature_vec& types) const = 0;
+
+  virtual void do_initialize (void) = 0;
+
+  // helper functions
+  // [start_idx, end_idx).
+  llvm::Value *create_arg_array (llvm::IRBuilderD& builder,
+                                 const jit_function &fn, size_t start_idx,
+                                 size_t end_idx) const;
+
+  llvm::Module *module;
+  llvm::ExecutionEngine *engine;
+};
+
+class
+jit_paren_subsref : public jit_index_operation
+{
+protected:
+  virtual jit_function *generate_matrix (const signature_vec& types) const;
+
+  virtual void do_initialize (void);
+private:
+  jit_function paren_scalar;
+};
+
+class
+jit_paren_subsasgn : public jit_index_operation
+{
+protected:
+  jit_function *generate_matrix (const signature_vec& types) const;
+
+  virtual void do_initialize (void);
+private:
+  jit_function paren_scalar;
+};
+
 // A singleton class which handles the construction of jit_types and
 // jit_operations.
 class
@@ -376,6 +446,8 @@
   static llvm::Type *get_scalar_llvm (void)
   { return instance->scalar->to_llvm (); }
 
+  static jit_type *get_scalar_ptr (void) { return instance->scalar_ptr; }
+
   static jit_type *get_range (void) { return instance->range; }
 
   static jit_type *get_string (void) { return instance->string; }
@@ -643,6 +715,7 @@
   jit_type *any;
   jit_type *matrix;
   jit_type *scalar;
+  jit_type *scalar_ptr; // a fake type for interfacing with C++
   jit_type *range;
   jit_type *string;
   jit_type *boolean;
@@ -663,8 +736,8 @@
   jit_operation for_index_fn;
   jit_operation logically_true_fn;
   jit_operation make_range_fn;
-  jit_operation paren_subsref_fn;
-  jit_operation paren_subsasgn_fn;
+  jit_paren_subsref paren_subsref_fn;
+  jit_paren_subsasgn paren_subsasgn_fn;
   jit_operation end_fn;
 
   // type id -> cast function TO that type
--- a/src/link-deps.mk
+++ b/src/link-deps.mk
@@ -3,7 +3,7 @@
 if AMCOND_ENABLE_DYNAMIC_LINKING
   LIBOCTINTERP_LINK_DEPS =
 else
-  LIBOCTINTERP_LINK_DEPS = $(DLD_FUNCTIONS_LIBS)
+  LIBOCTINTERP_LINK_DEPS = $(DLDFCN_LIBS)
 endif
 
 LIBOCTINTERP_LINK_DEPS += \
--- a/src/mxarray.in.h
+++ b/src/mxarray.in.h
@@ -1,3 +1,4 @@
+// DO NOT EDIT!  Generated automatically from mxarray.in.h by configure
 /*
 
 Copyright (C) 2001-2012 Paul Kienzle
--- a/src/oct-conf.in.h
+++ b/src/oct-conf.in.h
@@ -1,4 +1,4 @@
-// oct-conf.h.in
+// DO NOT EDIT!  Generated automatically from oct-conf.in.h by configure
 /*
 
 Copyright (C) 1996-2012 John W. Eaton
rename from src/lex.h
rename to src/parse-tree/lex.h
rename from src/lex.ll
rename to src/parse-tree/lex.ll
--- a/src/parse-tree/module.mk
+++ b/src/parse-tree/module.mk
@@ -1,6 +1,18 @@
 EXTRA_DIST += \
   parse-tree/module.mk
 
+PARSER_INCLUDES = \
+  parse-tree/lex.h \
+  parse-tree/parse.h \
+  parse-tree/parse-private.h
+
+PARSER_SRC = \
+  parse-tree/lex.ll \
+  parse-tree/oct-parse.yy
+
+lex.lo lex.o oct-parse.lo oct-parse.o: \
+  AM_CXXFLAGS := $(filter-out -Wold-style-cast, $(AM_CXXFLAGS))
+
 PT_INCLUDES = \
   parse-tree/pt-all.h \
   parse-tree/pt-arg-list.h \
@@ -31,7 +43,8 @@
   parse-tree/pt-stmt.h \
   parse-tree/pt-unop.h \
   parse-tree/pt-walk.h \
-  parse-tree/pt.h
+  parse-tree/pt.h \
+	$(PARSER_INCLUDES)
 
 PARSE_TREE_SRC = \
   parse-tree/pt-arg-list.cc \
@@ -61,5 +74,6 @@
   parse-tree/pt-select.cc \
   parse-tree/pt-stmt.cc \
   parse-tree/pt-unop.cc \
-  parse-tree/pt.cc
+  parse-tree/pt.cc \
+	$(PARSER_SRC)
 
rename from src/oct-parse.yy
rename to src/parse-tree/oct-parse.yy
rename from src/parse-private.h
rename to src/parse-tree/parse-private.h
rename from src/parse.h
rename to src/parse-tree/parse.h
--- a/src/pt-jit.cc
+++ b/src/pt-jit.cc
@@ -518,11 +518,7 @@
 void
 jit_convert::visit_index_expression (tree_index_expression& exp)
 {
-  std::pair<jit_value *, jit_value *> res = resolve (exp);
-  jit_value *object = res.first;
-  jit_value *index = res.second;
-
-  result = create_checked (jit_typeinfo::paren_subsref, object, index);
+  result = resolve (jit_typeinfo::paren_subsref (), exp);
 }
 
 void
@@ -813,8 +809,9 @@
   return ss.str ();
 }
 
-std::pair<jit_value *, jit_value *>
-jit_convert::resolve (tree_index_expression& exp)
+jit_instruction *
+jit_convert::resolve (const jit_operation& fres, tree_index_expression& exp,
+                      jit_value *extra_arg)
 {
   std::string type = exp.type_tags ();
   if (! (type.size () == 1 && type[0] == '('))
@@ -828,21 +825,31 @@
   if (! arg_list)
     throw jit_fail_exception ("null argument list");
 
-  if (arg_list->size () != 1)
-    throw jit_fail_exception ("Bad number of arguments in arg_list");
+  if (arg_list->size () < 1)
+    throw jit_fail_exception ("Empty arg_list");
 
   tree_expression *tree_object = exp.expression ();
   jit_value *object = visit (tree_object);
 
-  end_context.push_back (object);
-
-  unwind_protect prot;
-  prot.add_method (&end_context, &std::vector<jit_value *>::pop_back);
+  size_t narg = arg_list->size ();
+  tree_argument_list::iterator iter = arg_list->begin ();
+  bool have_extra = extra_arg;
+  std::vector<jit_value *> call_args (narg + 1 + have_extra);
+  call_args[0] = object;
 
-  tree_expression *arg0 = arg_list->front ();
-  jit_value *index = visit (arg0);
+  for (size_t idx = 0; iter != arg_list->end (); ++idx, ++iter)
+    {
+      unwind_protect prot;
+      prot.add_method (&end_context,
+                       &std::vector<jit_magic_end::context>::pop_back);
+      end_context.push_back (jit_magic_end::context (object, idx, narg));
+      call_args[idx + 1] = visit (*iter);
+    }
 
-  return std::make_pair (object, index);
+  if (extra_arg)
+    call_args[call_args.size () - 1] = extra_arg;
+
+  return create_checked (fres, call_args);
 }
 
 jit_value *
@@ -856,14 +863,9 @@
   else if (tree_index_expression *idx
            = dynamic_cast<tree_index_expression *> (exp))
     {
-      std::pair<jit_value *, jit_value *> res = resolve (*idx);
-      jit_value *object = res.first;
-      jit_value *index = res.second;
-      jit_call *new_object = create<jit_call> (&jit_typeinfo::paren_subsasgn,
-                                               object, index, rhs);
-      block->append (new_object);
+      jit_value *new_object = resolve (jit_typeinfo::paren_subsasgn (), *idx,
+                                       rhs);
       do_assign (idx->expression (), new_object, true);
-      create_check (new_object);
 
       // FIXME: Will not work for values that must be release/grabed
       return rhs;
@@ -1853,4 +1855,53 @@
 %! endfor
 %! assert (result == m(end) * niter);
 
+%!test
+%! ndim = 100;
+%! result = 0;
+%! m = zeros (ndim);
+%! m(:) = 1:ndim^2;
+%! i = 1;
+%! while (i <= ndim)
+%!   for j = 1:ndim
+%!     result = result + m(i, j);
+%!    endfor
+%!   i = i + 1;
+%! endwhile
+%! assert (result == sum (sum (m)));
+
+%!test
+%! ndim = 100;
+%! m = zeros (ndim);
+%! i = 1;
+%! while (i <= ndim)
+%!   for j = 1:ndim
+%!     m(i, j) = (j - 1) * ndim + i;
+%!   endfor
+%!   i = i + 1;
+%! endwhile
+%! m2 = zeros (ndim);
+%! m2(:) = 1:(ndim^2);
+%! assert (all (m == m2));
+
+%!test
+%! ndim = 2;
+%! m = zeros (ndim, ndim, ndim, ndim);
+%! result = 0;
+%! i0 = 1;
+%! while (i0 <= ndim)
+%!   for i1 = 1:ndim
+%!     for i2 = 1:ndim
+%!       for i3 = 1:ndim
+%!         m(i0, i1, i2, i3) = 1;
+%!         m(i0, i1, i2, i3, 1, 1, 1, 1, 1, 1) = 1;
+%!         result = result + m(i0, i1, i2, i3);
+%!       endfor
+%!     endfor
+%!   endfor
+%!   i0 = i0 + 1;
+%! endwhile
+%! expected = ones (ndim, ndim, ndim, ndim);
+%! assert (all (m == expected));
+%! assert (result == sum (expected (:)));
+
 */
--- a/src/pt-jit.h
+++ b/src/pt-jit.h
@@ -244,7 +244,7 @@
 
   std::list<jit_value *> all_values;
 
-  std::vector<jit_value *> end_context;
+  std::vector<jit_magic_end::context> end_context;
 
   size_t iterator_count;
   size_t for_bounds_count;
@@ -296,7 +296,9 @@
 
   std::string next_name (const char *prefix, size_t& count, bool inc);
 
-  std::pair<jit_value *, jit_value *> resolve (tree_index_expression& exp);
+  jit_instruction *resolve (const jit_operation& fres,
+                            tree_index_expression& exp,
+                            jit_value *extra_arg = 0);
 
   jit_value *do_assign (tree_expression *exp, jit_value *rhs,
                         bool artificial = false);
--- a/src/version.in.h
+++ b/src/version.in.h
@@ -1,3 +1,4 @@
+// DO NOT EDIT!  Generated automatically from version.in.h by configure
 /*
 
 Copyright (C) 1992-2012 John W. Eaton