Mercurial > hg > octave-lojdl
changeset 14022:de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
* balance.cc, getgrent.cc, getpwent.cc, spparms.cc, sqrtm.cc, urlwrite.cc,
data.cc, dirfns.cc, graphics.cc, oct-stream.cc, syscalls.cc:
Return retval(1) before retval(0) to avoid re-sizing call on retval.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Fri, 09 Dec 2011 11:17:13 -0800 |
parents | e3bed294b117 |
children | d51b321b5fef |
files | src/DLD-FUNCTIONS/balance.cc src/DLD-FUNCTIONS/getgrent.cc src/DLD-FUNCTIONS/getpwent.cc src/DLD-FUNCTIONS/spparms.cc src/DLD-FUNCTIONS/sqrtm.cc src/DLD-FUNCTIONS/urlwrite.cc src/data.cc src/dirfns.cc src/graphics.cc src/oct-stream.cc src/syscalls.cc |
diffstat | 11 files changed, 46 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/balance.cc +++ b/src/DLD-FUNCTIONS/balance.cc @@ -169,8 +169,8 @@ else { retval(2) = result.balanced_matrix (); + retval(1) = result.permuting_vector (); retval(0) = result.scaling_vector (); - retval(1) = result.permuting_vector (); } } @@ -188,8 +188,8 @@ else { retval(2) = result.balanced_matrix (); + retval(1) = result.permuting_vector (); retval(0) = result.scaling_vector (); - retval(1) = result.permuting_vector (); } } } @@ -209,8 +209,8 @@ else { retval(2) = result.balanced_matrix (); + retval(1) = result.permuting_vector (); retval(0) = result.scaling_vector (); - retval(1) = result.permuting_vector (); } } else @@ -227,8 +227,8 @@ else { retval(2) = result.balanced_matrix (); + retval(1) = result.permuting_vector (); retval(0) = result.scaling_vector (); - retval(1) = result.permuting_vector (); } } }
--- a/src/DLD-FUNCTIONS/getgrent.cc +++ b/src/DLD-FUNCTIONS/getgrent.cc @@ -80,8 +80,8 @@ { std::string msg; + retval(1) = msg; retval(0) = mk_gr_map (octave_group::getgrent (msg)); - retval(1) = msg; } else print_usage (); @@ -116,8 +116,8 @@ std::string msg; + retval(1) = msg; retval(0) = mk_gr_map (octave_group::getgrgid (gid, msg)); - retval(1) = msg; } else error ("getgrgid: GID must be an integer"); @@ -152,8 +152,8 @@ { std::string msg; + retval(1) = msg; retval(0) = mk_gr_map (octave_group::getgrnam (s.c_str (), msg)); - retval(1) = msg; } } else @@ -179,8 +179,8 @@ { std::string msg; + retval(1) = msg; retval(0) = static_cast<double> (octave_group::setgrent (msg)); - retval(1) = msg; } else print_usage (); @@ -205,8 +205,8 @@ { std::string msg; + retval(1) = msg; retval(0) = static_cast<double> (octave_group::endgrent (msg)); - retval(1) = msg; } else print_usage ();
--- a/src/DLD-FUNCTIONS/getpwent.cc +++ b/src/DLD-FUNCTIONS/getpwent.cc @@ -84,8 +84,8 @@ { std::string msg; + retval(1) = msg; retval(0) = mk_pw_map (octave_passwd::getpwent (msg)); - retval(1) = msg; } else print_usage (); @@ -120,8 +120,8 @@ std::string msg; + retval(1) = msg; retval(0) = mk_pw_map (octave_passwd::getpwuid (uid, msg)); - retval(1) = msg; } else error ("getpwuid: UID must be an integer"); @@ -156,8 +156,8 @@ { std::string msg; + retval(1) = msg; retval(0) = mk_pw_map (octave_passwd::getpwnam (s, msg)); - retval(1) = msg; } } else @@ -183,8 +183,8 @@ { std::string msg; + retval(1) = msg; retval(0) = static_cast<double> (octave_passwd::setpwent (msg)); - retval(1) = msg; } else print_usage (); @@ -209,8 +209,8 @@ { std::string msg; + retval(1) = msg; retval(0) = static_cast<double> (octave_passwd::endpwent (msg)); - retval(1) = msg; } else print_usage ();
--- a/src/DLD-FUNCTIONS/spparms.cc +++ b/src/DLD-FUNCTIONS/spparms.cc @@ -113,8 +113,8 @@ retval(0) = octave_sparse_params::get_vals (); else if (nargout == 2) { + retval (1) = octave_sparse_params::get_vals (); retval (0) = octave_sparse_params::get_keys (); - retval (1) = octave_sparse_params::get_vals (); } else error ("spparms: too many output arguments");
--- a/src/DLD-FUNCTIONS/sqrtm.cc +++ b/src/DLD-FUNCTIONS/sqrtm.cc @@ -232,6 +232,12 @@ return retval; } + if (nargout > 1) + { + retval.resize (1, 2); + retval(2) = -1.0; + } + if (arg.is_diag_matrix ()) // sqrtm of a diagonal matrix is just sqrt. retval(0) = arg.sqrt ();
--- a/src/DLD-FUNCTIONS/urlwrite.cc +++ b/src/DLD-FUNCTIONS/urlwrite.cc @@ -945,10 +945,10 @@ if (nargout > 0) { - retval(0) = buf.str (); - retval(1) = ok; // Return empty string if no error occured. retval(2) = ok ? "" : curl.lasterror (); + retval(1) = ok; + retval(0) = buf.str (); } if (nargout < 2 && ! ok)
--- a/src/data.cc +++ b/src/data.cc @@ -5974,6 +5974,8 @@ if (return_idx) { + retval.resize (2); + Array<octave_idx_type> sidx; retval (0) = arg.sort (sidx, dim, smode);
--- a/src/dirfns.cc +++ b/src/dirfns.cc @@ -187,8 +187,8 @@ if (dir) { string_vector dirlist = dir.read (); + retval(1) = 0.0; retval(0) = Cell (dirlist.sort ()); - retval(1) = 0.0; } else { @@ -487,12 +487,10 @@ int status = octave_readlink (symlink, result, msg); - retval(0) = result; - - retval(1) = status; - if (status < 0) retval(2) = msg; + retval(1) = status; + retval(0) = result; } } else
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -284,7 +284,8 @@ static Matrix default_axes_ticklength (void) { - Matrix m (1, 2, 0.01); + Matrix m (1, 2, 0.0); + m(0) = 0.01; m(1) = 0.025; return m; } @@ -351,7 +352,8 @@ retval(0) = 0; retval(1) = 0; - retval(2) = retval(3) = 0.5; + retval(2) = 0.5; + retval(3) = 0.5; return retval; } @@ -5727,8 +5729,8 @@ retval.resize (1, 2); + retval(1) = max_val; retval(0) = min_val; - retval(1) = max_val; return retval; }
--- a/src/oct-stream.cc +++ b/src/oct-stream.cc @@ -4181,9 +4181,9 @@ { retval.resize (3); - retval(0) = os.name (); + retval(2) = oct_mach_info::float_format_as_string (os.float_format ()); retval(1) = octave_stream::mode_as_string (os.mode ()); - retval(2) = oct_mach_info::float_format_as_string (os.float_format ()); + retval(0) = os.name (); } else ::error ("invalid file id = %d", fid);
--- a/src/syscalls.cc +++ b/src/syscalls.cc @@ -145,8 +145,8 @@ int status = octave_syscalls::dup2 (i_old, i_new, msg); + retval(1) = msg; retval(0) = status; - retval(1) = msg; } } } @@ -224,8 +224,8 @@ int status = octave_syscalls::execvp (exec_file, exec_args, msg); + retval(1) = msg; retval(0) = status; - retval(1) = msg; } } else @@ -347,9 +347,9 @@ Cell file_ids (1, 2); - retval(0) = octave_stream_list::insert (os); + retval(2) = pid; retval(1) = octave_stream_list::insert (is); - retval(2) = pid; + retval(0) = octave_stream_list::insert (os); } else error (msg.c_str ()); @@ -496,8 +496,8 @@ int status = octave_fcntl (fid, req, arg, msg); + retval(1) = msg; retval(0) = status; - retval(1) = msg; } } } @@ -546,8 +546,8 @@ pid_t pid = octave_syscalls::fork (msg); + retval(1) = msg; retval(0) = pid; - retval(1) = msg; } else print_usage (); @@ -572,8 +572,8 @@ { std::string msg; + retval(1) = msg; retval(0) = octave_syscalls::getpgrp (msg); - retval(1) = msg; } else print_usage (); @@ -865,10 +865,9 @@ octave_stream os = octave_stdiostream::create (nm, ofile, std::ios::out); + retval(2) = status; retval(1) = octave_stream_list::insert (os); retval(0) = octave_stream_list::insert (is); - - retval(2) = status; } } else @@ -1270,8 +1269,8 @@ int status = octave_unlink (name, msg); + retval(1) = msg; retval(0) = status; - retval(1) = msg; } else error ("unlink: FILE must be a string"); @@ -1354,9 +1353,9 @@ pid_t result = octave_syscalls::waitpid (pid, &status, options, msg); - retval(0) = result; + retval(2) = msg; retval(1) = status; - retval(2) = msg; + retval(0) = result; } else error ("waitpid: OPTIONS must be an integer");