[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
nargin / argv not working as (I) expected at octave-2.1.57 startu p
From: |
John W. Eaton |
Subject: |
nargin / argv not working as (I) expected at octave-2.1.57 startu p |
Date: |
Fri, 7 May 2004 12:32:20 -0500 |
On 7-May-2004, Hall, Benjamin <address@hidden> wrote:
| I'm trying to setup some octave scripts to be called directly from the
| command line, but the nargin and argv are not working as expected. The
| following script (myargex.m, basically straight from the documentation)
|
| #########################################
| #! /usr/local/bin/octave -qf
|
| printf("Program: %s\n",program_name)
|
| nargin
|
| for kk = 1:nargin
| printf(" arg %d: %s\n",kk,argv{kk} )
| end
| #########################################
|
| works as expected in octave 2.1.50
|
| /usr/local/bin/octave-2.1.50 -qf myargex.m some args here
|
| displays all the arguments, but in 2.1.57
|
| /usr/local/bin/octave-2.1.57 -qf myargex.m some args here
|
| displays, nargin = 0, and of course none of the arguments
|
| Any thoughts on how to fix this?
Please try the following patch.
Thanks,
jwe
src/ChangeLog:
2004-05-07 John W. Eaton <address@hidden>
* octave.cc (intern_argv): Insert __nargin__ in top_level_sym_tab
instead of making it a builtin variable. Mark it static.
* ov-usr-fcn.cc (install_automatic_vars): Mark local automatic
variables static.
Index: src/octave.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/octave.cc,v
retrieving revision 1.201
diff -u -r1.201 octave.cc
--- a/src/octave.cc 10 Mar 2004 05:12:07 -0000 1.201
+++ b/src/octave.cc 7 May 2004 17:31:56 -0000
@@ -164,7 +164,11 @@
static void
intern_argv (int argc, char **argv)
{
- bind_builtin_variable ("__nargin__", argc-1, true, true, 0);
+ symbol_record *nargin_sr = top_level_sym_tab->lookup ("__nargin__", true);
+
+ nargin_sr->mark_as_static ();
+
+ nargin_sr->define (argc-1);
Cell args;
Index: src/ov-usr-fcn.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/ov-usr-fcn.cc,v
retrieving revision 1.52
diff -u -r1.52 ov-usr-fcn.cc
--- a/src/ov-usr-fcn.cc 7 Feb 2004 06:27:28 -0000 1.52
+++ b/src/ov-usr-fcn.cc 7 May 2004 17:31:56 -0000
@@ -556,8 +556,15 @@
nargin_sr = sym_tab->lookup ("__nargin__", true);
nargout_sr = sym_tab->lookup ("__nargout__", true);
+ argn_sr->mark_as_static ();
+ nargin_sr->mark_as_static ();
+ nargout_sr->mark_as_static ();
+
if (takes_varargs ())
- varargin_sr = sym_tab->lookup ("varargin", true);
+ {
+ varargin_sr = sym_tab->lookup ("varargin", true);
+ varargin_sr->mark_as_static ();
+ }
}
}
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------