From: <ha...@us...> - 2009-06-14 18:33:11
|
Revision: 5941 http://octave.svn.sourceforge.net/octave/?rev=5941&view=rev Author: hauberg Date: 2009-06-14 18:33:10 +0000 (Sun, 14 Jun 2009) Log Message: ----------- Clean up properly using unwind_protect Modified Paths: -------------- trunk/octave-forge/extra/generate_html/inst/html_help_text.m Modified: trunk/octave-forge/extra/generate_html/inst/html_help_text.m =================================================================== --- trunk/octave-forge/extra/generate_html/inst/html_help_text.m 2009-06-14 18:06:28 UTC (rev 5940) +++ trunk/octave-forge/extra/generate_html/inst/html_help_text.m 2009-06-14 18:33:10 UTC (rev 5941) @@ -192,52 +192,57 @@ if (exist (diary_file, "file")) delete (diary_file); endif - def = get (0, "defaultfigurevisible"); - set (0, "defaultfigurevisible", "off"); - more_val = page_screen_output (false); - ## Evaluate the code - diary (diary_file); - eval (code); - diary ("off"); + unwind_protect + ## Setup figure and pager properties + def = get (0, "defaultfigurevisible"); + set (0, "defaultfigurevisible", "off"); + more_val = page_screen_output (false); - ## Read the results - fid = fopen (diary_file, "r"); - diary_data = char (fread (fid).'); - fclose (fid); - delete (diary_file); + ## Evaluate the code + diary (diary_file); + eval (code); + diary ("off"); + + ## Read the results + fid = fopen (diary_file, "r"); + diary_data = char (fread (fid).'); + fclose (fid); - ## Remove 'diary ("off");' from the diary - idx = strfind (diary_data, "diary (\"off\");"); - if (isempty (idx)) - text = diary_data; - else - text = diary_data (1:idx (end)-1); - endif - text = strtrim (text); + ## Remove 'diary ("off");' from the diary + idx = strfind (diary_data, "diary (\"off\");"); + if (isempty (idx)) + text = diary_data; + else + text = diary_data (1:idx (end)-1); + endif + text = strtrim (text); - ## Save figures - if (!isempty (get (0, "currentfigure")) && !exist (full_imagedir, "dir")) - mkdir (full_imagedir); - endif + ## Save figures + if (!isempty (get (0, "currentfigure")) && !exist (full_imagedir, "dir")) + mkdir (full_imagedir); + endif - images = {}; - while (!isempty (get (0, "currentfigure"))) - fig = gcf (); - r = round (1000*rand ()); - name = sprintf ("%s_%d.png", fileprefix, r); - full_filename = fullfile (full_imagedir, name); - filename = fullfile (imagedir, name); - print (fig, full_filename); - images {end+1} = filename; - close (fig); - endwhile + images = {}; + while (!isempty (get (0, "currentfigure"))) + fig = gcf (); + r = round (1000*rand ()); + name = sprintf ("%s_%d.png", fileprefix, r); + full_filename = fullfile (full_imagedir, name); + filename = fullfile (imagedir, name); + print (fig, full_filename); + images {end+1} = filename; + close (fig); + endwhile - ## Reverse image list, since we got them latest-first - images = images (end:-1:1); + ## Reverse image list, since we got them latest-first + images = images (end:-1:1); - set (0, "defaultfigurevisible", def); - page_screen_output (more_val); + unwind_protect_cleanup + delete (diary_file); + set (0, "defaultfigurevisible", def); + page_screen_output (more_val); + end_unwind_protect endfunction function text = images_in_html (images) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2012-03-31 21:36:19
|
Revision: 10118 http://octave.svn.sourceforge.net/octave/?rev=10118&view=rev Author: carandraug Date: 2012-03-31 21:36:13 +0000 (Sat, 31 Mar 2012) Log Message: ----------- html_help_text: reverting changes comitted by accident in r8745 Revision Links: -------------- http://octave.svn.sourceforge.net/octave/?rev=8745&view=rev Modified Paths: -------------- trunk/octave-forge/extra/generate_html/inst/html_help_text.m Modified: trunk/octave-forge/extra/generate_html/inst/html_help_text.m =================================================================== --- trunk/octave-forge/extra/generate_html/inst/html_help_text.m 2012-03-30 15:59:45 UTC (rev 10117) +++ trunk/octave-forge/extra/generate_html/inst/html_help_text.m 2012-03-31 21:36:13 UTC (rev 10118) @@ -72,7 +72,6 @@ endif ## Run makeinfo -pwd [text, status] = __makeinfo__ (text, "html", seealso); if (status != 0) error ("html_help_text: couln't parse file '%s'", name); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |