changeset 15315:67ef63ead023

Merge in Thorsten Liebig's changes
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Thu, 06 Sep 2012 13:04:48 -0400
parents 34ae358bd566 (current diff) de9bfcf637df (diff)
children 35fe4b9909a8
files libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h libgui/src/m-editor/file-editor.cc
diffstat 27 files changed, 387 insertions(+), 254 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac
+++ b/configure.ac
@@ -672,56 +672,69 @@
   [zlib.h], [gzclearerr])
 
 ### Check for the LLVM library
-dnl
-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"
 
-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_IF([test "x$enable_jit_debug" = "xyes"], [
-  AC_DEFINE(OCTAVE_JIT_DEBUG, 1, [Define to 1 for JIT debug printing.])
-])
+build_jit=false
+AC_ARG_ENABLE([jit],
+  [AS_HELP_STRING([--enable-jit],
+    [(EXPERIMENTAL) enable JIT compiler])],
+  [if test "$enableval" = yes; then
+     build_jit=true
+   fi],
+  [])
 
 LLVM_CXXFLAGS=
 LLVM_CPPFLAGS=
 LLVM_LDFLAGS=
 LLVM_LIBS=
 
-if test "x$ac_cv_env_LLVM_CONFIG_set" = "xset"; then
-  warn_llvm="LLVM was not found or is to old. JIT is disabled."
+if test $build_jit = true; then
+
+  ## Find llvm-config program from environment variable or by searching
+  AC_ARG_VAR(LLVM_CONFIG, [path to llvm-config utility])
+  AC_CHECK_PROG(LLVM_CONFIG, llvm-config, llvm-config, [])
+  
+  AC_ARG_ENABLE([jit-debug],
+    [AS_HELP_STRING([--enable-jit-debug], [enable debug printing of JIT IRs])])
 
-  ## 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
-    AC_MSG_NOTICE([using -isystem for llvm headers])])
+  if test x$enable_jit_debug = "xyes"; then
+    AC_DEFINE(OCTAVE_JIT_DEBUG, 1, [Define to 1 for JIT debug printing.])
+  fi
+
+  if test -z "$LLVM_CONFIG"; then
+    warn_llvm="llvm-config utility not found.  JIT compiler is disabled."
+  else
+    ## Preset warning message in case compile fails
+    warn_llvm="LLVM was not found or is to old.  JIT compiler is disabled."
+
+    save_CPPFLAGS="$CPPFLAGS"
+    save_CXXFLAGS="$CXXFLAGS"
+    save_LIBS="$LIBS"
+    save_LDFLAGS="$LDFLAGS"
 
-  LLVM_LDFLAGS="-L`$LLVM_CONFIG --libdir`"
-  LLVM_LIBS=`$LLVM_CONFIG --libs`
-  dnl Use -isystem so we don't get warnings from llvm headers
-  LLVM_CPPFLAGS="$LLVM_INCLUDE_FLAG `$LLVM_CONFIG --includedir`"
-  LLVM_CXXFLAGS=
+    ## Use -isystem if available because we don't want to see warnings in LLVM
+    LLVM_INCLUDE_FLAG=-I
+    OCTAVE_CC_FLAG(-isystem ., [
+      LLVM_INCLUDE_FLAG=-isystem
+      AC_MSG_NOTICE([using -isystem for LLVM headers])])
+
+    LLVM_LDFLAGS="-L`$LLVM_CONFIG --libdir`"
+    LLVM_LIBS=`$LLVM_CONFIG --libs`
+    dnl Use -isystem so we don't get warnings from llvm headers
+    LLVM_CPPFLAGS="$LLVM_INCLUDE_FLAG `$LLVM_CONFIG --includedir`"
+    LLVM_CXXFLAGS=
 
-  dnl
-  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"
-  CXXFLAGS="$LLVM_CXXFLAGS $CXXFLAGS"
-  LIBS="$LLVM_LIBS $LIBS"
-  LDFLAGS="$LLVM_LDFLAGS $LDFLAGS"
+    dnl
+    dnl 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
+    dnl very helpful.
+    dnl
+    CPPFLAGS="-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS $LLVM_CPPFLAGS $CPPFLAGS"
+    CXXFLAGS="$LLVM_CXXFLAGS $CXXFLAGS"
+    LIBS="$LLVM_LIBS $LIBS"
+    LDFLAGS="$LLVM_LDFLAGS $LDFLAGS"
 
-  AC_LANG_PUSH(C++)
-    AC_CHECK_HEADERS([llvm/LLVMContext.h, llvm/Support/TargetSelect.h], [
+    AC_LANG_PUSH(C++)
+    AC_CHECK_HEADERS([llvm/LLVMContext.h llvm/Support/TargetSelect.h], [
       AC_MSG_CHECKING([for llvm::getGlobalContext in llvm/LLVMContext.h])
         AC_COMPILE_IFELSE(
           [AC_LANG_PROGRAM([[
@@ -735,32 +748,36 @@
           [AC_MSG_RESULT([no])
       ])
     ])
-  AC_LANG_POP(C++)
-  
-else
-  warn_llvm="LLVM_CONFIG not set. The experiential JIT feature is disabled."
+    AC_LANG_POP(C++)
+    CPPFLAGS="$save_CPPFLAGS"
+    CXXFLAGS="$save_CXXFLAGS"
+    LIBS="$save_LIBS"
+    LDFLAGS="$save_LDFLAGS"
+  fi
+
+  if test -z "$warn_llvm"; then
+    AC_DEFINE(HAVE_LLVM, 1, [Define to 1 if LLVM is available.])
+  else
+    build_jit=false
+    LLVM_CPPFLAGS=
+    LLVM_CXXFLAGS=
+    LLVM_LDFLAGS=
+    LLVM_LIBS=
+    OCTAVE_CONFIGURE_WARNING([warn_llvm])
+  fi
+
+## FIXME: Re-instate when JIT is enabled by default
+#else
+#  ## JIT build disabled
+#  warn_llvm="JIT compiler disabled, some performance loss for loops"
+#  OCTAVE_CONFIGURE_WARNING([warn_llvm])
 fi
 
-if test -z "$warn_llvm"; then
-  AC_DEFINE(HAVE_LLVM, 1, [Define to 1 if LLVM is available.])
-else
-  LLVM_CXXFLAGS=
-  LLVM_CPPFLAGS=
-  LLVM_LDFLAGS=
-  LLVM_LIBS=
-  OCTAVE_CONFIGURE_WARNING([warn_llvm])
-fi
-
+AC_SUBST(LLVM_CPPFLAGS)
 AC_SUBST(LLVM_CXXFLAGS)
-AC_SUBST(LLVM_CPPFLAGS)
 AC_SUBST(LLVM_LDFLAGS)
 AC_SUBST(LLVM_LIBS)
 
-CPPFLAGS="$save_CPPFLAGS"
-CXXFLAGS="$save_CXXFLAGS"
-LIBS="$save_LIBS"
-LDFLAGS="$save_LDFLAGS"
-
 ### Check for HDF5 library.
 
 save_CPPFLAGS="$CPPFLAGS"
@@ -1743,20 +1760,7 @@
 esac
 
 ## Find a termlib to use.
-octave_found_termlib=no
-for termlib in ncurses curses termcap terminfo termlib; do
-  AC_CHECK_LIB(${termlib}, tputs, [
-    TERM_LIBS="-l${termlib}"
-    octave_found_termlib=yes
-    break])
-done
-
-if test "$octave_found_termlib" = no; then
-  warn_termlibs="I couldn't find -ltermcap, -lterminfo, -lncurses, -lcurses, o\
-r -ltermlib!"
-  AC_MSG_WARN([$warn_termlibs])
-fi
-AC_SUBST(TERM_LIBS)
+OCTAVE_CHECK_LIB_TERMLIB
 
 ### Checks for header files.
 
@@ -2183,13 +2187,13 @@
 QT_INCDIR=
 QT_LIBDIR=
 win32_terminal=no
-build_gui=yes
+build_gui=true
 GUIDIR=libgui
 AC_ARG_ENABLE(gui,
   [AS_HELP_STRING([--disable-gui], [don't build the GUI])],
-  [if test "$enableval" = no; then build_gui=no; fi], [build_gui=yes])
+  [if test "$enableval" = no; then build_gui=false; fi], [build_gui=true])
 
-if test $build_gui = yes; then
+if test $build_gui = true; then
   ## Check for Qt libraries
   PKG_CHECK_MODULES(QT, [QtCore, QtGui, QtNetwork],
     [],
@@ -2263,7 +2267,7 @@
   ## GUI disabled.  Eliminate building GUIDIR directory
   GUIDIR=
 fi
-AM_CONDITIONAL([AMCOND_BUILD_GUI], [test $build_gui = yes])
+AM_CONDITIONAL([AMCOND_BUILD_GUI], [test $build_gui = true])
 AM_CONDITIONAL([WIN32_TERMINAL], [test $win32_terminal = yes])
 AC_SUBST(QT_INCDIR)
 AC_SUBST(QT_LIBDIR)
@@ -2558,6 +2562,8 @@
   Default pager:               $DEFAULT_PAGER
   gnuplot:                     $GNUPLOT
 
+  Build Octave GUI:                   $build_gui
+  JIT compiler for loops:             $build_jit
   Do internal array bounds checking:  $BOUNDS_CHECKING
   Use octave_allocator:               $USE_OCTAVE_ALLOCATOR
   Build static libraries:             $STATIC_LIBS
--- a/libgui/src/files-dockwidget.cc
+++ b/libgui/src/files-dockwidget.cc
@@ -119,7 +119,7 @@
 }
 
 void
-files_dock_widget::set_current_directory (QString currentDirectory)
+files_dock_widget::set_current_directory (const QString& currentDirectory)
 {
   display_directory (currentDirectory);
 }
@@ -139,7 +139,7 @@
 }
 
 void
-files_dock_widget::display_directory (QString directory)
+files_dock_widget::display_directory (const QString& directory)
 {
   QFileInfo fileInfo (directory);
   if (fileInfo.exists ())
--- a/libgui/src/files-dockwidget.h
+++ b/libgui/src/files-dockwidget.h
@@ -57,12 +57,12 @@
   void do_up_directory ();
 
   /** Sets the current directory being displayed. */
-  void set_current_directory (QString currentDirectory);
+  void set_current_directory (const QString& currentDirectory);
 
   /** Accepts user input a the line edit for the current directory. */
   void handle_directory_entered ();
 
-  void display_directory (QString directory);
+  void display_directory (const QString& directory);
 
   /** Tells the widget to react on changed settings. */
   void notice_settings ();
@@ -72,10 +72,10 @@
 
 signals:
   /** Emitted, whenever the user requested to open a file. */
-  void open_file (QString fileName);
+  void open_file (const QString& fileName);
 
   /** Emitted, whenever the currently displayed directory changed. */
-  void displayed_directory_changed (QString directory);
+  void displayed_directory_changed (const QString& directory);
 
   /** Custom signal that tells if a user has clicke away that dock widget. */
   void active_changed (bool active);
--- a/libgui/src/history-dockwidget.h
+++ b/libgui/src/history-dockwidget.h
@@ -48,10 +48,10 @@
   void reset_model ();
 
 signals:
-  void information (QString message);
+  void information (const QString& message);
 
   /** Emitted, whenever the user double-clicked a command in the history. */
-  void command_double_clicked (QString command);
+  void command_double_clicked (const QString& command);
 
   /** Custom signal that tells if a user has clicked away that dock widget. */
   void active_changed (bool active);
--- a/libgui/src/m-editor/file-editor-interface.h
+++ b/libgui/src/m-editor/file-editor-interface.h
@@ -57,7 +57,7 @@
   public slots:
     virtual void request_new_file () = 0;
     virtual void request_open_file () = 0;
-    virtual void request_open_file (QString fileName) = 0;
+    virtual void request_open_file (const QString& fileName) = 0;
 
   signals:
       void active_changed (bool active);
--- a/libgui/src/m-editor/file-editor-tab.cc
+++ b/libgui/src/m-editor/file-editor-tab.cc
@@ -198,7 +198,7 @@
 }
 
 void
-file_editor_tab::set_file_name (QString fileName)
+file_editor_tab::set_file_name (const QString& fileName)
 {
   _file_name = fileName;
   update_lexer ();
@@ -436,7 +436,7 @@
 }
 
 int
-file_editor_tab::check_file_modified (QString msg, int cancelButton)
+file_editor_tab::check_file_modified (const QString& msg, int cancelButton)
 {
   int decision = QMessageBox::Yes;
   if (_edit_area->isModified ())
@@ -627,7 +627,7 @@
 }
 
 void
-file_editor_tab::load_file (QString fileName)
+file_editor_tab::load_file (const QString& fileName)
 {
   if (!_file_editor->isVisible ())
     {
@@ -676,7 +676,7 @@
 }
 
 bool
-file_editor_tab::save_file (QString saveFileName)
+file_editor_tab::save_file (const QString& saveFileName)
 {
   // it is a new file with the name "<unnamed>" -> call saveFielAs
   if (saveFileName == UNNAMED_FILE || saveFileName.isEmpty ())
@@ -778,7 +778,7 @@
 }
 
 void
-file_editor_tab::file_has_changed (QString fileName)
+file_editor_tab::file_has_changed (const QString& fileName)
 {
   Q_UNUSED (fileName);
   if (QFile::exists (_file_name))
--- a/libgui/src/m-editor/file-editor-tab.h
+++ b/libgui/src/m-editor/file-editor-tab.h
@@ -64,26 +64,25 @@
 
   void set_modified (bool modified = true);
 
-  bool open_file (QString dir = QString ());
-  void load_file (QString fileName);
+  bool open_file (const QString& dir = QString ());
+  void load_file (const QString& fileName);
   void new_file ();
   bool save_file ();
-  bool save_file(QString saveFileName);
+  bool save_file (const QString& saveFileName);
   bool save_file_as();
   void run_file ();
 
-  void file_has_changed (QString fileName);
-  
+  void file_has_changed (const QString& fileName);
   QString get_file_name () const {return _file_name;} 
 
 signals:
-  void file_name_changed (QString fileName);
+  void file_name_changed (const QString& fileName);
   void editor_state_changed ();
   void close_request ();
 
 protected:
   void closeEvent (QCloseEvent *event);
-  void set_file_name (QString fileName);
+  void set_file_name (const QString& fileName);
 
 private:
   void update_lexer ();
@@ -91,7 +90,7 @@
   void request_remove_breakpoint (int line);
 
   void update_tracked_file ();
-  int check_file_modified (QString msg, int cancelButton);
+  int check_file_modified (const QString& msg, int cancelButton);
   void do_comment_selected_text (bool comment);
 
   file_editor *         _file_editor;
--- a/libgui/src/m-editor/file-editor.cc
+++ b/libgui/src/m-editor/file-editor.cc
@@ -116,7 +116,7 @@
 }
 
 void
-file_editor::request_open_file (QString fileName)
+file_editor::request_open_file (const QString& fileName)
 {
   if (!isVisible ())
     {
@@ -284,7 +284,7 @@
 }
 
 void
-file_editor::handle_file_name_changed (QString fileName)
+file_editor::handle_file_name_changed (const QString& fileName)
 {
   QObject *senderObject = sender ();
   file_editor_tab *fileEditorTab
--- a/libgui/src/m-editor/file-editor.h
+++ b/libgui/src/m-editor/file-editor.h
@@ -50,7 +50,7 @@
 public:
   file_editor (QTerminal *terminal, main_window *m);
   ~file_editor ();
-  void loadFile (QString fileName);
+  void loadFile (const QString& fileName);
 
   QTerminal *       terminal ();
   main_window *     get_main_window ();
@@ -64,7 +64,7 @@
 public slots:
   void request_new_file ();
   void request_open_file ();
-  void request_open_file (QString fileName);
+  void request_open_file (const QString& fileName);
 
   void request_undo ();
   void request_redo ();
@@ -88,7 +88,7 @@
   void request_uncomment_selected_text ();
   void request_find ();
 
-  void handle_file_name_changed (QString fileName);
+  void handle_file_name_changed (const QString& fileName);
   void handle_tab_close_request (int index);
   void handle_tab_close_request ();
   void active_tab_changed (int index);
--- a/libgui/src/main-window.cc
+++ b/libgui/src/main-window.cc
@@ -85,14 +85,14 @@
 }
 
 void
-main_window::open_file (QString file_name)
+main_window::open_file (const QString& file_name)
 {
   _file_editor->request_open_file (file_name);
   focus_editor ();
 }
 
 void
-main_window::report_status_message (QString statusMessage)
+main_window::report_status_message (const QString& statusMessage)
 {
   _status_bar->showMessage (statusMessage, 1000);
 }
@@ -140,7 +140,7 @@
 }
 
 void
-main_window::handle_command_double_clicked (QString command)
+main_window::handle_command_double_clicked (const QString& command)
 {
   _terminal->sendText (command);
   _terminal->setFocus ();
@@ -216,7 +216,7 @@
 }
 
 void
-main_window::current_working_directory_has_changed (QString directory)
+main_window::current_working_directory_has_changed (const QString& directory)
 {
   if (_current_directory_combo_box->count () > 31)
     {
@@ -244,7 +244,7 @@
 }
 
 void
-main_window::set_current_working_directory (QString directory)
+main_window::set_current_working_directory (const QString& directory)
 {
   octave_link::instance ()
       ->post_event (new octave_change_directory_event (*this,
--- a/libgui/src/main-window.h
+++ b/libgui/src/main-window.h
@@ -83,15 +83,15 @@
   void settings_changed ();
 
 public slots:
-  void report_status_message (QString statusMessage);
+  void report_status_message (const QString& statusMessage);
   void handle_save_workspace_request ();
   void handle_load_workspace_request ();
   void handle_clear_workspace_request ();
   void handle_clear_history_request ();
-  void handle_command_double_clicked (QString command);
+  void handle_command_double_clicked (const QString& command);
   void new_file ();
   void open_file ();
-  void open_file (QString file_name);
+  void open_file (const QString& file_name);
   void open_bug_tracker_page ();
   void open_agora_page ();
   void open_octave_forge_page ();
@@ -100,9 +100,9 @@
   void notice_settings ();
   void prepare_for_quit ();
   void reset_windows ();
-  void current_working_directory_has_changed (QString directory);
+  void current_working_directory_has_changed (const QString& directory);
   void change_current_working_directory ();
-  void set_current_working_directory (QString directory);
+  void set_current_working_directory (const QString& directory);
   void current_working_directory_up ();
 
   void focus_command_window ();
--- a/libgui/src/octave-qt-event-listener.h
+++ b/libgui/src/octave-qt-event-listener.h
@@ -41,7 +41,7 @@
     void quit_debug_mode ();
 
   signals:
-    void current_directory_has_changed_signal (QString directory);
+    void current_directory_has_changed_signal (const QString& directory);
     void entered_debug_mode_signal ();
     void quit_debug_mode_signal ();
 };
--- a/libgui/src/qtinfo/parser.cc
+++ b/libgui/src/qtinfo/parser.cc
@@ -41,7 +41,7 @@
 }
 
 void
-parser::set_info_path (QString infoPath)
+parser::set_info_path (const QString& infoPath)
 {
   this->_info_path = infoPath;
 
@@ -100,7 +100,7 @@
 }
 
 int
-parser::is_ref (QString node)
+parser::is_ref (const QString& node)
 {
   if (_ref_map.contains (node))
     {
@@ -112,8 +112,10 @@
 }
 
 QString
-parser::search_node (QString node)
+parser::search_node (const QString& node_arg)
 {
+  QString node = node_arg;
+
   QFileInfo file_info;
   QString ref;
 
@@ -152,7 +154,7 @@
 }
 
 QString
-parser::search_node (QString node, QIODevice *io)
+parser::search_node (const QString& node, QIODevice *io)
 {
   while (!io->atEnd ())
     {
@@ -186,7 +188,7 @@
 }
 
 static QString
-get_first_line (QString text)
+get_first_line (const QString& text)
 {
   int n = text.indexOf ("\n");
 
@@ -200,7 +202,7 @@
 }
 
 static QString
-parser_node (QString text, QString node_name)
+parser_node (const QString& text, const QString& node_name)
 {
   QString firstLine = get_first_line (text);
   QStringList nodes = firstLine.split (",");
@@ -217,31 +219,31 @@
 }
 
 QString
-parser::get_node_name (QString text)
+parser::get_node_name (const QString& text)
 {
   return parser_node (text, "Node:");
 }
 
 QString
-parser::get_node_up (QString text)
+parser::get_node_up (const QString& text)
 {
   return parser_node (text, "Up:");
 }
 
 QString
-parser::get_node_next (QString text)
+parser::get_node_next (const QString& text)
 {
   return parser_node (text, "Next:");
 }
 
 QString
-parser::get_node_prev (QString text)
+parser::get_node_prev (const QString& text)
 {
   return parser_node (text, "Prev:");
 }
 
 static void
-replace_links (QString &text)
+replace_links (QString& text)
 {
   QRegExp re ("(\\*[N|n]ote|\n\\*)([ |\n]+)([^:]+):([^:\\.,]*)([:,\\.])");
   int i = 0, f;
@@ -282,7 +284,7 @@
 }
 
 static void
-replace_colons (QString &text)
+replace_colons (QString& text)
 {
   QRegExp re ("`([^']+)'");
   int i = 0, f;
@@ -298,7 +300,7 @@
 }
 
 static void
-info_to_html (QString &text)
+info_to_html (QString& text)
 {
   text.replace ("&", "&amp;");
   text.replace ("<", "&lt;");
@@ -311,8 +313,11 @@
 }
 
 QString
-parser::node_text_to_html (QString text, int anchorPos, QString anchor)
+parser::node_text_to_html (const QString& text_arg, int anchorPos,
+                           const QString& anchor)
 {
+  QString text = text_arg;
+
   QString nodeName = get_node_name (text);
   QString nodeUp   = get_node_up (text);
   QString nodeNext = get_node_next (text);
@@ -479,7 +484,7 @@
 }
 
 static void
-replace (QString &text, QRegExp re, QString after)
+replace (QString& text, const QRegExp& re, const QString& after)
 {
   int pos = 0;
 
@@ -495,7 +500,7 @@
 }
 
 QString
-parser::global_search (QString text, int max_founds)
+parser::global_search (const QString& text, int max_founds)
 {
   QString results;
   QStringList words = text.split (" ",QString::SkipEmptyParts);
--- a/libgui/src/qtinfo/parser.h
+++ b/libgui/src/qtinfo/parser.h
@@ -45,20 +45,21 @@
 
 public:
   parser (QObject *parent = 0);
-  void set_info_path (QString _info_path);
+  void set_info_path (const QString& _info_path);
   QString get_info_path ();
-  QString search_node (QString node);
-  QString global_search (QString text, int maxFounds);
+  QString search_node (const QString& node);
+  QString global_search (const QString& text, int maxFounds);
 
   /** Checks if this node is reference. If node is reference, it will be returned its position
     * in text, else  it will be returned -1.
     */
-  int is_ref (QString node);
+  int is_ref (const QString& node);
 
   /**Translates text of node to Html. If anchorPos is not -1, then anchor is inserted in that
     * position.
     */
-  QString node_text_to_html (QString text, int anchorPos=-1, QString anchor=QString());
+  QString node_text_to_html (const QString& text, int anchorPos = -1,
+                             const QString& anchor = QString ());
 
 private:
   struct node_position
@@ -78,12 +79,12 @@
     int real_size;
   };
 
-  QString search_node (QString node, QIODevice * io);
+  QString search_node (const QString& node, QIODevice * io);
   QString get_next_node (QIODevice * io);
-  QString get_node_name (QString text);
-  QString get_node_up (QString text);
-  QString get_node_next (QString text);
-  QString get_node_prev (QString text);
+  QString get_node_name (const QString& text);
+  QString get_node_up (const QString& text);
+  QString get_node_next (const QString& text);
+  QString get_node_prev (const QString& text);
 
   /** Parses info files and gets map of node positions.*/
   void parse_info_map();
--- a/libgui/src/qtinfo/webinfo.cc
+++ b/libgui/src/qtinfo/webinfo.cc
@@ -31,7 +31,7 @@
 
 
 webinfo::webinfo (QWidget *parent)
-  :QWidget (parent)
+  : QWidget (parent)
 {
   _font_web = font ();
 
@@ -90,14 +90,14 @@
 }
 
 void
-webinfo::set_info_path (QString info_path)
+webinfo::set_info_path (const QString& info_path)
 {
   _parser.set_info_path (info_path);
   load_node ("Top");
 }
 
 void
-webinfo::load_node (QString node_name)
+webinfo::load_node (const QString& node_name)
 {
   //Check if node has been already opened.
   for (int i = 0;i < _tab_bar->count (); i++)
@@ -142,7 +142,7 @@
 }
 
 QTextBrowser *
-webinfo::addNewTab(QString name)
+webinfo::addNewTab (const QString& name)
 {
   _text_browser = new QTextBrowser (this);
   _text_browser->setOpenLinks (false);
--- a/libgui/src/qtinfo/webinfo.h
+++ b/libgui/src/qtinfo/webinfo.h
@@ -31,11 +31,11 @@
   Q_OBJECT
 public:
   webinfo (QWidget *parent = 0);
-  void set_info_path (QString info_path);
-  void load_node (QString node_name);
+  void set_info_path (const QString& info_path);
+  void load_node (const QString& node_name);
 
 public slots:
-  void link_clicked (const QUrl &link);
+  void link_clicked (const QUrl& link);
   void current_tab_changed (int index);
   void close_tab ();
   void search ();
@@ -55,6 +55,6 @@
   parser              _parser;
   QFont               _font_web;
 
-  QTextBrowser *addNewTab (QString name);
+  QTextBrowser *addNewTab (const QString& name);
   void closeTab(int index);
 };
--- a/libgui/src/resource-manager.cc
+++ b/libgui/src/resource-manager.cc
@@ -53,7 +53,7 @@
 }
 
 QString
-resource_manager::find_translator_file (QString language)
+resource_manager::find_translator_file (const QString& language)
 {
   // TODO: Quick hack to be able to test language files.
   return QString ("../languages/%1.qm").arg (language);
@@ -127,7 +127,7 @@
 }
 
 void
-resource_manager::do_set_settings (QString file)
+resource_manager::do_set_settings (const QString& file)
 {
   delete settings;
   settings = new QSettings (file, QSettings::IniFormat);
--- a/libgui/src/resource-manager.h
+++ b/libgui/src/resource-manager.h
@@ -54,13 +54,13 @@
       instance->do_reload_settings ();
   }
 
-  static void set_settings (QString file)
+  static void set_settings (const QString& file)
   {
     if (instance_ok ())
       instance->do_set_settings (file);
   }
 
-  static QString find_translator_file (QString language);
+  static QString find_translator_file (const QString& language);
 
   static void update_network_settings (void)
   {
@@ -101,7 +101,7 @@
 
   void do_reload_settings (void);
 
-  void do_set_settings (QString file);
+  void do_set_settings (const QString& file);
 
   void do_update_network_settings (void);
 
--- a/libinterp/interp-core/jit-typeinfo.cc
+++ b/libinterp/interp-core/jit-typeinfo.cc
@@ -2198,7 +2198,7 @@
   if (ov.is_range ())
     return get_range ();
 
-  if (ov.is_double_type ())
+  if (ov.is_double_type () && ! ov.is_complex_type ())
     {
       if (ov.is_real_scalar ())
         return get_scalar ();
--- a/libinterp/interp-core/pt-jit.cc
+++ b/libinterp/interp-core/pt-jit.cc
@@ -27,9 +27,18 @@
 #include <config.h>
 #endif
 
-#ifdef HAVE_LLVM
+#include "defun.h"
+#include "ov.h"
+#include "pt-all.h"
+#include "pt-jit.h"
+#include "symtab.h"
+#include "variables.h"
 
-#include "pt-jit.h"
+bool Venable_jit_debug = false;
+
+bool Venable_jit_compiler = true;
+
+#ifdef HAVE_LLVM
 
 #include <llvm/Analysis/CallGraph.h>
 #include <llvm/Analysis/Passes.h>
@@ -50,9 +59,6 @@
 #include <llvm/Bitcode/ReaderWriter.h>
 #endif
 
-#include "symtab.h"
-#include "pt-all.h"
-
 static llvm::IRBuilder<> builder (llvm::getGlobalContext ());
 
 static llvm::LLVMContext& context = llvm::getGlobalContext ();
@@ -483,7 +489,7 @@
 jit_convert::visit_constant (tree_constant& tc)
 {
   octave_value v = tc.rvalue1 ();
-  if (v.is_real_scalar () && v.is_double_type ())
+  if (v.is_real_scalar () && v.is_double_type () && ! v.is_complex_type ())
     {
       double dv = v.double_value ();
       result = factory.create<jit_const_scalar> (dv);
@@ -1710,12 +1716,15 @@
 
       infer.infer ();
 #ifdef OCTAVE_JIT_DEBUG
-      jit_block_list& blocks = infer.get_blocks ();
-      jit_block *entry_block = blocks.front ();
-      entry_block->label ();
-      std::cout << "-------------------- Compiling tree --------------------\n";
-      std::cout << tee.str_print_code () << std::endl;
-      blocks.print (std::cout, "octave jit ir");
+      if (Venable_jit_debug)
+        {
+          jit_block_list& blocks = infer.get_blocks ();
+          jit_block *entry_block = blocks.front ();
+          entry_block->label ();
+          std::cout << "-------------------- Compiling tree --------------------\n";
+          std::cout << tee.str_print_code () << std::endl;
+          blocks.print (std::cout, "octave jit ir");
+        }
 #endif
 
       jit_factory& factory = conv.get_factory ();
@@ -1728,29 +1737,39 @@
   catch (const jit_fail_exception& e)
     {
 #ifdef OCTAVE_JIT_DEBUG
-      if (e.known ())
-        std::cout << "jit fail: " << e.what () << std::endl;
+      if (Venable_jit_debug)
+        {
+          if (e.known ())
+            std::cout << "jit fail: " << e.what () << std::endl;
+        }
 #endif
     }
 
   if (llvm_function)
     {
 #ifdef OCTAVE_JIT_DEBUG
-      std::cout << "-------------------- llvm ir --------------------";
       llvm::raw_os_ostream llvm_cout (std::cout);
-      llvm_function->print (llvm_cout);
-      std::cout << std::endl;
-      llvm::verifyFunction (*llvm_function);
+
+      if (Venable_jit_debug)
+        {
+          std::cout << "-------------------- llvm ir --------------------";
+          llvm_function->print (llvm_cout);
+          std::cout << std::endl;
+          llvm::verifyFunction (*llvm_function);
+        }
 #endif
 
       tjit.optimize (llvm_function);
 
 #ifdef OCTAVE_JIT_DEBUG
-      std::cout << "-------------------- optimized llvm ir "
-                << "--------------------\n";
-      llvm_function->print (llvm_cout);
-      llvm_cout.flush ();
-      std::cout << std::endl;
+      if (Venable_jit_debug)
+        {
+          std::cout << "-------------------- optimized llvm ir "
+                    << "--------------------\n";
+          llvm_function->print (llvm_cout);
+          llvm_cout.flush ();
+          std::cout << std::endl;
+        }
 #endif
 
       void *void_fn = engine->getPointerToFunction (llvm_function);
@@ -1768,6 +1787,34 @@
 
 #endif
 
+DEFUN (enable_jit_debug, args, nargout,
+  "-*- texinfo -*-\n\
+@deftypefn {Built-in Function} {} enable_jit_debug ()\n\
+Query or set the internal variable that determines whether\n\
+debugging/tracing is enabled for Octave's JIT compiler.\n\
+@end deftypefn")
+{
+#if defined (HAVE_LLVM) && defined (OCTAVE_JIT_DEBUG)
+  return SET_INTERNAL_VARIABLE (enable_jit_debug);
+#else
+  warning ("enable_jit_debug: JIT compiling not available in this version of Octave");
+  return octave_value ();
+#endif
+}
+
+DEFUN (enable_jit_compiler, args, nargout,
+  "-*- texinfo -*-\n\
+@deftypefn {Built-in Function} {} enable_jit_compiler ()\n\
+Query or set the internal variable that enables Octave's JIT compiler.\n\
+@end deftypefn")
+{
+#if defined (HAVE_LLVM)
+  return SET_INTERNAL_VARIABLE (enable_jit_compiler);
+#else
+  warning ("enable_jit_compiler: JIT compiling not available in this version of Octave");
+  return octave_value ();
+#endif
+}
 
 /*
 Test some simple cases that compile.
@@ -2052,4 +2099,13 @@
 %! assert (a, 2000);
 %! assert (b, 1);
 
+%!test
+%! a = [1+1i 1+2i];
+%! b = 0;
+%! while 1
+%!   b = a(1);
+%!   break;
+%! endwhile
+%! assert (b, a(1));
+
 */
--- a/libinterp/interp-core/pt-jit.h
+++ b/libinterp/interp-core/pt-jit.h
@@ -378,4 +378,11 @@
 };
 
 #endif
+
+// If TRUE, enable JIT compiler debugging/tracing.
+extern bool Venable_jit_debug;
+
+// If TRUE, enable JIT compiler.
+extern bool Venable_jit_compiler;
+
 #endif
--- a/libinterp/interpfcn/toplev.cc
+++ b/libinterp/interpfcn/toplev.cc
@@ -1474,12 +1474,17 @@
 
       if (! error_state)
         {
-          Cell c = m.contents (arg.c_str ());
+          if (m.isfield (arg))
+            {
+              Cell c = m.contents (arg);
 
-          if (c.is_empty ())
-            error ("octave_config_info: no info for `%s'", arg.c_str ());
+              if (c.is_empty ())
+                error ("octave_config_info: no info for `%s'", arg.c_str ());
+              else
+                retval = c(0);
+            }
           else
-            retval = c(0);
+            error ("octave_config_info: invalid parameter `%s'", arg.c_str ());
         }
     }
   else if (nargin == 0)
--- a/libinterp/octave.cc
+++ b/libinterp/octave.cc
@@ -128,6 +128,14 @@
 // (--no-gui)
 static bool no_gui_option = false;
 
+// If TRUE, disable the JIT compiler.
+// (--no-jit-compiler)
+static bool no_jit_compiler_option = false;
+
+// If TRUE, enable JIT compiler debugging/tracing.
+// (--jit-debug)
+static bool jit_debug_option = false;
+
 // If TRUE, force readline command line editing.
 // (--line-editing)
 static bool forced_line_editing = false;
@@ -178,10 +186,11 @@
   "octave [-HVdfhiqvx] [--debug] [--echo-commands] [--eval CODE]\n\
        [--exec-path path] [--force-gui] [--help] [--image-path path]\n\
        [--info-file file] [--info-program prog] [--interactive]\n\
-       [--line-editing] [--no-gui] [--no-history] [--no-init-file]\n\
-       [--no-init-path] [--no-line-editing] [--no-site-file]\n\
-       [--no-window-system] [-p path] [--path path] [--silent]\n\
-       [--traditional] [--verbose] [--version] [file]";
+       [--jit-debug] [--line-editing] [--no-gui] [--no-history]\n\
+       [--no-init-file] [--no-init-path] [--no-jit-compiler]\n\
+       [--no-line-editing] [--no-site-file] [--no-window-system]\n\
+       [-p path] [--path path] [--silent] [--traditional]\n\
+       [--verbose] [--version] [file]";
 
 // This is here so that it's more likely that the usage message and
 // the real set of options will agree.  Note: the `+' must come first
@@ -203,16 +212,18 @@
 #define IMAGE_PATH_OPTION 5
 #define INFO_FILE_OPTION 6
 #define INFO_PROG_OPTION 7
-#define LINE_EDITING_OPTION 8
-#define NO_GUI_OPTION 9
-#define NO_INIT_FILE_OPTION 10
-#define NO_INIT_PATH_OPTION 11
-#define NO_LINE_EDITING_OPTION 12
-#define NO_SITE_FILE_OPTION 13
-#define NO_WINDOW_SYSTEM_OPTION 14
-#define PERSIST_OPTION 15
-#define TEXI_MACROS_FILE_OPTION 16
-#define TRADITIONAL_OPTION 17
+#define JIT_DEBUG_OPTION 8
+#define LINE_EDITING_OPTION 9
+#define NO_GUI_OPTION 10
+#define NO_INIT_FILE_OPTION 11
+#define NO_INIT_PATH_OPTION 12
+#define NO_JIT_COMPILER_OPTION 13
+#define NO_LINE_EDITING_OPTION 14
+#define NO_SITE_FILE_OPTION 15
+#define NO_WINDOW_SYSTEM_OPTION 16
+#define PERSIST_OPTION 17
+#define TEXI_MACROS_FILE_OPTION 18
+#define TRADITIONAL_OPTION 19
 struct option long_opts[] =
   {
     { "braindead",        no_argument,       0, TRADITIONAL_OPTION },
@@ -227,11 +238,13 @@
     { "info-file",        required_argument, 0, INFO_FILE_OPTION },
     { "info-program",     required_argument, 0, INFO_PROG_OPTION },
     { "interactive",      no_argument,       0, 'i' },
+    { "jit-debug",        no_argument,       0, JIT_DEBUG_OPTION },
     { "line-editing",     no_argument,       0, LINE_EDITING_OPTION },
     { "no-gui",           no_argument,       0, NO_GUI_OPTION },
     { "no-history",       no_argument,       0, 'H' },
     { "no-init-file",     no_argument,       0, NO_INIT_FILE_OPTION },
     { "no-init-path",     no_argument,       0, NO_INIT_PATH_OPTION },
+    { "no-jit",           no_argument,       0, NO_JIT_COMPILER_OPTION },
     { "no-line-editing",  no_argument,       0, NO_LINE_EDITING_OPTION },
     { "no-site-file",     no_argument,       0, NO_SITE_FILE_OPTION },
     { "no-window-system", no_argument,       0, NO_WINDOW_SYSTEM_OPTION },
@@ -575,11 +588,13 @@
   --info-file FILE        Use top-level info file FILE.\n\
   --info-program PROGRAM  Use PROGRAM for reading info files.\n\
   --interactive, -i       Force interactive behavior.\n\
+  --jit-debug             Enable JIT compiler debugging/tracing.\n\
   --line-editing          Force readline use for command-line editing.\n\
   --no-gui                Disable the graphical user interface.\n\
   --no-history, -H        Don't save commands to the history list\n\
   --no-init-file          Don't read the ~/.octaverc or .octaverc files.\n\
   --no-init-path          Don't initialize function search path.\n\
+  --no-jit-compiler       Disable the JIT compiler.\n\
   --no-line-editing       Don't use readline for command-line editing.\n\
   --no-site-file          Don't read the site-wide octaverc file.\n\
   --no-window-system      Disable window system, including graphics.\n\
@@ -801,20 +816,28 @@
             info_program = optarg;
           break;
 
+        case JIT_DEBUG_OPTION:
+          jit_debug_option = true;
+          break;
+
         case LINE_EDITING_OPTION:
           forced_line_editing = true;
           break;
 
+        case NO_GUI_OPTION:
+          no_gui_option = true;
+          break;
+
         case NO_INIT_FILE_OPTION:
           read_init_files = false;
           break;
 
-        case NO_GUI_OPTION:
-          no_gui_option = true;
+        case NO_INIT_PATH_OPTION:
+          set_initial_path = false;
           break;
 
-        case NO_INIT_PATH_OPTION:
-          set_initial_path = false;
+        case NO_JIT_COMPILER_OPTION:
+          no_jit_compiler_option = true;
           break;
 
         case NO_LINE_EDITING_OPTION:
@@ -944,6 +967,12 @@
   if (! texi_macros_file.empty ())
     bind_internal_variable ("texi_macros_file", texi_macros_file);
 
+  if (jit_debug_option)
+    bind_internal_variable ("enable_jit_debugging", true);
+
+  if (no_jit_compiler_option)
+    bind_internal_variable ("enable_jit_compiler", false);
+
   // Make sure we clean up when we exit.  Also allow users to register
   // functions.  If we don't have atexit or on_exit, we're going to
   // leave some junk files around if we exit abnormally.
--- a/libinterp/parse-tree/pt-eval.cc
+++ b/libinterp/parse-tree/pt-eval.cc
@@ -44,9 +44,10 @@
 #include "symtab.h"
 #include "unwind-prot.h"
 
-#if HAVE_LLVM
 //FIXME: This should be part of tree_evaluator
 #include "pt-jit.h"
+
+#if HAVE_LLVM
 static tree_jit jiter;
 #endif
 
@@ -310,7 +311,7 @@
   octave_value rhs = expr->rvalue1 ();
 
 #if HAVE_LLVM
-  if (jiter.execute (cmd, rhs))
+  if (Venable_jit_compiler && jiter.execute (cmd, rhs))
     return;
 #endif
 
@@ -1047,7 +1048,7 @@
     return;
 
 #if HAVE_LLVM
-  if (jiter.execute (cmd))
+  if (Venable_jit_compiler && jiter.execute (cmd))
     return;
 #endif
 
--- a/m4/acinclude.m4
+++ b/m4/acinclude.m4
@@ -675,6 +675,25 @@
   fi
 ])
 dnl
+dnl Find a suitable termlib to use.
+dnl
+AC_DEFUN([OCTAVE_CHECK_LIB_TERMLIB], [
+  TERM_LIBS=
+  octave_found_termlib=no
+  for termlib in ncurses curses termcap terminfo termlib; do
+    AC_CHECK_LIB([${termlib}], [tputs], [
+      TERM_LIBS="-l${termlib}"
+      octave_found_termlib=yes
+      break])
+  done
+
+  if test "$octave_found_termlib" = no; then
+    warn_termlibs="I couldn't find -ltermcap, -lterminfo, -lncurses, -lcurses, or -ltermlib!"
+    AC_MSG_WARN([$warn_termlibs])
+  fi
+  AC_SUBST(TERM_LIBS)
+])
+dnl
 dnl Check for support of OpenMP with a given compiler flag.
 dnl If found define HAVE_OPENMP and add the compile flag
 dnl to CFLAGS and CXXFLAGS.
@@ -1082,6 +1101,8 @@
        warn_readline="command editing and history features require GNU Readline"
      fi])
   if $USE_READLINE; then
+    dnl RHEL 5 and older systems require termlib set before enabling readline
+    AC_REQUIRE([OCTAVE_CHECK_LIB_TERMLIB])
     save_LIBS="$LIBS"
     LIBS="$TERM_LIBS"
     AC_CHECK_LIB(readline, rl_set_keyboard_input_timeout,
--- a/scripts/plot/print.m
+++ b/scripts/plot/print.m
@@ -21,19 +21,19 @@
 ## @deftypefnx {Function File} {} print (@var{options})
 ## @deftypefnx {Function File} {} print (@var{filename}, @var{options})
 ## @deftypefnx {Function File} {} print (@var{h}, @var{filename}, @var{options})
-## Print a graph, or save it to a file.  Both output formatted for 
+## Print a plot, or save it to a file.  Both output formatted for 
 ## printing (PDF and PostScript), and many bitmapped and vector
 ## image formats are supported.
 ##
-## @var{h} specifies the figure handle.  If no handle is specified
-## the handle for the current figure is used.
-##
 ## @var{filename} defines the name of the output file.  If the
 ## file name has no suffix, one is inferred from the specified
 ## device and appended to the file name.  If no filename is
 ## specified, the output is sent to the printer.
 ##
-## For output to a printer, to a PostScript file, or a PDF file,
+## @var{h} specifies the figure handle.  If no handle is specified
+## the handle for the current figure is used.
+##
+## For output to a printer, PostScript file, or PDF file,
 ## the paper size is specified by the figure's @code{papersize}
 ## property.  The location and size of the image on the page are
 ## specified by the figure's @code{paperposition} property.  The
@@ -43,19 +43,19 @@
 ## The width and height of images are specified by the figure's
 ## @code{paperpositon(3:4)} property values.
 ##
-## The @code{print} command supports several @var{options}:
+## The @code{print} command supports many @var{options}:
 ##
 ## @table @code
 ## @item -f@var{h}
 ##   Specify the handle, @var{h}, of the figure to be printed.  The
-##   default is the current figure.
+## default is the current figure.
 ##
 ## @item -P@var{printer}
-##   Set the @var{printer} name to which the graph is sent if no
-##   @var{filename} is specified.
+##   Set the @var{printer} name to which the plot is sent if no
+## @var{filename} is specified.
 ##
 ## @item -G@var{ghostscript_command}
-##   Specify the command for calling Ghostscript.  For Unix and Windows,
+##   Specify the command for calling Ghostscript.  For Unix and Windows
 ## the defaults are 'gs' and 'gswin32c', respectively.
 ##
 ## @item -color
@@ -64,7 +64,7 @@
 ##
 ## @item -solid
 ## @itemx -dashed
-##   Forces all lines to be solid or dashed, respectively.
+##   Force all lines to be solid or dashed, respectively.
 ##
 ## @item -portrait
 ## @itemx -landscape
@@ -81,11 +81,11 @@
 ## For bitmap and printer output anti-aliasing is applied using
 ## Ghostscript's TextAlphaBits and GraphicsAlphaBits options.
 ## The default number of bits for each is 4.
-## Allowed values, for @var{N}, are 1, 2, or 4.
+## Allowed values for @var{N} are 1, 2, or 4.
 ##
 ## @item -d@var{device}
 ##   The available output format is specified by the option @var{device},
-##   and is one of:
+## and is one of:
 ##
 ##   @table @code
 ##   @item ps
@@ -93,7 +93,7 @@
 ##   @itemx psc
 ##   @itemx psc2
 ##     Postscript (level 1 and 2, mono and color).  The FLTK graphics
-##     toolkit generates Postscript level 3.0.
+## toolkit generates Postscript level 3.0.
 ##
 ##   @item eps
 ##   @itemx eps2
@@ -108,7 +108,7 @@
 ##   @itemx pstex
 ##   @itemx pslatex
 ##   @itemx pdflatex
-##     Generate a @LaTeX{} (or @TeX{}) file for labels, and eps/ps/pdf
+##     Generate a @LaTeX{} (or @TeX{}) file for labels and eps/ps/pdf
 ## for graphics.  The file produced by @code{epslatexstandalone} can be
 ## processed directly by @LaTeX{}.  The other formats are intended to
 ## be included in a @LaTeX{} (or @TeX{}) document.  The @code{tex} device
@@ -116,8 +116,8 @@
 ## is only available for the FLTK graphics toolkit.
 ##
 ##   @item tikz
-##     Generate a @LaTeX{} file using PGF/TikZ@.  For the FLTK the result is
-##   PGF.
+##     Generate a @LaTeX{} file using PGF/TikZ@.  For the FLTK toolkit
+## the result is PGF.
 ##
 ##   @item ill
 ##   @itemx aifm
@@ -136,9 +136,9 @@
 ##
 ##   @item fig
 ##     XFig.  For the Gnuplot graphics toolkit, the additional options
-##     @option{-textspecial} or @option{-textnormal} can be used to control
-##     whether the special flag should be set for the text in
-##     the figure (default is @option{-textnormal}).
+## @option{-textspecial} or @option{-textnormal} can be used to control
+## whether the special flag should be set for the text in
+## the figure.  (default is @option{-textnormal})
 ##
 ##   @item hpgl
 ##     HP plotter language
@@ -208,52 +208,52 @@
 ## the figure's "paperposition" property.
 ##
 ## @itemx -append
-##   Appends the PS, or PDF output to a pre-existing file of the
+##   Append Postscript or PDF output to a pre-existing file of the
 ## same type.
 ##
 ## @itemx -r@var{NUM}
 ##   Resolution of bitmaps in pixels per inch.  For both metafiles and
-## SVG the default is the screen resolution, for other it is 150 dpi.
+## SVG the default is the screen resolution; for other formats it is 150 dpi.
 ## To specify screen resolution, use "-r0".
 ##
 ## @item -tight
-##   Forces a tight bounding box for eps-files.
+##   Force a tight bounding box for eps files.
 ##
 ## @item -@var{preview}
-##   Adds a preview to eps-files.  Supported formats are;
+##   Add a preview to eps files.  Supported formats are:
 ##
 ##   @table @code
 ##   @item -interchange
-##     Provides an interchange preview.
+##     Provide an interchange preview.
 ##
 ##   @item -metalfile
-##     Provides a metafile preview.
+##     Provide a metafile preview.
 ##
 ##   @item -pict
-##     Provides pict preview.
+##     Provide pict preview.
 ##
 ##   @item -tiff
-##     Provides a tiff preview.
+##     Provide a tiff preview.
 ##   @end table
 ##
 ## @item -S@var{xsize},@var{ysize}
-##   Plot size in pixels for EMF, GIF, JPEG, PBM, PNG and SVG@.  For
+##   Plot size in pixels for EMF, GIF, JPEG, PBM, PNG, and SVG@.  For
 ## PS, EPS, PDF, and other vector formats the plot size is in points.
 ## This option is equivalent to changing the size of the plot box
-## associated with "paperposition" property.  Using the command form of
-## the print function, you must quote the @var{xsize},@var{ysize}
-## option.  For example, by writing @w{@code{"-S640,480"}}.
+## associated with the "paperposition" property.  When using the command form
+## of the print function you must quote the @var{xsize},@var{ysize}
+## option.  For example, by writing @w{"-S640,480"}.
 ##
 ## @item -F@var{fontname}
 ## @itemx -F@var{fontname}:@var{size}
 ## @itemx -F:@var{size}
-##   Associates all text with the @var{fontname} and/or @var{fontsize}.
-## @var{fontname} is ignored for some devices; dxf, fig, hpgl, etc.
+##   Use @var{fontname} and/or @var{fontsize} for all text.
+## @var{fontname} is ignored for some devices: dxf, fig, hpgl, etc.
 ## @end table
 ##
 ## The filename and options can be given in any order.
 ##
-## Example: Print to a file, using the svg device.
+## Example: Print to a file using the svg device.
 ##
 ## @example
 ## @group
--- a/src/mkoctfile.in.cc
+++ b/src/mkoctfile.in.cc
@@ -25,6 +25,7 @@
 #endif
 
 #include <string>
+#include <cstring>
 #include <map>
 #include <list>
 #include <algorithm>
@@ -48,11 +49,11 @@
 
 static string OCTAVE_VERSION = %OCTAVE_CONF_VERSION%;
 
-static std::string
-substitute_prefix (const std::string& s, const std::string& prefix,
-                   const std::string& new_prefix)
+static string
+substitute_prefix (const string& s, const string& prefix,
+                   const string& new_prefix)
 {
-  std::string retval = s;
+  string retval = s;
 
   if (!prefix.empty () && new_prefix != prefix)
     {
@@ -62,7 +63,7 @@
     }
 
 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
-  std::replace (retval.begin (), retval.end (), '/', '\\');
+  replace (retval.begin (), retval.end (), '/', '\\');
 #endif
 
   return retval;
@@ -123,7 +124,7 @@
 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
   int n = 1024;
 
-  std::string bin_dir (n, '\0');
+  string bin_dir (n, '\0');
 
   while (true)
     {
@@ -154,10 +155,10 @@
 
   vars["OCTAVE_PREFIX"] = %OCTAVE_CONF_PREFIX%;
 
-  std::string DEFAULT_OCTINCLUDEDIR = %OCTAVE_CONF_OCTINCLUDEDIR%;
-  std::string DEFAULT_INCLUDEDIR = %OCTAVE_CONF_INCLUDEDIR%;
-  std::string DEFAULT_LIBDIR = %OCTAVE_CONF_LIBDIR%;
-  std::string DEFAULT_OCTLIBDIR = %OCTAVE_CONF_OCTLIBDIR%;
+  string DEFAULT_OCTINCLUDEDIR = %OCTAVE_CONF_OCTINCLUDEDIR%;
+  string DEFAULT_INCLUDEDIR = %OCTAVE_CONF_INCLUDEDIR%;
+  string DEFAULT_LIBDIR = %OCTAVE_CONF_LIBDIR%;
+  string DEFAULT_OCTLIBDIR = %OCTAVE_CONF_OCTLIBDIR%;
 
   if (! vars["OCTAVE_HOME"].empty ())
     {
@@ -184,18 +185,18 @@
   vars["OCTLIBDIR"] = get_variable ("OCTLIBDIR", DEFAULT_OCTLIBDIR);
 
 #if defined (__WIN32__) && ! defined (_POSIX_VERSION)
-  std::string DEFAULT_INCFLAGS
+  string DEFAULT_INCFLAGS
     = "-I" + quote_path (vars["OCTINCLUDEDIR"] + "\\..")
     + " -I" + quote_path (vars["OCTINCLUDEDIR"]);
 #else
-  std::string DEFAULT_INCFLAGS
+  string DEFAULT_INCFLAGS
     = "-I" + quote_path (vars["OCTINCLUDEDIR"] + "/..")
     + " -I" + quote_path (vars["OCTINCLUDEDIR"]);
 #endif
   if (vars["INCLUDEDIR"] != "/usr/include")
     DEFAULT_INCFLAGS += " -I" + quote_path (vars["INCLUDEDIR"]);
 
-  std::string DEFAULT_LFLAGS = "-L" + quote_path (vars["OCTLIBDIR"]);
+  string DEFAULT_LFLAGS = "-L" + quote_path (vars["OCTLIBDIR"]);
   if (vars["LIBDIR"] != "/usr/lib")
     DEFAULT_LFLAGS += " -L" + quote_path (vars["LIBDIR"]);
 
@@ -319,7 +320,7 @@
 "                            F77_INTEGER_8_FLAG        SED\n"             
 "                            FFLAGS                    XTRA_CFLAGS\n"     
 "                            FFTW3_LDFLAGS             XTRA_CXXFLAGS\n"   
-"                            FFTW3_LIBS                                   
+"                            FFTW3_LIBS\n"      
 "                            FFTW3F_LDFLAGS\n"
 "                            FFTW3F_LIBS\n"
 "\n"
@@ -352,21 +353,23 @@
 static string
 basename (const string& s, bool strip_path = false)
 {
+  string retval;
   size_t pos = s.rfind ('.');
-  string retval;
 
   if (pos == string::npos)
     retval = s;
   else
     retval = s.substr (0, pos);
+
   if (strip_path)
     {
       size_t p1 = retval.rfind ('/'), p2 = retval.rfind ('\\');
       pos = (p1 != string::npos && p2 != string::npos
              ? max (p1, p2) : (p2 != string::npos ? p2 : p1));
       if (pos != string::npos)
-        retval = retval.substr (0, pos);
+        retval = retval.substr (++pos, string::npos);
     }
+
   return retval;
 }