changeset 22313:7cd75d61bbae

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".
author Rik <rik@octave.org>
date Tue, 16 Aug 2016 10:29:11 -0700
parents 533c3c4059a3
children a1840b139c37
files scripts/testfun/private/dump_demos.m
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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