Mercurial > hg > octave-nkf
changeset 506:0f388340e607
[project @ 1994-07-09 06:10:34 by jwe]
author | jwe |
---|---|
date | Sat, 09 Jul 1994 06:10:34 +0000 |
parents | f264c1454c2b |
children | 68c580e45518 |
files | src/balance.cc src/chol.cc src/colloc.cc src/dassl.cc src/det.cc src/dynamic-ld.cc src/dynamic-ld.h src/eig.cc src/expm.cc src/fft.cc src/file-io.cc src/file-io.h src/fsolve.cc src/fsqp.cc src/g-builtins.cc src/g-builtins.h src/givens.cc src/hess.cc src/ifft.cc src/inv.cc src/lpsolve.cc src/lsode.cc src/lu.cc src/npsol.cc src/pt-const.cc src/pt-const.h src/pt-exp-base.cc src/pt-exp-base.h src/qpsol.cc src/qr.cc src/quad.cc src/qzval.cc src/rand.cc src/schur.cc src/svd.cc src/syl.cc src/tc-inlines.h src/tc-rep.cc src/tc-rep.h src/variables.cc |
diffstat | 40 files changed, 830 insertions(+), 533 deletions(-) [+] |
line wrap: on
line diff
--- a/src/balance.cc +++ b/src/balance.cc @@ -43,19 +43,21 @@ #ifdef WITH_DLD Octave_object -builtin_balance_2 (const Octave_object& args, int nargin, int nargout) +builtin_balance_2 (const Octave_object& args, int nargout) { - return balance (args, nargin, nargout); + return balance (args, nargout); } #endif Octave_object -balance (const Octave_object& args, int nargin, int nargout) +balance (const Octave_object& args, int nargout) { char *bal_job; int my_nargin; // # args w/o optional string arg Octave_object retval; + int nargin = args.length (); + // determine if balancing option is listed // set my_nargin to the number of matrix inputs if (args(nargin-1).const_type () == tree_constant_rep::string_constant ){
--- a/src/chol.cc +++ b/src/chol.cc @@ -36,7 +36,7 @@ #ifdef WITH_DLD Octave_object* -builtin_chol_2 (const Octave_object& args, int nargin, int nargout) +builtin_chol_2 (const Octave_object& args, int nargout) { Octave_object retval (1); retval(0) = chol (args(1));
--- a/src/colloc.cc +++ b/src/colloc.cc @@ -34,17 +34,19 @@ #ifdef WITH_DLD Octave_object -builtin_colloc_2 (const Octave_object& args, int nargin, int nargout) +builtin_colloc_2 (const Octave_object& args, int nargout) { - return collocation_weights (args, nargin); + return collocation_weights (args); } #endif Octave_object -collocation_weights (const Octave_object& args, int nargin) +collocation_weights (const Octave_object& args) { Octave_object retval; + int nargin = args.length (); + if (args(1).const_type () != tree_constant_rep::complex_scalar_constant && args(1).const_type () != tree_constant_rep::scalar_constant) {
--- a/src/dassl.cc +++ b/src/dassl.cc @@ -42,15 +42,15 @@ #ifdef WITH_DLD Octave_object -builtin_dassl_2 (const Octave_object& args, int nargin, int nargout) +builtin_dassl_2 (const Octave_object& args, int nargout) { - return dassl (args, nargin, nargout); + return dassl (args, nargout); } Octave_object -builtin_dassl_options_2 (const Octave_object& args, int nargin, int nargout) +builtin_dassl_options_2 (const Octave_object& args, int nargout) { - return dassl_options (args, nargin, nargout); + return dassl_options (args, nargout); } #endif @@ -96,7 +96,7 @@ if (dassl_fcn != (tree_fvc *) NULL) { - Octave_object tmp = dassl_fcn->eval (0, 1, args, 4); + Octave_object tmp = dassl_fcn->eval (0, 1, args); if (error_state) { @@ -119,12 +119,14 @@ } Octave_object -dassl (const Octave_object& args, int nargin, int nargout) +dassl (const Octave_object& args, int nargout) { // Assumes that we have been given the correct number of arguments. Octave_object retval; + int nargin = args.length (); + dassl_fcn = is_valid_function (args(1), "dassl", 1); if (dassl_fcn == (tree_fvc *) NULL || takes_correct_nargs (dassl_fcn, 4, "dassl", 1) != 1) @@ -268,10 +270,12 @@ } Octave_object -dassl_options (const Octave_object& args, int nargin, int nargout) +dassl_options (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 1) print_dassl_option_list (); else if (nargin == 3)
--- a/src/det.cc +++ b/src/det.cc @@ -36,7 +36,7 @@ #ifdef WITH_DLD Octave_object -builtin_det_2 (const Octave_object& args, int nargin, int nargout) +builtin_det_2 (const Octave_object& args, int nargout) { Octave_object retval (1); retval(0) = determinant (args(1));
--- a/src/dynamic-ld.cc +++ b/src/dynamic-ld.cc @@ -40,7 +40,7 @@ void octave_dld_tc2_unlink_by_symbol (const char *name, int hard = 1) { - char *mangled_fcn_name = strconcat (name, "__FP13tree_constantii"); + char *mangled_fcn_name = strconcat (name, "__FP13tree_constanti"); int status = dld_unlink_by_symbol (mangled_fcn_name, hard); if (status != 0) dld_perror ("octave_dld_tc2_unlink_by_symbol"); @@ -117,7 +117,7 @@ octave_dld_init (); - char *mangled_fcn_name = strconcat (fcn, "__FP13tree_constantii"); + char *mangled_fcn_name = strconcat (fcn, "__FP13tree_constanti"); // See if the function has already been loaded. If not, mark it as // undefined. @@ -141,7 +141,7 @@ } Octave_object -octave_dld_tc2_and_go (const Octave_object& args, int nargin, int nargout, +octave_dld_tc2_and_go (const Octave_object& args, int nargout, const char *name, const char *fcn, const char *object) { Octave_object retval; @@ -149,7 +149,7 @@ builtin_fcn_ptr fcn_to_call = octave_dld_tc2 (name, fcn, object); if (fcn_to_call != (builtin_fcn_ptr) NULL) - retval = (*fcn_to_call) (args, nargin, nargout); + retval = (*fcn_to_call) (args, nargout); else error ("octave_dld_tc2_and_go: failed to load `%s'", name);
--- a/src/dynamic-ld.h +++ b/src/dynamic-ld.h @@ -37,7 +37,7 @@ const char *object); extern Octave_object octave_dld_tc2_and_go (const Octave_object&, - int nargin, int nargout, + int nargout, const char *name, const char *fcn, const char *object);
--- a/src/eig.cc +++ b/src/eig.cc @@ -35,14 +35,14 @@ #ifdef WITH_DLD Octave_object -builtin_eig_2 (const Octave_object& args, int nargin, int nargout) +builtin_eig_2 (const Octave_object& args, int nargout) { - return eig (args, nargin, nargout); + return eig (args, nargout); } #endif Octave_object -eig (const Octave_object& args, int nargin, int nargout) +eig (const Octave_object& args, int nargout) { Octave_object retval;
--- a/src/expm.cc +++ b/src/expm.cc @@ -44,7 +44,7 @@ #ifdef WITH_DLD Octave_object -builtin_matrix_exp_2 (const Octave_object& args, int nargin, int nargout) +builtin_matrix_exp_2 (const Octave_object& args, int nargout) { Octave_object retval (1); retval(0) = matrix_exp (args(1));
--- a/src/fft.cc +++ b/src/fft.cc @@ -36,7 +36,7 @@ #ifdef WITH_DLD Octave_object -builtin_fft_2 (const Octave_object& args, int nargin, int nargout) +builtin_fft_2 (const Octave_object& args, int nargout) { Octave_object retval (1); retval(0) = fft (args(1));
--- a/src/file-io.cc +++ b/src/file-io.cc @@ -512,10 +512,12 @@ } Octave_object -fseek_internal (const Octave_object& args, int nargin) +fseek_internal (const Octave_object& args) { Octave_object retval; + int nargin = args.length (); + Pix p = file_io_get_file (args(1), "a+", "fseek"); if (p == (Pix) NULL) @@ -606,10 +608,12 @@ static int process_printf_format (const char *s, const Octave_object& args, - ostrstream& sb, const char *type, int nargin) + ostrstream& sb, const char *type) { ostrstream fmt; + int nargin = args.length (); + fmt << "%"; // do_printf() already blew past this one... tree_constant_rep::constant_type arg_type; @@ -804,8 +808,7 @@ Octave_object -do_printf (const char *type, const Octave_object& args, int nargin, - int nargout) +do_printf (const char *type, const Octave_object& args, int nargout) { Octave_object retval; fmt_arg_count = 1; @@ -878,8 +881,7 @@ // We must be looking at a format specifier. Extract it or fail. - int status = process_printf_format (ptr, args, output_buf, type, - nargin); + int status = process_printf_format (ptr, args, output_buf, type); if (status < 0) return retval; @@ -1069,7 +1071,7 @@ } Octave_object -do_scanf (const char *type, const Octave_object& args, int nargin, int nargout) +do_scanf (const char *type, const Octave_object& args, int nargout) { Octave_object retval; char *scanf_fmt = (char *) NULL; @@ -1271,10 +1273,12 @@ * count : number of elements read */ Octave_object -fread_internal (const Octave_object& args, int nargin, int nargout) +fread_internal (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + Pix p = file_io_get_file (args(1), "r", "fread"); if (p == (Pix) NULL) @@ -1405,10 +1409,12 @@ * count : the number of elements written */ Octave_object -fwrite_internal (const Octave_object& args, int nargin, int nargout) +fwrite_internal (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + Pix p = file_io_get_file (args(1), "a+", "fwrite"); if (p == (Pix) NULL) @@ -1448,7 +1454,7 @@ * eof : non zero for an end of file condition */ Octave_object -feof_internal (const Octave_object& args, int nargin, int nargout) +feof_internal (const Octave_object& args, int nargout) { Octave_object retval; @@ -1476,7 +1482,7 @@ * errnum : error number */ Octave_object -ferror_internal (const Octave_object& args, int nargin, int nargout) +ferror_internal (const Octave_object& args, int nargout) { Octave_object retval;
--- a/src/file-io.h +++ b/src/file-io.h @@ -33,31 +33,27 @@ extern Pix return_valid_file (const tree_constant& arg); extern Octave_object fclose_internal (const Octave_object& args); -extern Octave_object feof_internal (const Octave_object& args, - int nargin, int nargout); -extern Octave_object ferror_internal (const Octave_object& args, - int nargin, int nargout); +extern Octave_object feof_internal (const Octave_object& args, int nargout); +extern Octave_object ferror_internal (const Octave_object& args, int nargout); extern Octave_object fflush_internal (const Octave_object& args); extern Octave_object fgets_internal (const Octave_object& args, int nargout); extern Octave_object fopen_internal (const Octave_object& args); -extern Octave_object fread_internal (const Octave_object& args, - int nargin, int nargout); +extern Octave_object fread_internal (const Octave_object& args, int nargout); extern Octave_object freport_internal (void); extern Octave_object frewind_internal (const Octave_object& args); -extern Octave_object fseek_internal (const Octave_object& args, int nargin); +extern Octave_object fseek_internal (const Octave_object& args); extern Octave_object ftell_internal (const Octave_object& args); -extern Octave_object fwrite_internal (const Octave_object& args, - int nargin, int nargout); +extern Octave_object fwrite_internal (const Octave_object& args, int nargout); extern void initialize_file_io (void); extern void close_files (void); extern Octave_object do_printf (const char *type, const Octave_object& args, - int nargin, int nargout); + int nargout); extern Octave_object do_scanf (const char *type, const Octave_object& args, - int nargin, int nargout); + int nargout); #endif
--- a/src/fsolve.cc +++ b/src/fsolve.cc @@ -42,15 +42,15 @@ #ifdef WITH_DLD Octave_object -builtin_fsolve_2 (const Octave_object& args, int nargin, int nargout) +builtin_fsolve_2 (const Octave_object& args, int nargout) { - return fsolve (args, nargin, nargout); + return fsolve (args, nargout); } Octave_object -builtin_fsolve_options (const Octave_object& args, int nargin, int nargout) +builtin_fsolve_options (const Octave_object& args, int nargout) { - return fsolve_options (args, nargin, nargout); + return fsolve_options (args, nargout); } #endif @@ -112,7 +112,7 @@ if (fsolve_fcn != (tree_fvc *) NULL) { - Octave_object tmp = fsolve_fcn->eval (0, 1, args, 2); + Octave_object tmp = fsolve_fcn->eval (0, 1, args); if (tmp.length () > 0 && tmp(0).is_defined ()) { retval = tmp(0).to_vector (); @@ -128,12 +128,14 @@ } Octave_object -fsolve (const Octave_object& args, int nargin, int nargout) +fsolve (const Octave_object& args, int nargout) { // Assumes that we have been given the correct number of arguments. Octave_object retval; + int nargin = args.length (); + fsolve_fcn = is_valid_function (args(1), "fsolve", 1); if (fsolve_fcn == (tree_fvc *) NULL || takes_correct_nargs (fsolve_fcn, 2, "fsolve", 1) != 1) @@ -251,10 +253,12 @@ } Octave_object -fsolve_options (const Octave_object& args, int nargin, int nargout) +fsolve_options (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 1) print_fsolve_option_list (); else if (nargin == 3)
--- a/src/fsqp.cc +++ b/src/fsqp.cc @@ -39,15 +39,15 @@ #ifdef WITH_DLD Octave_object -builtin_fsqp_2 (const Octave_object& args, int nargin, int nargout) +builtin_fsqp_2 (const Octave_object& args, int nargout) { - return fsqp (args, nargin, nargout); + return fsqp (args nargout); } Octave_object -builtin_fsqp_options_2 (const Octave_object& args, int nargin, int nargout) +builtin_fsqp_options_2 (const Octave_object& args, int nargout) { - return fsqp_options (args, nargin, nargout); + return fsqp_options (args, nargout); } #endif @@ -65,7 +65,7 @@ } Octave_object -fsqp (const Octave_object& args, int nargin, int nargout) +fsqp (const Octave_object& args, int nargout) { /* @@ -90,7 +90,7 @@ } Octave_object -fsqp_options (const Octave_object& args, int nargin, int nargout) +fsqp_options (const Octave_object& args, int nargout) { // Assumes that we have been given the correct number of arguments.
--- a/src/g-builtins.cc +++ b/src/g-builtins.cc @@ -105,13 +105,13 @@ #include "dynamic-ld.h" #define Q_STR(name) #name #define DLD_FCN(name) Q_STR (builtin_##name##_2) -#define DLD_OBJ(name) Q_STR (tc-##name##.o) -#define DLD_BUILTIN(args,n_in,n_out,name,code) \ -return octave_dld_tc2_and_go (args, n_in, n_out, Q_STR (name), \ +#define DLD_OBJ(name) Q_STR (f-##name##.o) +#define DLD_BUILTIN(args,n_out,name,code) \ +return octave_dld_tc2_and_go (args, n_out, Q_STR (name), \ DLD_FCN (name), DLD_OBJ (name)); #else -#define DLD_BUILTIN(name,args,n_in,n_out,code) code +#define DLD_BUILTIN(name,args,n_out,code) code #endif // Non-zero means that pwd always give verbatim directory, regardless @@ -122,15 +122,17 @@ * Are all elements of a constant nonzero? */ Octave_object -builtin_all (const Octave_object& args, int nargin, int nargout) +builtin_all (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("all"); else { - if (args.length () > 0 && args(1).is_defined ()) + if (nargin > 0 && args(1).is_defined ()) { retval.resize (1); retval(0) = args(1).all (); @@ -144,15 +146,17 @@ * Are any elements of a constant nonzero? */ Octave_object -builtin_any (const Octave_object& args, int nargin, int nargout) +builtin_any (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("any"); else { - if (args.length () > 0 && args(1).is_defined ()) + if (nargin > 0 && args(1).is_defined ()) { retval.resize (1); retval(0) = args(1).any (); @@ -166,16 +170,18 @@ * Balancing for eigenvalue problems */ Octave_object -builtin_balance (const Octave_object& args, int nargin, int nargout) +builtin_balance (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin <= 1 || nargin > 4 || nargout < 0 || nargout > 4) print_usage ("balance"); else { - DLD_BUILTIN (args, nargin, nargout, balance, - retval = balance (args, nargin, nargout)); + DLD_BUILTIN (args, nargout, balance, + retval = balance (args, nargout)); } return retval; @@ -185,12 +191,14 @@ * Cholesky factorization. */ Octave_object -builtin_chol (const Octave_object& args, int nargin, int nargout) +builtin_chol (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2 && (nargout == 0 || nargout == 1)) - DLD_BUILTIN (args, nargin, nargout, chol, + DLD_BUILTIN (args, nargout, chol, { retval.resize (1); retval(0) = chol (args(1)); @@ -205,7 +213,7 @@ * Clear the screen? */ Octave_object -builtin_clc (const Octave_object& args, int nargin, int nargout) +builtin_clc (const Octave_object& args, int nargout) { Octave_object retval; @@ -230,7 +238,7 @@ * Time in a vector. */ Octave_object -builtin_clock (const Octave_object& args, int nargin, int nargout) +builtin_clock (const Octave_object& args, int nargout) { Octave_object retval; @@ -258,7 +266,7 @@ * Close the stream to the plotter. */ Octave_object -builtin_closeplot (const Octave_object& args, int nargin, int nargout) +builtin_closeplot (const Octave_object& args, int nargout) { Octave_object retval; close_plot_stream (); @@ -269,15 +277,17 @@ * Collocation roots and weights. */ Octave_object -builtin_colloc (const Octave_object& args, int nargin, int nargout) +builtin_colloc (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin < 2 || nargin > 4) print_usage ("colloc"); else - DLD_BUILTIN (args, nargin, nargout, colloc, - retval = collocation_weights (args, nargin);) + DLD_BUILTIN (args, nargout, colloc, + retval = collocation_weights (args);) return retval; } @@ -286,15 +296,17 @@ * Cumulative sums and products. */ Octave_object -builtin_cumprod (const Octave_object& args, int nargin, int nargout) +builtin_cumprod (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("cumprod"); else { - if (args.length () > 0 && args(1).is_defined ()) + if (nargin > 0 && args(1).is_defined ()) { retval.resize (1); retval(0) = args(1).cumprod (); @@ -305,15 +317,17 @@ } Octave_object -builtin_cumsum (const Octave_object& args, int nargin, int nargout) +builtin_cumsum (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("cumsum"); else { - if (args.length () > 0 && args(1).is_defined ()) + if (nargin > 0 && args(1).is_defined ()) { retval.resize (1); retval(0) = args(1).cumsum (); @@ -327,13 +341,15 @@ * DAEs. */ Octave_object -builtin_dassl (const Octave_object& args, int nargin, int nargout) +builtin_dassl (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if ((nargin == 5 || nargin == 6) && nargout >= 0) - DLD_BUILTIN (args, nargin, nargout, dassl, - retval = dassl (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, dassl, + retval = dassl (args, nargout);) else print_usage ("dassl"); @@ -341,12 +357,12 @@ } Octave_object -builtin_dassl_options (const Octave_object& args, int nargin, int nargout) +builtin_dassl_options (const Octave_object& args, int nargout) { Octave_object retval; - DLD_BUILTIN (args, nargin, nargout, dassl_options, - retval = dassl_options (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, dassl_options, + retval = dassl_options (args, nargout);) return retval; } @@ -355,7 +371,7 @@ * Time in a string. */ Octave_object -builtin_date (const Octave_object& args, int nargin, int nargout) +builtin_date (const Octave_object& args, int nargout) { Octave_object retval; @@ -379,12 +395,14 @@ * Determinant of a matrix. */ Octave_object -builtin_det (const Octave_object& args, int nargin, int nargout) +builtin_det (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2) - DLD_BUILTIN (args, nargin, nargout, det, + DLD_BUILTIN (args, nargout, det, { retval.resize (1); retval(0) = determinant (args(1)); @@ -399,10 +417,12 @@ * Diagonal elements of a matrix. */ Octave_object -builtin_diag (const Octave_object& args, int nargin, int nargout) +builtin_diag (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2) { retval.resize (1); @@ -423,10 +443,12 @@ * Display value without trimmings. */ Octave_object -builtin_disp (const Octave_object& args, int nargin, int nargout) +builtin_disp (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2) args(1).eval (1); else @@ -439,13 +461,15 @@ * Compute eigenvalues and eigenvectors. */ Octave_object -builtin_eig (const Octave_object& args, int nargin, int nargout) +builtin_eig (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2 && (nargout == 0 || nargout == 1 || nargout == 2)) - DLD_BUILTIN (args, nargin, nargout, eig, - retval = eig (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, eig, + retval = eig (args, nargout);) else print_usage ("eig"); @@ -458,13 +482,15 @@ * messages as we go. */ Octave_object -builtin_error (const Octave_object& args, int nargin, int nargout) +builtin_error (const Octave_object& args, int nargout) { Octave_object retval; char *msg = "unspecified_error"; - if (nargin == 2 && args.length () > 0 && args(1).is_defined ()) + int nargin = args.length (); + + if (nargin == 2 && args(1).is_defined ()) { if (args(1).is_string_type ()) { @@ -488,10 +514,12 @@ * Evaluate text argument as octave source. */ Octave_object -builtin_eval (const Octave_object& args, int nargin, int nargout) +builtin_eval (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2) { int parse_status = 0; @@ -508,10 +536,12 @@ * Check if variable or file exists. */ Octave_object -builtin_exist (const Octave_object& args, int nargin, int nargout) +builtin_exist (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2 && args(1).is_string_type ()) { int status = identifier_exists (args(1).string_value ()); @@ -528,12 +558,14 @@ * Matrix exponential. */ Octave_object -builtin_expm (const Octave_object& args, int nargin, int nargout) +builtin_expm (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2) - DLD_BUILTIN (args, nargin, nargout, matrix_exp, + DLD_BUILTIN (args, nargout, matrix_exp, { retval.resize (1); retval(0) = matrix_exp (args(1)); @@ -548,10 +580,12 @@ * Identity matrix. */ Octave_object -builtin_eye (const Octave_object& args, int nargin, int nargout) +builtin_eye (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + switch (nargin) { case 2: @@ -574,10 +608,12 @@ * Closing a file */ Octave_object -builtin_fclose (const Octave_object& args, int nargin, int nargout) +builtin_fclose (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("fclose"); else @@ -590,14 +626,16 @@ * Check file for EOF condition. */ Octave_object -builtin_feof (const Octave_object& args, int nargin, int nargout) +builtin_feof (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("feof"); else - retval = feof_internal (args, nargin, nargout); + retval = feof_internal (args, nargout); return retval; } @@ -606,14 +644,16 @@ * Check file for error condition. */ Octave_object -builtin_ferror (const Octave_object& args, int nargin, int nargout) +builtin_ferror (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("ferror"); else - retval = ferror_internal (args, nargin, nargout); + retval = ferror_internal (args, nargout); return retval; } @@ -622,12 +662,14 @@ * Evaluate first argument as a function. */ Octave_object -builtin_feval (const Octave_object& args, int nargin, int nargout) +builtin_feval (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin > 1) - retval = feval (args, nargin, nargout); + retval = feval (args, nargout); else print_usage ("feval"); @@ -638,10 +680,12 @@ * Flushing output to a file. */ Octave_object -builtin_fflush (const Octave_object& args, int nargin, int nargout) +builtin_fflush (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("fflush"); else @@ -654,12 +698,14 @@ * Fast Fourier Transform. */ Octave_object -builtin_fft (const Octave_object& args, int nargin, int nargout) +builtin_fft (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2) - DLD_BUILTIN (args, nargin, nargout, fft, + DLD_BUILTIN (args, nargout, fft, { retval.resize (1); retval(0) = fft (args(1)); @@ -674,10 +720,12 @@ * Get a string from a file. */ Octave_object -builtin_fgets (const Octave_object& args, int nargin, int nargout) +builtin_fgets (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 3) print_usage ("fgets"); else @@ -691,10 +739,12 @@ * do_fortran_indexing is true... */ Octave_object -builtin_find (const Octave_object& args, int nargin, int nargout) +builtin_find (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2) { retval.resize (1); @@ -710,10 +760,12 @@ * Don\'t really count floating point operations. */ Octave_object -builtin_flops (const Octave_object& args, int nargin, int nargout) +builtin_flops (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin > 2) print_usage ("flops"); @@ -729,10 +781,12 @@ * Opening a file. */ Octave_object -builtin_fopen (const Octave_object& args, int nargin, int nargout) +builtin_fopen (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 3) print_usage ("fopen"); else @@ -745,14 +799,16 @@ * Formatted printing to a file. */ Octave_object -builtin_fprintf (const Octave_object& args, int nargin, int nargout) +builtin_fprintf (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin < 3) print_usage ("fprintf"); else - retval = do_printf ("fprintf", args, nargin, nargout); + retval = do_printf ("fprintf", args, nargout); return retval; } @@ -761,14 +817,16 @@ * Read binary data from a file. */ Octave_object -builtin_fread (const Octave_object& args, int nargin, int nargout) +builtin_fread (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin < 2 || nargin > 4) print_usage ("fread"); else - retval = fread_internal (args, nargin, nargout); + retval = fread_internal (args, nargout); return retval; } @@ -777,10 +835,12 @@ * Rewind a file. */ Octave_object -builtin_frewind (const Octave_object& args, int nargin, int nargout) +builtin_frewind (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("frewind"); else @@ -793,10 +853,12 @@ * Report on open files. */ Octave_object -builtin_freport (const Octave_object& args, int nargin, int nargout) +builtin_freport (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin > 1) warning ("freport: ignoring extra arguments"); @@ -809,14 +871,16 @@ * Formatted reading from a file. */ Octave_object -builtin_fscanf (const Octave_object& args, int nargin, int nargout) +builtin_fscanf (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2 && nargin != 3) print_usage ("fscanf"); else - retval = do_scanf ("fscanf", args, nargin, nargout); + retval = do_scanf ("fscanf", args, nargout); return retval; } @@ -825,14 +889,16 @@ * Seek a point in a file for reading and/or writing. */ Octave_object -builtin_fseek (const Octave_object& args, int nargin, int nargout) +builtin_fseek (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 3 && nargin != 4) print_usage ("fseek"); else - retval = fseek_internal (args, nargin); + retval = fseek_internal (args); return retval; } @@ -841,13 +907,15 @@ * Nonlinear algebraic equations. */ Octave_object -builtin_fsolve (const Octave_object& args, int nargin, int nargout) +builtin_fsolve (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin >= 3 && nargin <= 7 && nargout >= 0 && nargout <= 3) - DLD_BUILTIN (args, nargin, nargout, fsolve, - retval = fsolve (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, fsolve, + retval = fsolve (args, nargout);) else print_usage ("fsolve"); @@ -855,12 +923,12 @@ } Octave_object -builtin_fsolve_options (const Octave_object& args, int nargin, int nargout) +builtin_fsolve_options (const Octave_object& args, int nargout) { Octave_object retval; - DLD_BUILTIN (args, nargin, nargout, fsolve_options, - retval = fsolve_options (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, fsolve_options, + retval = fsolve_options (args, nargout);) return retval; } @@ -869,18 +937,20 @@ * NLPs. */ Octave_object -builtin_fsqp (const Octave_object& args, int nargin, int nargout) +builtin_fsqp (const Octave_object& args, int nargout) { Octave_object retval; #if defined (FSQP_MISSING) print_usage ("fsqp"); #else + int nargin = args.length (); + if ((nargin == 3 || nargin == 5 || nargin == 6 || nargin == 8 || nargin == 9 || nargin == 11) && (nargout >= 0 && nargout <= 3)) - DLD_BUILTIN (args, nargin, nargout, fsqp, - retval = fsqp (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, fsqp, + retval = fsqp (args, nargout);) else print_usage ("fsolve"); #endif @@ -889,15 +959,15 @@ } Octave_object -builtin_fsqp_options (const Octave_object& args, int nargin, int nargout) +builtin_fsqp_options (const Octave_object& args, int nargout) { Octave_object retval; #if defined (FSQP_MISSING) print_usage ("fsqp_options"); #else - DLD_BUILTIN (args, nargin, nargout, fsqp_options, - retval = fsqp_options (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, fsqp_options, + retval = fsqp_options (args, nargout);) #endif return retval; @@ -907,10 +977,12 @@ * Tell current position of file. */ Octave_object -builtin_ftell (const Octave_object& args, int nargin, int nargout) +builtin_ftell (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("ftell"); else @@ -923,14 +995,16 @@ * Write binary data to a file. */ Octave_object -builtin_fwrite (const Octave_object& args, int nargin, int nargout) +builtin_fwrite (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin < 3 || nargin > 4) print_usage ("fwrite"); else - retval = fwrite_internal (args, nargin, nargout); + retval = fwrite_internal (args, nargout); return retval; } @@ -939,10 +1013,12 @@ * Get the value of an environment variable. */ Octave_object -builtin_getenv (const Octave_object& args, int nargin, int nargout) +builtin_getenv (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2 && args(1).is_string_type ()) { retval.resize (1); @@ -962,12 +1038,14 @@ * Inverse Fast Fourier Transform. */ Octave_object -builtin_ifft (const Octave_object& args, int nargin, int nargout) +builtin_ifft (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2) - DLD_BUILTIN (args, nargin, nargout, ifft, + DLD_BUILTIN (args, nargout, ifft, { retval.resize (1); retval(0) = ifft (args(1)); @@ -982,12 +1060,14 @@ * Inverse of a square matrix. */ Octave_object -builtin_inv (const Octave_object& args, int nargin, int nargout) +builtin_inv (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2) - DLD_BUILTIN (args, nargin, nargout, inv, + DLD_BUILTIN (args, nargout, inv, { retval.resize (1); retval(0) = inverse (args(1)); @@ -1002,14 +1082,16 @@ * Prompt user for input. */ Octave_object -builtin_input (const Octave_object& args, int nargin, int nargout) +builtin_input (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2 || nargin == 3) { retval.resize (1); - retval(0) = get_user_input (args, nargin, nargout); + retval(0) = get_user_input (args, nargout); } else print_usage ("input"); @@ -1021,11 +1103,13 @@ * Does the given string name a global variable? */ Octave_object -builtin_is_global (const Octave_object& args, int nargin, int nargout) +builtin_is_global (const Octave_object& args, int nargout) { Octave_object retval(1); retval(0) = tree_constant (0.0); + int nargin = args.length (); + if (nargin == 2 && args(1).is_string_type ()) { char *name = args(1).string_value (); @@ -1042,15 +1126,17 @@ * Is the argument a string? */ Octave_object -builtin_isstr (const Octave_object& args, int nargin, int nargout) +builtin_isstr (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("isstr"); else { - if (args.length () > 0 && args(1).is_defined ()) + if (nargin > 0 && args(1).is_defined ()) { retval.resize (1); retval(0) = args(1).isstr (); @@ -1061,7 +1147,7 @@ } Octave_object -builtin_kbhit (const Octave_object& args, int nargin, int nargout) +builtin_kbhit (const Octave_object& args, int nargout) { Octave_object retval; @@ -1084,14 +1170,16 @@ * Maybe help in debugging. */ Octave_object -builtin_keyboard (const Octave_object& args, int nargin, int nargout) +builtin_keyboard (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 1 || nargin == 2) { retval.resize (1); - retval(0) = get_user_input (args, nargin, nargout, 1); + retval(0) = get_user_input (args, nargout, 1); } else print_usage ("keyboard"); @@ -1103,10 +1191,12 @@ * Matrix logarithm. */ Octave_object -builtin_logm (const Octave_object& args, int nargin, int nargout) +builtin_logm (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2) retval = matrix_log (args(1)); else @@ -1119,7 +1209,7 @@ * LPs. */ Octave_object -builtin_lpsolve (const Octave_object& args, int nargin, int nargout) +builtin_lpsolve (const Octave_object& args, int nargout) { Octave_object retval; @@ -1130,9 +1220,11 @@ retval(1) = tree_constant (m); retval(2) = tree_constant (-1.0); + int nargin = args.length (); + if (nargin == 0) - DLD_BUILTIN (args, nargin, nargout, lpsolve, - retval = lpsolve (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, lpsolve, + retval = lpsolve (args, nargout);) else print_usage ("lp_solve"); @@ -1140,12 +1232,12 @@ } Octave_object -builtin_lpsolve_options (const Octave_object& args, int nargin, int nargout) +builtin_lpsolve_options (const Octave_object& args, int nargout) { Octave_object retval; - DLD_BUILTIN (args, nargin, nargout, lpsolve_options, - retval = lpsolve_options (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, lpsolve_options, + retval = lpsolve_options (args, nargout);) return retval; } @@ -1154,13 +1246,15 @@ * ODEs. */ Octave_object -builtin_lsode (const Octave_object& args, int nargin, int nargout) +builtin_lsode (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if ((nargin == 4 || nargin == 5) && (nargout == 0 || nargout == 1)) - DLD_BUILTIN (args, nargin, nargout, lsode, - retval = lsode (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, lsode, + retval = lsode (args, nargout);) else print_usage ("lsode"); @@ -1168,12 +1262,12 @@ } Octave_object -builtin_lsode_options (const Octave_object& args, int nargin, int nargout) +builtin_lsode_options (const Octave_object& args, int nargout) { Octave_object retval; - DLD_BUILTIN (args, nargin, nargout, lsode_options, - retval = lsode_options (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, lsode_options, + retval = lsode_options (args, nargout);) return retval; } @@ -1182,12 +1276,14 @@ * LU factorization. */ Octave_object -builtin_lu (const Octave_object& args, int nargin, int nargout) +builtin_lu (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2 && nargout < 4) - DLD_BUILTIN (args, nargin, nargout, lu, + DLD_BUILTIN (args, nargout, lu, retval = lu (args(1), nargout);) else print_usage ("lu"); @@ -1199,13 +1295,15 @@ * Max values. */ Octave_object -builtin_max (const Octave_object& args, int nargin, int nargout) +builtin_max (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if ((nargin == 2 && (nargout == 0 || nargout == 1 || nargout == 2)) || (nargin == 3 && (nargout == 0 || nargout == 1))) - retval = column_max (args, nargin, nargout); + retval = column_max (args, nargout); else print_usage ("max"); @@ -1216,13 +1314,15 @@ * Min values. */ Octave_object -builtin_min (const Octave_object& args, int nargin, int nargout) +builtin_min (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if ((nargin == 2 && (nargout == 0 || nargout == 1 || nargout == 2)) || (nargin == 3 && (nargout == 0 || nargout == 1))) - retval = column_min (args, nargin, nargout); + retval = column_min (args, nargout); else print_usage ("min"); @@ -1233,7 +1333,7 @@ * NLPs. */ Octave_object -builtin_npsol (const Octave_object& args, int nargin, int nargout) +builtin_npsol (const Octave_object& args, int nargout) { Octave_object retval; @@ -1247,11 +1347,13 @@ retval(3) = tree_constant (m); print_usage ("npsol"); #else + int nargin = args.length (); + if ((nargin == 3 || nargin == 5 || nargin == 6 || nargin == 8 || nargin == 9 || nargin == 11) && (nargout >= 0 && nargout <= 4)) - DLD_BUILTIN (args, nargin, nargout, npsol, - retval = npsol (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, npsol, + retval = npsol (args, nargout);) else print_usage ("npsol"); #endif @@ -1260,15 +1362,15 @@ } Octave_object -builtin_npsol_options (const Octave_object& args, int nargin, int nargout) +builtin_npsol_options (const Octave_object& args, int nargout) { Octave_object retval; #if defined (NPSOL_MISSING) print_usage ("npsol_options"); #else - DLD_BUILTIN (args, nargin, nargout, npsol_options, - retval = npsol_options (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, npsol_options, + retval = npsol_options (args, nargout);) #endif return retval; @@ -1278,10 +1380,12 @@ * A matrix of ones. */ Octave_object -builtin_ones (const Octave_object& args, int nargin, int nargout) +builtin_ones (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + switch (nargin) { case 2: @@ -1304,10 +1408,12 @@ * You guessed it. */ Octave_object -builtin_pause (const Octave_object& args, int nargin, int nargout) +builtin_pause (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (! (nargin == 1 || nargin == 2)) { print_usage ("pause"); @@ -1341,7 +1447,7 @@ * Delete turds from /tmp. */ Octave_object -builtin_purge_tmp_files (const Octave_object& , int, int) +builtin_purge_tmp_files (const Octave_object& args, int nargout) { Octave_object retval; cleanup_tmp_files (); @@ -1352,14 +1458,16 @@ * Formatted printing. */ Octave_object -builtin_printf (const Octave_object& args, int nargin, int nargout) +builtin_printf (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin < 2) print_usage ("printf"); else - retval = do_printf ("printf", args, nargin, nargout); + retval = do_printf ("printf", args, nargout); return retval; } @@ -1368,15 +1476,17 @@ * Product. */ Octave_object -builtin_prod (const Octave_object& args, int nargin, int nargout) +builtin_prod (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("prod"); else { - if (args.length () > 0 && args(1).is_defined ()) + if (nargin > 0 && args(1).is_defined ()) { retval.resize (1); retval(0) = args(1).prod (); @@ -1390,7 +1500,7 @@ * Print name of current working directory. */ Octave_object -builtin_pwd (const Octave_object& args, int nargin, int nargout) +builtin_pwd (const Octave_object& args, int nargout) { Octave_object retval; char *directory; @@ -1425,7 +1535,7 @@ * QPs. */ Octave_object -builtin_qpsol (const Octave_object& args, int nargin, int nargout) +builtin_qpsol (const Octave_object& args, int nargout) { Octave_object retval; @@ -1439,10 +1549,12 @@ retval(3) = tree_constant (m); print_usage ("qpsol"); #else + int nargin = args.length (); + if ((nargin == 4 || nargin == 6 || nargin == 7 || nargin == 9) && (nargout >= 0 && nargout <= 4)) - DLD_BUILTIN (args, nargin, nargout, qpsol, - retval = qpsol (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, qpsol, + retval = qpsol (args, nargout);) else print_usage ("qpsol"); #endif @@ -1451,15 +1563,15 @@ } Octave_object -builtin_qpsol_options (const Octave_object& args, int nargin, int nargout) +builtin_qpsol_options (const Octave_object& args, int nargout) { Octave_object retval; #if defined (QPSOL_MISSING) print_usage ("qpsol"); #else - DLD_BUILTIN (args, nargin, nargout, qpsol_options, - retval = qpsol_options (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, qpsol_options, + retval = qpsol_options (args, nargout);) #endif return retval; @@ -1469,12 +1581,14 @@ * QR factorization. */ Octave_object -builtin_qr (const Octave_object& args, int nargin, int nargout) +builtin_qr (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2 && nargout < 3) - DLD_BUILTIN (args, nargin, nargout, qr, + DLD_BUILTIN (args, nargout, qr, retval = qr (args(1), nargout);) else print_usage ("qr"); @@ -1486,13 +1600,15 @@ * generalized eigenvalues via qz */ Octave_object -builtin_qzval (const Octave_object& args, int nargin, int nargout) +builtin_qzval (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 3 && nargout < 2) - DLD_BUILTIN (args, nargin, nargout, qzvalue, - retval = qzvalue (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, qzvalue, + retval = qzvalue (args, nargout);) else print_usage ("qzval"); @@ -1503,13 +1619,15 @@ * Random numbers. */ Octave_object -builtin_quad (const Octave_object& args, int nargin, int nargout) +builtin_quad (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if ((nargin > 3 && nargin < 7) && (nargout >= 0 && nargout < 5)) - DLD_BUILTIN (args, nargin, nargout, quad, - retval = do_quad (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, quad, + retval = do_quad (args, nargout);) else print_usage ("quad"); @@ -1517,12 +1635,12 @@ } Octave_object -builtin_quad_options (const Octave_object& args, int nargin, int nargout) +builtin_quad_options (const Octave_object& args, int nargout) { Octave_object retval; - DLD_BUILTIN (args, nargin, nargout, quad_options, - retval = quad_options (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, quad_options, + retval = quad_options (args, nargout);) return retval; } @@ -1531,7 +1649,7 @@ * I'm outta here. */ Octave_object -builtin_quit (const Octave_object& args, int nargin, int nargout) +builtin_quit (const Octave_object& args, int nargout) { Octave_object retval; quitting_gracefully = 1; @@ -1543,13 +1661,15 @@ * Random numbers. */ Octave_object -builtin_rand (const Octave_object& args, int nargin, int nargout) +builtin_rand (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if ((nargin > 0 && nargin < 4) && (nargout == 0 || nargout == 1)) - DLD_BUILTIN (args, nargin, nargout, rand, - retval = rand_internal (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, rand, + retval = rand_internal (args, nargout);) else print_usage ("rand"); @@ -1560,14 +1680,16 @@ * Formatted reading. */ Octave_object -builtin_scanf (const Octave_object& args, int nargin, int nargout) +builtin_scanf (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("scanf"); else - retval = do_scanf ("scanf", args, nargin, nargout); + retval = do_scanf ("scanf", args, nargout); return retval; } @@ -1576,10 +1698,12 @@ * Convert a vector to a string. */ Octave_object -builtin_setstr (const Octave_object& args, int nargin, int nargout) +builtin_setstr (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2) { retval.resize (1); @@ -1595,10 +1719,12 @@ * Execute a shell command. */ Octave_object -builtin_shell_command (const Octave_object& args, int nargin, int nargout) +builtin_shell_command (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2 && args(1).is_string_type ()) { iprocstream cmd (args(1).string_value ()); @@ -1633,15 +1759,17 @@ * Report rows and columns. */ Octave_object -builtin_size (const Octave_object& args, int nargin, int nargout) +builtin_size (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("size"); else { - if (args.length () > 0 && args(1).is_defined ()) + if (nargin > 0 && args(1).is_defined ()) { int nr = args(1).rows (); int nc = args(1).columns (); @@ -1671,12 +1799,14 @@ * Sort columns. */ Octave_object -builtin_sort (const Octave_object& args, int nargin, int nargout) +builtin_sort (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2) - retval = sort (args, nargin, nargout); + retval = sort (args, nargout); else print_usage ("sort"); @@ -1687,14 +1817,16 @@ * Formatted printing to a string. */ Octave_object -builtin_sprintf (const Octave_object& args, int nargin, int nargout) +builtin_sprintf (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin < 2) print_usage ("sprintf"); else - retval = do_printf ("sprintf", args, nargin, nargout); + retval = do_printf ("sprintf", args, nargout); return retval; } @@ -1703,10 +1835,12 @@ * Matrix sqrt. */ Octave_object -builtin_sqrtm (const Octave_object& args, int nargin, int nargout) +builtin_sqrtm (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2) retval = matrix_sqrt (args(1)); else @@ -1719,14 +1853,16 @@ * Formatted reading from a string. */ Octave_object -builtin_sscanf (const Octave_object& args, int nargin, int nargout) +builtin_sscanf (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 3) print_usage ("sscanf"); else - retval = do_scanf ("sscanf", args, nargin, nargout); + retval = do_scanf ("sscanf", args, nargout); return retval; } @@ -1735,15 +1871,17 @@ * Sum. */ Octave_object -builtin_sum (const Octave_object& args, int nargin, int nargout) +builtin_sum (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("sum"); else { - if (args.length () > 0 && args(1).is_defined ()) + if (nargin > 0 && args(1).is_defined ()) { retval.resize (1); retval(0) = args(1).sum (); @@ -1757,15 +1895,17 @@ * Sum of squares. */ Octave_object -builtin_sumsq (const Octave_object& args, int nargin, int nargout) +builtin_sumsq (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin != 2) print_usage ("sumsq"); else { - if (args.length () > 0 && args(1).is_defined ()) + if (nargin > 0 && args(1).is_defined ()) { retval.resize (1); retval(0) = args(1).sumsq (); @@ -1779,13 +1919,15 @@ * Singluar value decomposition. */ Octave_object -builtin_svd (const Octave_object& args, int nargin, int nargout) +builtin_svd (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2 && (nargout == 0 || nargout == 1 || nargout == 3)) - DLD_BUILTIN (args, nargin, nargout, svd, - retval = svd (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, svd, + retval = svd (args, nargout);) else print_usage ("svd"); @@ -1796,13 +1938,15 @@ * Sylvester equation solver. */ Octave_object -builtin_syl (const Octave_object& args, int nargin, int nargout) +builtin_syl (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if ((nargin == 4) && (nargout == 0 || nargout == 1)) - DLD_BUILTIN (args, nargin, nargout, syl, - retval = syl (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, syl, + retval = syl (args, nargout);) else print_usage ("syl"); @@ -1813,14 +1957,16 @@ * Schur Decomposition. */ Octave_object -builtin_schur (const Octave_object& args, int nargin, int nargout) +builtin_schur (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if ((nargin == 3 || nargin == 2) && (nargout == 0 || nargout == 1 || nargout == 2)) - DLD_BUILTIN (args, nargin, nargout, schur, - retval = schur (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, schur, + retval = schur (args, nargout);) else print_usage ("schur"); @@ -1831,12 +1977,14 @@ * Givens rotation. */ Octave_object -builtin_givens (const Octave_object& args, int nargin, int nargout) +builtin_givens (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 3 && (nargout == 0 || nargout == 1 || nargout == 2 )) - retval = givens (args, nargin, nargout); + retval = givens (args, nargout); else print_usage ("givens"); @@ -1847,13 +1995,15 @@ * Hessenberg Decomposition. */ Octave_object -builtin_hess (const Octave_object& args, int nargin, int nargout) +builtin_hess (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 2 && (nargout == 0 || nargout == 1 || nargout == 2)) - DLD_BUILTIN (args, nargin, nargout, hess, - retval = hess (args, nargin, nargout);) + DLD_BUILTIN (args, nargout, hess, + retval = hess (args, nargout);) else print_usage ("hess"); @@ -1864,9 +2014,12 @@ * Variable argument lists. */ Octave_object -builtin_va_arg (const Octave_object& args, int nargin, int nargout) +builtin_va_arg (const Octave_object& args, int nargout) { Octave_object retval; + + int nargin = args.length (); + if (nargin == 1) { if (curr_function != (tree_function *) NULL) @@ -1892,9 +2045,12 @@ } Octave_object -builtin_va_start (const Octave_object& args, int nargin, int nargout) +builtin_va_start (const Octave_object& args, int nargout) { Octave_object retval; + + int nargin = args.length (); + if (nargin == 1) { if (curr_function != (tree_function *) NULL) @@ -1920,7 +2076,7 @@ * Copying information. */ Octave_object -builtin_warranty (const Octave_object& args, int nargin, int nargout) +builtin_warranty (const Octave_object& args, int nargout) { Octave_object retval; @@ -1950,10 +2106,12 @@ * A matrix of zeros. */ Octave_object -builtin_zeros (const Octave_object& args, int nargin, int nargout) +builtin_zeros (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + switch (nargin) { case 2:
--- a/src/g-builtins.h +++ b/src/g-builtins.h @@ -35,101 +35,207 @@ char *help_string; }; -extern Octave_object builtin_all (const Octave_object&, int, int); -extern Octave_object builtin_any (const Octave_object&, int, int); -extern Octave_object builtin_balance (const Octave_object&, int, int); -extern Octave_object builtin_chol (const Octave_object&, int, int); -extern Octave_object builtin_clc (const Octave_object&, int, int); -extern Octave_object builtin_clock (const Octave_object&, int, int); -extern Octave_object builtin_closeplot (const Octave_object&, int, int); -extern Octave_object builtin_colloc (const Octave_object&, int, int); -extern Octave_object builtin_cumprod (const Octave_object&, int, int); -extern Octave_object builtin_cumsum (const Octave_object&, int, int); -extern Octave_object builtin_dassl (const Octave_object&, int, int); -extern Octave_object builtin_dassl_options (const Octave_object&, int, int); -extern Octave_object builtin_date (const Octave_object&, int, int); -extern Octave_object builtin_det (const Octave_object&, int, int); -extern Octave_object builtin_diag (const Octave_object&, int, int); -extern Octave_object builtin_disp (const Octave_object&, int, int); -extern Octave_object builtin_eig (const Octave_object&, int, int); -extern Octave_object builtin_error (const Octave_object&, int, int); -extern Octave_object builtin_eval (const Octave_object&, int, int); -extern Octave_object builtin_exist (const Octave_object&, int, int); -extern Octave_object builtin_expm (const Octave_object&, int, int); -extern Octave_object builtin_eye (const Octave_object&, int, int); -extern Octave_object builtin_fclose (const Octave_object&, int, int); -extern Octave_object builtin_feof (const Octave_object&, int, int); -extern Octave_object builtin_ferror (const Octave_object&, int, int); -extern Octave_object builtin_feval (const Octave_object&, int, int); -extern Octave_object builtin_fflush (const Octave_object&, int, int); -extern Octave_object builtin_fft (const Octave_object&, int, int); -extern Octave_object builtin_fgets (const Octave_object&, int, int); -extern Octave_object builtin_find (const Octave_object&, int, int); -extern Octave_object builtin_flops (const Octave_object&, int, int); -extern Octave_object builtin_fopen (const Octave_object&, int, int); -extern Octave_object builtin_fprintf (const Octave_object&, int, int); -extern Octave_object builtin_fread (const Octave_object&, int, int); -extern Octave_object builtin_frewind (const Octave_object&, int, int); -extern Octave_object builtin_freport (const Octave_object&, int, int); -extern Octave_object builtin_fscanf (const Octave_object&, int, int); -extern Octave_object builtin_fseek (const Octave_object&, int, int); -extern Octave_object builtin_fsolve (const Octave_object&, int, int); -extern Octave_object builtin_fsolve_options (const Octave_object&, int, int); -extern Octave_object builtin_fsqp (const Octave_object&, int, int); -extern Octave_object builtin_fsqp_options (const Octave_object&, int, int); -extern Octave_object builtin_ftell (const Octave_object&, int, int); -extern Octave_object builtin_fwrite (const Octave_object&, int, int); -extern Octave_object builtin_getenv (const Octave_object&, int, int); -extern Octave_object builtin_givens (const Octave_object&, int, int); -extern Octave_object builtin_hess (const Octave_object&, int, int); -extern Octave_object builtin_input (const Octave_object&, int, int); -extern Octave_object builtin_ifft (const Octave_object&, int, int); -extern Octave_object builtin_inv (const Octave_object&, int, int); -extern Octave_object builtin_is_global (const Octave_object&, int, int); -extern Octave_object builtin_isstr (const Octave_object&, int, int); -extern Octave_object builtin_kbhit (const Octave_object&, int, int); -extern Octave_object builtin_keyboard (const Octave_object&, int, int); -extern Octave_object builtin_logm (const Octave_object&, int, int); -extern Octave_object builtin_lpsolve (const Octave_object&, int, int); -extern Octave_object builtin_lpsolve_options (const Octave_object&, int, int); -extern Octave_object builtin_lsode (const Octave_object&, int, int); -extern Octave_object builtin_lsode_options (const Octave_object&, int, int); -extern Octave_object builtin_lu (const Octave_object&, int, int); -extern Octave_object builtin_max (const Octave_object&, int, int); -extern Octave_object builtin_min (const Octave_object&, int, int); -extern Octave_object builtin_npsol (const Octave_object&, int, int); -extern Octave_object builtin_npsol_options (const Octave_object&, int, int); -extern Octave_object builtin_ones (const Octave_object&, int, int); -extern Octave_object builtin_pause (const Octave_object&, int, int); -extern Octave_object builtin_purge_tmp_files (const Octave_object&, int, int); -extern Octave_object builtin_printf (const Octave_object&, int, int); -extern Octave_object builtin_prod (const Octave_object&, int, int); -extern Octave_object builtin_pwd (const Octave_object&, int, int); -extern Octave_object builtin_qpsol (const Octave_object&, int, int); -extern Octave_object builtin_qpsol_options (const Octave_object&, int, int); -extern Octave_object builtin_qr (const Octave_object&, int, int); -extern Octave_object builtin_quad (const Octave_object&, int, int); -extern Octave_object builtin_quad_options (const Octave_object&, int, int); -extern Octave_object builtin_quit (const Octave_object&, int, int); -extern Octave_object builtin_qzval (const Octave_object&, int, int); -extern Octave_object builtin_rand (const Octave_object&, int, int); -extern Octave_object builtin_setstr (const Octave_object&, int, int); -extern Octave_object builtin_scanf (const Octave_object&, int, int); -extern Octave_object builtin_schur (const Octave_object&, int, int); -extern Octave_object builtin_shell_command (const Octave_object&, int, int); -extern Octave_object builtin_size (const Octave_object&, int, int); -extern Octave_object builtin_sort (const Octave_object&, int, int); -extern Octave_object builtin_sprintf (const Octave_object&, int, int); -extern Octave_object builtin_sqrtm (const Octave_object&, int, int); -extern Octave_object builtin_sscanf (const Octave_object&, int, int); -extern Octave_object builtin_sum (const Octave_object&, int, int); -extern Octave_object builtin_sumsq (const Octave_object&, int, int); -extern Octave_object builtin_svd (const Octave_object&, int, int); -extern Octave_object builtin_syl (const Octave_object&, int, int); -extern Octave_object builtin_va_arg (const Octave_object&, int, int); -extern Octave_object builtin_va_start (const Octave_object&, int, int); -extern Octave_object builtin_warranty (const Octave_object&, int, int); -extern Octave_object builtin_zeros (const Octave_object&, int, int); +extern Octave_object builtin_all (const Octave_object& args, int nargout); + +extern Octave_object builtin_any (const Octave_object& args, int nargout); + +extern Octave_object builtin_balance (const Octave_object& args, int nargout); + +extern Octave_object builtin_chol (const Octave_object& args, int nargout); + +extern Octave_object builtin_clc (const Octave_object& args, int nargout); + +extern Octave_object builtin_clock (const Octave_object& args, int nargout); + +extern Octave_object builtin_closeplot (const Octave_object& args, + int nargout); + +extern Octave_object builtin_colloc (const Octave_object& args, int nargout); + +extern Octave_object builtin_cumprod (const Octave_object& args, int nargout); + +extern Octave_object builtin_cumsum (const Octave_object& args, int nargout); + +extern Octave_object builtin_dassl (const Octave_object& args, int nargout); + +extern Octave_object builtin_dassl_options (const Octave_object& args, + int nargout); + +extern Octave_object builtin_date (const Octave_object& args, int nargout); + +extern Octave_object builtin_det (const Octave_object& args, int nargout); + +extern Octave_object builtin_diag (const Octave_object& args, int nargout); + +extern Octave_object builtin_disp (const Octave_object& args, int nargout); + +extern Octave_object builtin_eig (const Octave_object& args, int nargout); + +extern Octave_object builtin_error (const Octave_object& args, int nargout); + +extern Octave_object builtin_eval (const Octave_object& args, int nargout); + +extern Octave_object builtin_exist (const Octave_object& args, int nargout); + +extern Octave_object builtin_expm (const Octave_object& args, int nargout); + +extern Octave_object builtin_eye (const Octave_object& args, int nargout); + +extern Octave_object builtin_fclose (const Octave_object& args, int nargout); + +extern Octave_object builtin_feof (const Octave_object& args, int nargout); + +extern Octave_object builtin_ferror (const Octave_object& args, int nargout); + +extern Octave_object builtin_feval (const Octave_object& args, int nargout); + +extern Octave_object builtin_fflush (const Octave_object& args, int nargout); + +extern Octave_object builtin_fft (const Octave_object& args, int nargout); + +extern Octave_object builtin_fgets (const Octave_object& args, int nargout); + +extern Octave_object builtin_find (const Octave_object& args, int nargout); + +extern Octave_object builtin_flops (const Octave_object& args, int nargout); + +extern Octave_object builtin_fopen (const Octave_object& args, int nargout); + +extern Octave_object builtin_fprintf (const Octave_object& args, int nargout); + +extern Octave_object builtin_fread (const Octave_object& args, int nargout); + +extern Octave_object builtin_frewind (const Octave_object& args, int nargout); + +extern Octave_object builtin_freport (const Octave_object& args, int nargout); + +extern Octave_object builtin_fscanf (const Octave_object& args, int nargout); + +extern Octave_object builtin_fseek (const Octave_object& args, int nargout); + +extern Octave_object builtin_fsolve (const Octave_object& args, int nargout); + +extern Octave_object builtin_fsolve_options (const Octave_object& args, + int nargout); + +extern Octave_object builtin_fsqp (const Octave_object& args, int nargout); + +extern Octave_object builtin_fsqp_options (const Octave_object& args, + int nargout); + +extern Octave_object builtin_ftell (const Octave_object& args, int nargout); + +extern Octave_object builtin_fwrite (const Octave_object& args, int nargout); + +extern Octave_object builtin_getenv (const Octave_object& args, int nargout); + +extern Octave_object builtin_givens (const Octave_object& args, int nargout); + +extern Octave_object builtin_hess (const Octave_object& args, int nargout); + +extern Octave_object builtin_input (const Octave_object& args, int nargout); + +extern Octave_object builtin_ifft (const Octave_object& args, int nargout); + +extern Octave_object builtin_inv (const Octave_object& args, int nargout); + +extern Octave_object builtin_is_global (const Octave_object& args, + int nargout); + +extern Octave_object builtin_isstr (const Octave_object& args, int nargout); + +extern Octave_object builtin_kbhit (const Octave_object& args, int nargout); + +extern Octave_object builtin_keyboard (const Octave_object& args, int nargout); + +extern Octave_object builtin_logm (const Octave_object& args, int nargout); + +extern Octave_object builtin_lpsolve (const Octave_object& args, int nargout); + +extern Octave_object builtin_lpsolve_options (const Octave_object& args, + int nargout); + +extern Octave_object builtin_lsode (const Octave_object& args, int nargout); + +extern Octave_object builtin_lsode_options (const Octave_object& args, + int nargout); + +extern Octave_object builtin_lu (const Octave_object& args, int nargout); + +extern Octave_object builtin_max (const Octave_object& args, int nargout); + +extern Octave_object builtin_min (const Octave_object& args, int nargout); + +extern Octave_object builtin_npsol (const Octave_object& args, int nargout); + +extern Octave_object builtin_npsol_options (const Octave_object& args, + int nargout); + +extern Octave_object builtin_ones (const Octave_object& args, int nargout); + +extern Octave_object builtin_pause (const Octave_object& args, int nargout); + +extern Octave_object builtin_purge_tmp_files (const Octave_object& args, + int nargout); + +extern Octave_object builtin_printf (const Octave_object& args, int nargout); + +extern Octave_object builtin_prod (const Octave_object& args, int nargout); + +extern Octave_object builtin_pwd (const Octave_object& args, int nargout); + +extern Octave_object builtin_qpsol (const Octave_object& args, int nargout); + +extern Octave_object builtin_qpsol_options (const Octave_object& args, + int nargout); + +extern Octave_object builtin_qr (const Octave_object& args, int nargout); + +extern Octave_object builtin_quad (const Octave_object& args, int nargout); + +extern Octave_object builtin_quad_options (const Octave_object& args, + int nargout); + +extern Octave_object builtin_quit (const Octave_object& args, int nargout); + +extern Octave_object builtin_qzval (const Octave_object& args, int nargout); + +extern Octave_object builtin_rand (const Octave_object& args, int nargout); + +extern Octave_object builtin_setstr (const Octave_object& args, int nargout); + +extern Octave_object builtin_scanf (const Octave_object& args, int nargout); + +extern Octave_object builtin_schur (const Octave_object& args, int nargout); + +extern Octave_object builtin_shell_command (const Octave_object& args, + int nargout); + +extern Octave_object builtin_size (const Octave_object& args, int nargout); + +extern Octave_object builtin_sort (const Octave_object& args, int nargout); + +extern Octave_object builtin_sprintf (const Octave_object& args, int nargout); + +extern Octave_object builtin_sqrtm (const Octave_object& args, int nargout); + +extern Octave_object builtin_sscanf (const Octave_object& args, int nargout); + +extern Octave_object builtin_sum (const Octave_object& args, int nargout); + +extern Octave_object builtin_sumsq (const Octave_object& args, int nargout); + +extern Octave_object builtin_svd (const Octave_object& args, int nargout); + +extern Octave_object builtin_syl (const Octave_object& args, int nargout); + +extern Octave_object builtin_va_arg (const Octave_object& args, int nargout); + +extern Octave_object builtin_va_start (const Octave_object& args, int nargout); + +extern Octave_object builtin_warranty (const Octave_object& args, int nargout); + +extern Octave_object builtin_zeros (const Octave_object& args, int nargout); #endif
--- a/src/givens.cc +++ b/src/givens.cc @@ -58,14 +58,14 @@ #ifdef WITH_DLD Octave_object -builtin_givens_2 (const Octave_object& args, int nargin, int nargout) +builtin_givens_2 (const Octave_object& args int nargout) { - return givens (args, nargin, nargout); + return givens (args, nargout); } #endif Octave_object -givens (const Octave_object& args, int nargin, int nargout) +givens (const Octave_object& args, int nargout) { Octave_object retval;
--- a/src/hess.cc +++ b/src/hess.cc @@ -36,14 +36,14 @@ #ifdef WITH_DLD Octave_object -builtin_hess_2 (const Octave_object& args, int nargin, int nargout) +builtin_hess_2 (const Octave_object& args, int nargout) { - return hess (args, nargin, nargout); + return hess (args, nargout); } #endif Octave_object -hess (const Octave_object& args, int nargin, int nargout) +hess (const Octave_object& args, int nargout) { Octave_object retval;
--- a/src/ifft.cc +++ b/src/ifft.cc @@ -36,7 +36,7 @@ #ifdef WITH_DLD Octave_object -builtin_ifft_2 (const Octave_object& args, int nargin, int nargout) +builtin_ifft_2 (const Octave_object& args, int nargout) { Octave_object retval (1); retval(0) = ifft (args(1));
--- a/src/inv.cc +++ b/src/inv.cc @@ -36,7 +36,7 @@ #ifdef WITH_DLD Octave_object -builtin_inv_2 (const Octave_object& args, int nargin, int nargout) +builtin_inv_2 (const Octave_object& args, int nargout) { Octave_object retval (1); retval(0) = inverse (args(1));
--- a/src/lpsolve.cc +++ b/src/lpsolve.cc @@ -33,20 +33,20 @@ #ifdef WITH_DLD Octave_object -builtin_lpsolve_2 (const Octave_object& args, int nargin, int nargout) +builtin_lpsolve_2 (const Octave_object& args, int nargout) { - return lpsolve (args, nargin, nargout); + return lpsolve (args, nargout); } Octave_object -builtin_lpsolve_options_2 (const Octave_object& args, int nargin, int nargout) +builtin_lpsolve_options_2 (const Octave_object& args, int nargout) { - return lpsolve_options (args, nargin, nargout); + return lpsolve_options (args, nargout); } #endif Octave_object -lpsolve (const Octave_object& args, int nargin, int nargout) +lpsolve (const Octave_object& args, int nargout) { // Assumes that we have been given the correct number of arguments. @@ -56,7 +56,7 @@ } Octave_object -lpsolve_options (const Octave_object& args, int nargin, int nargout) +lpsolve_options (const Octave_object& args, int nargout) { // Assumes that we have been given the correct number of arguments.
--- a/src/lsode.cc +++ b/src/lsode.cc @@ -42,15 +42,15 @@ #ifdef WITH_DLD Octave_object -builtin_lsode_2 (const Octave_object& args, int nargin, int nargout) +builtin_lsode_2 (const Octave_object& args int nargout) { - return lsode (args, nargin, nargout); + return lsode (args, nargout); } Octave_object -builtin_lsode_options_2 (const Octave_object& args, int nargin, int nargout) +builtin_lsode_options_2 (const Octave_object& args, int nargout) { - return lsode_options (args, nargin, nargout); + return lsode_options (args, nargout); } #endif @@ -85,7 +85,7 @@ if (lsode_fcn != (tree_fvc *) NULL) { - Octave_object tmp = lsode_fcn->eval (0, 1, args, 3); + Octave_object tmp = lsode_fcn->eval (0, 1, args); if (error_state) { @@ -108,12 +108,14 @@ } Octave_object -lsode (const Octave_object& args, int nargin, int nargout) +lsode (const Octave_object& args, int nargout) { // Assumes that we have been given the correct number of arguments. Octave_object retval; + int nargin = args.length (); + lsode_fcn = is_valid_function (args(1), "lsode", 1); if (lsode_fcn == (tree_fvc *) NULL || takes_correct_nargs (lsode_fcn, 3, "lsode", 1) != 1) @@ -256,10 +258,12 @@ } Octave_object -lsode_options (const Octave_object& args, int nargin, int nargout) +lsode_options (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 1) print_lsode_option_list (); else if (nargin == 3)
--- a/src/lu.cc +++ b/src/lu.cc @@ -35,7 +35,7 @@ #ifdef WITH_DLD Octave_object -builtin_lu_2 (const Octave_object& args, int nargin, int nargout) +builtin_lu_2 (const Octave_object& args, int nargout) { return lu (args(1), nargout); }
--- a/src/npsol.cc +++ b/src/npsol.cc @@ -46,15 +46,15 @@ #ifdef WITH_DLD Octave_object -builtin_npsol_2 (const Octave_object& args, int nargin, int nargout) +builtin_npsol_2 (const Octave_object& args, int nargout) { - return npsol (args, nargin, nargout); + return npsol (args, nargout); } Octave_object -builtin_npsol_options_2 (const Octave_object& args, int nargin, int nargout) +builtin_npsol_options_2 (const Octave_object& args, int nargout) { - return npsol_options (args, nargin, nargout); + return npsol_options (args, nargout); } #endif @@ -90,7 +90,7 @@ tree_constant objective_value; if (npsol_objective != (tree_fvc *) NULL) { - Octave_object tmp = npsol_objective->eval (0, 1, args, 2); + Octave_object tmp = npsol_objective->eval (0, 1, args); if (error_state) { @@ -163,7 +163,7 @@ if (npsol_constraints != (tree_fvc *)NULL) { - Octave_object tmp = npsol_constraints->eval (0, 1, args, 2); + Octave_object tmp = npsol_constraints->eval (0, 1, args); if (error_state) { @@ -246,7 +246,7 @@ } Octave_object -npsol (const Octave_object& args, int nargin, int nargout) +npsol (const Octave_object& args, int nargout) { /* @@ -267,6 +267,8 @@ Octave_object retval; + int nargin = args.length (); + ColumnVector x = args(1).to_vector (); if (x.capacity () == 0) @@ -696,10 +698,12 @@ } Octave_object -npsol_options (const Octave_object& args, int nargin, int nargout) +npsol_options (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 1) { print_npsol_option_list ();
--- a/src/pt-const.cc +++ b/src/pt-const.cc @@ -703,7 +703,7 @@ } Octave_object -column_max (const Octave_object& args, int nargin, int nargout) +column_max (const Octave_object& args, int nargout) { Octave_object retval; @@ -714,6 +714,8 @@ tree_constant_rep::constant_type arg2_type = tree_constant_rep::unknown_constant; + int nargin = args.length (); + switch (nargin) { case 3: @@ -874,7 +876,7 @@ } Octave_object -column_min (const Octave_object& args, int nargin, int nargout) +column_min (const Octave_object& args, int nargout) { Octave_object retval; @@ -885,6 +887,8 @@ tree_constant_rep::constant_type arg2_type = tree_constant_rep::unknown_constant; + int nargin = args.length (); + switch (nargin) { case 3: @@ -1179,7 +1183,7 @@ } Octave_object -sort (const Octave_object& args, int nargin, int nargout) +sort (const Octave_object& args, int nargout) { // Assumes that we have been given the correct number of arguments. @@ -1274,7 +1278,7 @@ } Octave_object -feval (const Octave_object& args, int nargin, int nargout) +feval (const Octave_object& args, int nargout) { // Assumes that we have been given the correct number of arguments. @@ -1283,10 +1287,11 @@ tree_fvc *fcn = is_valid_function (args(1), "feval", 1); if (fcn != (tree_fvc *) NULL) { - Octave_object tmp_args (--nargin); + int nargin = args.length () - 1; + Octave_object tmp_args (nargin); for (int i = 0; i < nargin; i++) tmp_args(i) = args(i+1); - retval = fcn->eval (0, nargout, tmp_args, nargin); + retval = fcn->eval (0, nargout, tmp_args); } return retval; @@ -1371,12 +1376,14 @@ } tree_constant -get_user_input (const Octave_object& args, int nargin, int nargout, - int debug = 0) +get_user_input (const Octave_object& args, int nargout, int debug = 0) { tree_constant retval; + int nargin = args.length (); + int read_as_string = 0; + if (nargin == 3) { if (args(2).is_string_type ()
--- a/src/pt-const.h +++ b/src/pt-const.h @@ -172,8 +172,7 @@ return rep->make_numeric (); } - tree_constant assign (tree_constant& rhs, const Octave_object& args, - int nargs) + tree_constant assign (tree_constant& rhs, const Octave_object& args) { if (rep->count > 1) { @@ -181,7 +180,7 @@ rep = new tree_constant_rep (*rep); rep->count = 1; } - rep->assign (rhs, args, nargs); + rep->assign (rhs, args); return *this; } @@ -267,13 +266,14 @@ return *this; } - Octave_object eval (int print, int nargout, const Octave_object& args, - int nargin) + Octave_object eval (int print, int nargout, const Octave_object& args) { Octave_object retval (1); - if (args.length () > 0 && nargin > 0) - retval(0) = rep->do_index (args, nargin); +// XXX FIXME XXX -- make it safe to call do_index() with +// args.length () == 0 + if (args.length () > 0) + retval(0) = rep->do_index (args); else retval(0) = *this; @@ -308,24 +308,18 @@ extern Octave_object matrix_log (const tree_constant& a); extern Octave_object matrix_sqrt (const tree_constant& a); -extern Octave_object column_max (const Octave_object& args, int nargin, - int nargout); - -extern Octave_object column_min (const Octave_object& args, int nargin, - int nargout); +extern Octave_object column_max (const Octave_object& args, int nargout); +extern Octave_object column_min (const Octave_object& args, int nargout); -extern Octave_object sort (const Octave_object& args, int nargin, - int nargout); +extern Octave_object sort (const Octave_object& args, int nargout); -extern Octave_object feval (const Octave_object& args, int nargin, - int nargout); +extern Octave_object feval (const Octave_object& args, int nargout); extern tree_constant eval_string (const tree_constant& arg, int& parse_status); extern tree_constant get_user_input (const Octave_object& args, - int nargin, int nargout, - int debug = 0); + int nargout, int debug = 0); #endif
--- a/src/pt-exp-base.cc +++ b/src/pt-exp-base.cc @@ -108,11 +108,13 @@ * Make sure that all arguments have values. */ static int -all_args_defined (const Octave_object& args, int nargs) +all_args_defined (const Octave_object& args) { - while (--nargs > 0) + int nargin = args.length (); + + while (--nargin > 0) { - if (args(nargs).is_undefined ()) + if (args(nargin).is_undefined ()) return 0; } return 1; @@ -122,11 +124,13 @@ * Are any of the arguments `:'? */ static int -any_arg_is_magic_colon (const Octave_object& args, int nargs) +any_arg_is_magic_colon (const Octave_object& args) { - while (--nargs > 0) + int nargin = args.length (); + + while (--nargin > 0) { - if (args(nargs).const_type () == tree_constant_rep::magic_colon) + if (args(nargin).const_type () == tree_constant_rep::magic_colon) return 1; } return 0; @@ -573,7 +577,7 @@ } tree_constant -tree_fvc::assign (tree_constant& t, const Octave_object& args, int nargs) +tree_fvc::assign (tree_constant& t, const Octave_object& args) { panic_impossible (); return tree_constant (); @@ -659,7 +663,7 @@ { Octave_object args (1); args(0) = tree_constant (my_name); - Octave_object tmp = (*general_fcn) (args, 1, 1); + Octave_object tmp = (*general_fcn) (args, 1); if (tmp.length () > 0) retval = tmp(0); } @@ -670,14 +674,15 @@ } Octave_object -tree_builtin::eval (int print, int nargout, const Octave_object& args, - int nargin) +tree_builtin::eval (int print, int nargout, const Octave_object& args) { Octave_object retval; if (error_state) return retval; + int nargin = args.length (); + if (text_fcn != (Text_fcn) NULL) { // XXX FIXME XXX -- what if some arg is not a string? @@ -697,10 +702,10 @@ } else if (general_fcn != (General_fcn) NULL) { - if (any_arg_is_magic_colon (args, nargin)) + if (any_arg_is_magic_colon (args)) ::error ("invalid use of colon in function argument list"); else - retval = (*general_fcn) (args, nargin, nargout); + retval = (*general_fcn) (args, nargout); } else { @@ -836,8 +841,7 @@ } tree_constant -tree_identifier::assign (tree_constant& rhs, const Octave_object& args, - int nargs) +tree_identifier::assign (tree_constant& rhs, const Octave_object& args) { tree_constant retval; @@ -859,7 +863,7 @@ if (sym->is_variable () && sym->is_defined ()) { tree_fvc *tmp = sym->def (); - retval = tmp->assign (rhs, args, nargs); + retval = tmp->assign (rhs, args); } else { @@ -873,7 +877,7 @@ } tree_constant *tmp = new tree_constant (); - retval = tmp->assign (rhs, args, nargs); + retval = tmp->assign (rhs, args); if (retval.is_defined ()) sym->define (tmp); } @@ -1153,7 +1157,7 @@ // int nargin = (ans->is_constant ()) ? 0 : 1; Octave_object tmp_args; - Octave_object tmp = ans->eval (0, nargout, tmp_args, 0); + Octave_object tmp = ans->eval (0, nargout, tmp_args); if (tmp.length () > 0) retval = tmp(0); @@ -1217,8 +1221,7 @@ } Octave_object -tree_identifier::eval (int print, int nargout, const Octave_object& args, - int nargin) +tree_identifier::eval (int print, int nargout, const Octave_object& args) { Octave_object retval; @@ -1242,7 +1245,7 @@ nargout = 0; - retval = ans->eval (0, nargout, args, nargin); + retval = ans->eval (0, nargout, args); if (retval.length () > 0 && retval(0).is_defined ()) { @@ -1262,7 +1265,7 @@ } } else - retval = ans->eval (print, nargout, args, nargin); + retval = ans->eval (print, nargout, args); } } @@ -1445,7 +1448,7 @@ return retval; Octave_object tmp_args; - Octave_object tmp = eval (print, 1, tmp_args, 0); + Octave_object tmp = eval (print, 1, tmp_args); if (! error_state && tmp.length () > 0) retval = tmp(0); @@ -1470,8 +1473,7 @@ } Octave_object -tree_function::eval (int print, int nargout, const Octave_object& args, - int nargin) +tree_function::eval (int print, int nargout, const Octave_object& args) { Octave_object retval; @@ -1481,6 +1483,8 @@ if (cmd_list == NULL_TREE) return retval; + int nargin = args.length (); + begin_unwind_frame ("func_eval"); unwind_protect_int (call_depth); @@ -1516,7 +1520,7 @@ if (param_list != (tree_parameter_list *) NULL && ! param_list->varargs_only ()) { - param_list->define_from_arg_vector (args, nargin); + param_list->define_from_arg_vector (args); if (error_state) goto abort; } @@ -1619,8 +1623,7 @@ } Octave_object -tree_expression::eval (int print, int nargout, const Octave_object& args, - int nargin) +tree_expression::eval (int print, int nargout, const Octave_object& args) { panic_impossible (); return Octave_object (); @@ -2128,14 +2131,15 @@ else { // Extract the arguments into a simple vector. - int nargs = 0; - Octave_object args = index->convert_to_const_vector (nargs); + Octave_object args = index->convert_to_const_vector (); + + int nargin = args.length (); if (error_state) eval_error (); - else if (nargs > 1) + else if (nargin > 1) { - ans = lhs->assign (rhs_val, args, nargs); + ans = lhs->assign (rhs_val, args); if (error_state) eval_error (); } @@ -2228,7 +2232,7 @@ return retval; Octave_object tmp_args; - Octave_object result = eval (print, 1, tmp_args, 0); + Octave_object result = eval (print, 1, tmp_args); if (result.length () > 0) retval = result(0); @@ -2238,8 +2242,7 @@ Octave_object tree_multi_assignment_expression::eval (int print, int nargout, - const Octave_object& args, - int nargin) + const Octave_object& args) { assert (etype == tree::multi_assignment); @@ -2248,7 +2251,7 @@ nargout = lhs->length (); Octave_object tmp_args; - Octave_object results = rhs->eval (0, nargout, tmp_args, 0); + Octave_object results = rhs->eval (0, nargout, tmp_args); if (error_state) eval_error (); @@ -2567,14 +2570,14 @@ else { // Extract the arguments into a simple vector. - int nargin = 0; - Octave_object args = list->convert_to_const_vector (nargin); + Octave_object args = list->convert_to_const_vector (); // Don't pass null arguments. + int nargin = args.length (); if (error_state) eval_error (); - else if (nargin > 1 && all_args_defined (args, nargin)) + else if (nargin > 1 && all_args_defined (args)) { - Octave_object tmp = id->eval (print, 1, args, nargin); + Octave_object tmp = id->eval (print, 1, args); if (error_state) eval_error (); @@ -2587,8 +2590,7 @@ } Octave_object -tree_index_expression::eval (int print, int nargout, - const Octave_object& args, int nargin) +tree_index_expression::eval (int print, int nargout, const Octave_object& args) { Octave_object retval; @@ -2598,21 +2600,20 @@ if (list == (tree_argument_list *) NULL) { Octave_object tmp_args; - retval = id->eval (print, nargout, tmp_args, 0); + retval = id->eval (print, nargout, tmp_args); if (error_state) eval_error (); } else { // Extract the arguments into a simple vector. - int nargin = 0; - Octave_object args = list->convert_to_const_vector (nargin); + Octave_object args = list->convert_to_const_vector (); // Don't pass null arguments. if (error_state) eval_error (); - else if (nargin > 1 && all_args_defined (args, nargin)) + else if (args.length () > 1 && all_args_defined (args)) { - retval = id->eval (print, nargout, args, nargin); + retval = id->eval (print, nargout, args); if (error_state) eval_error (); } @@ -2717,9 +2718,9 @@ * evaluating them along the way. */ Octave_object -tree_argument_list::convert_to_const_vector (int& len) +tree_argument_list::convert_to_const_vector (void) { - len = length () + 1; + int len = length () + 1; Octave_object args (len); @@ -2862,12 +2863,13 @@ } void -tree_parameter_list::define_from_arg_vector (const Octave_object& args, - int nargin) +tree_parameter_list::define_from_arg_vector (const Octave_object& args) { if (args.length () <= 0) return; + int nargin = args.length (); + int expected_nargin = length () + 1; tree_parameter_list *ptr = this;
--- a/src/pt-exp-base.h +++ b/src/pt-exp-base.h @@ -39,7 +39,7 @@ class symbol_table; typedef Octave_object (*Text_fcn)(int, char **, int); -typedef Octave_object (*General_fcn)(const Octave_object&, int, int); +typedef Octave_object (*General_fcn)(const Octave_object&, int); class tree_matrix; class tree_builtin; @@ -88,7 +88,7 @@ { panic_impossible (); } virtual Octave_object eval (int print, int nargout, - const Octave_object& args, int nargin); + const Octave_object& args); protected: expression_type etype; @@ -268,8 +268,7 @@ tree_constant eval (int print); - Octave_object eval (int print, int nargout, const Octave_object& args, - int nargin); + Octave_object eval (int print, int nargout, const Octave_object& args); void eval_error (void); @@ -327,8 +326,7 @@ tree_constant eval (int print); - Octave_object eval (int print, int nargout, const Octave_object& args, - int nargin); + Octave_object eval (int print, int nargout, const Octave_object& args); void eval_error (void); @@ -350,8 +348,7 @@ // virtual int is_builtin (void) const // { return 0; } - virtual tree_constant assign (tree_constant& t, const Octave_object& args, - int nargs); + virtual tree_constant assign (tree_constant& t, const Octave_object& args); virtual char *name (void) const { panic_impossible (); return (char *) NULL; } @@ -400,8 +397,7 @@ tree_constant eval (int print); - Octave_object eval (int print, int nargout, const Octave_object& args, - int nargin); + Octave_object eval (int print, int nargout, const Octave_object& args); char *name (void) const; @@ -441,8 +437,7 @@ void document (char *s); tree_constant assign (tree_constant& t); - tree_constant assign (tree_constant& t, const Octave_object& args, - int nargs); + tree_constant assign (tree_constant& t, const Octave_object& args); int is_defined (void); @@ -460,8 +455,7 @@ tree_constant eval (int print); - Octave_object eval (int print, int nargout, const Octave_object& args, - int nargin); + Octave_object eval (int print, int nargout, const Octave_object& args); void eval_undefined_error (void); @@ -504,8 +498,7 @@ tree_constant eval (int print); - Octave_object eval (int print, int nargout, const Octave_object& args, - int nargin); + Octave_object eval (int print, int nargout, const Octave_object& args); int max_expected_args (void); @@ -546,7 +539,7 @@ tree_argument_list *next_elem (void); - Octave_object convert_to_const_vector (int& nargs); + Octave_object convert_to_const_vector (void); tree_constant eval (int print); @@ -585,7 +578,7 @@ tree_identifier *define (tree_constant *t); - void define_from_arg_vector (const Octave_object& args, int nargin); + void define_from_arg_vector (const Octave_object& args); int is_defined (void);
--- a/src/qpsol.cc +++ b/src/qpsol.cc @@ -48,22 +48,22 @@ #ifdef WITH_DLD Octave_object -builtin_qpsol_2 (const Octave_object& args, int nargin, int nargout) +builtin_qpsol_2 (const Octave_object& args, int nargout) { - return qpsol (args, nargin, nargout); + return qpsol (args, nargout); } Octave_object -builtin_qpsol_options_2 (const Octave_object& args, int nargin, int nargout) +builtin_qpsol_options_2 (const Octave_object& args, int nargout) { - return qpsol_options (args, nargin, nargout); + return qpsol_options (args, nargout); } #endif static QPSOL_options qpsol_opts; Octave_object -qpsol (const Octave_object& args, int nargin, int nargout) +qpsol (const Octave_object& args, int nargout) { /* @@ -80,6 +80,8 @@ Octave_object retval; + int nargin = args.length (); + ColumnVector x = args(1).to_vector (); if (x.capacity () == 0) { @@ -317,10 +319,12 @@ } Octave_object -qpsol_options (const Octave_object& args, int nargin, int nargout) +qpsol_options (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 1) { print_qpsol_option_list ();
--- a/src/qr.cc +++ b/src/qr.cc @@ -35,7 +35,7 @@ #ifdef WITH_DLD Octave_object -builtin_qr_2 (const Octave_object& args, int nargin, int nargout) +builtin_qr_2 (const Octave_object& args, int nargout) { return qr (args(1), nargout); }
--- a/src/quad.cc +++ b/src/quad.cc @@ -43,15 +43,15 @@ #ifdef WITH_DLD Octave_object -builtin_quad_2 (const Octave_object& args, int nargin, int nargout) +builtin_quad_2 (const Octave_object& args, int nargout) { - return do_quad (args, nargin, nargout); + return do_quad (args, nargout); } Octave_object -builtin_quad_options_2 (const Octave_object& args, int nargin, int nargout) +builtin_quad_options_2 (const Octave_object& args, int nargout) { - return quad_options (args, nargin, nargout); + return quad_options (args, nargout); } #endif @@ -69,7 +69,7 @@ if (quad_fcn != (tree_fvc *) NULL) { - Octave_object tmp = quad_fcn->eval (0, 1, args, 2); + Octave_object tmp = quad_fcn->eval (0, 1, args); if (error_state) { @@ -91,12 +91,14 @@ } Octave_object -do_quad (const Octave_object& args, int nargin, int nargout) +do_quad (const Octave_object& args, int nargout) { // Assumes that we have been given the correct number of arguments. Octave_object retval; + int nargin = args.length (); + quad_fcn = is_valid_function (args(1), "fsolve", 1); if (quad_fcn == (tree_fvc *) NULL || takes_correct_nargs (quad_fcn, 2, "fsolve", 1) != 1) @@ -285,10 +287,12 @@ } Octave_object -quad_options (const Octave_object& args, int nargin, int nargout) +quad_options (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + if (nargin == 1) print_quad_option_list (); else if (nargin == 3)
--- a/src/qzval.cc +++ b/src/qzval.cc @@ -54,14 +54,14 @@ #ifdef WITH_DLD Octave_object -builtin_qzvalue_2 (const Octave_object& args, int nargin, int nargout) +builtin_qzvalue_2 (const Octave_object& args, int nargout) { - return qzvalue (args, nargin, nargout); + return qzvalue (args, nargout); } #endif Octave_object -qzvalue (const Octave_object& args, int nargin, int nargout) +qzvalue (const Octave_object& args, int nargout) { Octave_object retval;
--- a/src/rand.cc +++ b/src/rand.cc @@ -47,9 +47,9 @@ #ifdef WITH_DLD Octave_object -builtin_rand_2 (const Octave_object& args, int nargin, int nargout) +builtin_rand_2 (const Octave_object& args, int nargout) { - return rand_internal (args, nargin, nargout); + return rand_internal (args, nargout); } #endif @@ -103,12 +103,14 @@ } Octave_object -rand_internal (const Octave_object& args, int nargin, int nargout) +rand_internal (const Octave_object& args, int nargout) { // Assumes that we have been given the correct number of arguments. Octave_object retval; + int nargin = args.length (); + static int initialized = 0; if (! initialized) {
--- a/src/schur.cc +++ b/src/schur.cc @@ -36,17 +36,19 @@ #ifdef WITH_DLD Octave_object -builtin_schur_2 (const Octave_object& args, int nargin, int nargout) +builtin_schur_2 (const Octave_object& args, int nargout) { - return schur (args, nargin, nargout); + return schur (args, nargout); } #endif Octave_object -schur (const Octave_object& args, int nargin, int nargout) +schur (const Octave_object& args, int nargout) { Octave_object retval; + int nargin = args.length (); + tree_constant arg = args(1).make_numeric (); char *ord;
--- a/src/svd.cc +++ b/src/svd.cc @@ -36,14 +36,14 @@ #ifdef WITH_DLD Octave_object -builtin_svd_2 (const Octave_object& args, int nargin, int nargout) +builtin_svd_2 (const Octave_object& args, int nargout) { - return svd (args, nargin, nargout); + return svd (args, nargout); } #endif Octave_object -svd (const Octave_object& args, int nargin, int nargout) +svd (const Octave_object& args, int nargout) { Octave_object retval;
--- a/src/syl.cc +++ b/src/syl.cc @@ -56,14 +56,14 @@ #ifdef WITH_DLD Octave_object -builtin_syl_2 (const Octave_object& args, int nargin, int nargout) +builtin_syl_2 (const Octave_object& args, int nargout) { - return syl (args, nargin, nargout); + return syl (args, nargout); } #endif Octave_object -syl (const Octave_object& args, int nargin, int nargout) +syl (const Octave_object& args, int nargout) { Octave_object retval;
--- a/src/tc-inlines.h +++ b/src/tc-inlines.h @@ -140,12 +140,13 @@ } static inline int -valid_scalar_indices (const Octave_object& args, int nargs) +valid_scalar_indices (const Octave_object& args) { - int valid = (args.length () > 0) - && ((nargs == 3 && args(2).valid_as_scalar_index () - && args(1).valid_as_scalar_index ()) - || (nargs == 2 && args(1).valid_as_scalar_index ())); + int nargin = args.length (); + int valid = ((nargin == 3 + && args(2).valid_as_scalar_index () + && args(1).valid_as_scalar_index ()) + || (nargin == 2 && args(1).valid_as_scalar_index ())); return valid; }
--- a/src/tc-rep.cc +++ b/src/tc-rep.cc @@ -1316,7 +1316,7 @@ } tree_constant -tree_constant_rep::do_index (const Octave_object& args, int nargin) +tree_constant_rep::do_index (const Octave_object& args) { tree_constant retval; @@ -1333,15 +1333,15 @@ { case complex_scalar_constant: case scalar_constant: - retval = do_scalar_index (args, nargin); + retval = do_scalar_index (args); break; case complex_matrix_constant: case matrix_constant: - retval = do_matrix_index (args, nargin); + retval = do_matrix_index (args); break; case string_constant: gripe_string_invalid (); -// retval = do_string_index (args, nargin); +// retval = do_string_index (args); break; case magic_colon: case range_constant: @@ -1349,7 +1349,7 @@ // range indexing functions. force_numeric (); assert (type_tag != magic_colon && type_tag != range_constant); - retval = do_index (args, nargin); + retval = do_index (args); break; default: panic_impossible (); @@ -2656,8 +2656,7 @@ * hand off to other functions to do the real work. */ void -tree_constant_rep::assign (tree_constant& rhs, - const Octave_object& args, int nargs) +tree_constant_rep::assign (tree_constant& rhs, const Octave_object& args) { tree_constant rhs_tmp = rhs.make_numeric (); @@ -2674,11 +2673,11 @@ case complex_scalar_constant: case scalar_constant: case unknown_constant: - do_scalar_assignment (rhs_tmp, args, nargs); + do_scalar_assignment (rhs_tmp, args); break; case complex_matrix_constant: case matrix_constant: - do_matrix_assignment (rhs_tmp, args, nargs); + do_matrix_assignment (rhs_tmp, args); break; case string_constant: ::error ("invalid assignment to string type"); @@ -2697,14 +2696,16 @@ */ void tree_constant_rep::do_scalar_assignment (tree_constant& rhs, - const Octave_object& args, int nargs) + const Octave_object& args) { assert (type_tag == unknown_constant || type_tag == scalar_constant || type_tag == complex_scalar_constant); + int nargin = args.length (); + if ((rhs.is_scalar_type () || rhs.is_zero_by_zero ()) - && valid_scalar_indices (args, nargs)) + && valid_scalar_indices (args)) { if (rhs.is_zero_by_zero ()) { @@ -2773,7 +2774,7 @@ // destroy the current value. tree_constant_rep::eval(int) will take // care of converting single element matrices back to scalars. - do_matrix_assignment (rhs, args, nargs); + do_matrix_assignment (rhs, args); // I don't think there's any other way to revert back to unknown // constant types, so here it is. @@ -2788,7 +2789,7 @@ type_tag = unknown_constant; } } - else if (nargs > 3 || nargs < 2) + else if (nargin > 3 || nargin < 2) ::error ("invalid index expression for scalar type"); else ::error ("index invalid or out of range for scalar type"); @@ -2802,7 +2803,7 @@ */ void tree_constant_rep::do_matrix_assignment (tree_constant& rhs, - const Octave_object& args, int nargs) + const Octave_object& args) { assert (type_tag == unknown_constant || type_tag == matrix_constant @@ -2829,9 +2830,11 @@ } } + int nargin = args.length (); + // The do_matrix_assignment functions can't handle empty matrices, so // don't let any pass through here. - switch (nargs) + switch (nargin) { case 2: if (args.length () <= 0) @@ -5001,10 +5004,9 @@ } tree_constant -tree_constant_rep::do_scalar_index (const Octave_object& args, - int nargs) const +tree_constant_rep::do_scalar_index (const Octave_object& args) const { - if (valid_scalar_indices (args, nargs)) + if (valid_scalar_indices (args)) { if (type_tag == scalar_constant) return tree_constant (scalar); @@ -5018,7 +5020,9 @@ int rows = 0; int cols = 0; - switch (nargs) + int nargin = args.length (); + + switch (nargin) { case 3: { @@ -5110,11 +5114,12 @@ } tree_constant -tree_constant_rep::do_matrix_index (const Octave_object& args, - int nargin) const +tree_constant_rep::do_matrix_index (const Octave_object& args) const { tree_constant retval; + int nargin = args.length (); + switch (nargin) { case 2:
--- a/src/tc-rep.h +++ b/src/tc-rep.h @@ -156,16 +156,13 @@ tree_constant_rep::constant_type force_numeric (int force_str_conv = 0); tree_constant make_numeric (int force_str_conv = 0) const; - void assign (tree_constant& rhs, const Octave_object& args, int nargs); + void assign (tree_constant& rhs, const Octave_object& args); - void do_scalar_assignment - (tree_constant& rhs, const Octave_object& args, int nargin); + void do_scalar_assignment (tree_constant& rhs, const Octave_object& args); - void do_matrix_assignment - (tree_constant& rhs, const Octave_object& args, int nargin); + void do_matrix_assignment (tree_constant& rhs, const Octave_object& args); - void do_matrix_assignment - (tree_constant& rhs, tree_constant& i_arg); + void do_matrix_assignment (tree_constant& rhs, tree_constant& i_arg); void do_matrix_assignment (tree_constant& rhs, tree_constant& i_arg, tree_constant& j_arg); @@ -232,11 +229,11 @@ void maybe_mutate (void); void print (void); - tree_constant do_index (const Octave_object& args, int nargin); + tree_constant do_index (const Octave_object& args); - tree_constant do_scalar_index (const Octave_object& args, int nargin) const; + tree_constant do_scalar_index (const Octave_object& args) const; - tree_constant do_matrix_index (const Octave_object& args, int nargin) const; + tree_constant do_matrix_index (const Octave_object& args) const; tree_constant do_matrix_index (const tree_constant& i_arg) const;
--- a/src/variables.cc +++ b/src/variables.cc @@ -677,13 +677,13 @@ takes_correct_nargs (tree_fvc *fcn, int expected_nargin, char *warn_for, int warn = 0) { - int nargs = fcn->max_expected_args () - 1; - int e_nargs = expected_nargin - 1; - if (nargs != e_nargs) + int nargin = fcn->max_expected_args () - 1; + int e_nargin = expected_nargin - 1; + if (nargin != e_nargin) { if (warn) error ("%s: expecting function to take %d argument%c", - warn_for, e_nargs, s_plural (e_nargs)); + warn_for, e_nargin, s_plural (e_nargin)); return 0; } return 1;