# HG changeset patch # User Rik # Date 1471368551 25200 # Node ID 7cd75d61bbae9db68c34b9adabad12d74a050b3f # Parent 533c3c4059a3be8fb412ba622e5c1cdd2c1a2a99 dump_demos.m: Handle in-place operators like += for Matlab. * dump_demos.m: Use regexprep to replace "A OP= B" with "A = A OP B". diff -r 533c3c4059a3 -r 7cd75d61bbae scripts/testfun/private/dump_demos.m --- a/scripts/testfun/private/dump_demos.m Tue Aug 16 10:07:34 2016 -0700 +++ b/scripts/testfun/private/dump_demos.m Tue Aug 16 10:29:11 2016 -0700 @@ -211,6 +211,7 @@ ## Fix the format specs for the errorbar demos changed by the line above code = strrep (code, "%r", "#r"); code = strrep (code, "%~", "#~"); + ## Shorten all long forms of endXXX to 'end' endkeywords = {"endfor", "endfunction", "endif", "endwhile", "end_try_catch"}; for k = 1:numel (endkeywords) @@ -221,6 +222,8 @@ for k = 1:numel (commentkeywords) code = strrep (code, commentkeywords{k}, ["%" commentkeywords{k}]); endfor + ## Fix in-place operators + code = regexprep (code, '(\S+)(\s*)(.?[+-/*])=', '$1 = $1 $3'); endfunction