changeset 6481:89ed13fec6fe

[project @ 2007-04-03 19:39:11 by jwe]
author jwe
date Tue, 03 Apr 2007 19:39:12 +0000
parents 23ed94dfbfa8
children 7e958a1532c6
files doc/ChangeLog doc/interpreter/basics.txi liboctave/Array.cc liboctave/ChangeLog src/ChangeLog src/ov-fcn-handle.cc
diffstat 6 files changed, 72 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/doc/ChangeLog	Tue Apr 03 16:24:54 2007 +0000
+++ b/doc/ChangeLog	Tue Apr 03 19:39:12 2007 +0000
@@ -1,3 +1,9 @@
+2007-04-03  Rafael Laboissiere  <rafael@debian.org>
+
+	* interpreter/basics.txi: Clarified some limitations of the #!
+	script mechanism, in particular related to the parsing of the
+	arguments.
+
 2007-03-29  Rafael Laboissiere  <rafael@debian.org>
 
 	* faq/Octave-FAQ.texi, interpreter/basics.txi,
--- a/doc/interpreter/basics.txi	Tue Apr 03 16:24:54 2007 +0000
+++ b/doc/interpreter/basics.txi	Tue Apr 03 19:39:12 2007 +0000
@@ -764,7 +764,11 @@
 Octave scripts, using the @samp{#!} script mechanism.  You can do this
 on GNU systems and on many Unix systems @footnote{The @samp{#!}
 mechanism works on Unix systems derived from Berkeley Unix, System V
-Release 4, and some System V Release 3 systems.}
+Release 4, and some System V Release 3 systems.}.
+
+Self-contained Octave scripts are useful when you want to write a
+program which users can invoke without knowing that the program is
+written in the Octave language.
 
 For example, you could create a text file named @file{hello}, containing
 the following lines:
@@ -779,7 +783,9 @@
 
 @noindent
 (where @var{octave-interpreter-name} should be replaced with the full
-file name for your Octave binary).  After making this file executable
+file name for your Octave binary).  Note that this will only work if
+@samp{#!} appears at the very beginning of the file. After making this
+file executable
 (with the @code{chmod} command), you can simply type:
 
 @example
@@ -804,18 +810,42 @@
 usually specified in stand-alone Octave programs to prevent them from
 printing the normal startup message, and to keep them from behaving
 differently depending on the contents of a particular user's
-@file{~/.octaverc} file.  @xref{Invoking Octave}.  Note that some
-operating systems may place a limit on the number of characters that are
-recognized after @samp{#!}.
+@file{~/.octaverc} file.  @xref{Invoking Octave}.
+
+Note that some operating systems may place a limit on the number of
+characters that are recognized after @samp{#!}.  Also, the various
+shells/systems parse differently the arguments appearing in a @samp{#!} 
+line.  The majority of them group together all the arguments in a string
+and pass it to the interepreter as a single argument.  In this case, the
+following script:
+
+@example
+@group
+#! @var{octave-interpreter-name} -q -f # comment
+@end group
+@end example
+
+@noindent
+is equivalent to type at the command line:
 
-Self-contained Octave scripts are useful when you want to write a
-program which users can invoke without knowing that the program is
-written in the Octave language.
+@example
+@group
+octave "-q -f # comment"
+@end group
+@end example
 
-The built-in function @code{argv} returns a cell array containing the
-command line arguments passed to an executable Octave script
-@xref{Command Line Options}.  For example, the following program will
-reproduce the command line that is used to execute it.
+@noindent
+which would obviously produce an error message.  Unfortunately, it is
+impossible for Octave to know whether it has been called from the command
+line or from a @samp{#!} script, so some care is needed when using the
+@samp{#!} mechanism.
+
+Note that when Octave is started from an executable script, the built-in
+function @code{argv} returns a cell array containing the command line
+arguments passed to an executable Octave script, not the arguments
+passed to the Octave interpreter on the @samp{#!} line of the script.
+For example, the following program will reproduce the command line that
+is used to execute script, not @samp{-qf}.
 
 @example
 @group
--- a/liboctave/Array.cc	Tue Apr 03 16:24:54 2007 +0000
+++ b/liboctave/Array.cc	Tue Apr 03 19:39:12 2007 +0000
@@ -3094,7 +3094,9 @@
 	      // index is a colon the new dimension is singleton.
 
 	      if (i < lhs_dims_len
-		  && (idx(i).is_colon () || idx(i).max () < lhs_dims(i)))
+		  && (idx(i).is_colon ()
+		      || idx(i).orig_empty ()
+		      || idx(i).max () < lhs_dims(i)))
 		new_dims(i) = lhs_dims(i);
 	      else if (! idx(i).is_colon ())
 		new_dims(i) = idx(i).max () + 1;
--- a/liboctave/ChangeLog	Tue Apr 03 16:24:54 2007 +0000
+++ b/liboctave/ChangeLog	Tue Apr 03 19:39:12 2007 +0000
@@ -1,3 +1,8 @@
+2007-04-03  John W. Eaton  <jwe@octave.org>
+
+	* Array.cc (assignN): Don't resize dimension if corresponding
+	index is empty.
+
 2007-04-02  John W. Eaton  <jwe@octave.org>
 
 	* dMatrix.h (Matrix::inverse): Reinstate versions without
--- a/src/ChangeLog	Tue Apr 03 16:24:54 2007 +0000
+++ b/src/ChangeLog	Tue Apr 03 19:39:12 2007 +0000
@@ -1,3 +1,8 @@
+2007-04-03  John W. Eaton  <jwe@octave.org>
+
+	* ov-fcn-handle.cc (make_fcn_handle): Pass ultimate parent
+	function name to lookup_function.
+
 2007-03-29  John W. Eaton  <jwe@octave.org>
 
 	* DLD-FUNCTIONS/filter.cc (filter): Fix typo in doc string.
--- a/src/ov-fcn-handle.cc	Tue Apr 03 16:24:54 2007 +0000
+++ b/src/ov-fcn-handle.cc	Tue Apr 03 19:39:12 2007 +0000
@@ -614,7 +614,17 @@
 
   octave_function *fcn = octave_call_stack::current ();
 
-  octave_value f = lookup_function (nm, fcn ? fcn->name () : std::string ());
+  std::string parent_name = fcn ? fcn->name () : std::string ();
+
+  if (! parent_name.empty ())
+    {
+      size_t pos = parent_name.find (':');
+
+      if (pos != NPOS)
+	parent_name = parent_name.substr (0, pos);
+    }
+
+  octave_value f = lookup_function (nm, parent_name);
 
   if (f.is_function ())
     retval = octave_value (new octave_fcn_handle (f, nm));