# HG changeset patch # User Rik # Date 1634146580 25200 # Node ID ba4aebad10d1c40d160e466361ad8826c4893361 # Parent a0bcfaf04cc1e8577afb097b9ffd6bb07dd7967c Return logical status variable from file functions for Matlab compatibility. * NEWS: Announce change. * dirfns.cc (Frmdir): Update documentation. Change return status to true/false rather than 1.0/0.0. * copyfile.m: Update documentation. Change internal variable "sts" to logical variable. Change any assignments to status to true/false. * movefile.m: Update documentation. Change internal variable "sts" to logical variable. Change any assignments to status to true/false. * mkdir.m: Update documentation. * mkdir.m (mkdir_recur): Change internal variable "status" to logical. diff -r a0bcfaf04cc1 -r ba4aebad10d1 NEWS --- a/NEWS Wed Oct 13 17:59:06 2021 +0200 +++ b/NEWS Wed Oct 13 10:36:20 2021 -0700 @@ -76,14 +76,14 @@ same number of digits for each value such as `[0x00_00_01; 0x00_01_00; 0x01_00_00]`. -- The `factor` function has been overhauled for speed. For large -composite numbers > 1e14, it can be up to 10,000 times faster. - - The `mldivide` function (i.e., the `\` operator) now uses an LU decomposition to solve nearly singular full square matrices. This is Matlab-compatible and yields results which more nearly minimize `norm (A*x - b)`. Previously, Octave computed a minimum-norm solution. +- The `factor` function has been overhauled for speed. For large +composite numbers > 1e14, it can be up to 10,000 times faster. + - The `betainc` function now calculates an exact output for the important special cases where a or b are 1. @@ -209,6 +209,9 @@ - The function `importdata` now produces more compatible results when the file contains a 2-D text matrix. +- The file functions `copyfile`, `mkdir`, `movefile`, `rmdir` now return +a logical value (true/false) rather than a numeric value (1/0). + - `uimenu` now accepts property `"Text"` which is identical to `"Label"`. Matlab recommends using `"Text"` in new code, although there is no announced date for deprecating `"Label"`. diff -r a0bcfaf04cc1 -r ba4aebad10d1 libinterp/corefcn/dirfns.cc --- a/libinterp/corefcn/dirfns.cc Wed Oct 13 17:59:06 2021 +0200 +++ b/libinterp/corefcn/dirfns.cc Wed Oct 13 10:36:20 2021 -0700 @@ -236,10 +236,10 @@ If the optional second parameter is supplied with value @qcode{"s"}, recursively remove all subdirectories as well. -If successful, @var{status} is 1, and @var{msg}, @var{msgid} are empty -character strings (""). Otherwise, @var{status} is 0, @var{msg} contains a -system-dependent error message, and @var{msgid} contains a unique message -identifier. +If successful, @var{status} is logical 1, and @var{msg}, @var{msgid} are empty +character strings (""). Otherwise, @var{status} is logical 0, @var{msg} +contains a system-dependent error message, and @var{msgid} contains a unique +message identifier. @seealso{mkdir, confirm_recursive_rmdir, pwd} @end deftypefn */) @@ -298,9 +298,9 @@ else { if (status < 0) - retval = ovl (0.0, msg, "rmdir"); + retval = ovl (false, msg, "rmdir"); else - retval = ovl (1.0, "", ""); + retval = ovl (true, "", ""); } return retval; diff -r a0bcfaf04cc1 -r ba4aebad10d1 scripts/miscellaneous/copyfile.m --- a/scripts/miscellaneous/copyfile.m Wed Oct 13 17:59:06 2021 +0200 +++ b/scripts/miscellaneous/copyfile.m Wed Oct 13 10:36:20 2021 -0700 @@ -38,11 +38,11 @@ ## When the force flag @qcode{'f'} is given any existing files will be ## overwritten without prompting. ## -## If successful, @var{status} is 1, and @var{msg}, @var{msgid} are empty -## character strings (""). Otherwise, @var{status} is 0, @var{msg} contains a -## system-dependent error message, and @var{msgid} contains a unique message -## identifier. Note that the status code is exactly opposite that of the -## @code{system} command. +## If successful, @var{status} is logical 1, and @var{msg}, @var{msgid} are +## empty character strings (""). Otherwise, @var{status} is logical 0, +## @var{msg} contains a system-dependent error message, and @var{msgid} +## contains a unique message identifier. Note that the status code is exactly +## opposite that of the @code{system} command. ## @seealso{movefile, rename, unlink, delete, glob} ## @end deftypefn @@ -53,7 +53,7 @@ endif max_cmd_line = 1024; - sts = 1; + sts = true; msg = ""; msgid = ""; @@ -90,7 +90,7 @@ if (nargout == 0) error ("copyfile: when copying multiple files, F2 must be a directory"); else - status = 0; + status = false; msg = "when copying multiple files, F2 must be a directory"; msgid = "copyfile"; return; @@ -107,7 +107,7 @@ if (nargout == 0) error ("copyfile: no files to move"); else - status = 0; + status = false; msg = "no files to move"; msgid = "copyfile"; return; @@ -136,7 +136,7 @@ ## Copy the files. [err, msg] = system (sprintf ('%s %s"%s"', cmd, p1, p2)); if (err != 0) - sts = 0; + sts = false; msgid = "copyfile"; break; endif @@ -151,13 +151,13 @@ ## Copy the files. [err, msg] = system (sprintf ('%s %s"%s"', cmd, p1, p2)); if (err != 0) - sts = 0; + sts = false; msgid = "copyfile"; endif endif if (nargout == 0) - if (sts == 0) + if (! sts) error ("copyfile: operation failed: %s", msg); endif else diff -r a0bcfaf04cc1 -r ba4aebad10d1 scripts/miscellaneous/mkdir.m --- a/scripts/miscellaneous/mkdir.m Wed Oct 13 17:59:06 2021 +0200 +++ b/scripts/miscellaneous/mkdir.m Wed Oct 13 10:36:20 2021 -0700 @@ -33,10 +33,11 @@ ## If @var{dirname} is a relative path, and no @var{parent} directory is ## specified, then the present working directory is used. ## -## If successful, @var{status} is 1, and @var{msg} and @var{msgid} are empty -## strings (""). Otherwise, @var{status} is 0, @var{msg} contains a -## system-dependent error message, and @var{msgid} contains a unique message -## identifier. +## If successful, @var{status} is logical 1, and @var{msg}, @var{msgid} are +## empty character strings (""). Otherwise, @var{status} is logical 0, +## @var{msg} contains a system-dependent error message, and @var{msgid} +## contains a unique message identifier. Note that the status code is exactly +## opposite that of the @code{system} command. ## ## When creating a directory permissions will be set to ## @w{@code{0777 - UMASK}}. @@ -84,7 +85,7 @@ ## Recursively make directories until parent/dirname can be created. function [status, msg, msgid] = mkdir_recur (parent, dirname) - status = 1; + status = true; if (isempty (parent)) error ("mkdir: invalid PARENT"); diff -r a0bcfaf04cc1 -r ba4aebad10d1 scripts/miscellaneous/movefile.m --- a/scripts/miscellaneous/movefile.m Wed Oct 13 17:59:06 2021 +0200 +++ b/scripts/miscellaneous/movefile.m Wed Oct 13 10:36:20 2021 -0700 @@ -44,11 +44,11 @@ ## When the force flag @qcode{'f'} is given any existing files will be ## overwritten without prompting. ## -## If successful, @var{status} is 1, and @var{msg}, @var{msgid} are empty -## character strings (""). Otherwise, @var{status} is 0, @var{msg} contains a -## system-dependent error message, and @var{msgid} contains a unique message -## identifier. Note that the status code is exactly opposite that of the -## @code{system} command. +## If successful, @var{status} is logical 1, and @var{msg}, @var{msgid} are +## empty character strings (""). Otherwise, @var{status} is logical 0, +## @var{msg} contains a system-dependent error message, and @var{msgid} +## contains a unique message identifier. Note that the status code is exactly +## opposite that of the @code{system} command. ## @seealso{rename, copyfile, unlink, delete, glob} ## @end deftypefn @@ -59,7 +59,7 @@ endif max_cmd_line = 1024; - sts = 1; + sts = true; msg = ""; msgid = ""; @@ -99,7 +99,7 @@ if (nargout == 0) error ("movefile: when copying multiple files, F2 must be a directory"); else - status = 0; + status = false; msg = "when copying multiple files, F2 must be a directory"; msgid = "movefile"; return; @@ -116,7 +116,7 @@ if (nargout == 0) error ("movefile: no files to move"); else - status = 0; + status = false; msg = "no files to move"; msgid = "movefile"; return; @@ -147,7 +147,7 @@ ## Move the file(s). [err, msg] = system (sprintf ('%s %s "%s"', cmd, p1, p2)); if (err != 0) - sts = 0; + sts = false; msgid = "movefile"; endif ## Load new file(s) in editor @@ -165,7 +165,7 @@ ## Move the file(s). [err, msg] = system (sprintf ('%s %s "%s"', cmd, p1, p2)); if (err != 0) - sts = 0; + sts = false; msgid = "movefile"; endif ## Load new file(s) in editor @@ -173,7 +173,7 @@ endif if (nargout == 0) - if (sts == 0) + if (! sts) error ("movefile: operation failed: %s", msg); endif else