Mercurial > jwe > octave
changeset 22189:829e0aafebdc
dump_demos.m: Change regex for replacement of double quotes, add dummy assert
author | Andreas Weber <andy.weber.aw@gmail.com> |
---|---|
date | Thu, 28 Jul 2016 16:54:54 +0200 |
parents | 1344509a480c |
children | e68128601f5e |
files | scripts/testfun/private/dump_demos.m |
diffstat | 1 files changed, 24 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/testfun/private/dump_demos.m Wed Jul 27 18:25:31 2016 -0400 +++ b/scripts/testfun/private/dump_demos.m Thu Jul 28 16:54:54 2016 +0200 @@ -177,11 +177,23 @@ ## Simple hacks to make things Matlab compatible code = strrep (code, "%!", "%%"); code = strrep (code, "!", "~"); + ## Simply replacing double quotes with single quotes - ## causes problems with strings like 'hello "world"' - ## More complicated regexprep targets only full double quoted strings - code = regexprep (code, "^([^']*)\"(.*)\"", "$1'$2'", + ## causes problems with strings like 'hello "world"' or transpose. + + ## Test input for double quote replacement: + ## title ("bar"); + ## a' + ## foo 'bar' "baz" + ## image (repmat ((1:64)', 1, 64)); + ## fprintf ('File "brighten_01.png" already exists.\n'); + ## title ({'x^2 + y^2'; 'plotted over circular disk with "circ"'}); + ## annotation ('textbox', [0.1 0 0.8 1], 'string', ... + ## '"headstyle" property:', ... + + code = regexprep (code, "[(,;\n][ ]*'[^']*'(*SKIP)(*F)|\"", "'", "lineanchors", "dotexceptnewline"); + code = strrep (code, "#", "%"); ## Fix the format specs for the errorbar demos changed by the line above code = strrep (code, "%r", "#r"); @@ -260,7 +272,15 @@ "end " ]); # End of rgbplot dump - fprintf (fid, "%s\n", repmat ("%", [1, 60])); + fprintf (fid, "\n"); + + ## Add dummy assert until we've removed all assert from demos + fdisp (fid, [ +"function assert (varargin) " +"end " +]); # End of dummy assert + + fprintf (fid, "\n%s\n", repmat ("%", [1, 60])); endfunction