Mercurial > octave
changeset 26961:1a79f289ca33
str2num.m: Don't halt in m-file if debug_on_error is true and error occurs (bug #55939).
* str2num.m: For Matlab compatibility, swallow any errors from eval() statement
by wrapping it in a try/catch block.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 22 Mar 2019 15:58:46 -0700 |
parents | 6731d89ef576 |
children | b033cf021048 |
files | scripts/strings/str2num.m |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/strings/str2num.m Thu Mar 21 19:06:09 2019 +0000 +++ b/scripts/strings/str2num.m Fri Mar 22 15:58:46 2019 -0700 @@ -59,7 +59,14 @@ s(:, end+1) = ";"; s = sprintf ("m = [%s];", reshape (s', 1, numel (s))); state = true; - eval (s, "m = []; state = false;"); + ## Swallow any errors from eval (bug #55939). + try + eval (s); + catch + m = []; + state = false; + end_try_catch + if (ischar (m)) m = []; state = false;