changeset 6365:ccdb8ffbb994

[project @ 2007-02-27 19:43:35 by jwe]
author jwe
date Tue, 27 Feb 2007 19:43:36 +0000
parents 0d41cafd2e0d
children 06f26e174fc9
files ChangeLog run-octave.in scripts/ChangeLog scripts/testfun/test.m src/ChangeLog src/load-path.cc src/load-path.h src/octave.cc src/parse.y
diffstat 9 files changed, 73 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Feb 27 15:18:35 2007 +0000
+++ b/ChangeLog	Tue Feb 27 19:43:36 2007 +0000
@@ -1,3 +1,9 @@
+2007-02-27  John W. Eaton  <jwe@octave.org>
+
+	* run-octave.in (run-octave.in): Use --no-initial-path.
+	Rename to qargs to args.  Use $args not "$args" when invoking Octave.
+	Try harder to get quoting right when passing args to Octave.
+
 2007-02-26  John W. Eaton  <jwe@octave.org>
 
 	* octMakefile.in (DISTDIRS): Eliminate variable.
--- a/run-octave.in	Tue Feb 27 15:18:35 2007 +0000
+++ b/run-octave.in	Tue Feb 27 19:43:36 2007 +0000
@@ -30,14 +30,13 @@
 LOADPATH="$d1_path:$d2_path:$d3_path:$d4_path"
 IMAGEPATH="$top_srcdir/scripts/image"
 
-args="--path=$LOADPATH --image-path=$IMAGEPATH"
-qargs="--path=\"$LOADPATH\" --image-path=\"$IMAGEPATH\""
+args="--no-initial-path --path=\"$LOADPATH\" --image-path=\"$IMAGEPATH\""
 
 if [ $# -gt 0 ]; then
   if [ "x$1" = "x-g" ]; then
     driver="gdb"
     if [ $(/bin/pwd) = "$builddir" ]; then
-      sed "s|^set args.*$|set args $qargs|" .gdbinit > .gdbinit-tmp
+      sed "s|^set args.*$|set args $args|" .gdbinit > .gdbinit-tmp
       mv .gdbinit-tmp .gdbinit
     fi
     args=""
@@ -55,7 +54,7 @@
   OCTAVE_SITE_INITFILE="$top_srcdir/scripts/startup/main-rcfile" \
   LD_PRELOAD="$liboctinterp $liboctave $libcruft" \
   %library_path_var%="$builddir/src:$builddir/liboctave:$builddir/libcruft:$%library_path_var%" \
-    exec $driver "$builddir/src/octave" "$args" "$@"
+    exec $driver "$builddir/src/octave" --no-initial-path --path="$LOADPATH" --image-path="$IMAGEPATH" "$@"
 else
   OCTAVE_SITE_INITFILE="$top_srcdir/scripts/startup/main-rcfile" \
   LD_PRELOAD="$liboctinterp $liboctave $libcruft" \
--- a/scripts/ChangeLog	Tue Feb 27 15:18:35 2007 +0000
+++ b/scripts/ChangeLog	Tue Feb 27 19:43:36 2007 +0000
@@ -1,3 +1,8 @@
+2007-02-27  John W. Eaton  <jwe@octave.org>
+
+	* testfun/test.m (test): Handle possibility of file_in_loadpath
+	returning an empty cell array.
+
 2007-02-27  From Michael Goffioul  <michael.goffioul@swing.be>
 
 	* pkg/pkg.m: Use fullfile to create filenames from parts.
--- a/scripts/testfun/test.m	Tue Feb 27 15:18:35 2007 +0000
+++ b/scripts/testfun/test.m	Tue Feb 27 19:43:36 2007 +0000
@@ -154,8 +154,12 @@
     __file = file_in_loadpath ([__name, ".cc"], "all");
   endif
   if (iscell (__file))
-    ## If repeats, return first in path.
-    __file = __file{1};
+      ## If repeats, return first in path.
+    if (isempty (__file))
+      __file = "";
+    else
+      __file = __file{1};
+    endif
   endif
   if (isempty (__file))
     if (__grabdemo)
--- a/src/ChangeLog	Tue Feb 27 15:18:35 2007 +0000
+++ b/src/ChangeLog	Tue Feb 27 19:43:36 2007 +0000
@@ -1,3 +1,19 @@
+2007-02-27  John W. Eaton  <jwe@octave.org>
+
+	* load-path.h, (load_path::initialize, load_path::do_initialize):
+	New arg, set_initial_path.
+	* load-path.cc (load_path::do_initialize): Don't add system
+	directories to apth if set_initial_path is false.
+	* octave.cc (set_initial_path): New static variable.
+	(NO_INITIAL_PATH_OPTION): New define.
+	(usage_string): Include --no-initial-path in message.
+	(long_opts): Include no-initial-path/NO_INITIAL_PATH_OPTION here.
+	(octave_main): Handle NO_INITIAL_PATH_OPTION.
+	Pass set_initial_path to load_path::initialize.
+
+	* parse.y (Fautoload): Warn about duplicate entries.  Only insert
+	the first found.
+
 2007-02-27  David Bateman  <dbateman@free.fr>
 
 	* error.cc (Vlast_error_file, Vlast_erro_name, Vlast_error_row,
--- a/src/load-path.cc	Tue Feb 27 15:18:35 2007 +0000
+++ b/src/load-path.cc	Tue Feb 27 19:43:36 2007 +0000
@@ -352,18 +352,21 @@
 }
 
 void
-load_path::do_initialize (void)
+load_path::do_initialize (bool set_initial_path)
 {
   Vsystem_path = dir_path::path_sep_str;
 
-  maybe_add_path_elts (Vsystem_path, Vlocal_ver_oct_file_dir);
-  maybe_add_path_elts (Vsystem_path, Vlocal_api_oct_file_dir);
-  maybe_add_path_elts (Vsystem_path, Vlocal_oct_file_dir);
-  maybe_add_path_elts (Vsystem_path, Vlocal_ver_fcn_file_dir);
-  maybe_add_path_elts (Vsystem_path, Vlocal_api_fcn_file_dir);
-  maybe_add_path_elts (Vsystem_path, Vlocal_fcn_file_dir);
-  maybe_add_path_elts (Vsystem_path, Voct_file_dir);
-  maybe_add_path_elts (Vsystem_path, Vfcn_file_dir);
+  if (set_initial_path)
+    {
+      maybe_add_path_elts (Vsystem_path, Vlocal_ver_oct_file_dir);
+      maybe_add_path_elts (Vsystem_path, Vlocal_api_oct_file_dir);
+      maybe_add_path_elts (Vsystem_path, Vlocal_oct_file_dir);
+      maybe_add_path_elts (Vsystem_path, Vlocal_ver_fcn_file_dir);
+      maybe_add_path_elts (Vsystem_path, Vlocal_api_fcn_file_dir);
+      maybe_add_path_elts (Vsystem_path, Vlocal_fcn_file_dir);
+      maybe_add_path_elts (Vsystem_path, Voct_file_dir);
+      maybe_add_path_elts (Vsystem_path, Vfcn_file_dir);
+    }
 
   std::string tpath = load_path::command_line_path;
 
--- a/src/load-path.h	Tue Feb 27 15:18:35 2007 +0000
+++ b/src/load-path.h	Tue Feb 27 19:43:36 2007 +0000
@@ -46,10 +46,10 @@
 
   ~load_path (void) { }
 
-  static void initialize (void)
+  static void initialize (bool set_initial_path = false)
   {
     if (instance_ok ())
-      instance->do_initialize ();
+      instance->do_initialize (set_initial_path);
   }
 
   static void clear (void)
@@ -295,7 +295,7 @@
 
   void move (std::list<dir_info>::iterator i, bool at_end);
 
-  void do_initialize (void);
+  void do_initialize (bool set_initial_path);
 
   void do_clear (void);
 
--- a/src/octave.cc	Tue Feb 27 15:18:35 2007 +0000
+++ b/src/octave.cc	Tue Feb 27 19:43:36 2007 +0000
@@ -106,6 +106,10 @@
 // (--norc; --no-site-file; -f)
 static bool read_site_files = true;
 
+// TRUE means we set the initial path to configured defaults.
+// (--no-initial-path)
+static bool set_initial_path = true;
+
 // TRUE means we don't print the usual startup message.
 // (--quiet; --silent; -q)
 static bool inhibit_startup_message = false;
@@ -123,8 +127,8 @@
   "octave [-?HVdfhiqvx] [--debug] [--echo-commands] [--eval CODE]\n\
        [--exec-path path] [--help] [--image-path path] [--info-file file]\n\
        [--info-program prog] [--interactive] [--no-history] [--no-init-file]\n\
-       [--no-line-editing] [--no-site-file] [-p path] [--path path]\n\
-       [--silent] [--traditional] [--verbose] [--version] [file]";
+       [--no-line-editing] [--no-site-file] [--no-init-path] [-p path]\n\
+       [--path path] [--silent] [--traditional] [--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
@@ -147,8 +151,9 @@
 #define NO_INIT_FILE_OPTION 6
 #define NO_LINE_EDITING_OPTION 7
 #define NO_SITE_FILE_OPTION 8
-#define PERSIST_OPTION 9
-#define TRADITIONAL_OPTION 10
+#define NO_INITIAL_PATH_OPTION 9
+#define PERSIST_OPTION 10
+#define TRADITIONAL_OPTION 11
 long_options long_opts[] =
   {
     { "debug",            prog_args::no_arg,       0, 'd' },
@@ -165,6 +170,7 @@
     { "no-init-file",     prog_args::no_arg,       0, NO_INIT_FILE_OPTION },
     { "no-line-editing",  prog_args::no_arg,       0, NO_LINE_EDITING_OPTION },
     { "no-site-file",     prog_args::no_arg,       0, NO_SITE_FILE_OPTION },
+    { "no-initial-path",  prog_args::no_arg,       0, NO_INITIAL_PATH_OPTION },
     { "norc",             prog_args::no_arg,       0, 'f' },
     { "path",             prog_args::required_arg, 0, 'p' },
     { "persist",          prog_args::no_arg,       0, PERSIST_OPTION },
@@ -646,6 +652,10 @@
 	  read_site_files = 0;
 	  break;
 
+	case NO_INITIAL_PATH_OPTION:
+	  set_initial_path = false;
+	  break;
+
 	case TRADITIONAL_OPTION:
 	  traditional = true;
 	  break;
@@ -683,7 +693,7 @@
 
   initialize_version_info ();
 
-  load_path::initialize ();
+  load_path::initialize (set_initial_path);
 
   execute_startup_files ();
 
--- a/src/parse.y	Tue Feb 27 15:18:35 2007 +0000
+++ b/src/parse.y	Tue Feb 27 19:43:36 2007 +0000
@@ -3541,7 +3541,13 @@
       string_vector argv = args.make_argv ("autoload");
 
       if (! error_state)
-	autoload_map[argv[1]] = argv[2];
+        {
+	  if (autoload_map.find (argv[1]) != autoload_map.end ())
+	    warning ("autoload: not replacing existing entry for %s => %s",
+		     argv[1].c_str (), argv[2].c_str ());
+	  else
+	    autoload_map[argv[1]] = argv[2];
+	}
     }
   else
     print_usage ();